ucan-ext-js-kitchen-sink
Version:
my-ext-gen-app description for Ext JS app MyExtGenApp
94 lines (80 loc) • 2.46 kB
JavaScript
Ext.define('UCAN.common.entity.list.EntityDeleteDialog', {
extend: 'Ext.Dialog',
xtype: 'entityDeleteDialog',
cls: 'js-ucan-entity-delete-dialog ucan-entity-delete-dialog',
config: {
entities: null,
deleteSuccessRoute: '',
translator: null
},
twoWayBindable: {
entities: true,
deleteSuccessRoute: false,
translator: false
},
publishes: ['entities', 'deleteSuccessRoute', 'translator'],
defaultListenerScope: this,
closable: true,
defaultFocus: '#ok',
maximizable: true,
maskTapHandler: function() {
const scope = this.up('[cls~=js-ucan-entity-delete-dialog]');
scope.onDeleteCancel();
},
bodyPadding: 20,
maxWidth: 300,
// region Update Attributes
updateTranslator: function(config) {
const descr = this.down('[cls~=js-ucan-entity-delete-dialog-descr]');
this.setTitle(config.get('remove'));
this.setMaximizeTool({tooltip: config.get('dialog_maximize')});
this.setRestoreTool({tooltip: config.get('dialog_restore')});
this.setButtons(
[
{
handler: this.onDeleteOK,
text: config.get('dialog_delete'),
cls: 'js-ucan-entity-delete-dialog-ok'
},
{
handler: this.onDeleteCancel,
text: config.get('dialog_cancel'),
cls: 'js-ucan-entity-delete-dialog-ok'
}
]
);
if (descr) {
descr.innerHTML = config.get('dialog_delete_entity_descr');
}
},
updateEntities: function(config) {
let htmlString = '<h3 class="js-ucan-entity-delete-dialog-descr">' + this.getTranslator().get('dialog_delete_entity_descr')
+ '</h3><ul>';
config.forEach(function(entry) {
htmlString += '<li>' + entry.get('asString') + ' (' + entry.get('id') + ')</li>';
});
htmlString += '</ul>';
this.setHtml(htmlString);
},
// endregion
// region Eventhandling
onDeleteCancel: function(button) {
Ext.destroy(button.up('window'));
},
onDeleteOK: function(button) {
const scope = this.up('[cls~=js-ucan-entity-delete-dialog]');
scope.getEntities().forEach(
function(entry) {
entry.erase({
success: function() {
if (!Ext.isEmpty(scope.getDeleteSuccessRoute())) {
window.location.replace(scope.getDeleteSuccessRoute());
}
}
});
}
);
Ext.destroy(button.up('window'));
}
// endregion
});