Icons for the IsValid and IsActive column
[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: "Saisons"
10                 ,xtype: 'grid'
11                 ,autoExpandColumn: 'Code'
12                 ,view: new Ext.grid.GroupingView({
13                         markDirty: false  
14                 })
15                 ,tbar: [{
16                         id: 'plantlistDeletePlant'
17                         ,text: 'Delete'
18                         ,icon: 'img/icons/cross.png'
19                         ,cls: 'x-btn-text-icon'
20                         ,disabled: true
21                         ,handler: function(){
22                                 var grid = Ext.getCmp("plantlistgrid");
23                                 var s = grid.getSelectionModel().getSelections();
24                                 for(var i = 0, r; r = s[i]; i++) {
25                                     grid.getStore().remove(r);
26                                 }
27                         }
28                 },{
29                         id: 'plantlistActivatePlant'
30                         ,text: 'Activate'
31                         ,icon: 'img/icons/award.png'
32                         ,cls: 'x-btn-text-icon'
33                         ,disabled: true
34                         ,handler: function(){
35                                 var grid = Ext.getCmp("plantlistgrid");
36                                 var selected = grid.getSelectionModel().getSelections();
37                                 if(selected.length > 0) {
38                                     editor.Activate(selected[0]);
39                                 }
40                         }
41                 },{
42                         id: 'plantlistEditPlant'
43                         ,text: 'Edit'
44                         ,icon: 'img/icons/edit.png'
45                         ,cls: 'x-btn-text-icon'
46                         ,disabled: true
47                         ,handler: function(){
48                                 var grid = Ext.getCmp("plantlistgrid");
49                                 var selected = grid.getSelectionModel().getSelections();
50                                 if(selected.length > 0) {
51                                     editor.Edit(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: 'IsValid'
105                                 ,header: 'Valid'
106                                 ,width: 50
107                                 ,sortable: true
108                                 ,dataIndex: 'IsValid'
109                                 ,renderer: function (value, metadata, record, rowindex, colindex, store) {
110                                         if (value) {
111                                                 return '<img src="img/icons/accept.png"/>';
112                                         } else {
113                                                 return '<img src="img/icons/cross.png"/>';
114                                         }
115                                 }
116                         },{
117                                 id: 'IsActive'
118                                 ,header: 'IsActive'
119                                 ,width: 50
120                                 ,sortable: true
121                                 ,dataIndex: 'IsActive'
122                                 ,renderer: function (value, metadata, record, rowindex, colindex, store) {
123                                         if (value) {
124                                                 return '<img src="img/icons/award.png"/>';
125                                         } else {
126                                                 return '';
127                                         }
128                                 }
129                         }
130                 ]
131                 ,sm: new Ext.grid.RowSelectionModel({
132                         singleSelect:true
133                         ,listeners: {
134                                 rowselect: function() {
135                                         Ext.getCmp("plantlistDeletePlant").enable();
136                                         Ext.getCmp("plantlistActivatePlant").enable();
137                                         Ext.getCmp("plantlistEditPlant").enable();
138                                 }
139                                 ,rowdeselect: function() {
140                                         Ext.getCmp("plantlistDeletePlant").disable();
141                                         Ext.getCmp("plantlistActivatePlant").disable();
142                                         Ext.getCmp("plantlistEditPlant").disable();
143                                 }
144                         }
145                 })
146         }]
147         ,listeners: {
148                 show: communication.GetPlantList.createDelegate(communication)
149         }
150 }