Commit 8bec2477 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update WithUrlSelector.js to use Dbui.getFields.

parent 18ad2ef1
......@@ -142,29 +142,29 @@ Ext.define('Dbui.panel.WithUrlSelector', {
"use strict";
var me = this,
i,
fields,
fieldName,
fieldValue,
li,
fName,
url = {
vars: {}
};
url;
function extract(key, subfield) {
url.vars[subfield.getName()] = subfield.getValue();
}
// instantiate the url object
url = {
vars: {}
};
fields = me.selectorPanel.query('field');
for (i = 0; i < fields.length; i += 1) {
// scan all descendant fields embedded in the selecor Panel
Dbui.getFields(me.selectorPanel).forEach(function(field) {
fieldName = fields[i].getName();
fieldValue = fields[i].getValue();
var fieldName, fieldValue, fName, fieldsToJson;
// the field name is encode TableField
li = Dbui.decodeCapitalizeWords(fieldName);
fName = li[1];
fieldName = field.getName();
fieldValue = field.getValue();
// JSON encoding
fieldsToJson = ["xdictfield", "xlistfield", "xtablefield"];
if (fieldsToJson.indexOf(field.getXType()) !== -1) {
fieldValue = Ext.JSON.encode(fieldValue);
}
// extract the field name from its encoded form, TableField
fName = Dbui.decodeCapitalizeWords(fieldName)[1];
switch (fName) {
......@@ -184,13 +184,7 @@ Ext.define('Dbui.panel.WithUrlSelector', {
url.vars[fieldName] = fieldValue;
break;
}
}
// complete URL parameters with those embedded in composite fields
fields = me.selectorPanel.query('fieldcontainer');
for (i = 0; i < fields.length; i += 1) {
fields[i].items.eachKey(extract);
}
});
// build the URL
url.http = me.baseUrl;
......@@ -290,15 +284,11 @@ Ext.define('Dbui.panel.WithUrlSelector', {
onReset: function () {
"use strict";
var me = this;
var me = this,
fields,
i;
fields = me.selectorPanel.query('field');
for (i = 0; i < fields.length; i += 1) {
fields[i].reset();
}
Dbui.getFields(me.selectorPanel).forEach(function(field) {
field.reset();
});
},
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment