PartMeasurementUnitGrid.js (1862B)
1 Ext.define('PartKeepr.PartMeasurementUnitGrid', { 2 extend: 'PartKeepr.EditorGrid', 3 alias: 'widget.PartMeasurementUnitGrid', 4 columns: [ 5 {header: i18n("Part Measurement Unit"), dataIndex: 'name', flex: 1}, 6 { 7 header: i18n("Default"), dataIndex: 'default', width: 60, renderer: function (val) 8 { 9 if (val === true) { 10 return "✓"; 11 } else { 12 return ""; 13 } 14 } 15 } 16 ], 17 addButtonText: i18n("Add Part Measurement Unit"), 18 addButtonIconCls: 'fugue-icon ruler--plus', 19 deleteButtonText: i18n("Delete Part Measurement Unit"), 20 deleteButtonIconCls: 'fugue-icon ruler--minus', 21 defaultButtonIconCls: "fugue-icon ruler--pencil", 22 automaticPageSize: true, 23 initComponent: function () 24 { 25 this.callParent(); 26 27 this.defaultButton = Ext.create("Ext.button.Button", { 28 iconCls: this.defaultButtonIconCls, 29 tooltip: i18n('Mark Part Measurement Unit as Default'), 30 disabled: true, 31 handler: this.onDefaultClick, 32 scope: this 33 }); 34 35 this.getSelectionModel().on("deselect", 36 Ext.bind(function (rsm, r, i) 37 { 38 this.defaultButton.disable(); 39 }, this)); 40 41 this.getSelectionModel().on("select", 42 Ext.bind(function (rsm, r, i) 43 { 44 this.defaultButton.enable(); 45 }, this)); 46 this.topToolbar.insert(2, {xtype: 'tbseparator'}); 47 this.topToolbar.insert(3, this.defaultButton); 48 }, 49 onDefaultClick: function () 50 { 51 var r = this.getSelectionModel().getLastSelected(); 52 53 r.callPutAction("setDefault", {}, this.onDefaultHandler.bind(this)); 54 }, 55 onDefaultHandler: function () 56 { 57 this.store.load(); 58 } 59 });