~ideamonk/sahana-eden/gsoc

« back to all changes in this revision

Viewing changes to static/scripts/S3UI/core.js

  • Committer: ideamonk
  • Date: 2010-08-16 20:58:53 UTC
  • Revision ID: abhishekmishra@mbp.local-20100816205853-t1jq0ao2aulk9e1q
grids now utilize listfields and fields.json, peace

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
            /* new and improved, doesn't cause any unREST and kills the reason
292
292
                for list_field hack to exist */
293
293
            var _parent = this;
294
 
            console.log("getting field list from ", url + '/fields.json');
 
294
            var real_list = [];
295
295
            Ext.Ajax.request({
296
 
                url : url + '/fields.json',
297
 
                method  : 'GET',
298
 
                success : function(response) {
299
 
                    var listjson = Ext.decode(response.responseText);
300
 
                    var filtered_list=[];
301
 
                    Ext.each(listjson["field"], function(f){
302
 
                        //name:"gov_uuid",type:"string", has_options:"False"
303
 
                        if (f["@readable"] == "True"){
304
 
                            var element = {};
305
 
                            element.name = f["@name"];
306
 
                            element.type = f["@type"];
307
 
                            element.label = f["@label"];
308
 
                            element.has_options = f["@has_options"];
309
 
                            if (element.name != "id"){
310
 
                                filtered_list.push(element);
311
 
                            }
 
296
                url : url + '/listfields.json',
 
297
                method : 'GET',
 
298
                success: function(response) {
 
299
                    real_list=Ext.decode(response.responseText);
 
300
                    console.log("getting field list from ", url + '/fields.json');
 
301
                    Ext.Ajax.request({
 
302
                        url : url + '/fields.json',
 
303
                        method  : 'GET',
 
304
                        success : function(response) {
 
305
                            var listjson = Ext.decode(response.responseText);
 
306
                            var filtered_list=[];
 
307
                            Ext.each(listjson["field"], function(f){
 
308
                                //name:"gov_uuid",type:"string", has_options:"False"
 
309
                                if (real_list.indexOf(f["@name"]) != -1){
 
310
                                    if (f["@readable"] == "True"){
 
311
                                        var element = {};
 
312
                                        element.name = f["@name"];
 
313
                                        element.type = f["@type"];
 
314
                                        element.label = f["@label"];
 
315
                                        element.has_options = f["@has_options"];
 
316
                                        if (element.name != "id"){
 
317
                                            filtered_list.push(element);
 
318
                                        }
 
319
                                    }
 
320
                                }
 
321
                            });
 
322
                            _parent.data_createFields(filtered_list, _parent);
 
323
                            callback();
 
324
                        },
 
325
 
 
326
                        failure : function(response,opts){
 
327
                            console.log("failed fetching fields", response, response.responseText);
312
328
                        }
313
329
                    });
314
 
                    _parent.data_createFields(filtered_list, _parent);
315
 
                    callback();
 
330
 
316
331
                },
317
 
 
318
332
                failure : function(response,opts){
319
333
                    console.log("failed fetching fields", response, response.responseText);
320
334
                }