ProjectReportList.js (1821B)
1 Ext.define("PartKeepr.Components.Project.ProjectReportList", { 2 extend: "PartKeepr.BaseGrid", 3 4 defaultListenerScope: true, 5 columns: [ 6 { 7 header: i18n("Qty"), dataIndex: 'quantity', 8 width: 50, 9 editor: { 10 xtype: 'numberfield', 11 minValue: 0 12 } 13 }, { 14 header: i18n("Project Name"), dataIndex: 'name', 15 flex: 1 16 }, { 17 header: i18n("Description"), dataIndex: 'description', 18 flex: 1 19 } 20 ], 21 22 bbar: [{ 23 xtype: 'button', 24 text: i18n("Create Report"), 25 iconCls: "fugue-icon notification-counter", 26 itemId: 'createReportButton' 27 }], 28 29 cellEditingPlugin: null, 30 31 initComponent: function () 32 { 33 this.createStore(); 34 35 this.cellEditingPlugin = Ext.create('Ext.grid.plugin.CellEditing', { 36 clicksToEdit: 1 37 }); 38 39 this.plugins = [this.cellEditingPlugin]; 40 41 this.callParent(arguments); 42 }, 43 createStore: function () 44 { 45 var config = { 46 autoLoad: true, 47 model: "PartKeepr.ProjectBundle.Entity.ProjectReportList", 48 pageSize: 999999999 49 }; 50 51 this.store = Ext.create('Ext.data.Store', config); 52 }, 53 getProjectsToReport: function () 54 { 55 var i, record; 56 var projects = []; 57 58 for (i = 0; i < this.getStore().getCount(); i++) 59 { 60 record = this.getStore().getAt(i); 61 62 if (record.get("quantity") > 0) 63 { 64 projects.push( 65 { 66 project: record.getId(), 67 quantity: record.get("quantity") 68 } 69 ); 70 } 71 } 72 73 return projects; 74 } 75 });