CallBackery
view release on metacpan or search on metacpan
lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Form.js view on Meta::CPAN
* create a page for the View Tab with the given title
*
* @param cfg {Object} plugin configuration map
* @param getParentFormData {Function} method to get data of parent form
*/
construct : function(cfg,getParentFormData) {
this.base(arguments);
var that = this;
this._urlFormElements = [];
if (cfg.form != null) {
cfg.form.forEach(function(s){
if (s.triggerFormReset) {
that._hasTrigger = true;
}
if (s.urlFormKey) {
that._urlFormElements.push({
urlKey : s.urlFormKey,
formKey : s.key,
});
}
});
}
this._cfg = cfg;
this._loading = 0;
this._getParentFormData = getParentFormData;
this._populate();
this._addValidation();
qx.core.Id.getInstance().register(this, cfg.name);
this.setQxObjectId(cfg.name);
this.addListener('appear',function () {
this._loadData(true);
}, this);
// a map of pending reconfigure requests. The keys are the
// names of the fields for which we postponed reconfiguration.
// With that we avoid multi-reconfiguration per field.
this._reconfPending = new Map();
if (this._action != null) {
this._actionResponseHandler = this._action.addListener('actionResponse',function(e){
var data = e.getData();
switch(data.action){
case 'reload':
case 'dataSaved':
this._loadData();
this._reconfForm();
break;
case 'reloadStatus':
this._loadDataReadOnly();
break;
case 'uriData':
var el = qx.dom.Element.create('a', {
href: 'data:'+data.type+';base64,'
+ qx.util.Base64.encode(data.data,true),
download: data.name
});
this.fireDataEvent('actionResponse',{action: 'dataSaved'});
// make sure we only run this once events have run
// their course
//window.setTimeout(function(){
qx.bom.Event.fire(el,'tap');
qx.dom.Element.remove(el);
//},0);
break;
}
this.fireDataEvent('actionResponse', e.getData());
},this);
}
},
events: {
actionResponse: 'qx.event.type.Data'
},
members: {
_form: null,
_urlFormElements: null,
_action: null,
_cfg: null,
_loading: null,
_actionResponseHandler : null,
_getParentFormData: null,
_hasTrigger: null,
_reConfFormInProgress: null,
_reconfPending: null,
_reconfSelectBoxRunning : 0,
_populate: function(){
var cfg = this._cfg;
this.setLayout(new qx.ui.layout.VBox(30));
var form = this._form = new callbackery.ui.form.Auto(
cfg.form,null,callbackery.ui.form.renderer.NoteForm,this
);
if (cfg['options'] && cfg.options['warnAboutUnsavedData']){
form.addListener('changeData',function(e){
if (this._loading == 0){ // only notify when update comes from human interaction
this.fireDataEvent('actionResponse',{action: 'dataModified'});
}
},this);
}
this.add(new qx.ui.container.Scroll(form),{flex: 1});
var that = this;
var action = this._action = new callbackery.ui.plugin.Action(
cfg,qx.ui.form.Button,
new qx.ui.layout.Flow(5,5,'right'),
function (){
if (that._form.validate()){
return that._form.getData();
}
else {
return false;
}
},
this
);
this.add(action);
},
_addValidation: function(){
var rpc = callbackery.data.Server.getInstance();
var cfg = this._cfg;
( run in 0.889 second using v1.01-cache-2.11-cpan-39bf76dae61 )