Mercurial > lada > lada-client
comparison app/controller/Sql.js @ 246:c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
list of defined filters for the selected query and show all matching filters.
If no filter is configured at all the whole filter widget is hidden.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 23 Jul 2013 14:18:11 +0200 |
parents | 4ca858026191 |
children | d79b3bab600c |
comparison
equal
deleted
inserted
replaced
245:9a2c04b19874 | 246:c5d7fae5997a |
---|---|
1 var queries = new Array('query1', 'query2'); | 1 var queries = new Array('query1', 'query2'); |
2 | |
2 Ext.define('Lada.controller.Sql', { | 3 Ext.define('Lada.controller.Sql', { |
3 extend: 'Ext.app.Controller', | 4 extend: 'Ext.app.Controller', |
4 stores: [ | 5 stores: [ |
5 'Proben', // List of found Proben | 6 'Proben', // List of found Proben |
6 'Queries' | 7 'Queries' |
29 onPanelRendered: function() { | 30 onPanelRendered: function() { |
30 console.log('The panel was rendered'); | 31 console.log('The panel was rendered'); |
31 }, | 32 }, |
32 selectSql: function(element, record, index) { | 33 selectSql: function(element, record, index) { |
33 var result = Ext.getCmp('result'); | 34 var result = Ext.getCmp('result'); |
34 var selection = element.getValue() - 1; | 35 var filters = Ext.getCmp('queryfilters'); |
35 console.log('Selected SQL ' + selection); | |
36 for (var i = 0; i < queries.length; ++i) { | |
37 var toHide = Ext.getCmp(queries[i]); | |
38 toHide.hide(); | |
39 } | |
40 var toShow = Ext.getCmp(queries[selection]); | |
41 var buttons = Ext.getCmp('SearchBtnPanel'); | 36 var buttons = Ext.getCmp('SearchBtnPanel'); |
37 var displayFields = record[0].data.fields; | |
38 var filterFields = record[0].data.filters; | |
42 this.reset(); | 39 this.reset(); |
43 var displayFields = record[0].data.fields | 40 |
41 // Setup Columns of the probenlist | |
44 result.setupColumns(displayFields); | 42 result.setupColumns(displayFields); |
45 toShow.show(); | 43 |
44 // Setup Columns of the probenlist | |
45 if (filterFields.length > 0) { | |
46 var items = filters.items.items; | |
47 for (var i=0; i < items.length; i++) { | |
48 var filtername = items[i].id; | |
49 items[i].hide(); | |
50 for (var j=0; j < filterFields.length; j++) { | |
51 if ('filter-'+filterFields[j] === filtername) { | |
52 items[i].show(); | |
53 }; | |
54 }; | |
55 | |
56 }; | |
57 filters.show(); | |
58 } else { | |
59 filters.hide(); | |
60 }; | |
46 buttons.show(); | 61 buttons.show(); |
47 }, | 62 }, |
48 search: function(element, record, index) { | 63 search: function(element, record, index) { |
49 var result = Ext.getCmp('result'); | 64 var result = Ext.getCmp('result'); |
50 console.log('Loading store'); | 65 console.log('Loading store'); |
75 result.show(); | 90 result.show(); |
76 }, | 91 }, |
77 reset: function(element, record, index) { | 92 reset: function(element, record, index) { |
78 var buttons = Ext.getCmp('SearchBtnPanel'); | 93 var buttons = Ext.getCmp('SearchBtnPanel'); |
79 var result = Ext.getCmp('result'); | 94 var result = Ext.getCmp('result'); |
80 for (var i = 0; i < queries.length; ++i) { | 95 //for (var i = 0; i < queries.length; ++i) { |
81 var toHide = Ext.getCmp(queries[i]); | 96 // var toHide = Ext.getCmp(queries[i]); |
82 toHide.hide(); | 97 // toHide.hide(); |
83 } | 98 //} |
84 //result.hide(); | 99 //result.hide(); |
85 //buttons.hide(); | 100 //buttons.hide(); |
86 } | 101 } |
87 }); | 102 }); |