Commit da7e8d21 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update Dbui.js and WithUrlSelector.js to add/use the methods...

Update Dbui.js and WithUrlSelector.js to add/use the methods registerExtraTypesForField and registerFieldsToJSON.
parent 2f2aae2c
......@@ -82,6 +82,37 @@ Ext.define('Dbui', {
tex: 'data:application/x-latex;charset=utf-8'
},
/**
* list of field which do not inherited from {@link Ext.form.field.Base}.
* It is used by the method {@link Dbui.getFelds}. The default list can
* be extended by the method {@link Dbui.registerExtraTypesForField}.
*
* @private
*
*/
extraTypesForField: [
"htmleditor",
"xdictfield",
"xlistfield",
"xtablefield"
],
/**
* list of xtype for fields which have to be converted into a JSON string.
* It is used by the method {@link Dbui.panel.WithUrlSelector#getUrlParams}.
*
* The default list can be extended by the method
* {@link Dbui.registerFieldsToJSON}
*
* @private
*
*/
fieldsToJSON: [
"xdictfield",
"xlistfield",
"xtablefield"
],
/**
* @property {String}
* The URL of the controller to convert latex string into PDF file,
......@@ -239,9 +270,12 @@ Ext.define('Dbui', {
/**
* Return all descendant fields embedded in the component.
* It includes {@link Ext.form.field.HtmlEditor},
* {@link Dbui.form.field.Dict}, {@link Dbui.form.field.List} and
* {@link Dbui.form.field.Table}.
* It includes all the field which inherited from
* {@link Ext.form.field.Base} as well as those defined in
* {@link Dbui.extraTypesForField}.
*
* Other types can be added using the method
* {@link Dbui.registerExtraTypesforField}.
*
* @param {Ext.Componnent} cmp Component or inherited class
*
......@@ -251,19 +285,14 @@ Ext.define('Dbui', {
getFields: function (cmp) {
"use strict";
var fields, fieldTypes;
var me = this,
fields;
// list of field which inherite from Ext.form.field.Base
fields = cmp.query('field');
// list of field which do not inherited form Ext.form.field.Base
fieldTypes = ["htmleditor",
"xdictfield",
"xlistfield",
"xtablefield"];
fieldTypes.forEach(function(type) {
me.extraTypesForField.forEach(function(type) {
Ext.Array.push(fields, cmp.query(type));
});
......@@ -393,6 +422,46 @@ Ext.define('Dbui', {
return false;
},
/**
* Register xtype for Fields which does not inherited from
* {@link Ext.form.field.Base}. The list of fields is stored in the private
* list {@link Dbui.extraTypesForField} and used by the method
* {@link Dbui.getFields}.
*
* The default list can be extend by this method in order to add specific
* field defined for a dedicated application.
*
* @param {String[]} types
*
*/
registerExtraTypesForField: function(types) {
"use strict";
var me = this;
me.extraTypesForField = me.extraTypesForField.concat(types);
},
/**
* Register xtype for Fields which have to be converted into a JSON
* string. The list of fields is stored in the private
* list {@link Dbui.fieldsToJSON} and used by the method
* {@link Dbui.panel.WithUrlSelector#getUrlParams}.
*
* The default list can be extend by this method in order to add specific
* field defined for a dedicated application.
*
* @param {String[]} types
*
*/
registerFieldsToJSON: function(types) {
"use strict";
var me = this;
me.fieldsToJSON = me.fieldsToJSON.concat(types);
},
/**
* Save the local data as a file using URI technique.
* The file name is defined by the browser.
......
......@@ -152,14 +152,13 @@ Ext.define("Dbui.panel.WithUrlSelector", {
// scan all descendant fields embedded in the selecor Panel
Dbui.getFields(me.selectorPanel).forEach(function(field) {
var fieldName, fieldValue, fName, fieldsToJson;
var fieldName, fieldValue, fName;
fieldName = field.getName();
fieldValue = field.getValue();
// JSON encoding
fieldsToJson = ["xdictfield", "xlistfield", "xtablefield"];
if (fieldsToJson.indexOf(field.getXType()) !== -1) {
if (Dbui.fieldsToJSON.indexOf(field.getXType()) !== -1) {
fieldValue = Ext.JSON.encode(fieldValue);
}
......
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