comindware.core.ui
Version:
Comindware Core UI provides the basic components like editors, lists, dropdowns, popups that we so desperately need while creating Marionette-based single-page applications.
57 lines (48 loc) • 1.86 kB
text/typescript
import RootView from './RootView';
import { RootViewFactoryOptions } from '../types';
import { iconNames } from '../meta';
const RootViewWithToolbar = Marionette.View.extend({
initialize(options: RootViewFactoryOptions) {
const buttons = this.__getButtons();
const toolbarItems = new Backbone.Collection(options.showResetButton ? buttons : buttons.filter(button => button.id !== 'reset'));
this.toolbarView = new Core.components.Toolbar({
class: 'tree-editor-toolbar',
toolbarItems
});
this.listenTo(this.toolbarView, 'command:execute', (actionModel: Backbone.Model) => this.options.reqres.request('command:execute', actionModel));
},
template: Handlebars.compile('<div class="js-toolbar-region"></div><div class="js-root-region"></div>'),
regions: {
toolbarRegion: {
el: '.js-toolbar-region',
replaceElement: true
},
rootRegion: {
el: '.js-root-region',
replaceElement: true
}
},
onRender() {
this.showChildView('toolbarRegion', this.toolbarView);
this.showChildView('rootRegion', new RootView(this.options));
},
__getButtons() {
return [
{
iconClass: iconNames.save,
id: 'apply',
name: Localizer.get('CORE.TOOLBAR.TREEEDITOR.APPLY'),
type: 'Action',
description: Localizer.get('CORE.TOOLBAR.TREEEDITOR.APPLY')
},
{
iconClass: iconNames.delete,
id: 'reset',
name: Localizer.get('CORE.TOOLBAR.TREEEDITOR.RESET'),
type: 'Action',
description: Localizer.get('CORE.TOOLBAR.TREEEDITOR.RESET')
}
];
}
});
export default RootViewWithToolbar;