UNPKG

comindware.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.

106 lines (97 loc) 3.73 kB
/** * Developer: Stepan Burguchev * Date: 2/27/2017 * Copyright: 2009-2017 Stepan Burguchev® * All Rights Reserved * Published under the MIT license */ define( [ 'comindware/core' ], function(core) { 'use strict'; return function() { const model = new Backbone.Model({ title: 'foo', idealDays: 12, dueDate: '2015-07-20T10:46:37Z', description: 'bar\nbaz', blocked: true }); const View = Marionette.LayoutView.extend({ initialize: function (options) { this.model = model; }, template: Handlebars.compile('<div class="js-layout" />'), regions: { layoutRegion: '.js-layout' }, behaviors: { BackboneFormBehavior: { behaviorClass: core.form.behaviors.BackboneFormBehavior, renderStrategy: 'manual', schema: function () { return { title: { title: 'Title', type: 'Text' }, idealDays: { title: 'Ideal Days', type: 'Number' }, dueDate: { title: 'Due Date', type: 'DateTime' }, description: { title: 'Description', type: 'TextArea' }, blocked: { type: 'Boolean', displayText: 'Blocked by another task' } }; } } }, onShow () { this.layoutRegion.show(core.layout.createFromSchema({ type: 'VerticalLayout', rows: [ { type: 'FieldAnchor', key: 'title' }, { type: 'HorizontalLayout', columns: [ { type: 'FieldAnchor', key: 'idealDays' }, { type: 'FieldAnchor', key: 'dueDate' } ] }, { type: 'FieldAnchor', key: 'description' }, { type: 'EditorAnchor', key: 'blocked' } ] })); this.renderForm(); } }); return new View(); }; } );