Last active
May 19, 2016 18:53
-
-
Save krasnobaev/07c352046c4234e15eed47c3d5322f03 to your computer and use it in GitHub Desktop.
sublime ui5 snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<core:FragmentDefinition | |
xmlns="sap.m" | |
xmlns:core="sap.ui.core" | |
> | |
<SelectDialog | |
title="Dialog Title" | |
noDataText="Model not loaded" | |
search="handleSearch" | |
liveChange="handleSearch" | |
confirm="handleDialogApply" | |
cancel="handleDialogClose" | |
items="{oModel>/}" | |
> | |
<items> | |
<StandardListItem | |
title="{oModel>title}" | |
description="{oModel>description}" | |
/> | |
</items> | |
</SelectDialog> | |
</core:FragmentDefinition> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sap.ui.define([ | |
'sap/ui/base/Object', | |
'sap/ui/model/Filter', | |
'sap/ui/model/FilterOperator', | |
], function (Object, Filter, FilterOperator) { | |
'use strict'; | |
return Object.extend('zlib.Dialog', { | |
oParentControl: null, | |
oDialog: null, | |
constructor: function (oControl) { | |
this.oParentControl = oControl; | |
Object.apply(this, arguments); | |
}, | |
/** | |
* @param {sap.ui.base.Event} oControlEvent | |
* @param {sap.ui.base.EventProvider} oControlEvent.getSource | |
* @param {object} oControlEvent.getParameters | |
*/ | |
open: function (oControlEvent) { | |
if (!this.oDialog) { | |
this.oDialog = sap.ui.xmlfragment( | |
'zlib.Dialog', this | |
); | |
// pseudo l13n | |
this.oDialog._oSearchField.setPlaceholder('Поиск'); | |
this.oDialog._oCancelButton.setText('Отмена'); | |
this.oParentControl.addDependent(this.oDialog); | |
} | |
this.oDialog.open(); | |
}, | |
/** | |
* @param {sap.ui.base.Event} oControlEvent | |
* @param {sap.ui.base.EventProvider} oControlEvent.getSource | |
* @param {object} oControlEvent.getParameters | |
*/ | |
handleChooseFunctionDialogApply: function (oControlEvent) { | |
}, | |
/** | |
* perform function search in dialog | |
* @param {sap.ui.base.Event} oControlEvent | |
* @param {sap.ui.base.EventProvider} oControlEvent.getSource | |
* @param {object} oControlEvent.getParameters | |
*/ | |
handleFunctionSearch: function (oControlEvent) { | |
var sValue = oControlEvent.getParameter('value'); | |
// add filter for search | |
var aFilters = []; | |
if (sValue && sValue.length > 0) { | |
var filter = new Filter('token', sap.ui.model.FilterOperator.Contains, sValue); | |
aFilters.push(filter); | |
} | |
var oBinding = oControlEvent.getSource().getBinding('items'); | |
oBinding.filter(aFilters); | |
}, | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @requires sap.ui.core.Control | |
*/ | |
sap.ui.define([ | |
'sap/ui/core/Control', | |
], function (Control) { | |
'use strict'; | |
/** | |
* @class zlib.ZControl | |
* @extends sap.ui.core.Control | |
* @author Aleksey Krasnobaev <[email protected]> | |
*/ | |
var ZControl = Control.extend('zlib.ZControl', /** @lends sap.ui.core.Control.prototype */ { | |
metadata: { | |
properties: {}, | |
aggregations: { | |
content: { | |
type: 'sap.ui.core.Control', | |
multiple: true, | |
}, | |
}, | |
defaultAggregation: 'content', | |
events: {}, | |
}, | |
/* events */ | |
/* mutators */ | |
/* public */ | |
/* private */ | |
/* renderer */ | |
renderer: { | |
/** | |
* | |
*/ | |
render: function (oRM, oElement) { | |
oRM.write("<div"); | |
oRM.writeControlData(oElement); | |
// support for custom classes and styles | |
oRM.writeClasses(); | |
oRM.writeStyles(); | |
var aContent = oElement.getContent(); | |
if (aContent.length > 0) { | |
oRM.write(">"); | |
for (var i = 0; i < aContent.length; i++) { | |
oRM.renderControl(aContent[i]); | |
} | |
// closing tag | |
oRM.write("</div>"); | |
} else { | |
oRM.write("/>"); | |
} | |
}, | |
}, | |
}); | |
return ZControl; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment