CallBackery
view release on metacpan or search on metacpan
lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Form.js view on Meta::CPAN
}
this._loading++;
var parentFormData = {};
if (this._getParentFormData){
parentFormData = this._getParentFormData();
}
rpc.callAsync(function(data,exc){
if (!exc){
if (that._form) {
var statusData = {};
that._cfg.form.forEach(function(item){
if (item.key in data && data[item.key] !== null) {
if (item.reloadOnFormReset === true) {
statusData[item.key] = data[item.key];
}
else if (item.reloadOnFormReset !== false){
if (item.set && item.set.readOnly){
statusData[item.key] = data[item.key];
}
}
}
});
that._form.setData(statusData,true);
}
}
that._loading--;
// a trigger field changed by the user while we were loading
// parks its reconfiguration in _reconfPending; without this
// drain the request would never be sent since
// _executeReconfPending only runs after a completed reconf.
if (that._loading === 0) {
that._executeReconfPending();
}
},'getPluginData',this._cfg.name,'allFields',parentFormData,{ currentFormData: this._form.getData()});
},
_getUrlData: function () {
let data = {};
let gotData = false;
let config = callbackery.data.Config.getInstance();
this._urlFormElements.forEach(urlFormElement => {
let urlValue = config.getUrlConfigValue(urlFormElement.urlKey);
if (urlValue) {
data[urlFormElement.formKey] = urlValue;
// only do it once for the time being
config.removeUrlConfigEntry(urlFormElement.urlKey);
gotData = true;
}
});
return data;
},
_loadData: function(mergeUrlData){
if (!this._form) return;
var that = this;
var rpc = callbackery.data.Server.getInstance();
this._loading++;
var parentFormData = {};
if (this._getParentFormData){
parentFormData = this._getParentFormData();
}
var busy = callbackery.ui.Busy.getInstance();
busy.manifest(this.tr('Loading Form Data'));
rpc.callAsync(function(data,exc){
if (!exc){
if (mergeUrlData) {
let urlData = that._getUrlData();
if (!data) {
data = urlData;
}
else {
Object.assign(data, urlData);
}
}
if (that._form) {
// A triggerFormReset field the user changed while this
// initial load was in flight is parked in _reconfPending.
// Don't let the backend snapshot clobber the user's value:
// the drain below (#244) re-fires the parked reconfiguration,
// but it runs against currentFormData, so a clobbered value
// leaves the fields it should reveal hidden.
if (data) {
for (let key of that._reconfPending.keys()) {
delete data[key];
}
}
that._form.setData(data,true);
if (that._hasTrigger) {
that._reconfForm();
}
}
}
else {
if (exc.code != 2){ /* 2 is for aborted calls, this happens when the popup is closed */
callbackery.ui.MsgBox.getInstance().exc(exc);
}
}
busy.vanish();
that._loading--;
// see _loadDataReadOnly: release reconfigurations parked
// while the form was loading (covers the error path too;
// on success _reconfForm above picks them up itself).
if (that._loading === 0) {
that._executeReconfPending();
}
},'getPluginData',this._cfg.name,'allFields',parentFormData,{ currentFormData: this._form.getData()});
}
},
destruct : function() {
// cleanup; setting _form=null will abort _reconfFormHandler()
this._form.destroy();
this._form = null;
if (this._actionResponseHandler) {
this.removeListenerById(this._actionResponseHandler);
}
}
});
( run in 0.444 second using v1.01-cache-2.11-cpan-302cb4679cc )