PartCategoryTree.js (1616B)
1 Ext.define("PartKeepr.PartCategoryTree", { 2 extend: 'PartKeepr.CategoryEditorTree', 3 alias: 'widget.PartCategoryTree', 4 5 viewConfig: { 6 plugins: { 7 ptype: 'treeviewdragdrop', 8 sortOnDrop: true, 9 ddGroup: 'PartTree' 10 } 11 }, 12 categoryModel: 'PartKeepr.PartBundle.Entity.PartCategory', 13 rootVisible: false, 14 15 initComponent: function () 16 { 17 this.store = Ext.create("PartKeepr.data.store.PartCategoryStore"); 18 19 this.callParent(); 20 21 this.syncButton = Ext.create("Ext.button.Button", { 22 tooltip: i18n("Reveal Category for selected part"), 23 iconCls: 'fugue-icon arrow-split-180', 24 handler: Ext.bind(function () 25 { 26 this.fireEvent("syncCategory"); 27 }, this), 28 disabled: true 29 }); 30 this.toolbar.add(['->', this.syncButton]); 31 }, 32 listeners: { 33 "foreignModelDrop": function (records, target) 34 { 35 for (var i in records) { 36 switch (Ext.getClassName(records[i])) { 37 case "PartKeepr.PartBundle.Entity.Part": 38 records[i].setCategory(target); 39 records[i].save(); 40 break; 41 case "PartKeepr.PartBundle.Entity.PartCategory": 42 records[i].callPutAction("move", { parent: target.getId() }, Ext.bind(function () { 43 this.store.load(); 44 }, this)); 45 break; 46 } 47 } 48 } 49 } 50 });