added activate plant functionality, improved datamapping, removed test button
[L-seed.git] / web / php / page / myplants.pg
1 {
2         id: 'ContentPanel_myplants'
3         ,closable: true
4         ,style: 'padding: 5px;'
5         ,title: 'Meine Pflanzen'
6         ,layout: 'fit'
7         ,items: [{
8                 id: "plantlistgrid"
9                 ,title: "Mein Pflanzen"
10                 ,xtype: 'grid'
11                 ,autoExpandColumn: 'Code'
12                 ,plugins: [new Ext.ux.RowEditor({
13                         id: 'plantlistgridEditor'
14                         ,saveText: 'Update'
15                 })]
16                 ,view: new Ext.grid.GroupingView({
17                         markDirty: false  
18                 })
19                 ,tbar: [{
20                         id: 'plantlistDeletePlant'
21                         ,text: 'Delete'
22                         ,icon: 'img/icons/cross.png'
23                         ,cls: 'x-btn-text-icon'
24                         ,disabled: true
25                         ,handler: function(){
26                                 Ext.getCmp("plantlistgridEditor").stopEditing();
27                                 var grid = Ext.getCmp("plantlistgrid");
28                                 var s = grid.getSelectionModel().getSelections();
29                                 for(var i = 0, r; r = s[i]; i++) {
30                                     grid.getStore().remove(r);
31                                 }
32                         }
33                 },{
34                         id: 'plantlistCheckPlantSyntax'
35                         ,text: 'Check Syntax'
36                         ,icon: 'img/icons/accept.png'
37                         ,cls: 'x-btn-text-icon'
38                         ,disabled: true
39                         ,handler: editor.CheckSyntax.createDelegate(editor, ['plantlistgrid'], true)
40                 },{
41                         id: 'plantlistActivatePlant'
42                         ,text: 'Activate'
43                         ,icon: 'img/icons/accept.png'
44                         ,cls: 'x-btn-text-icon'
45                         ,disabled: true
46                         ,handler: function(){
47                                 Ext.getCmp("plantlistgridEditor").stopEditing();
48                                 var grid = Ext.getCmp("plantlistgrid");
49                                 var selected = grid.getSelectionModel().getSelections();
50                                 if(selected.length > 0) {
51                                     editor.Activate(selected[0]);
52                                 }
53                         }
54                 },{
55                         id: 'plantlistRefresh'
56                         ,text: 'Refresh'
57                         ,icon: 'img/icons/arrow_refresh.png'
58                         ,cls: 'x-btn-text-icon'
59                         ,handler: communication.GetPlantList.createDelegate(communication)
60                 }]
61                 ,store: new Ext.data.GroupingStore({
62                         reader: new Ext.data.JsonReader({fields: Lseed.Plant})
63                         ,sortInfo: {field: 'Name', direction: 'ASC'}
64                         ,data: []
65                         ,listeners: {
66                                 add: function(sender, records, index) {
67                                 },
68                                 remove: function(sender, record, index) {
69                                         editor.Delete(record);
70                                 },
71                                 update: function(sender, record, operation) {
72                                         if (operation == Ext.data.Record.EDIT) {
73                                         } else if (Ext.data.Record.REJECT) {
74                                         } else if (Ext.data.Record.COMMIT) {
75                                         }
76                                 }
77                         }
78                 })
79                 ,columns: [
80                         new Ext.grid.RowNumberer()
81                         ,{
82                                 id: 'ID'
83                                 ,header: 'ID'
84                                 ,width: 200
85                                 ,sortable: true
86                                 ,dataIndex: 'ID'
87                         },{
88                                 id: 'Name'
89                                 ,header: 'Name'
90                                 ,width: 200
91                                 ,sortable: true
92                                 ,dataIndex: 'Name'
93                         },{
94                                 id: 'Code'
95                                 ,header: 'Code'
96                                 ,width: 200
97                                 ,sortable: true
98                                 ,dataIndex: 'Code'
99                                 ,editor: {
100                                         xtype: 'textfield'
101                                         ,allowBlank: true
102                                 }
103                         },{
104                                 id: 'IsActive'
105                                 ,header: 'IsActive'
106                                 ,width: 200
107                                 ,sortable: true
108                                 ,dataIndex: 'IsActive'
109                         }
110                 ]
111                 ,sm: new Ext.grid.RowSelectionModel({
112                         singleSelect:true
113                         ,listeners: {
114                                 rowselect: function() {
115                                         Ext.getCmp("plantlistDeletePlant").enable();
116                                         Ext.getCmp("plantlistCheckPlantSyntax").enable();
117                                         Ext.getCmp("plantlistActivatePlant").enable();
118                                 }
119                                 ,rowdeselect: function() {
120                                         Ext.getCmp("plantlistDeletePlant").disable();
121                                         Ext.getCmp("plantlistCheckPlantSyntax").disable();
122                                         Ext.getCmp("plantlistActivatePlant").disable();
123                                         Ext.getCmp("plantlistActivatePlant").disable();
124                                 }
125                         }
126                 })
127         }]
128         ,listeners: {
129                 show: communication.GetPlantList.createDelegate(communication)
130         }
131 }