@xuda.io/runtime-bundle 1.0.1147 → 1.0.1148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30952,3949 +30952,7 @@ func.datasource.get_args_property_value = async function (SESSION_ID, dsSession,
|
|
|
30952
30952
|
|
|
30953
30953
|
return _value;
|
|
30954
30954
|
};
|
|
30955
|
-
|
|
30956
|
-
func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callingDataSource_objP, $callingContainerP, triggerIdP, rowIdP, jobNoP, is_panelP, parameters_obj_inP, source_functionP, call_screen_propertiesP, refreshed_ds, parameters_raw_obj) {
|
|
30957
|
-
if (!prog_id) return console.error('program is empty');
|
|
30958
|
-
let screen_ret = await func.utils.get_screen_obj(SESSION_ID, prog_id);
|
|
30959
|
-
if (!screen_ret) return console.error('program is not a screen object');
|
|
30960
|
-
await func.UI.utils.init_ui_framework(SESSION_ID, prog_id);
|
|
30961
|
-
|
|
30962
|
-
let _session = SESSION_OBJ[SESSION_ID];
|
|
30963
|
-
|
|
30964
|
-
const screenInfo = _.cloneDeep(screen_ret);
|
|
30965
|
-
// const $callingContainerP_data = $callingContainerP.clone(true)?.data();
|
|
30966
|
-
|
|
30967
|
-
var screen_type = source_functionP?.split('_')?.[1]; //|| (is_panelP && "panel");
|
|
30968
|
-
|
|
30969
|
-
var screenId = (glb.screen_num++).toString();
|
|
30970
|
-
|
|
30971
|
-
if (SCREEN_BLOCKER_OBJ[prog_id + (sourceScreenP ? '_' + sourceScreenP : '')]) {
|
|
30972
|
-
const wait_for_SCREEN_BLOCKER_release = () => {
|
|
30973
|
-
return new Promise((resolve) => {
|
|
30974
|
-
var interval = setInterval(function () {
|
|
30975
|
-
if (!SCREEN_BLOCKER_OBJ[prog_id + (sourceScreenP ? '_' + sourceScreenP : '')]) {
|
|
30976
|
-
window.clearInterval(interval);
|
|
30977
|
-
resolve();
|
|
30978
|
-
// run_screen();
|
|
30979
|
-
}
|
|
30980
|
-
}, 5);
|
|
30981
|
-
});
|
|
30982
|
-
};
|
|
30983
|
-
await wait_for_SCREEN_BLOCKER_release();
|
|
30984
|
-
}
|
|
30985
|
-
|
|
30986
|
-
func.UI.utils.screen_blocker(true, prog_id + (sourceScreenP ? '_' + sourceScreenP : ''));
|
|
30987
|
-
|
|
30988
|
-
if ($callingContainerP && !_.isEmpty($callingContainerP)) $callingContainerP.data().xuData.screenInfo = screenInfo;
|
|
30989
|
-
|
|
30990
|
-
var $dialogDiv;
|
|
30991
|
-
var $rootFrame;
|
|
30992
|
-
var containerId;
|
|
30993
|
-
|
|
30994
|
-
var params = {
|
|
30995
|
-
prog_id,
|
|
30996
|
-
sourceScreenP,
|
|
30997
|
-
$callingContainerP,
|
|
30998
|
-
triggerIdP,
|
|
30999
|
-
callingDataSource_objP,
|
|
31000
|
-
rowIdP,
|
|
31001
|
-
renderType: screenInfo.properties?.renderType,
|
|
31002
|
-
parameters_obj_inP,
|
|
31003
|
-
source_functionP,
|
|
31004
|
-
is_panelP,
|
|
31005
|
-
screen_type,
|
|
31006
|
-
screenInfo,
|
|
31007
|
-
call_screen_propertiesP,
|
|
31008
|
-
parentDataSourceNoP: _session.DS_GLB?.[callingDataSource_objP?.dsSession]?.dsSession || callingDataSource_objP?.parentDataSourceNo || 0,
|
|
31009
|
-
parameters_raw_obj,
|
|
31010
|
-
};
|
|
31011
|
-
|
|
31012
|
-
switch (screen_type) {
|
|
31013
|
-
case 'embed':
|
|
31014
|
-
$dialogDiv = $('<div>')
|
|
31015
|
-
.attr({
|
|
31016
|
-
id: screenId,
|
|
31017
|
-
ui_engine: UI_FRAMEWORK_INSTALLED,
|
|
31018
|
-
})
|
|
31019
|
-
.addClass('xu_embed_container')
|
|
31020
|
-
.css({ display: 'contents' })
|
|
31021
|
-
.data({
|
|
31022
|
-
xuData: {
|
|
31023
|
-
paramsP: params,
|
|
31024
|
-
screenInfo: params.screenInfo,
|
|
31025
|
-
},
|
|
31026
|
-
});
|
|
31027
|
-
|
|
31028
|
-
let rootTagName = 'div';
|
|
31029
|
-
if (typeof glb.SLIM_BUNDLE === 'undefined' && !glb.SLIM_BUNDLE) {
|
|
31030
|
-
const ui_plugin_core = new UI_FRAMEWORK_PLUGIN.core();
|
|
31031
|
-
rootTagName = ui_plugin_core?.rootTagName();
|
|
31032
|
-
}
|
|
31033
|
-
|
|
31034
|
-
$rootFrame = $(`<${rootTagName}>`).data('xuData', {}).data('xuAttributes', {}).appendTo($dialogDiv);
|
|
31035
|
-
|
|
31036
|
-
$dialogDiv.appendTo($callingContainerP);
|
|
31037
|
-
break;
|
|
31038
|
-
|
|
31039
|
-
case 'panel':
|
|
31040
|
-
$dialogDiv = $callingContainerP;
|
|
31041
|
-
$dialogDiv.data({
|
|
31042
|
-
xuData: {
|
|
31043
|
-
paramsP: params,
|
|
31044
|
-
screenInfo: params.screenInfo,
|
|
31045
|
-
},
|
|
31046
|
-
});
|
|
31047
|
-
$rootFrame = $dialogDiv;
|
|
31048
|
-
break;
|
|
31049
|
-
|
|
31050
|
-
case 'page':
|
|
31051
|
-
case 'modal':
|
|
31052
|
-
case 'popover':
|
|
31053
|
-
$dialogDiv = $('<div>');
|
|
31054
|
-
$rootFrame = $('<div>').appendTo($dialogDiv);
|
|
31055
|
-
$dialogDiv.appendTo('body');
|
|
31056
|
-
break;
|
|
31057
|
-
|
|
31058
|
-
default:
|
|
31059
|
-
}
|
|
31060
|
-
|
|
31061
|
-
params.containerIdP = $rootFrame.attr('id');
|
|
31062
|
-
params.$container = $rootFrame;
|
|
31063
|
-
|
|
31064
|
-
containerId = 'container_' + params.screenInfo.properties?.id + '_' + screenId;
|
|
31065
|
-
|
|
31066
|
-
var data = {
|
|
31067
|
-
note: ' ROOT container',
|
|
31068
|
-
root: true,
|
|
31069
|
-
screenId,
|
|
31070
|
-
is_panelP,
|
|
31071
|
-
prog_id,
|
|
31072
|
-
screen_type,
|
|
31073
|
-
container: '#' + containerId, // initiate container that hold the element
|
|
31074
|
-
};
|
|
31075
|
-
if (is_panelP) {
|
|
31076
|
-
$rootFrame.data().xuData.rootFrame = data;
|
|
31077
|
-
} else {
|
|
31078
|
-
if (!$rootFrame.data().xuData) {
|
|
31079
|
-
$rootFrame.data().xuData = {};
|
|
31080
|
-
}
|
|
31081
|
-
$rootFrame.attr('id', containerId).data().xuData.rootFrame = data;
|
|
31082
|
-
$rootFrame.css('display', 'contents');
|
|
31083
|
-
}
|
|
31084
|
-
|
|
31085
|
-
var node = JSON.parse(JSON.stringify(screen_ret.progUi));
|
|
31086
|
-
|
|
31087
|
-
func.UI.utils.indicator.screen.busy();
|
|
31088
|
-
|
|
31089
|
-
const ret = await func.datasource.create(SESSION_ID, prog_id, refreshed_ds, params.parentDataSourceNoP, $rootFrame.attr('id'), rowIdP, jobNoP, null, parameters_raw_obj, null, null, null, null, null, parameters_obj_inP);
|
|
31090
|
-
|
|
31091
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[ret.dsSessionP];
|
|
31092
|
-
_ds.screen_params = params;
|
|
31093
|
-
|
|
31094
|
-
params.dsSessionP = ret.dsSessionP;
|
|
31095
|
-
|
|
31096
|
-
func.UI.screen.update_SYS_OBJ_WIN_INFO(SESSION_ID, params.dsSessionP);
|
|
31097
|
-
|
|
31098
|
-
if (ret.dsSessionP >= 0) {
|
|
31099
|
-
// Call from contact info screen
|
|
31100
|
-
var viewDoc;
|
|
31101
|
-
let view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[ret.dsSessionP].prog_id);
|
|
31102
|
-
if (view_ret) {
|
|
31103
|
-
viewDoc = view_ret;
|
|
31104
|
-
}
|
|
31105
|
-
if (!viewDoc?.progUi) {
|
|
31106
|
-
return func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0780', params.renderType, ret.dsSessionP);
|
|
31107
|
-
}
|
|
31108
|
-
var node;
|
|
31109
|
-
node = _.cloneDeep(viewDoc.progUi);
|
|
31110
|
-
if (!node.length) return console.warn('ui node empty');
|
|
31111
|
-
const ret_render_$container = await func.UI.screen.render_ui_tree(SESSION_ID, $rootFrame, node[0], null, params, jobNoP, null, null, null, null, null, $rootFrame);
|
|
31112
|
-
|
|
31113
|
-
// $(".skeleton_wrapper").remove();
|
|
31114
|
-
|
|
31115
|
-
// fix for svg // deprecated Aug 12 25
|
|
31116
|
-
|
|
31117
|
-
// const fix_svg = function () {
|
|
31118
|
-
// let $svg = $('svg');
|
|
31119
|
-
// $.each($svg, function (key, elm) {
|
|
31120
|
-
// elm.outerHTML = elm.outerHTML;
|
|
31121
|
-
// });
|
|
31122
|
-
// };
|
|
31123
|
-
// setTimeout(function () {
|
|
31124
|
-
// fix_svg();
|
|
31125
|
-
// }, 200);
|
|
31126
|
-
|
|
31127
|
-
func.UI.utils.indicator.screen.normal();
|
|
31128
|
-
|
|
31129
|
-
let ret_screen_loading = await func.UI.screen.screen_loading_done(SESSION_ID, params, ret_render_$container, jobNoP);
|
|
31130
|
-
|
|
31131
|
-
// for (const [container_xu_ui_id, val] of Object.entries(UI_WORKER_OBJ.pending_for_viewport_render)) {
|
|
31132
|
-
// const height = val.base_$div.height();
|
|
31133
|
-
// if (height) {
|
|
31134
|
-
// const total_height = height * val.data.length || 1;
|
|
31135
|
-
// if (total_height > val.$container.height()) {
|
|
31136
|
-
// val.$container.css('height', height * val.data.length);
|
|
31137
|
-
// }
|
|
31138
|
-
// }
|
|
31139
|
-
// debugger;
|
|
31140
|
-
// }
|
|
31141
|
-
|
|
31142
|
-
return ret_screen_loading;
|
|
31143
|
-
}
|
|
31144
|
-
};
|
|
31145
|
-
|
|
31146
|
-
func.UI.screen.update_SYS_OBJ_WIN_INFO = function (SESSION_ID, dsNoP) {
|
|
31147
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsNoP];
|
|
31148
|
-
if (!_ds) return;
|
|
31149
|
-
if (!_ds.data_system) {
|
|
31150
|
-
_ds.data_system = {};
|
|
31151
|
-
}
|
|
31152
|
-
|
|
31153
|
-
_ds.data_system['SYS_STR_WIN_ID'] = _ds.tree_obj?.id;
|
|
31154
|
-
_ds.data_system['SYS_STR_WIN_NAME'] = _ds.tree_obj?.menuName;
|
|
31155
|
-
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsNoP].mode) {
|
|
31156
|
-
_ds.data_system['SYS_STR_WIN_MODE'] = SESSION_OBJ[SESSION_ID].DS_GLB[dsNoP].mode;
|
|
31157
|
-
}
|
|
31158
|
-
// _ds.data_system["SYS_OBJ_WIN_INFO"] = func.UI.screen.get_info(
|
|
31159
|
-
// SESSION_ID,
|
|
31160
|
-
// dsNoP
|
|
31161
|
-
// );
|
|
31162
|
-
// get all top fields into json
|
|
31163
|
-
};
|
|
31164
|
-
|
|
31165
|
-
func.UI.screen.validate_exit_events = async function (SESSION_ID, div_data_paramsP, forceP) {
|
|
31166
|
-
return new Promise(async (resolve) => {
|
|
31167
|
-
await func.events.validate(SESSION_ID, 'on_exit', div_data_paramsP.dsSessionP, null, 'screen');
|
|
31168
|
-
|
|
31169
|
-
var interval = setInterval(function () {
|
|
31170
|
-
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length || forceP) {
|
|
31171
|
-
clearInterval(interval);
|
|
31172
|
-
resolve();
|
|
31173
|
-
}
|
|
31174
|
-
}, 5);
|
|
31175
|
-
});
|
|
31176
|
-
};
|
|
31177
|
-
|
|
31178
|
-
func.UI.screen.call_embed = function (SESSION_ID, prog) {
|
|
31179
|
-
$('#embed_' + SESSION_ID)
|
|
31180
|
-
.empty()
|
|
31181
|
-
.data().xuData.screenInfo = null;
|
|
31182
|
-
|
|
31183
|
-
_.forEach(SESSION_OBJ[SESSION_ID].DS_GLB, function (val, key) {
|
|
31184
|
-
if (key) func.datasource.del(SESSION_ID, key);
|
|
31185
|
-
});
|
|
31186
|
-
func.UI.main.embed_prog_execute(SESSION_ID, prog);
|
|
31187
|
-
};
|
|
31188
|
-
func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, jobNoP, $elm_to_search, dsSession_changed, avoid_xu_for_refresh, trigger) {
|
|
31189
|
-
if (trigger !== 'click') {
|
|
31190
|
-
if (!_.isEmpty(SCREEN_BLOCKER_OBJ)) {
|
|
31191
|
-
// let dom to finish
|
|
31192
|
-
setTimeout(() => {
|
|
31193
|
-
func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_arr, jobNoP, $elm_to_search, dsSession_changed);
|
|
31194
|
-
}, 100);
|
|
31195
|
-
return;
|
|
31196
|
-
}
|
|
31197
|
-
}
|
|
31198
|
-
|
|
31199
|
-
UI_WORKER_OBJ.cache = {};
|
|
31200
|
-
const _session = SESSION_OBJ[SESSION_ID];
|
|
31201
|
-
if (glb.DEBUG_MODE) {
|
|
31202
|
-
console.info('========= xu-attributes refresh info ==============');
|
|
31203
|
-
console.info('fields_arr:', fields_arr);
|
|
31204
|
-
}
|
|
31205
|
-
|
|
31206
|
-
var selectors = {};
|
|
31207
|
-
var search_from = 'body';
|
|
31208
|
-
var new_job = jobNoP;
|
|
31209
|
-
|
|
31210
|
-
if ($elm_to_search) {
|
|
31211
|
-
search_from = '#' + $elm_to_search.attr('id');
|
|
31212
|
-
}
|
|
31213
|
-
const get_selectors = function () {
|
|
31214
|
-
$.each(fields_arr, function (key_field, val_field) {
|
|
31215
|
-
$(search_from)
|
|
31216
|
-
.find('*')
|
|
31217
|
-
.filter(function () {
|
|
31218
|
-
// check if the changed field include in the calling in parameters
|
|
31219
|
-
const elm_data = $(this).data();
|
|
31220
|
-
if (!elm_data.xuData) return true;
|
|
31221
|
-
|
|
31222
|
-
if (typeof dsSession_changed !== 'undefined' && elm_data.xuData.paramsP && elm_data.xuData.paramsP.dsSessionP < dsSession_changed) return true;
|
|
31223
|
-
|
|
31224
|
-
let attr = [];
|
|
31225
|
-
|
|
31226
|
-
const validate_param_in = function (exp, without_var) {
|
|
31227
|
-
let exp_val_for_parameter_in_validation;
|
|
31228
|
-
if (typeof exp === 'string') exp_val_for_parameter_in_validation = exp;
|
|
31229
|
-
if (typeof exp === 'object') exp_val_for_parameter_in_validation = JSON.stringify(exp);
|
|
31230
|
-
if (!exp_val_for_parameter_in_validation) return;
|
|
31231
|
-
if (!exp.includes('@')) return;
|
|
31232
|
-
if (_.isEmpty(elm_data?.xuData?.paramsP?.parameters_raw_obj)) return;
|
|
31233
|
-
|
|
31234
|
-
for (const [param_key, param_val] of Object.entries(elm_data?.xuData?.paramsP?.parameters_raw_obj)) {
|
|
31235
|
-
if (!param_val.includes('@')) continue;
|
|
31236
|
-
exp_val_for_parameter_in_validation = exp_val_for_parameter_in_validation.replaceAll((without_var ? '' : '@') + param_key, param_val);
|
|
31237
|
-
}
|
|
31238
|
-
return exp_val_for_parameter_in_validation?.includes?.((without_var ? '' : '@') + val_field);
|
|
31239
|
-
};
|
|
31240
|
-
|
|
31241
|
-
$.each(elm_data?.xuAttributes, function (key, val) {
|
|
31242
|
-
if (typeof val !== 'string' && typeof val !== 'object') return true;
|
|
31243
|
-
if (typeof val === 'string' && !val?.includes('@') && key !== 'xu-bind' && key !== 'xu-for') return true;
|
|
31244
|
-
if (key.substr(0, 3) !== 'xu-') return true;
|
|
31245
|
-
|
|
31246
|
-
if (key === 'xu-bind' || key === 'xu-for') {
|
|
31247
|
-
if (val?.includes?.(val_field) || validate_param_in(val, true)) {
|
|
31248
|
-
attr.push(key);
|
|
31249
|
-
}
|
|
31250
|
-
return true;
|
|
31251
|
-
}
|
|
31252
|
-
|
|
31253
|
-
// if (key === 'xu-for') {
|
|
31254
|
-
// // match static value for xu-for
|
|
31255
|
-
// if (val?.includes?.(val_field) || validate_param_in(val)) {
|
|
31256
|
-
// attr.push(key);
|
|
31257
|
-
// }
|
|
31258
|
-
// return true;
|
|
31259
|
-
// }
|
|
31260
|
-
|
|
31261
|
-
// console.log(key, val);
|
|
31262
|
-
|
|
31263
|
-
if (key.substr(0, 6) === 'xu-exp' && key.substr(6, 1) === ':') {
|
|
31264
|
-
if (val?.includes?.('@' + val_field) || validate_param_in(val)) {
|
|
31265
|
-
attr.push(key);
|
|
31266
|
-
}
|
|
31267
|
-
return true;
|
|
31268
|
-
}
|
|
31269
|
-
|
|
31270
|
-
if (key.substr(0, 8) === 'xu-class') {
|
|
31271
|
-
try {
|
|
31272
|
-
const classes_string = val;
|
|
31273
|
-
const classes_obj = _.isString(classes_string) ? JSON.parse(classes_string) : _.defaults(classes_string, {});
|
|
31274
|
-
|
|
31275
|
-
$.each(classes_obj, function (cla, cond) {
|
|
31276
|
-
if (cond.includes('@' + val_field) || validate_param_in(cond)) {
|
|
31277
|
-
attr.push('xu-class');
|
|
31278
|
-
return false;
|
|
31279
|
-
}
|
|
31280
|
-
});
|
|
31281
|
-
if (attr.length) {
|
|
31282
|
-
return false;
|
|
31283
|
-
}
|
|
31284
|
-
} catch (e) {
|
|
31285
|
-
console.warn('parse error:' + val);
|
|
31286
|
-
}
|
|
31287
|
-
}
|
|
31288
|
-
|
|
31289
|
-
if (key === 'xu-ui-plugin') {
|
|
31290
|
-
const plugin_str = JSON.stringify(val);
|
|
31291
|
-
if (plugin_str.includes('@' + val_field) || validate_param_in(plugin_str)) {
|
|
31292
|
-
attr.push(key);
|
|
31293
|
-
return false;
|
|
31294
|
-
}
|
|
31295
|
-
}
|
|
31296
|
-
});
|
|
31297
|
-
|
|
31298
|
-
// const selector_id = glb.new_xu_render ? $(this).data()?.xuData?.ui_id : $(this).data()?.xuData?.xu_id;
|
|
31299
|
-
|
|
31300
|
-
const selector_id = $(this).attr('xu-ui-id');
|
|
31301
|
-
|
|
31302
|
-
if (attr.length) {
|
|
31303
|
-
selectors[selector_id] = selectors[selector_id];
|
|
31304
|
-
|
|
31305
|
-
if (!selectors[selector_id]) {
|
|
31306
|
-
selectors[selector_id] = { attributes: [], $elm: $(this) };
|
|
31307
|
-
}
|
|
31308
|
-
attr.forEach(function (value) {
|
|
31309
|
-
if (!selectors[selector_id].attributes.includes(value)) selectors[selector_id].attributes.push(value);
|
|
31310
|
-
});
|
|
31311
|
-
}
|
|
31312
|
-
});
|
|
31313
|
-
});
|
|
31314
|
-
};
|
|
31315
|
-
|
|
31316
|
-
get_selectors();
|
|
31317
|
-
// console.log('selectors>>>>', selectors);
|
|
31318
|
-
|
|
31319
|
-
for await (let [elem_key, elem_val] of Object.entries(selectors)) {
|
|
31320
|
-
if (elem_key === 'length') break;
|
|
31321
|
-
|
|
31322
|
-
if (!elem_val.$elm.data().xuData) continue;
|
|
31323
|
-
if (elem_val.$elm.data().xuData.pending_to_delete) continue;
|
|
31324
|
-
|
|
31325
|
-
const add_execute_queue = async function (type) {
|
|
31326
|
-
if (!elem_val.$elm?.data?.()?.xuData) return;
|
|
31327
|
-
try {
|
|
31328
|
-
const obj = {
|
|
31329
|
-
ui_type: elem_val.$elm.data().xuData.ui_type,
|
|
31330
|
-
SESSION_ID,
|
|
31331
|
-
fields_arr,
|
|
31332
|
-
elem_key,
|
|
31333
|
-
elem_val,
|
|
31334
|
-
};
|
|
31335
|
-
|
|
31336
|
-
new_job = await func.UI.worker.add_to_queue(SESSION_ID, 'gui event', type, obj, new_job, elem_val.$elm);
|
|
31337
|
-
|
|
31338
|
-
if (glb.DEBUG_MODE) {
|
|
31339
|
-
console.log(type + '>>>', new_job, obj);
|
|
31340
|
-
}
|
|
31341
|
-
} catch (error) {
|
|
31342
|
-
debugger;
|
|
31343
|
-
}
|
|
31344
|
-
};
|
|
31345
|
-
//////////// process render first ///////////////
|
|
31346
|
-
|
|
31347
|
-
var performed_render = undefined;
|
|
31348
|
-
|
|
31349
|
-
if (!elem_val?.$elm?.data()?.xuAttributes) continue;
|
|
31350
|
-
|
|
31351
|
-
if (elem_val.attributes.includes('xu-exp:xu-render')) {
|
|
31352
|
-
var res = await func.expression.get(SESSION_ID, elem_val.$elm.data().xuAttributes['xu-exp:xu-render'], elem_val.$elm.data().xuData.paramsP.dsSessionP, 'UI Property EXP', elem_val.$elm.data().xuData.recordid);
|
|
31353
|
-
|
|
31354
|
-
var attr_value = await func.common.get_cast_val(SESSION_ID, 'refresh xu-attributes', 'xu-render', 'bool', res.result);
|
|
31355
|
-
|
|
31356
|
-
if (!attr_value && elem_val.$elm[0].tagName === 'XURENDER') continue; // bypass job
|
|
31357
|
-
|
|
31358
|
-
if (attr_value && elem_val.$elm[0].tagName !== 'XURENDER') {
|
|
31359
|
-
await add_execute_queue('execute_xu_all_attributes');
|
|
31360
|
-
|
|
31361
|
-
continue; // bypass render job
|
|
31362
|
-
}
|
|
31363
|
-
|
|
31364
|
-
if (!elem_val?.$elm?.data()?.xuData?.ui_type) continue;
|
|
31365
|
-
|
|
31366
|
-
// RENDER = false handler
|
|
31367
|
-
const obj = {
|
|
31368
|
-
ui_type: elem_val.$elm.data().xuData.ui_type,
|
|
31369
|
-
SESSION_ID,
|
|
31370
|
-
elem_key,
|
|
31371
|
-
elem_val,
|
|
31372
|
-
fields_arr,
|
|
31373
|
-
attr_value,
|
|
31374
|
-
};
|
|
31375
|
-
new_job = jobNoP;
|
|
31376
|
-
new_job = await func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'execute_xu_render_attributes', obj, new_job, elem_val.$elm, elem_val.$elm.data().xuData.paramsP.dsSessionP);
|
|
31377
|
-
performed_render = true;
|
|
31378
|
-
|
|
31379
|
-
// mark children items ignore list
|
|
31380
|
-
$.each(elem_val.$elm.find('*'), function (key, val) {
|
|
31381
|
-
if ($(val).data().xuData) {
|
|
31382
|
-
$(val).data().xuData.pending_to_delete = true;
|
|
31383
|
-
}
|
|
31384
|
-
});
|
|
31385
|
-
|
|
31386
|
-
if (glb.DEBUG_MODE) {
|
|
31387
|
-
console.info('execute_xu_render_attributes', obj);
|
|
31388
|
-
}
|
|
31389
|
-
}
|
|
31390
|
-
|
|
31391
|
-
if (performed_render || elem_val.$elm[0].tagName === 'XURENDER') continue; // bypass job
|
|
31392
|
-
|
|
31393
|
-
if (elem_val.attributes.includes('xu-exp:xu-for') || elem_val.attributes.includes('xu-for')) continue;
|
|
31394
|
-
|
|
31395
|
-
add_execute_queue('execute_xu_all_attributes');
|
|
31396
|
-
}
|
|
31397
|
-
|
|
31398
|
-
// xu-for
|
|
31399
|
-
selectors = {};
|
|
31400
|
-
get_selectors();
|
|
31401
|
-
// console.log('selectors', selectors);
|
|
31402
|
-
let refreshed_ids = [];
|
|
31403
|
-
// handle xu-for
|
|
31404
|
-
let parent_element_ui_id;
|
|
31405
|
-
for await (let [elem_key, elem_val] of Object.entries(selectors)) {
|
|
31406
|
-
if (elem_key === 'length') break;
|
|
31407
|
-
|
|
31408
|
-
if (!elem_val.$elm.data().xuData) continue;
|
|
31409
|
-
if (elem_val.$elm.data().xuData.pending_to_delete) continue;
|
|
31410
|
-
|
|
31411
|
-
if (!elem_val.attributes.includes('xu-exp:xu-for') && !elem_val.attributes.includes('xu-for')) continue;
|
|
31412
|
-
|
|
31413
|
-
let _parent_element_ui_id;
|
|
31414
|
-
if (elem_val?.$elm?.data()?.xuPanelData) {
|
|
31415
|
-
// handle li panel
|
|
31416
|
-
_parent_element_ui_id = elem_val?.$elm?.data()?.xuPanelData?.parent_element_ui_id;
|
|
31417
|
-
} else {
|
|
31418
|
-
// handle regular li
|
|
31419
|
-
_parent_element_ui_id = elem_val?.$elm?.data()?.xuData?.parent_element_ui_id;
|
|
31420
|
-
}
|
|
31421
|
-
|
|
31422
|
-
if (!parent_element_ui_id || _parent_element_ui_id != parent_element_ui_id) {
|
|
31423
|
-
parent_element_ui_id = _parent_element_ui_id;
|
|
31424
|
-
|
|
31425
|
-
const _$elem = $(`[xu-ui-id=${parent_element_ui_id}]`);
|
|
31426
|
-
const _elem_key = parent_element_ui_id;
|
|
31427
|
-
const _elem_val = { attributes: [], $elm: _$elem };
|
|
31428
|
-
|
|
31429
|
-
$.each(_$elem.data()?.xuAttributes, function (key, val) {
|
|
31430
|
-
_elem_val.attributes.push(key);
|
|
31431
|
-
});
|
|
31432
|
-
const obj = {
|
|
31433
|
-
ui_type: _elem_val.$elm.data().xuData.ui_type,
|
|
31434
|
-
SESSION_ID,
|
|
31435
|
-
elem_key: _elem_key,
|
|
31436
|
-
elem_val: _elem_val,
|
|
31437
|
-
fields_arr,
|
|
31438
|
-
xu_for_item_id: elem_val?.$elm?.data()?.xuPanelData ? elem_val?.$elm?.data()?.xuPanelData.node.id : elem_val?.$elm?.data().xuData.nodeid,
|
|
31439
|
-
};
|
|
31440
|
-
if (avoid_xu_for_refresh) return;
|
|
31441
|
-
await func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'execute_xu_for', obj, new_job, _elem_val.$elm, _elem_val.$elm.data().xuData.paramsP.dsSessionP);
|
|
31442
|
-
|
|
31443
|
-
refreshed_ids.push(parent_element_ui_id);
|
|
31444
|
-
|
|
31445
|
-
if (glb.DEBUG_MODE) {
|
|
31446
|
-
console.info('execute_xu_for', obj);
|
|
31447
|
-
}
|
|
31448
|
-
}
|
|
31449
|
-
}
|
|
31450
|
-
|
|
31451
|
-
/////////// xu-for for non displayed elements ////////////
|
|
31452
|
-
const iterate_field_in_progUi = async function (progUi, field_id, panel_val) {
|
|
31453
|
-
let found;
|
|
31454
|
-
const iterate_progUi = async function (node, node_id) {
|
|
31455
|
-
for (let item of node) {
|
|
31456
|
-
if (!_.isEmpty(item.attributes)) {
|
|
31457
|
-
const parent_element_ui_id = node_id;
|
|
31458
|
-
// const _$elem = $(`[xu-node-id="${parent_element_ui_id}"]`);
|
|
31459
|
-
for await (const [attr, val] of Object.entries(item.attributes)) {
|
|
31460
|
-
if (attr === 'xu-exp:xu-for' || attr === 'xu-for') {
|
|
31461
|
-
if (val?.includes(field_id)) {
|
|
31462
|
-
// const parent_element_ui_id = node_id;
|
|
31463
|
-
// debugger;
|
|
31464
|
-
// let _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
|
|
31465
|
-
// let _$elem = $(`[xu-node-id=${parent_element_ui_id}]`);
|
|
31466
|
-
const _$elem = func.UI.utils.find_in_element_data('xuData', $(SESSION_OBJ[SESSION_ID].root_element), 'nodeid', parent_element_ui_id);
|
|
31467
|
-
// const _elem_key = parent_element_ui_id;
|
|
31468
|
-
const _elem_key = _$elem.attr('xu-ui-id');
|
|
31469
|
-
const _elem_val = { attributes: [], $elm: _$elem };
|
|
31470
|
-
if (!_$elem?.length) continue;
|
|
31471
|
-
|
|
31472
|
-
if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
|
|
31473
|
-
|
|
31474
|
-
$.each(_$elem.data()?.xuAttributes, function (key, val) {
|
|
31475
|
-
_elem_val.attributes.push(key);
|
|
31476
|
-
});
|
|
31477
|
-
const obj = {
|
|
31478
|
-
ui_type: _elem_val.$elm.data().xuData.ui_type,
|
|
31479
|
-
SESSION_ID,
|
|
31480
|
-
elem_key: _elem_key,
|
|
31481
|
-
elem_val: _elem_val,
|
|
31482
|
-
fields_arr,
|
|
31483
|
-
xu_for_item_id: item.id,
|
|
31484
|
-
};
|
|
31485
|
-
if (avoid_xu_for_refresh) return;
|
|
31486
|
-
await func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'execute_xu_for', obj, new_job, _elem_val.$elm, _elem_val.$elm.data().xuData.paramsP.dsSessionP);
|
|
31487
|
-
|
|
31488
|
-
if (glb.DEBUG_MODE) {
|
|
31489
|
-
console.info('node execute_xu_for', obj, panel_val);
|
|
31490
|
-
}
|
|
31491
|
-
|
|
31492
|
-
break;
|
|
31493
|
-
}
|
|
31494
|
-
}
|
|
31495
|
-
|
|
31496
|
-
// if (glb.new_xu_render) {
|
|
31497
|
-
// if (attr === 'xu-exp:xu-render') {
|
|
31498
|
-
// //|| attr === 'xu-render'
|
|
31499
|
-
// for await (const [key, val] of Object.entries(_$elem)) {
|
|
31500
|
-
// if (key === 'length') break;
|
|
31501
|
-
// if ($(val).data().xuData.node) {
|
|
31502
|
-
// for await (const node of $(val).data().xuData.node.children) {
|
|
31503
|
-
// if (item.id !== node.id) continue;
|
|
31504
|
-
|
|
31505
|
-
// if (typeof node.xu_render_made !== 'undefined' && !node.xu_render_made) {
|
|
31506
|
-
// const node_data = UI_WORKER_OBJ.xu_render_cache[node.xu_render_xu_ui_id + node.xu_render_cache_id];
|
|
31507
|
-
// parent_element_ui_id;
|
|
31508
|
-
// const elem_key = node.xu_render_xu_ui_id;
|
|
31509
|
-
// const elem_val = { attributes: [attr], $elm: node_data.$div, data: node_data.data };
|
|
31510
|
-
// if (!elem_val.data?.xuData) continue;
|
|
31511
|
-
// elem_val.data.xuData.parent_element_ui_id = $(val).attr('xu-ui-id');
|
|
31512
|
-
// var res = await func.expression.get(SESSION_ID, elem_val.data.xuAttributes['xu-exp:xu-render'], elem_val.data.xuData.paramsP.dsSessionP, 'UI Property EXP', elem_val.data.xuData.recordid);
|
|
31513
|
-
|
|
31514
|
-
// var attr_value = await func.common.get_cast_val(SESSION_ID, 'refresh xu-attributes', 'xu-render', 'bool', res.result);
|
|
31515
|
-
// try {
|
|
31516
|
-
// const obj = {
|
|
31517
|
-
// ui_type: elem_val.data.xuData.ui_type,
|
|
31518
|
-
// SESSION_ID,
|
|
31519
|
-
// elem_key,
|
|
31520
|
-
// elem_val,
|
|
31521
|
-
// fields_arr,
|
|
31522
|
-
// attr_value,
|
|
31523
|
-
// };
|
|
31524
|
-
// func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'execute_xu_render_attributes', obj, new_job, elem_val.$elm, elem_val.data.xuData.paramsP.dsSessionP);
|
|
31525
|
-
// } catch (error) {
|
|
31526
|
-
// debugger;
|
|
31527
|
-
// }
|
|
31528
|
-
// }
|
|
31529
|
-
// }
|
|
31530
|
-
// }
|
|
31531
|
-
// }
|
|
31532
|
-
// }
|
|
31533
|
-
// }
|
|
31534
|
-
}
|
|
31535
|
-
}
|
|
31536
|
-
if (found) break;
|
|
31537
|
-
|
|
31538
|
-
if (item.children) {
|
|
31539
|
-
await iterate_progUi(item.children, item.id);
|
|
31540
|
-
}
|
|
31541
|
-
}
|
|
31542
|
-
};
|
|
31543
|
-
await iterate_progUi(progUi);
|
|
31544
|
-
return found;
|
|
31545
|
-
};
|
|
31546
|
-
|
|
31547
|
-
const $xu_embed_container = $('.xu_embed_container');
|
|
31548
|
-
const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $xu_embed_container, true);
|
|
31549
|
-
|
|
31550
|
-
for await (const field_id of fields_arr) {
|
|
31551
|
-
// run root
|
|
31552
|
-
if ($xu_embed_container.length) {
|
|
31553
|
-
const progUi = $xu_embed_container?.data()?.xuData?.screenInfo?.progUi;
|
|
31554
|
-
if (progUi) {
|
|
31555
|
-
await iterate_field_in_progUi(progUi, field_id);
|
|
31556
|
-
}
|
|
31557
|
-
}
|
|
31558
|
-
// run panels
|
|
31559
|
-
for await (const [panel_wrapper_element_ui_id, panel_val] of Object.entries(panels_obj)) {
|
|
31560
|
-
await iterate_field_in_progUi(panel_val.progUi, field_id, panel_val);
|
|
31561
|
-
}
|
|
31562
|
-
}
|
|
31563
|
-
|
|
31564
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
31565
|
-
|
|
31566
|
-
if (glb.DEBUG_MODE) {
|
|
31567
|
-
console.info('===================================================');
|
|
31568
|
-
}
|
|
31569
|
-
};
|
|
31570
|
-
|
|
31571
|
-
func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
|
|
31572
|
-
var found, refresh_reason, refresh_details;
|
|
31573
|
-
const validate_change = function (prog_doc, panelXuAttributes, skip_ui_check) {
|
|
31574
|
-
found = null;
|
|
31575
|
-
refresh_reason = null;
|
|
31576
|
-
refresh_details = null;
|
|
31577
|
-
const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
|
|
31578
|
-
for (const field_id of fields_changed_arr) {
|
|
31579
|
-
// get panel attributes
|
|
31580
|
-
const _attributes = panelXuAttributes || {};
|
|
31581
|
-
|
|
31582
|
-
// detect if program changed
|
|
31583
|
-
found = _attributes['xu-exp:program']?.includes('@' + field_id);
|
|
31584
|
-
|
|
31585
|
-
if (found) {
|
|
31586
|
-
refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
|
|
31587
|
-
refresh_details = _attributes;
|
|
31588
|
-
break;
|
|
31589
|
-
}
|
|
31590
|
-
|
|
31591
|
-
// _attributes holds also info of parameters in code_in: @code
|
|
31592
|
-
// search field changed in panel call send parameters exp
|
|
31593
|
-
for (const [attr, value] of Object.entries(_attributes)) {
|
|
31594
|
-
const pattern = /xu-exp:(\w+)/;
|
|
31595
|
-
const match = attr.match(pattern);
|
|
31596
|
-
|
|
31597
|
-
if (!match) {
|
|
31598
|
-
// continue if attribute is not expression
|
|
31599
|
-
continue;
|
|
31600
|
-
}
|
|
31601
|
-
// code_in
|
|
31602
|
-
const parameter_in_field_id = match?.[1];
|
|
31603
|
-
// @code
|
|
31604
|
-
if (value.includes(field_id)) {
|
|
31605
|
-
// search parameter in field in the target program's progDataSource
|
|
31606
|
-
found = progDataSource_str?.includes('@' + parameter_in_field_id);
|
|
31607
|
-
|
|
31608
|
-
if (found) {
|
|
31609
|
-
refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
|
|
31610
|
-
refresh_details = prog_doc?.progDataSource;
|
|
31611
|
-
|
|
31612
|
-
break;
|
|
31613
|
-
}
|
|
31614
|
-
if (!skip_ui_check) {
|
|
31615
|
-
found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
|
|
31616
|
-
|
|
31617
|
-
if (found) {
|
|
31618
|
-
refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
|
|
31619
|
-
refresh_details = found;
|
|
31620
|
-
|
|
31621
|
-
break;
|
|
31622
|
-
}
|
|
31623
|
-
}
|
|
31624
|
-
}
|
|
31625
|
-
}
|
|
31626
|
-
|
|
31627
|
-
if (found) break;
|
|
31628
|
-
|
|
31629
|
-
// search field changed in the target program's progDataSource // @code
|
|
31630
|
-
found = progDataSource_str?.includes('@' + field_id);
|
|
31631
|
-
if (found) {
|
|
31632
|
-
refresh_reason = `field ${field_id} in progDataSource changed`;
|
|
31633
|
-
refresh_details = prog_doc?.progDataSource;
|
|
31634
|
-
|
|
31635
|
-
break;
|
|
31636
|
-
}
|
|
31637
|
-
if (!skip_ui_check) {
|
|
31638
|
-
found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, field_id, 'xu-for').length;
|
|
31639
|
-
if (found) {
|
|
31640
|
-
refresh_reason = `field ${field_id} in progUi xu-for changed`;
|
|
31641
|
-
refresh_details = found;
|
|
31642
|
-
|
|
31643
|
-
break;
|
|
31644
|
-
}
|
|
31645
|
-
}
|
|
31646
|
-
|
|
31647
|
-
if (found) {
|
|
31648
|
-
break;
|
|
31649
|
-
}
|
|
31650
|
-
}
|
|
31651
|
-
};
|
|
31652
|
-
|
|
31653
|
-
// check the main program
|
|
31654
|
-
if (fields_changed_datasource) {
|
|
31655
|
-
const _session = SESSION_OBJ[SESSION_ID];
|
|
31656
|
-
const _ds = _session.DS_GLB[fields_changed_datasource];
|
|
31657
|
-
const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
31658
|
-
if (prog_doc.progUi) {
|
|
31659
|
-
validate_change(prog_doc, null, true);
|
|
31660
|
-
if (found) {
|
|
31661
|
-
const $elm = $(`#container_${_ds.prog_id}_0`);
|
|
31662
|
-
if ($elm?.length) {
|
|
31663
|
-
const elm_data = $elm.data();
|
|
31664
|
-
const $wrapper = $elm.parent();
|
|
31665
|
-
|
|
31666
|
-
const refreshed_ds = _ds.dsSession;
|
|
31667
|
-
|
|
31668
|
-
$elm.empty();
|
|
31669
|
-
if ($elm.data()) {
|
|
31670
|
-
const new_$div = await func.UI.screen.render_ui_tree(
|
|
31671
|
-
SESSION_ID,
|
|
31672
|
-
$elm, // the wrapper
|
|
31673
|
-
_.cloneDeep($elm.data().xuData.node), // the xu-panel node
|
|
31674
|
-
{},
|
|
31675
|
-
elm_data.xuData.paramsP, // the wrapper params
|
|
31676
|
-
null,
|
|
31677
|
-
null,
|
|
31678
|
-
elm_data.xuData.key, // the wrapper key
|
|
31679
|
-
refreshed_ds, // the refreshed_ds
|
|
31680
|
-
elm_data.xuData.parent_node, // the wrapper parent node
|
|
31681
|
-
null,
|
|
31682
|
-
elm_data.xuData.$root_container, // the wrapper root container
|
|
31683
|
-
);
|
|
31684
|
-
|
|
31685
|
-
if (glb.DEBUG_MODE) {
|
|
31686
|
-
console.info('========= refresh main info ==============');
|
|
31687
|
-
console.info('reason:', refresh_reason);
|
|
31688
|
-
console.info('element:', $elm);
|
|
31689
|
-
console.info('==========================================');
|
|
31690
|
-
}
|
|
31691
|
-
|
|
31692
|
-
return;
|
|
31693
|
-
}
|
|
31694
|
-
}
|
|
31695
|
-
}
|
|
31696
|
-
}
|
|
31697
|
-
}
|
|
31698
|
-
|
|
31699
|
-
const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
|
|
31700
|
-
|
|
31701
|
-
for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
|
|
31702
|
-
// const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
|
|
31703
|
-
if (!panel_val.$panel_div?.data()?.xuData) continue;
|
|
31704
|
-
|
|
31705
|
-
if (panel_val.$panel_div.data().xuData.pending_to_delete) continue;
|
|
31706
|
-
|
|
31707
|
-
if (fields_changed_arr) {
|
|
31708
|
-
if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
|
|
31709
|
-
continue;
|
|
31710
|
-
}
|
|
31711
|
-
validate_change(panel_val.prog_doc, panel_val?.panelXuAttributes);
|
|
31712
|
-
}
|
|
31713
|
-
|
|
31714
|
-
if (datasource_changed) {
|
|
31715
|
-
if (panel_val._ds.dsSession == datasource_changed) {
|
|
31716
|
-
refresh_reason = `panel datasource ${datasource_changed} changed`;
|
|
31717
|
-
refresh_details = '';
|
|
31718
|
-
|
|
31719
|
-
found = true;
|
|
31720
|
-
}
|
|
31721
|
-
}
|
|
31722
|
-
if (found) {
|
|
31723
|
-
UI_WORKER_OBJ.cache = {};
|
|
31724
|
-
const _session = SESSION_OBJ[SESSION_ID];
|
|
31725
|
-
if (glb.DEBUG_MODE) {
|
|
31726
|
-
console.info('========= refresh info ==============');
|
|
31727
|
-
console.info('reason:', refresh_reason);
|
|
31728
|
-
console.info('details:', refresh_details);
|
|
31729
|
-
console.info('panel:', panel_val);
|
|
31730
|
-
console.info('=====================================');
|
|
31731
|
-
}
|
|
31732
|
-
const $div_elm = panel_val.$panel_div;
|
|
31733
|
-
const wrapper_data = $div_elm.data();
|
|
31734
|
-
|
|
31735
|
-
if (_.isEmpty(wrapper_data)) continue;
|
|
31736
|
-
|
|
31737
|
-
try {
|
|
31738
|
-
const ts = Date.now();
|
|
31739
|
-
// remove old panel content
|
|
31740
|
-
$.each(panel_val.ids, async function (key, val) {
|
|
31741
|
-
$("[xu-ui-id='" + val + "']")
|
|
31742
|
-
.attr('xu-ui-id', val + ts)
|
|
31743
|
-
.removeData();
|
|
31744
|
-
});
|
|
31745
|
-
|
|
31746
|
-
let refreshed_ds;
|
|
31747
|
-
// check if ds exist and deleted by garbage collector
|
|
31748
|
-
|
|
31749
|
-
if (_session.DS_GLB[panel_val._ds.dsSession]) {
|
|
31750
|
-
refreshed_ds = panel_val._ds.dsSession;
|
|
31751
|
-
}
|
|
31752
|
-
for await (const item of wrapper_data.xuData.node_org.children) {
|
|
31753
|
-
if (item.tagName !== 'xu-panel') continue;
|
|
31754
|
-
|
|
31755
|
-
const new_$div = await func.UI.screen.render_ui_tree(
|
|
31756
|
-
SESSION_ID,
|
|
31757
|
-
$div_elm, // the wrapper
|
|
31758
|
-
_.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
|
|
31759
|
-
{},
|
|
31760
|
-
wrapper_data.xuData.paramsP, // the wrapper params
|
|
31761
|
-
null,
|
|
31762
|
-
null,
|
|
31763
|
-
wrapper_data.xuData.key, // the wrapper key
|
|
31764
|
-
refreshed_ds, // the refreshed_ds
|
|
31765
|
-
wrapper_data.xuData.parent_node, // the wrapper parent node
|
|
31766
|
-
null,
|
|
31767
|
-
wrapper_data.xuData.$root_container, // the wrapper root container
|
|
31768
|
-
);
|
|
31769
|
-
}
|
|
31770
|
-
|
|
31771
|
-
// remove old panel content
|
|
31772
|
-
$.each(panel_val.ids, async function (key, val) {
|
|
31773
|
-
$("[xu-ui-id='" + val + ts + "']").remove();
|
|
31774
|
-
});
|
|
31775
|
-
} catch (error) {
|
|
31776
|
-
debugger;
|
|
31777
|
-
}
|
|
31778
|
-
// continue;
|
|
31779
|
-
}
|
|
31780
|
-
}
|
|
31781
|
-
};
|
|
31782
|
-
|
|
31783
|
-
const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {
|
|
31784
|
-
const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
|
|
31785
|
-
if (!_prog) return;
|
|
31786
|
-
|
|
31787
|
-
// get in parameters
|
|
31788
|
-
let params_res = {},
|
|
31789
|
-
params_raw = {};
|
|
31790
|
-
if (_prog?.properties?.progParams) {
|
|
31791
|
-
for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
|
|
31792
|
-
if (!['in', 'out'].includes(val.data.dir)) continue;
|
|
31793
|
-
|
|
31794
|
-
if (nodeP.attributes) {
|
|
31795
|
-
if (nodeP.attributes[val.data.parameter]) {
|
|
31796
|
-
params_res[val.data.parameter] = nodeP.attributes[val.data.parameter];
|
|
31797
|
-
} else if (nodeP.attributes[`xu-exp:${val.data.parameter}`]) {
|
|
31798
|
-
if (val.data.dir == 'out') {
|
|
31799
|
-
// only reference
|
|
31800
|
-
params_res[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
|
|
31801
|
-
} else {
|
|
31802
|
-
// in parameter
|
|
31803
|
-
let ret = await func.expression.get(SESSION_ID, nodeP.attributes[`xu-exp:${val.data.parameter}`], dsSession, 'parameters');
|
|
31804
|
-
params_res[val.data.parameter] = ret.result;
|
|
31805
|
-
params_raw[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`];
|
|
31806
|
-
}
|
|
31807
|
-
}
|
|
31808
|
-
continue;
|
|
31809
|
-
}
|
|
31810
|
-
console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
|
|
31811
|
-
}
|
|
31812
|
-
}
|
|
31813
|
-
return { params_res, params_raw };
|
|
31814
|
-
};
|
|
31815
|
-
|
|
31816
|
-
func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, xu_func, $elm, val, is_init, refreshed_ds) {
|
|
31817
|
-
if (is_skeleton) return;
|
|
31818
|
-
|
|
31819
|
-
// console.log(nodeP.id, xu_func, val);
|
|
31820
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
31821
|
-
const tag_fx = {
|
|
31822
|
-
[`xu-panel`]: {
|
|
31823
|
-
program: async function ($elm, val) {
|
|
31824
|
-
var ret = {};
|
|
31825
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
31826
|
-
var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
31827
|
-
const init_program = async function () {
|
|
31828
|
-
async function render_panel() {
|
|
31829
|
-
const prog_id = val.value?.prog || val.value;
|
|
31830
|
-
const params_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
|
|
31831
|
-
let ret_panel = await func.UI.screen.init(SESSION_ID, prog_id, paramsP.screenId, _ds, $elm, null, _ds.currentRecordId, null, true, params_obj.params_res, 'initXu_panel', undefined, prog_id !== _ds.prog_id ? null : refreshed_ds, params_obj.params_raw);
|
|
31832
|
-
ret = { $new_div: ret_panel };
|
|
31833
|
-
if ($container.data().xuData) {
|
|
31834
|
-
$container.data().xuData.xuPanelProps = $elm.data().xuAttributes;
|
|
31835
|
-
$container.data().xuData.xuPanelData = ret_panel.data();
|
|
31836
|
-
}
|
|
31837
|
-
return ret;
|
|
31838
|
-
}
|
|
31839
|
-
|
|
31840
|
-
if (!val.value) {
|
|
31841
|
-
val.value = '_empty_panel_program';
|
|
31842
|
-
}
|
|
31843
|
-
|
|
31844
|
-
ret = await render_panel();
|
|
31845
|
-
|
|
31846
|
-
return ret;
|
|
31847
|
-
};
|
|
31848
|
-
const alter_program = async function () {
|
|
31849
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
31850
|
-
var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
31851
|
-
|
|
31852
|
-
/////////////////
|
|
31853
|
-
async function render_panel() {
|
|
31854
|
-
// // if (!cache_str) {
|
|
31855
|
-
// // await update_container(screen_ready_function);
|
|
31856
|
-
// // }
|
|
31857
|
-
// // if (cache_str && !CACHE_PROG_UI[cache_str]) {
|
|
31858
|
-
// // await update_container(screen_ready_function);
|
|
31859
|
-
// // save_cache();
|
|
31860
|
-
// // }
|
|
31861
|
-
// // if (callback) callback($div);
|
|
31862
|
-
// // $container.data().xuData.node.children =
|
|
31863
|
-
// // $div.data().xuData.node.children;
|
|
31864
|
-
// // //swiper-wrapper
|
|
31865
|
-
// // var restore_slides_elements = async function () {
|
|
31866
|
-
// // if ($tmp_div.children().length) {
|
|
31867
|
-
// // $tmp_div
|
|
31868
|
-
// // .find(".swiper-wrapper")
|
|
31869
|
-
// // .empty()
|
|
31870
|
-
// // .append($new_div.children());
|
|
31871
|
-
// // $new_div.append($tmp_div.children());
|
|
31872
|
-
// // }
|
|
31873
|
-
// // };
|
|
31874
|
-
// // // console.log($tmp_div);
|
|
31875
|
-
// // await restore_slides_elements();
|
|
31876
|
-
// // // CHANGE_PANEL_BUSY = false;
|
|
31877
|
-
// // func.events.delete_job(SESSION_ID, jobNo);
|
|
31878
|
-
// };
|
|
31879
|
-
const program = val.value?.prog || val.value;
|
|
31880
|
-
var $wrapper = $('<div>');
|
|
31881
|
-
var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, nodeP.attributes, null, null, null, $wrapper, '');
|
|
31882
|
-
const params_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
|
|
31883
|
-
let ret_init = await func.UI.screen.init(SESSION_ID, program, paramsP.screenId, _ds, $div, null, _ds.currentRecordId, jobNoP, true, params_obj.params_res, 'alterXu_panel', undefined, undefined, params_obj.params_raw);
|
|
31884
|
-
ret = {
|
|
31885
|
-
$new_div: ret_init,
|
|
31886
|
-
abort: true,
|
|
31887
|
-
};
|
|
31888
|
-
await func.UI.screen.panel_post_render_handler(SESSION_ID, $elm, $new_div, nodeP, $div.clone(true), jobNoP);
|
|
31889
|
-
|
|
31890
|
-
return ret;
|
|
31891
|
-
}
|
|
31892
|
-
if (!val.value) {
|
|
31893
|
-
return { abort: true };
|
|
31894
|
-
}
|
|
31895
|
-
await render_panel();
|
|
31896
|
-
return ret;
|
|
31897
|
-
};
|
|
31898
|
-
|
|
31899
|
-
if (is_init) {
|
|
31900
|
-
let ret = await init_program();
|
|
31901
|
-
return ret;
|
|
31902
|
-
}
|
|
31903
|
-
return alter_program();
|
|
31904
|
-
},
|
|
31905
|
-
|
|
31906
|
-
'xu-render': async function ($elm, val) {
|
|
31907
|
-
let ret = await common_fx['xu-render']($elm, val, true);
|
|
31908
|
-
return ret;
|
|
31909
|
-
},
|
|
31910
|
-
'xu-ref': async function ($elm, val) {
|
|
31911
|
-
let ret = await common_fx['xu-ref']($container, val, $container.data().xuData.xuPanelData.xuData.paramsP.dsSessionP);
|
|
31912
|
-
return ret;
|
|
31913
|
-
},
|
|
31914
|
-
},
|
|
31915
|
-
[`xu-teleport`]: {
|
|
31916
|
-
to: async function ($elm, val) {
|
|
31917
|
-
if (!glb.new_xu_render) {
|
|
31918
|
-
if (val.value) {
|
|
31919
|
-
// parent_infoP.is_xu_teleport;
|
|
31920
|
-
if ($elm?.parent()?.data()?.xuData?.length) {
|
|
31921
|
-
$elm.parent().data('xuTeleportData', []);
|
|
31922
|
-
for (const [key, node] of Object.entries(nodeP.children)) {
|
|
31923
|
-
const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $(val.value), node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
31924
|
-
|
|
31925
|
-
$elm.parent().data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
31926
|
-
$teleport_elm.attr('xu-teleport-parent-id', $elm.parent().attr('xu-ui-id'));
|
|
31927
|
-
}
|
|
31928
|
-
$elm.remove();
|
|
31929
|
-
} else {
|
|
31930
|
-
$elm.data('xuTeleportData', []).attr('hidden', true);
|
|
31931
|
-
for (const [key, node] of Object.entries(nodeP.children)) {
|
|
31932
|
-
const $to_container = $(val.value);
|
|
31933
|
-
if (!$to_container?.length) {
|
|
31934
|
-
return console.error(`container ${val.value} for xuTeleportData not found`);
|
|
31935
|
-
}
|
|
31936
|
-
const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $to_container, node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
31937
|
-
|
|
31938
|
-
$elm.data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
31939
|
-
$teleport_elm.attr('xu-teleport-parent-id', $elm.attr('xu-ui-id'));
|
|
31940
|
-
}
|
|
31941
|
-
}
|
|
31942
|
-
}
|
|
31943
|
-
return { abort: true };
|
|
31944
|
-
}
|
|
31945
|
-
|
|
31946
|
-
if (val.value) {
|
|
31947
|
-
// // parent_infoP.is_xu_teleport;
|
|
31948
|
-
// if ($elm?.parent()?.data()?.xuData?.length) {
|
|
31949
|
-
// $elm.parent().data('xuTeleportData', []);
|
|
31950
|
-
// for (const [key, node] of Object.entries(nodeP.children)) {
|
|
31951
|
-
// const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $(val.value), node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
31952
|
-
// $elm.parent().data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
31953
|
-
// $teleport_elm.attr('xu-teleport-parent-id', $elm.parent().attr('xu-ui-id'));
|
|
31954
|
-
// }
|
|
31955
|
-
// $elm.remove();
|
|
31956
|
-
// } else {
|
|
31957
|
-
// $elm.data('xuTeleportData', []).attr('hidden', true);
|
|
31958
|
-
// for (const [key, node] of Object.entries(nodeP.children)) {
|
|
31959
|
-
// const $to_container = $(val.value);
|
|
31960
|
-
// if (!$to_container?.length) {
|
|
31961
|
-
// return console.error(`container ${val.value} for xuTeleportData not found`);
|
|
31962
|
-
// }
|
|
31963
|
-
// const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $to_container, node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
31964
|
-
// $elm.data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
31965
|
-
// $teleport_elm.attr('xu-teleport-parent-id', $elm.attr('xu-ui-id'));
|
|
31966
|
-
// }
|
|
31967
|
-
// }
|
|
31968
|
-
}
|
|
31969
|
-
return {};
|
|
31970
|
-
},
|
|
31971
|
-
'xu-render': async function ($elm, val) {
|
|
31972
|
-
let ret = await common_fx['xu-render']($elm, val, true);
|
|
31973
|
-
return ret;
|
|
31974
|
-
},
|
|
31975
|
-
'xu-show': async function ($elm, val) {
|
|
31976
|
-
let ret = await common_fx['xu-show']($elm, val, true);
|
|
31977
|
-
return ret;
|
|
31978
|
-
},
|
|
31979
|
-
},
|
|
31980
|
-
};
|
|
31981
|
-
|
|
31982
|
-
const load_cdn = async function (resource) {
|
|
31983
|
-
// console.log("loading cdn", resource);
|
|
31984
|
-
if (!_.isObject(resource) && _.isString(resource)) {
|
|
31985
|
-
resource = { src: resource, type: 'js' };
|
|
31986
|
-
}
|
|
31987
|
-
if (!_.isObject(resource)) {
|
|
31988
|
-
throw new Error('cdn resource in wrong format');
|
|
31989
|
-
}
|
|
31990
|
-
return new Promise(async (resolve) => {
|
|
31991
|
-
try {
|
|
31992
|
-
switch (resource.type) {
|
|
31993
|
-
case 'js':
|
|
31994
|
-
await func.utils.load_js_on_demand(resource.src);
|
|
31995
|
-
break;
|
|
31996
|
-
case 'css':
|
|
31997
|
-
await func.utils.load_js_on_demand(resource.src);
|
|
31998
|
-
break;
|
|
31999
|
-
case 'module':
|
|
32000
|
-
func.utils.load_js_on_demand(resource.src, 'module');
|
|
32001
|
-
break;
|
|
32002
|
-
|
|
32003
|
-
default:
|
|
32004
|
-
await func.utils.load_js_on_demand(resource.src);
|
|
32005
|
-
break;
|
|
32006
|
-
}
|
|
32007
|
-
resolve();
|
|
32008
|
-
} catch (error) {
|
|
32009
|
-
func.utils.debug_report(SESSION_ID, 'xu-cdn', 'Fail to load: ' + resource, 'W');
|
|
32010
|
-
resolve();
|
|
32011
|
-
}
|
|
32012
|
-
|
|
32013
|
-
// if (resource.type === "js" || !resource.type) {
|
|
32014
|
-
// await func.utils.load_js_on_demand(resource.src);
|
|
32015
|
-
// return resolve();
|
|
32016
|
-
// }
|
|
32017
|
-
// if (resource.type === "css") {
|
|
32018
|
-
// func.utils.load_css_on_demand(resource.src);
|
|
32019
|
-
// return resolve();
|
|
32020
|
-
// }
|
|
32021
|
-
// if (resource.type === "module") {
|
|
32022
|
-
// func.utils.load_js_on_demand(resource.src, "module");
|
|
32023
|
-
// return resolve();
|
|
32024
|
-
// }
|
|
32025
|
-
// func.utils.debug_report(
|
|
32026
|
-
// SESSION_ID,
|
|
32027
|
-
// "xu-cdn",
|
|
32028
|
-
// "Fail to load: " + resource,
|
|
32029
|
-
// "W"
|
|
32030
|
-
// );
|
|
32031
|
-
// return resolve();
|
|
32032
|
-
});
|
|
32033
|
-
};
|
|
32034
|
-
|
|
32035
|
-
const common_fx = {
|
|
32036
|
-
'xu-attrs': async function ($elm, val) {
|
|
32037
|
-
if (!val.value) return {};
|
|
32038
|
-
if (!_.isObject(val.value)) throw 'xu-attrs value us not an object';
|
|
32039
|
-
for (const [attr_key, attr_val] of Object.entries(val.value)) {
|
|
32040
|
-
nodeP.attributes[attr_key] = attr_val;
|
|
32041
|
-
}
|
|
32042
|
-
|
|
32043
|
-
return {};
|
|
32044
|
-
},
|
|
32045
|
-
'xu-ref': async function ($elm, val, dsSession) {
|
|
32046
|
-
if (!val.value) return {};
|
|
32047
|
-
|
|
32048
|
-
func.UI.update_xu_ref(SESSION_ID, dsSession || paramsP.dsSessionP, val.value, $elm);
|
|
32049
|
-
|
|
32050
|
-
// Select the node that will be observed for mutations
|
|
32051
|
-
const targetNode = $elm[0];
|
|
32052
|
-
|
|
32053
|
-
if (!targetNode) return;
|
|
32054
|
-
|
|
32055
|
-
// Options for the observer (which mutations to observe)
|
|
32056
|
-
const config = { attributes: true, childList: true, subtree: true };
|
|
32057
|
-
|
|
32058
|
-
// Callback function to execute when mutations are observed
|
|
32059
|
-
const callback = (mutationList, observer) => {
|
|
32060
|
-
func.UI.screen.refresh_xu_attributes(SESSION_ID, [val.value]);
|
|
32061
|
-
};
|
|
32062
|
-
|
|
32063
|
-
// Create an observer instance linked to the callback function
|
|
32064
|
-
const observer = new MutationObserver(callback);
|
|
32065
|
-
|
|
32066
|
-
// Start observing the target node for configured mutations
|
|
32067
|
-
observer.observe(targetNode, config);
|
|
32068
|
-
|
|
32069
|
-
// Later, you can stop observing
|
|
32070
|
-
// observer.disconnect();
|
|
32071
|
-
|
|
32072
|
-
return {};
|
|
32073
|
-
},
|
|
32074
|
-
'xu-bind': async function ($elm, val) {
|
|
32075
|
-
if (is_skeleton) return;
|
|
32076
|
-
|
|
32077
|
-
let val_is_reference_field = false;
|
|
32078
|
-
|
|
32079
|
-
let _prog_id = $elm.data().xuData.paramsP.prog_id;
|
|
32080
|
-
let _dsP = $elm.data().xuData.paramsP.dsSessionP;
|
|
32081
|
-
const view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _prog_id);
|
|
32082
|
-
if (!view_ret) return {};
|
|
32083
|
-
|
|
32084
|
-
let is_dynamic_field = false;
|
|
32085
|
-
let field_prop;
|
|
32086
|
-
let bind_field_id;
|
|
32087
|
-
|
|
32088
|
-
const input_field_type = $elm.attr('type');
|
|
32089
|
-
|
|
32090
|
-
const get_bind_field = async function (field_id) {
|
|
32091
|
-
if (['_FOR_VAL', '_FOR_KEY'].includes(field_id)) {
|
|
32092
|
-
is_dynamic_field = true;
|
|
32093
|
-
field_prop = _ds.dynamic_fields[field_id];
|
|
32094
|
-
} else {
|
|
32095
|
-
field_prop = func.common.find_item_by_key(view_ret.progFields, 'field_id', field_id);
|
|
32096
|
-
if (!field_prop) {
|
|
32097
|
-
/// find the field everywhere in the chain Aug 30 2024
|
|
32098
|
-
const ret_get_value = await func.datasource.get_value(SESSION_ID, field_id, _dsP);
|
|
32099
|
-
|
|
32100
|
-
if (ret_get_value.found) {
|
|
32101
|
-
_dsP = ret_get_value.dsSessionP;
|
|
32102
|
-
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
|
|
32103
|
-
_prog_id = _ds.prog_id;
|
|
32104
|
-
const view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _prog_id);
|
|
32105
|
-
if (!view_ret) return {};
|
|
32106
|
-
field_prop = func.common.find_item_by_key(view_ret.progFields, 'field_id', field_id);
|
|
32107
|
-
}
|
|
32108
|
-
if (!field_prop) {
|
|
32109
|
-
throw `field ${field_id} not found in the program scope`;
|
|
32110
|
-
}
|
|
32111
|
-
}
|
|
32112
|
-
}
|
|
32113
|
-
return field_id;
|
|
32114
|
-
};
|
|
32115
|
-
|
|
32116
|
-
try {
|
|
32117
|
-
bind_field_id = await get_bind_field(val.value.split('.')[0]);
|
|
32118
|
-
val_is_reference_field = true;
|
|
32119
|
-
} catch (err) {
|
|
32120
|
-
console.error(err?.message || err);
|
|
32121
|
-
return {};
|
|
32122
|
-
}
|
|
32123
|
-
|
|
32124
|
-
const field_changed = async function (e) {
|
|
32125
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
|
|
32126
|
-
|
|
32127
|
-
// update array for checkbox that not in xu-for
|
|
32128
|
-
if (field_prop.props.fieldType === 'array' && input_field_type === 'checkbox' && val_is_reference_field) {
|
|
32129
|
-
let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
|
|
32130
|
-
let value_from_getter = bind.getter($elm[0]);
|
|
32131
|
-
let value;
|
|
32132
|
-
if (arr_value_before_cast.includes(value_from_getter)) {
|
|
32133
|
-
value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
|
|
32134
|
-
} else {
|
|
32135
|
-
arr_value_before_cast.push(value_from_getter);
|
|
32136
|
-
value = arr_value_before_cast;
|
|
32137
|
-
}
|
|
32138
|
-
|
|
32139
|
-
let datasource_changes = {
|
|
32140
|
-
[_dsP]: {
|
|
32141
|
-
[_ds.currentRecordId]: {
|
|
32142
|
-
[bind_field_id]: value,
|
|
32143
|
-
},
|
|
32144
|
-
},
|
|
32145
|
-
};
|
|
32146
|
-
|
|
32147
|
-
return await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32148
|
-
}
|
|
32149
|
-
|
|
32150
|
-
// update array for radio that not in xu-for
|
|
32151
|
-
if (field_prop.props.fieldType === 'array' && input_field_type === 'radio' && val_is_reference_field) {
|
|
32152
|
-
let value_from_getter = bind.getter($elm[0]);
|
|
32153
|
-
|
|
32154
|
-
let datasource_changes = {
|
|
32155
|
-
[_dsP]: {
|
|
32156
|
-
[_ds.currentRecordId]: {
|
|
32157
|
-
[bind_field_id]: [value_from_getter],
|
|
32158
|
-
},
|
|
32159
|
-
},
|
|
32160
|
-
};
|
|
32161
|
-
|
|
32162
|
-
return await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32163
|
-
}
|
|
32164
|
-
|
|
32165
|
-
var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_prop.props.fieldType, bind.getter($elm[0]));
|
|
32166
|
-
|
|
32167
|
-
if (field_prop.props.fieldType === 'object') {
|
|
32168
|
-
value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, bind.getter($elm[0]));
|
|
32169
|
-
}
|
|
32170
|
-
|
|
32171
|
-
if (!_ds.currentRecordId) return;
|
|
32172
|
-
|
|
32173
|
-
let datasource_changes = {
|
|
32174
|
-
[_dsP]: {
|
|
32175
|
-
[_ds.currentRecordId]: {
|
|
32176
|
-
[bind_field_id]: value,
|
|
32177
|
-
},
|
|
32178
|
-
},
|
|
32179
|
-
};
|
|
32180
|
-
|
|
32181
|
-
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32182
|
-
const iterate_info = $elm?.data()?.xuData?.iterate_info;
|
|
32183
|
-
const reference_source_obj = iterate_info?.reference_source_obj;
|
|
32184
|
-
if (reference_source_obj) {
|
|
32185
|
-
if (reference_source_obj.ret.type === 'array') {
|
|
32186
|
-
if (iterate_info.iterator_val === bind_field_id) {
|
|
32187
|
-
const arr_idx = Number($elm?.data()?.xuData?.iterate_info._key);
|
|
32188
|
-
|
|
32189
|
-
const dataset_arr = await func.datasource.get_value(SESSION_ID, reference_source_obj.fieldIdP, _dsP, reference_source_obj.currentRecordId);
|
|
32190
|
-
let new_arr = _.cloneDeep(dataset_arr.ret.value);
|
|
32191
|
-
|
|
32192
|
-
if (field_prop.props.fieldType === 'object' && val_is_reference_field) {
|
|
32193
|
-
let obj_item = new_arr[arr_idx];
|
|
32194
|
-
|
|
32195
|
-
let e_exp = val.value.replace(bind_field_id, 'obj_item');
|
|
32196
|
-
|
|
32197
|
-
let new_val = eval(e_exp + (input_field_type === 'string' ? `="${value}"` : `=${value}`));
|
|
32198
|
-
|
|
32199
|
-
new_arr[arr_idx] = obj_item;
|
|
32200
|
-
} else {
|
|
32201
|
-
new_arr[arr_idx] = value;
|
|
32202
|
-
}
|
|
32203
|
-
// datasource_changes[_dsP][_ds.currentRecordId][reference_source_obj.fieldIdP] = new_arr;
|
|
32204
|
-
|
|
32205
|
-
let datasource_changes = {
|
|
32206
|
-
[_dsP]: {
|
|
32207
|
-
[_ds.currentRecordId]: {
|
|
32208
|
-
[reference_source_obj.fieldIdP]: new_arr,
|
|
32209
|
-
},
|
|
32210
|
-
},
|
|
32211
|
-
};
|
|
32212
|
-
|
|
32213
|
-
await func.datasource.update(SESSION_ID, datasource_changes, null, true);
|
|
32214
|
-
}
|
|
32215
|
-
}
|
|
32216
|
-
}
|
|
32217
|
-
|
|
32218
|
-
await func.datasource.update_changes_for_out_parameter(SESSION_ID, _dsP, _ds.parentDataSourceNo);
|
|
32219
|
-
};
|
|
32220
|
-
|
|
32221
|
-
const bind = new UI_FRAMEWORK_PLUGIN.bind();
|
|
32222
|
-
|
|
32223
|
-
bind.listener($elm[0], field_changed);
|
|
32224
|
-
|
|
32225
|
-
const set_value = function () {
|
|
32226
|
-
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
32227
|
-
if (!_ds.currentRecordId) return;
|
|
32228
|
-
let value;
|
|
32229
|
-
try {
|
|
32230
|
-
if (val_is_reference_field) {
|
|
32231
|
-
if (is_dynamic_field) {
|
|
32232
|
-
value = _ds.dynamic_fields[bind_field_id].value;
|
|
32233
|
-
} else {
|
|
32234
|
-
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
32235
|
-
value = _ds.data_feed.rows?.[row_idx]?.[bind_field_id];
|
|
32236
|
-
}
|
|
32237
|
-
if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && $elm.attr('value')) {
|
|
32238
|
-
if (value.includes($elm.attr('value'))) {
|
|
32239
|
-
value = true;
|
|
32240
|
-
} else {
|
|
32241
|
-
value = false;
|
|
32242
|
-
}
|
|
32243
|
-
} else if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && $elm.attr('value')) {
|
|
32244
|
-
if (value.includes($elm.attr('value'))) {
|
|
32245
|
-
value = $elm.attr('value');
|
|
32246
|
-
} else {
|
|
32247
|
-
value = false;
|
|
32248
|
-
}
|
|
32249
|
-
} else if (field_prop.props.fieldType === 'object' && val.value.split('.').length > 1) {
|
|
32250
|
-
let str = val.value.replace(bind_field_id, '(' + JSON.stringify(value) + ')');
|
|
32251
|
-
value = eval(str);
|
|
32252
|
-
}
|
|
32253
|
-
} else {
|
|
32254
|
-
value = val.value;
|
|
32255
|
-
}
|
|
32256
|
-
if (typeof value === 'undefined') return;
|
|
32257
|
-
bind.setter($elm[0], value);
|
|
32258
|
-
} catch (err) {
|
|
32259
|
-
console.error(err);
|
|
32260
|
-
}
|
|
32261
|
-
};
|
|
32262
|
-
/// init value from ds
|
|
32263
|
-
$('body').on('xu-bind-refresh.' + _ds.dsSession.toString(), () => {
|
|
32264
|
-
set_value();
|
|
32265
|
-
});
|
|
32266
|
-
|
|
32267
|
-
set_value();
|
|
32268
|
-
return {};
|
|
32269
|
-
},
|
|
32270
|
-
'xu-render': async function ($elm, val, from_panel) {
|
|
32271
|
-
const old_render = async function () {
|
|
32272
|
-
var value = await func.common.get_cast_val(SESSION_ID, 'common fx', 'xu-render', 'bool', val.value);
|
|
32273
|
-
const init_render = function () {
|
|
32274
|
-
if (!value) {
|
|
32275
|
-
var cloned_$div = $elm.clone(true);
|
|
32276
|
-
|
|
32277
|
-
let $xurender = $('<xurender>').attr('xu-ui-id', $elm.attr('xu-ui-id')).attr('hidden', true).appendTo($container); //.hide();
|
|
32278
|
-
let original_data_obj = {
|
|
32279
|
-
$container: cloned_$div,
|
|
32280
|
-
nodeP: _.cloneDeep(nodeP),
|
|
32281
|
-
parent_infoP,
|
|
32282
|
-
paramsP,
|
|
32283
|
-
keyP,
|
|
32284
|
-
parent_nodeP,
|
|
32285
|
-
$root_container,
|
|
32286
|
-
};
|
|
32287
|
-
$xurender.data('xuData', cloned_$div.data().xuData);
|
|
32288
|
-
$xurender.data().xuData.original_data_obj = original_data_obj;
|
|
32289
|
-
$xurender.data().xuData.xurender_node = cloned_$div;
|
|
32290
|
-
$xurender.data().xuAttributes = nodeP.attributes || {};
|
|
32291
|
-
// $xurender.hide();
|
|
32292
|
-
|
|
32293
|
-
$elm.remove();
|
|
32294
|
-
return { abort: true };
|
|
32295
|
-
}
|
|
32296
|
-
return {};
|
|
32297
|
-
};
|
|
32298
|
-
|
|
32299
|
-
const post_render = async function () {
|
|
32300
|
-
if (value) {
|
|
32301
|
-
try {
|
|
32302
|
-
// abort if already rended
|
|
32303
|
-
if ($elm[0].tagName !== 'XURENDER' && $elm?.length) {
|
|
32304
|
-
return func.events.delete_job(SESSION_ID, jobNoP);
|
|
32305
|
-
}
|
|
32306
|
-
|
|
32307
|
-
let original_data_obj = $elm.data().xuData.original_data_obj;
|
|
32308
|
-
|
|
32309
|
-
if (!original_data_obj) {
|
|
32310
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32311
|
-
return { delete_job: jobNoP };
|
|
32312
|
-
}
|
|
32313
|
-
|
|
32314
|
-
const new_$div = await func.UI.screen.render_ui_tree(
|
|
32315
|
-
SESSION_ID,
|
|
32316
|
-
$elm, //original_data_obj.$container,
|
|
32317
|
-
_.cloneDeep(original_data_obj.nodeP),
|
|
32318
|
-
original_data_obj.parent_infoP,
|
|
32319
|
-
original_data_obj.paramsP,
|
|
32320
|
-
jobNoP,
|
|
32321
|
-
null,
|
|
32322
|
-
original_data_obj.keyP,
|
|
32323
|
-
null,
|
|
32324
|
-
original_data_obj.parent_nodeP,
|
|
32325
|
-
null,
|
|
32326
|
-
original_data_obj.$root_container,
|
|
32327
|
-
);
|
|
32328
|
-
|
|
32329
|
-
new_$div.data().xuData.original_data_obj = original_data_obj;
|
|
32330
|
-
new_$div.data().xuData.xurender_node = $elm.clone(true);
|
|
32331
|
-
new_$div.data().xuAttributes = $elm.data().xuAttributes || {};
|
|
32332
|
-
|
|
32333
|
-
const replace = async function () {
|
|
32334
|
-
$elm.replaceWith(new_$div);
|
|
32335
|
-
if (from_panel) {
|
|
32336
|
-
const xuPanelWrapper = _.clone(new_$div.data().xuPanelWrapper);
|
|
32337
|
-
$elm.parent().data().xuPanelWrapper = xuPanelWrapper;
|
|
32338
|
-
$elm.replaceWith(new_$div.children());
|
|
32339
|
-
}
|
|
32340
|
-
|
|
32341
|
-
if (val.fields_arr) {
|
|
32342
|
-
return await func.UI.screen.refresh_xu_attributes(SESSION_ID, val.fields_arr, val.jobNoP, new_$div);
|
|
32343
|
-
}
|
|
32344
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32345
|
-
};
|
|
32346
|
-
// if ($elm && func.UI.utils.find_in_element_data('xuData', $(SESSION_OBJ[SESSION_ID].root_element), 'xu_id', $elm.data().xuData.xu_id).length) {
|
|
32347
|
-
if ($elm && $(`[xu-ui-id="${$elm.attr('xu-ui-id')}"]`).length) {
|
|
32348
|
-
if (new_$div.data().xuData.paramsP) {
|
|
32349
|
-
return await replace();
|
|
32350
|
-
}
|
|
32351
|
-
|
|
32352
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32353
|
-
}
|
|
32354
|
-
} catch (error) {
|
|
32355
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32356
|
-
}
|
|
32357
|
-
return;
|
|
32358
|
-
}
|
|
32359
|
-
// if (!value) {
|
|
32360
|
-
if ($elm.prop('tagName') === 'XURENDER') {
|
|
32361
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32362
|
-
return;
|
|
32363
|
-
}
|
|
32364
|
-
|
|
32365
|
-
let tmp_$div = $('<div>');
|
|
32366
|
-
|
|
32367
|
-
let $xurender = $('<xurender>').attr('xu-ui-id', $elm.attr('xu-ui-id')).appendTo(tmp_$div); //.hide();
|
|
32368
|
-
// was true before
|
|
32369
|
-
if ($elm.data().xuData.xurender_node) {
|
|
32370
|
-
$xurender.data({
|
|
32371
|
-
xuAttributes: $elm.data().xuData.xurender_node.data().xuAttributes || {},
|
|
32372
|
-
xuData: $elm.data().xuData.xurender_node.data().xuData || {},
|
|
32373
|
-
});
|
|
32374
|
-
} else {
|
|
32375
|
-
// default new state
|
|
32376
|
-
|
|
32377
|
-
$xurender.data({
|
|
32378
|
-
xuAttributes: $elm.data().xuAttributes || {},
|
|
32379
|
-
xuData: $elm.data().xuData || {},
|
|
32380
|
-
});
|
|
32381
|
-
const original_data_obj = {
|
|
32382
|
-
nodeP: _.cloneDeep($elm.data().xuData.node_org),
|
|
32383
|
-
paramsP: $elm.data().xuData.paramsP,
|
|
32384
|
-
$container: $elm.clone(true),
|
|
32385
|
-
parent_infoP: parent_infoP,
|
|
32386
|
-
};
|
|
32387
|
-
|
|
32388
|
-
$xurender.data().xuData.original_data_obj = original_data_obj;
|
|
32389
|
-
}
|
|
32390
|
-
|
|
32391
|
-
//remove xu-teleport trace
|
|
32392
|
-
$.each($elm.find('xu-teleport'), (key, val) => {
|
|
32393
|
-
const xuTeleportData = $(val).data().xuTeleportData || [];
|
|
32394
|
-
for (const teleported_elm_id of xuTeleportData) {
|
|
32395
|
-
$(`[xu-ui-id="${teleported_elm_id}"]`).remove();
|
|
32396
|
-
}
|
|
32397
|
-
});
|
|
32398
|
-
|
|
32399
|
-
$elm.replaceWith(tmp_$div.children());
|
|
32400
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32401
|
-
// }
|
|
32402
|
-
};
|
|
32403
|
-
if (is_init) {
|
|
32404
|
-
return init_render();
|
|
32405
|
-
}
|
|
32406
|
-
return await post_render();
|
|
32407
|
-
};
|
|
32408
|
-
|
|
32409
|
-
const new_render = async function () {
|
|
32410
|
-
var value = await func.common.get_cast_val(SESSION_ID, 'common fx', 'xu-render', 'bool', val.value);
|
|
32411
|
-
const has_xu_render_attribute = true;
|
|
32412
|
-
const has_xu_exp_render_attribute = $elm.data()?.xuData?.attr_exp_info?.['xu-render'] ? true : false;
|
|
32413
|
-
const init_render = async function () {
|
|
32414
|
-
nodeP.xu_render_made = value;
|
|
32415
|
-
if (!value) {
|
|
32416
|
-
if (has_xu_exp_render_attribute) {
|
|
32417
|
-
return { has_xu_exp_render_attribute, has_xu_render_attribute, xu_render_background_processing: true };
|
|
32418
|
-
}
|
|
32419
|
-
return { has_xu_render_attribute, abort: true };
|
|
32420
|
-
}
|
|
32421
|
-
return { has_xu_exp_render_attribute, has_xu_render_attribute };
|
|
32422
|
-
};
|
|
32423
|
-
|
|
32424
|
-
const post_render = async function () {
|
|
32425
|
-
// always come from refresh
|
|
32426
|
-
let nodeP = $container.data().xuData.node.children[keyP];
|
|
32427
|
-
nodeP.xu_render_made = value;
|
|
32428
|
-
if (value) {
|
|
32429
|
-
try {
|
|
32430
|
-
const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($elm.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
|
|
32431
|
-
const xu_ui_id = $elm.attr('xu-ui-id');
|
|
32432
|
-
let new_$div = UI_WORKER_OBJ?.xu_render_cache?.[xu_ui_id + xu_render_cache_id]?.$div.clone(true);
|
|
32433
|
-
let found_parent_vars = false;
|
|
32434
|
-
if (new_$div) {
|
|
32435
|
-
// validate if $div contains fields from parent ds
|
|
32436
|
-
const parent_data = get_parent_ds_fields(SESSION_ID, paramsP.dsSessionP);
|
|
32437
|
-
const parent_fields = Object.keys(parent_data);
|
|
32438
|
-
|
|
32439
|
-
$.each(new_$div.find('*'), (key, val) => {
|
|
32440
|
-
const _xuAttributes = $(val)?.data()?.xuAttributes;
|
|
32441
|
-
if (found_parent_vars || !_xuAttributes) return;
|
|
32442
|
-
for (const [attr_key, attr_val] of Object.entries(_xuAttributes)) {
|
|
32443
|
-
if (found_parent_vars) break;
|
|
32444
|
-
for (const [key, val] of Object.entries(parent_fields)) {
|
|
32445
|
-
if (attr_val.includes('@' + key)) {
|
|
32446
|
-
found_parent_vars = true;
|
|
32447
|
-
break;
|
|
32448
|
-
}
|
|
32449
|
-
}
|
|
32450
|
-
}
|
|
32451
|
-
});
|
|
32452
|
-
}
|
|
32453
|
-
|
|
32454
|
-
if (!new_$div || found_parent_vars) {
|
|
32455
|
-
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { paramsP };
|
|
32456
|
-
nodeP.xu_render_xu_ui_id = xu_ui_id;
|
|
32457
|
-
nodeP.xu_render_cache_id = xu_render_cache_id;
|
|
32458
|
-
new_$div = await func.UI.screen.render_ui_tree(SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, null, keyP, null, parent_nodeP, null, $root_container);
|
|
32459
|
-
const _$div = new_$div.clone(true);
|
|
32460
|
-
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id].$div = _$div;
|
|
32461
|
-
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id].data = _$div.data();
|
|
32462
|
-
}
|
|
32463
|
-
// append order handling
|
|
32464
|
-
|
|
32465
|
-
if (!$container.children().length) {
|
|
32466
|
-
new_$div.appendTo($container);
|
|
32467
|
-
} else {
|
|
32468
|
-
// iterate the container node
|
|
32469
|
-
let $last_elm_found = [];
|
|
32470
|
-
$.each($container.data().xuData.node.children, (item_key, item_val) => {
|
|
32471
|
-
// const $elm = $(`[xu-node-id="${item_val.id}"]`);
|
|
32472
|
-
const $elm = func.UI.utils.find_in_element_data('xuData', $(SESSION_OBJ[SESSION_ID].root_element), 'nodeid', item_val.id);
|
|
32473
|
-
if ($elm.length) {
|
|
32474
|
-
$last_elm_found = $elm;
|
|
32475
|
-
}
|
|
32476
|
-
if (keyP == item_key) {
|
|
32477
|
-
if ($last_elm_found.length) {
|
|
32478
|
-
new_$div.after($last_elm_found);
|
|
32479
|
-
} else {
|
|
32480
|
-
$container.prepend(new_$div);
|
|
32481
|
-
}
|
|
32482
|
-
}
|
|
32483
|
-
});
|
|
32484
|
-
}
|
|
32485
|
-
} catch (error) {
|
|
32486
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32487
|
-
}
|
|
32488
|
-
return;
|
|
32489
|
-
}
|
|
32490
|
-
|
|
32491
|
-
/////////// !value ///////////
|
|
32492
|
-
|
|
32493
|
-
const xu_ui_id = $elm.attr('xu-ui-id');
|
|
32494
|
-
|
|
32495
|
-
const cache_str = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($elm.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
|
|
32496
|
-
const _$div = $elm.clone(true);
|
|
32497
|
-
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + cache_str] = { $div: _$div, data: _$div.data(), paramsP };
|
|
32498
|
-
$elm.remove();
|
|
32499
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32500
|
-
};
|
|
32501
|
-
if (is_init) {
|
|
32502
|
-
return await init_render();
|
|
32503
|
-
}
|
|
32504
|
-
return await post_render();
|
|
32505
|
-
};
|
|
32506
|
-
|
|
32507
|
-
if (glb.new_xu_render) {
|
|
32508
|
-
return new_render();
|
|
32509
|
-
}
|
|
32510
|
-
return old_render();
|
|
32511
|
-
},
|
|
32512
|
-
'xu-show': async function ($elm, val) {
|
|
32513
|
-
var value = await func.common.get_cast_val(SESSION_ID, 'common fx', 'xu-show', 'bool', val.value);
|
|
32514
|
-
if (value) {
|
|
32515
|
-
$elm.show();
|
|
32516
|
-
}
|
|
32517
|
-
if (!value) {
|
|
32518
|
-
$elm.hide();
|
|
32519
|
-
}
|
|
32520
|
-
return {};
|
|
32521
|
-
},
|
|
32522
|
-
'xu-content': async function ($elm, val) {
|
|
32523
|
-
try {
|
|
32524
|
-
$elm.html(val.value);
|
|
32525
|
-
} catch (error) {
|
|
32526
|
-
console.warn(e);
|
|
32527
|
-
}
|
|
32528
|
-
return;
|
|
32529
|
-
},
|
|
32530
|
-
'xu-text': async function ($elm, val) {
|
|
32531
|
-
try {
|
|
32532
|
-
$elm.text(val.value);
|
|
32533
|
-
} catch (error) {
|
|
32534
|
-
console.warn(e);
|
|
32535
|
-
}
|
|
32536
|
-
return;
|
|
32537
|
-
},
|
|
32538
|
-
'xu-html': async function ($elm, val) {
|
|
32539
|
-
try {
|
|
32540
|
-
$elm.html(val.value);
|
|
32541
|
-
} catch (error) {
|
|
32542
|
-
console.warn(e);
|
|
32543
|
-
}
|
|
32544
|
-
return;
|
|
32545
|
-
},
|
|
32546
|
-
'xu-for': async function ($elm, data) {
|
|
32547
|
-
// exit if call from rendered xu-for item to prevent infante loop (parent_infoP?.iterate_info indicate call from rendered item)
|
|
32548
|
-
if (parent_infoP?.iterate_info) return {};
|
|
32549
|
-
if (!data.value) return {};
|
|
32550
|
-
try {
|
|
32551
|
-
// data.value (xu-for) can store actual values such as an array, a CSV, or a field_id that references a specific field within the dataset, initialized with values for the iteration.
|
|
32552
|
-
let arr = data.value;
|
|
32553
|
-
|
|
32554
|
-
// find reference source field
|
|
32555
|
-
let reference_source_obj;
|
|
32556
|
-
|
|
32557
|
-
const _progFields = await func.datasource.get_progFields(SESSION_ID, paramsP.dsSessionP);
|
|
32558
|
-
|
|
32559
|
-
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', data.value);
|
|
32560
|
-
// detect if data.value (xu-for) is reference field_id by checking if exist in the dataset
|
|
32561
|
-
if (view_field_obj) {
|
|
32562
|
-
// xu-for is reference field_id
|
|
32563
|
-
reference_source_obj = await func.datasource.get_value(SESSION_ID, data.value, paramsP.dsSessionP);
|
|
32564
|
-
arr = reference_source_obj?.ret?.value;
|
|
32565
|
-
} else {
|
|
32566
|
-
// xu-for is actual data
|
|
32567
|
-
if (typeof data.value === 'string') {
|
|
32568
|
-
arr = eval(data.value.replaceAll('\\', ''));
|
|
32569
|
-
}
|
|
32570
|
-
if (typeof arr === 'number') {
|
|
32571
|
-
arr = Array.from(Array(arr).keys());
|
|
32572
|
-
}
|
|
32573
|
-
}
|
|
32574
|
-
|
|
32575
|
-
const custom_iterator_key = $elm.data().xuData.iterator_key;
|
|
32576
|
-
const custom_iterator_val = $elm.data().xuData.iterator_val;
|
|
32577
|
-
|
|
32578
|
-
let iterator_key = custom_iterator_key;
|
|
32579
|
-
let iterator_val = custom_iterator_val;
|
|
32580
|
-
let is_key_dynamic_field, is_val_dynamic_field;
|
|
32581
|
-
|
|
32582
|
-
// custom FOR_VAL name or namespaced default name
|
|
32583
|
-
if (!custom_iterator_key) {
|
|
32584
|
-
is_key_dynamic_field = true;
|
|
32585
|
-
|
|
32586
|
-
iterator_key = '_FOR_KEY';
|
|
32587
|
-
}
|
|
32588
|
-
|
|
32589
|
-
if (!custom_iterator_val) {
|
|
32590
|
-
is_val_dynamic_field = true;
|
|
32591
|
-
|
|
32592
|
-
iterator_val = '_FOR_VAL';
|
|
32593
|
-
}
|
|
32594
|
-
|
|
32595
|
-
var i = 0;
|
|
32596
|
-
for await (let [_key, _val] of Object.entries(arr)) {
|
|
32597
|
-
if (_.isArray(arr)) {
|
|
32598
|
-
_key = Number(_key);
|
|
32599
|
-
}
|
|
32600
|
-
|
|
32601
|
-
const set_value = async function (is_dynamic_field, currentRecordId, field_id, value) {
|
|
32602
|
-
if (is_dynamic_field) {
|
|
32603
|
-
func.datasource.add_dynamic_field_to_ds(SESSION_ID, paramsP.dsSessionP, field_id, value);
|
|
32604
|
-
} else {
|
|
32605
|
-
const _progFields = await func.datasource.get_progFields(SESSION_ID, paramsP.dsSessionP);
|
|
32606
|
-
|
|
32607
|
-
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
32608
|
-
if (view_field_obj) {
|
|
32609
|
-
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
32610
|
-
try {
|
|
32611
|
-
const row_idx = func.common.find_ROWID_idx(_ds, currentRecordId);
|
|
32612
|
-
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
32613
|
-
} catch (err) {
|
|
32614
|
-
console.error(err);
|
|
32615
|
-
}
|
|
32616
|
-
} else {
|
|
32617
|
-
console.error('field not exist in dataset for xu-for method');
|
|
32618
|
-
}
|
|
32619
|
-
}
|
|
32620
|
-
};
|
|
32621
|
-
|
|
32622
|
-
var currentRecordId = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId.toString();
|
|
32623
|
-
|
|
32624
|
-
await set_value(is_key_dynamic_field, currentRecordId, iterator_key, _key);
|
|
32625
|
-
await set_value(is_val_dynamic_field, currentRecordId, iterator_val, _val);
|
|
32626
|
-
|
|
32627
|
-
var iterate_info = {
|
|
32628
|
-
_val,
|
|
32629
|
-
_key,
|
|
32630
|
-
iterator_key,
|
|
32631
|
-
iterator_val,
|
|
32632
|
-
is_key_dynamic_field,
|
|
32633
|
-
is_val_dynamic_field,
|
|
32634
|
-
reference_source_obj,
|
|
32635
|
-
};
|
|
32636
|
-
let _parent_info = _.cloneDeep(parent_infoP) || {};
|
|
32637
|
-
_parent_info.iterate_info = iterate_info;
|
|
32638
|
-
|
|
32639
|
-
const $divP = await func.UI.screen.render_ui_tree(
|
|
32640
|
-
SESSION_ID,
|
|
32641
|
-
$container,
|
|
32642
|
-
nodeP,
|
|
32643
|
-
_parent_info, //parent_infoP ? _.cloneDeep(_parent_info) : null,
|
|
32644
|
-
paramsP,
|
|
32645
|
-
jobNoP,
|
|
32646
|
-
null,
|
|
32647
|
-
i,
|
|
32648
|
-
null,
|
|
32649
|
-
nodeP,
|
|
32650
|
-
null,
|
|
32651
|
-
$root_container,
|
|
32652
|
-
);
|
|
32653
|
-
|
|
32654
|
-
$.each($divP.children(), function (key, val) {
|
|
32655
|
-
if ($(val)?.data()?.xuData) {
|
|
32656
|
-
$(val).data().xuData.iterate_info = iterate_info;
|
|
32657
|
-
}
|
|
32658
|
-
});
|
|
32659
|
-
|
|
32660
|
-
i++;
|
|
32661
|
-
}
|
|
32662
|
-
$elm.remove();
|
|
32663
|
-
return { abort: true };
|
|
32664
|
-
} catch (e) {
|
|
32665
|
-
console.error(' Iterator Arr parse error');
|
|
32666
|
-
return { abort: true };
|
|
32667
|
-
}
|
|
32668
|
-
},
|
|
32669
|
-
'xu-for-key': async function ($elm, val) {
|
|
32670
|
-
$elm.data().xuData.iterator_key = val.value;
|
|
32671
|
-
return {};
|
|
32672
|
-
},
|
|
32673
|
-
'xu-for-val': async function ($elm, val) {
|
|
32674
|
-
$elm.data().xuData.iterator_val = val.value;
|
|
32675
|
-
return {};
|
|
32676
|
-
},
|
|
32677
|
-
'xu-class': async function ($elm, val) {
|
|
32678
|
-
try {
|
|
32679
|
-
const classes_string = val.value;
|
|
32680
|
-
// let obj = _.isString(classes_string) ? JSON.parse(classes_string) : _.defaults(classes_string, {});
|
|
32681
|
-
|
|
32682
|
-
const classes_obj = _.isString(classes_string) ? JSON.parse(classes_string) : _.defaults(classes_string, {});
|
|
32683
|
-
for await (const [cla, cond] of Object.entries(classes_obj)) {
|
|
32684
|
-
let res = await func.expression.get(
|
|
32685
|
-
SESSION_ID,
|
|
32686
|
-
cond,
|
|
32687
|
-
paramsP.dsSessionP,
|
|
32688
|
-
'UI Attr EXP',
|
|
32689
|
-
$elm.data().xuData.currentRecordId, // SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId
|
|
32690
|
-
null,
|
|
32691
|
-
null,
|
|
32692
|
-
null,
|
|
32693
|
-
null,
|
|
32694
|
-
null,
|
|
32695
|
-
$elm.data().xuData.iterate_info,
|
|
32696
|
-
);
|
|
32697
|
-
|
|
32698
|
-
if (res.result) {
|
|
32699
|
-
$elm.addClass(cla);
|
|
32700
|
-
} else {
|
|
32701
|
-
$elm.removeClass(cla);
|
|
32702
|
-
}
|
|
32703
|
-
|
|
32704
|
-
$elm.data().xuData.debug_info.attribute_stat['xu-class'] = $elm.attr('class');
|
|
32705
|
-
}
|
|
32706
|
-
return {};
|
|
32707
|
-
} catch (e) {
|
|
32708
|
-
console.warn('parse error:' + val.value);
|
|
32709
|
-
return { abort: true };
|
|
32710
|
-
}
|
|
32711
|
-
},
|
|
32712
|
-
'xu-exp': async function ($elm, val) {
|
|
32713
|
-
let exp = val.value === null ? true : val.value;
|
|
32714
|
-
|
|
32715
|
-
let exp_ret = await func.expression.get(SESSION_ID, exp, paramsP.dsSessionP, 'UI Attr EXP', SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId, null, null, null, null, null, $elm.data().xuData.iterate_info);
|
|
32716
|
-
|
|
32717
|
-
let value = func.UI.screen.fix_val_defaults(val.key, exp_ret.result);
|
|
32718
|
-
|
|
32719
|
-
var new_val = {
|
|
32720
|
-
key: val.key,
|
|
32721
|
-
value,
|
|
32722
|
-
};
|
|
32723
|
-
|
|
32724
|
-
if (nodeP.tagName.substr(0, 3) === 'xu-') {
|
|
32725
|
-
if (tag_fx[nodeP.tagName][new_val.key]) {
|
|
32726
|
-
return await tag_fx[nodeP.tagName][new_val.key]($elm, new_val);
|
|
32727
|
-
}
|
|
32728
|
-
console.warn(`attribute ${new_val.key} not found for ${nodeP.tagName}`);
|
|
32729
|
-
return {};
|
|
32730
|
-
}
|
|
32731
|
-
if (!$elm.data().xuData) return;
|
|
32732
|
-
|
|
32733
|
-
$elm.data().xuData.debug_info.attribute_stat[new_val.key] = new_val.value;
|
|
32734
|
-
|
|
32735
|
-
// IGNORE UNDEFINED or NULL ATTRIBUTES
|
|
32736
|
-
if (typeof new_val.value === 'undefined' || new_val.value === null) {
|
|
32737
|
-
return {};
|
|
32738
|
-
}
|
|
32739
|
-
|
|
32740
|
-
// IGNORE ATTRIBUTES WITH EMPTY VALUES
|
|
32741
|
-
if (glb.solid_attributes.includes(new_val.key) && !new_val.value) {
|
|
32742
|
-
return {};
|
|
32743
|
-
}
|
|
32744
|
-
|
|
32745
|
-
if (new_val.key.substr(0, 2) === 'xu') {
|
|
32746
|
-
return await common_fx[new_val.key]($elm, new_val);
|
|
32747
|
-
}
|
|
32748
|
-
|
|
32749
|
-
$elm.attr(new_val.key, ($elm.attr(new_val.key) || '') + new_val.value);
|
|
32750
|
-
return {};
|
|
32751
|
-
},
|
|
32752
|
-
'xu-on': async function ($elm, val) {
|
|
32753
|
-
CLIENT_ACTIVITY_TS = Date.now();
|
|
32754
|
-
const trigger = val.key.split('xu-on:')[1].toLowerCase();
|
|
32755
|
-
$elm.on(trigger, async function (evt) {
|
|
32756
|
-
const _$elm = $(evt.currentTarget);
|
|
32757
|
-
if (_.isEmpty(_$elm.data().xuAttributes)) return;
|
|
32758
|
-
|
|
32759
|
-
for await (const [key, val] of Object.entries(_$elm.data().xuAttributes['xu-on:' + evt.type])) {
|
|
32760
|
-
if (!_.isEmpty(val.props.condition)) {
|
|
32761
|
-
const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
|
|
32762
|
-
if (!expCond.result) continue;
|
|
32763
|
-
}
|
|
32764
|
-
|
|
32765
|
-
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
32766
|
-
evt[val.event_modifiers]();
|
|
32767
|
-
}
|
|
32768
|
-
|
|
32769
|
-
// if (val.handler === 'custom') {
|
|
32770
|
-
if (val.workflow) {
|
|
32771
|
-
// do BL
|
|
32772
|
-
for await (const [key2, val2] of Object.entries(val.workflow)) {
|
|
32773
|
-
// var cond = val2.data.enabled;
|
|
32774
|
-
// if (val2.data.enabled && val2.props.condition) {
|
|
32775
|
-
// expCond = await func.expression.get(SESSION_ID, val2.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
|
|
32776
|
-
// cond = expCond.result;
|
|
32777
|
-
// }
|
|
32778
|
-
// if (!cond) continue;
|
|
32779
|
-
|
|
32780
|
-
if (!val2.data.enabled) continue; // added Jul 3, 25 - condition validate on execution
|
|
32781
|
-
|
|
32782
|
-
func.events.add_to_queue(SESSION_ID, 'element event', val2.id, evt.type, val2.data.action, val2.data.name, null, _$elm.attr('xu-ui-id'), null, evt, null, null, null, paramsP.dsSessionP, null, null, null, evt.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
|
|
32783
|
-
}
|
|
32784
|
-
}
|
|
32785
|
-
}
|
|
32786
|
-
});
|
|
32787
|
-
return {};
|
|
32788
|
-
},
|
|
32789
|
-
'xu-script': async function ($elm, val) {
|
|
32790
|
-
var checkExist = setInterval(function () {
|
|
32791
|
-
if ($elm.is(':visible')) {
|
|
32792
|
-
try {
|
|
32793
|
-
// var res = eval('(' + val.value + ')');
|
|
32794
|
-
const fn = `(function(el, evt) {
|
|
32795
|
-
${val.value}
|
|
32796
|
-
})(document.querySelector(\`[xu-ui-id="${$elm.attr('xu-ui-id')}"]\`),evt));`;
|
|
32797
|
-
|
|
32798
|
-
var res = eval(fn);
|
|
32799
|
-
// if (typeof res === 'function') {
|
|
32800
|
-
// res($elm[0]);
|
|
32801
|
-
// }
|
|
32802
|
-
} catch (e) {
|
|
32803
|
-
eval(val.value);
|
|
32804
|
-
}
|
|
32805
|
-
|
|
32806
|
-
clearInterval(checkExist);
|
|
32807
|
-
}
|
|
32808
|
-
}, 100); // check every 100ms
|
|
32809
|
-
|
|
32810
|
-
return {};
|
|
32811
|
-
},
|
|
32812
|
-
'xu-style-global': async function ($elm, val) {
|
|
32813
|
-
$('head').append(`<style>${val.value}</style>`);
|
|
32814
|
-
return {};
|
|
32815
|
-
},
|
|
32816
|
-
'xu-style': async function ($elm, val) {
|
|
32817
|
-
var cssString = val.value;
|
|
32818
|
-
|
|
32819
|
-
var parser = new cssjs();
|
|
32820
|
-
|
|
32821
|
-
var parsed = parser.parseCSS(cssString);
|
|
32822
|
-
var xuUiId = `[xu-ui-id="${$elm.attr('xu-ui-id')}"]`;
|
|
32823
|
-
|
|
32824
|
-
$.each(parsed, function (key, val) {
|
|
32825
|
-
var selectors_arr = val.selector.split(',');
|
|
32826
|
-
|
|
32827
|
-
$.each(selectors_arr, function (key2, val2) {
|
|
32828
|
-
selectors_arr[key2] = `${xuUiId} ${val2}, ${xuUiId}${val2}`;
|
|
32829
|
-
// console.log(new_selector);
|
|
32830
|
-
});
|
|
32831
|
-
|
|
32832
|
-
val.selector = selectors_arr.join(',');
|
|
32833
|
-
// console.log(parsed);
|
|
32834
|
-
});
|
|
32835
|
-
|
|
32836
|
-
var newCSSString = parser.getCSSForEditor(parsed);
|
|
32837
|
-
|
|
32838
|
-
$('head').append(`<style>${newCSSString}</style>`);
|
|
32839
|
-
return {};
|
|
32840
|
-
},
|
|
32841
|
-
'xu-cdn': async function ($elm, val) {
|
|
32842
|
-
for await (const [key, resource] of Object.entries(val.value)) {
|
|
32843
|
-
await load_cdn(resource);
|
|
32844
|
-
}
|
|
32845
|
-
|
|
32846
|
-
return {};
|
|
32847
|
-
},
|
|
32848
|
-
'xu-ui-plugin': async function ($elm, val) {
|
|
32849
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
32850
|
-
|
|
32851
|
-
for await (const [plugin_name, value] of Object.entries(val.value)) {
|
|
32852
|
-
const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
|
|
32853
|
-
if (_plugin?.installed && _plugin?.manifest?.['runtime.mjs']?.exist && _plugin?.manifest?.['index.mjs']?.exist && value.enabled) {
|
|
32854
|
-
if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
|
|
32855
|
-
const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
|
|
32856
|
-
func.utils.load_css_on_demand(plugin_runtime_css_url);
|
|
32857
|
-
}
|
|
32858
|
-
|
|
32859
|
-
const plugin_index_src = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
|
|
32860
|
-
|
|
32861
|
-
const plugin_index_resources = await import(plugin_index_src);
|
|
32862
|
-
|
|
32863
|
-
let properties = _.cloneDeep(plugin_index_resources.properties);
|
|
32864
|
-
for await (let [prop_name, prop_val] of Object.entries(properties)) {
|
|
32865
|
-
prop_val.value = value?.attributes?.[prop_name];
|
|
32866
|
-
if (value?.attributes?.[`xu-exp:${prop_name}`]) {
|
|
32867
|
-
const res = await func.expression.get(SESSION_ID, value?.attributes?.[`xu-exp:${prop_name}`], paramsP.dsSessionP, 'UI Attr EXP');
|
|
32868
|
-
prop_val.value = res.result;
|
|
32869
|
-
}
|
|
32870
|
-
}
|
|
32871
|
-
// $elm.data().xu_ui_plugin = { properties };
|
|
32872
|
-
const plugin_runtime_src = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
|
|
32873
|
-
|
|
32874
|
-
const plugin_runtime_resources = await import(plugin_runtime_src);
|
|
32875
|
-
|
|
32876
|
-
if (plugin_runtime_resources.cdn && typeof _.isArray(plugin_runtime_resources.cdn)) {
|
|
32877
|
-
for await (const resource of plugin_runtime_resources.cdn) {
|
|
32878
|
-
await load_cdn(resource);
|
|
32879
|
-
}
|
|
32880
|
-
}
|
|
32881
|
-
|
|
32882
|
-
if (plugin_runtime_resources.fn) {
|
|
32883
|
-
await plugin_runtime_resources.fn(plugin_name, $elm?.[0], properties);
|
|
32884
|
-
// await plugin_runtime_resources.fn(plugin_name, $elm?.[0], $elm.data().xu_ui_plugin.properties);
|
|
32885
|
-
}
|
|
32886
|
-
}
|
|
32887
|
-
}
|
|
32888
|
-
|
|
32889
|
-
return {};
|
|
32890
|
-
},
|
|
32891
|
-
'xu-store': async function ($elm, val) {
|
|
32892
|
-
try {
|
|
32893
|
-
const fields_obj = JSON5.parse(val.value);
|
|
32894
|
-
for (const [field_id, value] of Object.entries(fields_obj)) {
|
|
32895
|
-
func.datasource.add_dynamic_field_to_ds(SESSION_ID, paramsP.dsSessionP, field_id, value);
|
|
32896
|
-
}
|
|
32897
|
-
} catch (err) {
|
|
32898
|
-
console.error(err);
|
|
32899
|
-
}
|
|
32900
|
-
return {};
|
|
32901
|
-
},
|
|
32902
|
-
'xu-viewport': async function ($elm, val) {
|
|
32903
|
-
// functionality in draw_html_element
|
|
32904
|
-
return {};
|
|
32905
|
-
},
|
|
32906
|
-
};
|
|
32907
|
-
|
|
32908
|
-
if (nodeP.tagName.substr(0, 3) === 'xu-') {
|
|
32909
|
-
if (xu_func === 'xu-exp') {
|
|
32910
|
-
return common_fx[xu_func]($elm, val);
|
|
32911
|
-
}
|
|
32912
|
-
|
|
32913
|
-
if (tag_fx?.[nodeP.tagName]?.[xu_func]) {
|
|
32914
|
-
let ret = await tag_fx[nodeP.tagName][xu_func]($elm, val);
|
|
32915
|
-
return ret;
|
|
32916
|
-
}
|
|
32917
|
-
// if (xu_func !== "tree_id")
|
|
32918
|
-
console.warn(`attribute ${xu_func} not found for ${nodeP.tagName}`);
|
|
32919
|
-
return {};
|
|
32920
|
-
}
|
|
32921
|
-
if (_.isEmpty($elm.data())) {
|
|
32922
|
-
return {};
|
|
32923
|
-
}
|
|
32924
|
-
if (!$elm.data().xuData.debug_info.attribute_stat) {
|
|
32925
|
-
$elm.data().xuData.debug_info.attribute_stat = {};
|
|
32926
|
-
}
|
|
32927
|
-
if (xu_func !== 'xu-exp') {
|
|
32928
|
-
$elm.data().xuData.debug_info.attribute_stat[xu_func] = val.value;
|
|
32929
|
-
}
|
|
32930
|
-
try {
|
|
32931
|
-
if (!common_fx[xu_func]) {
|
|
32932
|
-
console.warn('invalid xu-tag', xu_func, error);
|
|
32933
|
-
return {};
|
|
32934
|
-
}
|
|
32935
|
-
|
|
32936
|
-
return await common_fx[xu_func]($elm, val);
|
|
32937
|
-
} catch (error) {
|
|
32938
|
-
debugger;
|
|
32939
|
-
}
|
|
32940
|
-
};
|
|
32941
|
-
|
|
32942
|
-
func.UI.screen.fix_val_defaults = function (key, val) {
|
|
32943
|
-
var ret = val;
|
|
32944
|
-
if (
|
|
32945
|
-
key === 'xu-render' &&
|
|
32946
|
-
(typeof val === 'undefined' || val === null || val === '') //|| val === ""
|
|
32947
|
-
) {
|
|
32948
|
-
// ret = 'Y'; // was ret = "N";
|
|
32949
|
-
ret = true;
|
|
32950
|
-
}
|
|
32951
|
-
if (
|
|
32952
|
-
key === 'xu-show' &&
|
|
32953
|
-
(typeof val === 'undefined' || val === null || val === '') //|| val === ""
|
|
32954
|
-
) {
|
|
32955
|
-
// ret = 'Y';
|
|
32956
|
-
ret = true;
|
|
32957
|
-
}
|
|
32958
|
-
return ret;
|
|
32959
|
-
};
|
|
32960
|
-
|
|
32961
|
-
func.UI.screen.set_attributes_new = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $elm, is_init, execute_attributes = [], refreshed_ds) {
|
|
32962
|
-
var done_exp = [];
|
|
32963
|
-
|
|
32964
|
-
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
32965
|
-
if (!_ds) return { abort: true };
|
|
32966
|
-
|
|
32967
|
-
const get_attr_value = async function (key) {
|
|
32968
|
-
let ret = func.UI.screen.fix_val_defaults(key, nodeP.attributes[key]);
|
|
32969
|
-
if (nodeP?.attributes?.hasOwnProperty(`xu-exp:${key}`)) {
|
|
32970
|
-
ret = await get_xuExp(key);
|
|
32971
|
-
}
|
|
32972
|
-
return ret;
|
|
32973
|
-
};
|
|
32974
|
-
|
|
32975
|
-
const get_xuExp = async function (attrib) {
|
|
32976
|
-
if (is_skeleton) return;
|
|
32977
|
-
if (glb.new_xu_render) {
|
|
32978
|
-
let _xuData = $elm.data().xuData;
|
|
32979
|
-
if (!_xuData.attr_exp_info) {
|
|
32980
|
-
_xuData.attr_exp_info = {};
|
|
32981
|
-
}
|
|
32982
|
-
}
|
|
32983
|
-
const attr = `xu-exp:${attrib}`;
|
|
32984
|
-
|
|
32985
|
-
if (!nodeP?.attributes?.hasOwnProperty(attr)) return;
|
|
32986
|
-
// const attr = `xu-exp-${attrib}`;
|
|
32987
|
-
var exp = nodeP.attributes[attr];
|
|
32988
|
-
// if (!value) return func.UI.screen.fix_val_defaults(attrib, exp || nodeP.attributes[attrib]);
|
|
32989
|
-
|
|
32990
|
-
var res = await func.expression.get(SESSION_ID, exp, paramsP.dsSessionP, 'UI Attr EXP', _ds.currentRecordId);
|
|
32991
|
-
if (glb.new_xu_render) {
|
|
32992
|
-
_xuData.attr_exp_info[attrib] = res;
|
|
32993
|
-
}
|
|
32994
|
-
// nodeP.attributes[attr] = value; //{ value: value, res: res };
|
|
32995
|
-
done_exp.push(attr);
|
|
32996
|
-
return res.result; //func.UI.screen.fix_val_defaults(attrib, res.result);
|
|
32997
|
-
};
|
|
32998
|
-
|
|
32999
|
-
var _ret = {};
|
|
33000
|
-
if (nodeP.type !== 'element' || !nodeP.attributes) return _ret;
|
|
33001
|
-
|
|
33002
|
-
for (let [key, val] of Object.entries(nodeP.attributes)) {
|
|
33003
|
-
// REMOVE STATIC ATTRIBUTES IF EXP EXISTS to avoid dup
|
|
33004
|
-
if (key.substring(0, 6) === 'xu-exp') {
|
|
33005
|
-
if (_.isEmpty(val)) {
|
|
33006
|
-
delete nodeP.attributes[key];
|
|
33007
|
-
continue;
|
|
33008
|
-
}
|
|
33009
|
-
const clean_key = key.split(':')[1];
|
|
33010
|
-
if (typeof nodeP.attributes[clean_key] !== 'undefined') {
|
|
33011
|
-
delete nodeP.attributes[clean_key];
|
|
33012
|
-
}
|
|
33013
|
-
}
|
|
33014
|
-
// FIX abbreviations
|
|
33015
|
-
if (glb.attr_abbreviations_arr.includes(key)) {
|
|
33016
|
-
nodeP.attributes[`xu-on:${key.substring(3)}`] = [
|
|
33017
|
-
{
|
|
33018
|
-
handler: 'custom',
|
|
33019
|
-
props: {},
|
|
33020
|
-
event: [
|
|
33021
|
-
{
|
|
33022
|
-
id: Date.now(),
|
|
33023
|
-
data: {
|
|
33024
|
-
action: 'update',
|
|
33025
|
-
name: { value: val },
|
|
33026
|
-
enabled: true,
|
|
33027
|
-
},
|
|
33028
|
-
props: {},
|
|
33029
|
-
},
|
|
33030
|
-
],
|
|
33031
|
-
},
|
|
33032
|
-
];
|
|
33033
|
-
delete nodeP.attributes[key];
|
|
33034
|
-
}
|
|
33035
|
-
}
|
|
33036
|
-
|
|
33037
|
-
for (let [key, val] of Object.entries(nodeP.attributes)) {
|
|
33038
|
-
// FIX STATIC DEFAULTS
|
|
33039
|
-
val = func.UI.screen.fix_val_defaults(key, val);
|
|
33040
|
-
|
|
33041
|
-
// REMOVE UNDEFINED or NULL ATTRIBUTES
|
|
33042
|
-
if (typeof val === 'undefined' || val === null) {
|
|
33043
|
-
delete nodeP.attributes[key];
|
|
33044
|
-
}
|
|
33045
|
-
|
|
33046
|
-
// REMOVE ATTRIBUTES WITH EMPTY VALUES
|
|
33047
|
-
if (glb.solid_attributes.includes(key) && !val) {
|
|
33048
|
-
delete nodeP.attributes[key];
|
|
33049
|
-
}
|
|
33050
|
-
}
|
|
33051
|
-
|
|
33052
|
-
// XU-ATTRS
|
|
33053
|
-
if (nodeP?.attributes?.['xu-attrs'] || nodeP?.attributes?.['xu-exp:xu-attrs']) {
|
|
33054
|
-
const attr = 'xu-attrs';
|
|
33055
|
-
let ret = await func.UI.screen.execute_xu_functions(
|
|
33056
|
-
SESSION_ID,
|
|
33057
|
-
is_skeleton,
|
|
33058
|
-
$root_container,
|
|
33059
|
-
nodeP,
|
|
33060
|
-
$container,
|
|
33061
|
-
paramsP,
|
|
33062
|
-
parent_infoP,
|
|
33063
|
-
jobNoP,
|
|
33064
|
-
keyP,
|
|
33065
|
-
parent_nodeP,
|
|
33066
|
-
attr,
|
|
33067
|
-
$elm,
|
|
33068
|
-
{
|
|
33069
|
-
key: attr,
|
|
33070
|
-
value: await get_attr_value(attr),
|
|
33071
|
-
},
|
|
33072
|
-
is_init,
|
|
33073
|
-
);
|
|
33074
|
-
}
|
|
33075
|
-
|
|
33076
|
-
// BEFORE
|
|
33077
|
-
if (!_.isEmpty(nodeP.attributes)) {
|
|
33078
|
-
for await (const [key, attr] of Object.entries(glb.run_xu_before)) {
|
|
33079
|
-
if (_ret.abort || $container?.data()?.xuData?.pending_to_delete) break;
|
|
33080
|
-
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) {
|
|
33081
|
-
continue;
|
|
33082
|
-
}
|
|
33083
|
-
|
|
33084
|
-
if (!nodeP?.attributes?.hasOwnProperty(attr) && !nodeP?.attributes?.hasOwnProperty(`xu-exp:${attr}`)) {
|
|
33085
|
-
continue;
|
|
33086
|
-
}
|
|
33087
|
-
|
|
33088
|
-
if (!nodeP.attributes[`xu-exp:${attr}`] && nodeP?.attributes?.hasOwnProperty(attr) && typeof func.UI.screen.fix_val_defaults(attr, nodeP.attributes[attr]) === 'undefined') {
|
|
33089
|
-
continue;
|
|
33090
|
-
}
|
|
33091
|
-
|
|
33092
|
-
let ret = await func.UI.screen.execute_xu_functions(
|
|
33093
|
-
SESSION_ID,
|
|
33094
|
-
is_skeleton,
|
|
33095
|
-
$root_container,
|
|
33096
|
-
nodeP,
|
|
33097
|
-
$container,
|
|
33098
|
-
paramsP,
|
|
33099
|
-
parent_infoP,
|
|
33100
|
-
jobNoP,
|
|
33101
|
-
keyP,
|
|
33102
|
-
parent_nodeP,
|
|
33103
|
-
attr,
|
|
33104
|
-
$elm,
|
|
33105
|
-
{
|
|
33106
|
-
key: attr,
|
|
33107
|
-
|
|
33108
|
-
value: await get_attr_value(attr),
|
|
33109
|
-
},
|
|
33110
|
-
is_init,
|
|
33111
|
-
);
|
|
33112
|
-
_ret = _.assignIn(_ret, ret);
|
|
33113
|
-
}
|
|
33114
|
-
}
|
|
33115
|
-
|
|
33116
|
-
// ALL
|
|
33117
|
-
|
|
33118
|
-
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
33119
|
-
if (_ret.abort || $container?.data()?.xuData?.pending_to_delete) break;
|
|
33120
|
-
if (glb.html5_events_handler.includes(key) || execute_attributes.includes(key)) {
|
|
33121
|
-
continue;
|
|
33122
|
-
}
|
|
33123
|
-
|
|
33124
|
-
const new_key = key.split(':')[0]; // break expression
|
|
33125
|
-
if (
|
|
33126
|
-
nodeP.tagName !== 'xu-panel' &&
|
|
33127
|
-
nodeP.tagName !== 'xu-teleport' && // nodeP.tagName.substr(0, 3) !== "xu-" &&
|
|
33128
|
-
(new_key.substr(0, 2) !== 'xu' || new_key.substr(2, 1) !== '-')
|
|
33129
|
-
) {
|
|
33130
|
-
// handle common html attributes
|
|
33131
|
-
try {
|
|
33132
|
-
$elm.get(0).setAttribute(key, val);
|
|
33133
|
-
} catch (err) {
|
|
33134
|
-
console.error(err.message);
|
|
33135
|
-
}
|
|
33136
|
-
|
|
33137
|
-
continue;
|
|
33138
|
-
}
|
|
33139
|
-
// handle xu attributes
|
|
33140
|
-
try {
|
|
33141
|
-
if ($elm?.data()?.xuAttributes) {
|
|
33142
|
-
// in some cases xu data delete in purpose when refreshing the screen
|
|
33143
|
-
$elm.data().xuAttributes[key] = val;
|
|
33144
|
-
}
|
|
33145
|
-
} catch (error) {
|
|
33146
|
-
debugger;
|
|
33147
|
-
console.error(error);
|
|
33148
|
-
}
|
|
33149
|
-
|
|
33150
|
-
if (new_key === 'xu-exp' || nodeP.attributes['xu-exp:' + new_key] || glb.run_xu_before.includes(new_key) || glb.run_xu_after.includes(new_key)) {
|
|
33151
|
-
continue;
|
|
33152
|
-
}
|
|
33153
|
-
|
|
33154
|
-
if (new_key === 'xu-on') {
|
|
33155
|
-
let ret = await func.UI.screen.execute_xu_functions(
|
|
33156
|
-
SESSION_ID,
|
|
33157
|
-
is_skeleton,
|
|
33158
|
-
$root_container,
|
|
33159
|
-
nodeP,
|
|
33160
|
-
$container,
|
|
33161
|
-
paramsP,
|
|
33162
|
-
parent_infoP,
|
|
33163
|
-
jobNoP,
|
|
33164
|
-
keyP,
|
|
33165
|
-
parent_nodeP,
|
|
33166
|
-
'xu-on',
|
|
33167
|
-
$elm,
|
|
33168
|
-
{
|
|
33169
|
-
key: key,
|
|
33170
|
-
// value: (await get_xuExp(new_key)) || func.UI.screen.fix_val_defaults(key, val),
|
|
33171
|
-
value: await get_attr_value(key),
|
|
33172
|
-
},
|
|
33173
|
-
is_init,
|
|
33174
|
-
refreshed_ds,
|
|
33175
|
-
);
|
|
33176
|
-
_ret = _.assignIn(_ret, ret);
|
|
33177
|
-
continue;
|
|
33178
|
-
}
|
|
33179
|
-
|
|
33180
|
-
let ret = await func.UI.screen.execute_xu_functions(
|
|
33181
|
-
SESSION_ID,
|
|
33182
|
-
is_skeleton,
|
|
33183
|
-
$root_container,
|
|
33184
|
-
nodeP,
|
|
33185
|
-
$container,
|
|
33186
|
-
paramsP,
|
|
33187
|
-
parent_infoP,
|
|
33188
|
-
jobNoP,
|
|
33189
|
-
keyP,
|
|
33190
|
-
parent_nodeP,
|
|
33191
|
-
new_key,
|
|
33192
|
-
$elm,
|
|
33193
|
-
{
|
|
33194
|
-
key: key,
|
|
33195
|
-
// value: (await get_xuExp(new_key)) || func.UI.screen.fix_val_defaults(key, val),
|
|
33196
|
-
value: await get_attr_value(key),
|
|
33197
|
-
},
|
|
33198
|
-
is_init,
|
|
33199
|
-
refreshed_ds,
|
|
33200
|
-
);
|
|
33201
|
-
|
|
33202
|
-
_ret = _.assignIn(_ret, ret);
|
|
33203
|
-
}
|
|
33204
|
-
|
|
33205
|
-
// EXP for
|
|
33206
|
-
|
|
33207
|
-
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
33208
|
-
if (_ret.abort || $container?.data()?.xuData?.pending_to_delete) break;
|
|
33209
|
-
|
|
33210
|
-
const attr = key.split('xu-exp:')[1];
|
|
33211
|
-
|
|
33212
|
-
if (!attr) {
|
|
33213
|
-
continue;
|
|
33214
|
-
}
|
|
33215
|
-
|
|
33216
|
-
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
|
|
33217
|
-
|
|
33218
|
-
if (done_exp.includes(key)) {
|
|
33219
|
-
continue;
|
|
33220
|
-
}
|
|
33221
|
-
let ret = await func.UI.screen.execute_xu_functions(
|
|
33222
|
-
SESSION_ID,
|
|
33223
|
-
is_skeleton,
|
|
33224
|
-
$root_container,
|
|
33225
|
-
nodeP,
|
|
33226
|
-
$container,
|
|
33227
|
-
paramsP,
|
|
33228
|
-
parent_infoP,
|
|
33229
|
-
jobNoP,
|
|
33230
|
-
keyP,
|
|
33231
|
-
parent_nodeP,
|
|
33232
|
-
'xu-exp',
|
|
33233
|
-
$elm,
|
|
33234
|
-
{
|
|
33235
|
-
key: attr,
|
|
33236
|
-
value: val,
|
|
33237
|
-
},
|
|
33238
|
-
true,
|
|
33239
|
-
refreshed_ds,
|
|
33240
|
-
);
|
|
33241
|
-
_ret = _.assignIn(_ret, ret);
|
|
33242
|
-
}
|
|
33243
|
-
|
|
33244
|
-
// AFTER
|
|
33245
|
-
|
|
33246
|
-
for await (const [key, attr] of Object.entries(glb.run_xu_after)) {
|
|
33247
|
-
if ($container?.data()?.xuData?.pending_to_delete) break;
|
|
33248
|
-
|
|
33249
|
-
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
|
|
33250
|
-
|
|
33251
|
-
if (!nodeP.attributes || !nodeP.attributes[attr] & !nodeP.attributes[`xu-exp:${attr}`]) continue;
|
|
33252
|
-
|
|
33253
|
-
let ret = await func.UI.screen.execute_xu_functions(
|
|
33254
|
-
SESSION_ID,
|
|
33255
|
-
is_skeleton,
|
|
33256
|
-
$root_container,
|
|
33257
|
-
nodeP,
|
|
33258
|
-
$container,
|
|
33259
|
-
paramsP,
|
|
33260
|
-
parent_infoP,
|
|
33261
|
-
jobNoP,
|
|
33262
|
-
keyP,
|
|
33263
|
-
parent_nodeP,
|
|
33264
|
-
attr,
|
|
33265
|
-
$elm,
|
|
33266
|
-
{
|
|
33267
|
-
key: attr,
|
|
33268
|
-
// value: (await get_xuExp(attr)) || func.UI.screen.fix_val_defaults(attr, nodeP.attributes[attr]),
|
|
33269
|
-
value: await get_attr_value(attr),
|
|
33270
|
-
},
|
|
33271
|
-
is_init,
|
|
33272
|
-
refreshed_ds,
|
|
33273
|
-
);
|
|
33274
|
-
_ret = _.assignIn(_ret, ret);
|
|
33275
|
-
}
|
|
33276
|
-
|
|
33277
|
-
// REGISTER EVENTS ATTRIBUTES
|
|
33278
|
-
|
|
33279
|
-
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
33280
|
-
if ($container?.data()?.xuData?.pending_to_delete) break;
|
|
33281
|
-
if (!glb.html5_events_handler.includes(key)) break;
|
|
33282
|
-
// $elm.attr(key, await get_xuExp(key)) || val;
|
|
33283
|
-
$elm.attr(key, await get_xuExp(key)) || val;
|
|
33284
|
-
}
|
|
33285
|
-
|
|
33286
|
-
return _ret;
|
|
33287
|
-
};
|
|
33288
|
-
|
|
33289
|
-
func.UI.screen.panel_post_render_handler = async function (
|
|
33290
|
-
SESSION_ID,
|
|
33291
|
-
$container, // the parent program container
|
|
33292
|
-
$wrapper, // the wrapper element contains the rendered panel elements e.g: xu-single-view
|
|
33293
|
-
nodeP, // the xu-panel node
|
|
33294
|
-
$panel_div, // the panel div
|
|
33295
|
-
jobNoP,
|
|
33296
|
-
) {
|
|
33297
|
-
const _container_ds = SESSION_OBJ[SESSION_ID].DS_GLB[$container.data().xuData.paramsP.dsSessionP];
|
|
33298
|
-
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[$wrapper.data().xuData.paramsP.dsSessionP];
|
|
33299
|
-
const find_old_panels_elements = function () {
|
|
33300
|
-
return func.UI.utils.find_in_element_data('xuPanelData', $container.parent(), 'xu-ui-id', $container.data()?.xuPanelData?.xu_panel_xu_ui_id);
|
|
33301
|
-
};
|
|
33302
|
-
var $old_panel_div = find_old_panels_elements();
|
|
33303
|
-
const set_xuPanelData_to_the_new_rendered_items = () => {
|
|
33304
|
-
$container.data().xuPanelWrapper = { isWrapper: true, panelXuAttributes: _.clone($wrapper.data().xuAttributes), panelDivData: _.clone($wrapper.data()) };
|
|
33305
|
-
$container.attr('xu-panel-wrapper-id', $wrapper.attr('xu-ui-id'));
|
|
33306
|
-
$.each($wrapper.children(), function (key, val) {
|
|
33307
|
-
if (!$(val).data().xuPanelData) {
|
|
33308
|
-
$(val).data().xuPanelData = {};
|
|
33309
|
-
}
|
|
33310
|
-
$(val).data().xuPanelData.parent_element_ui_id = $old_panel_div?.length ? $container.parent().data().xuData.ui_id : $container.data().xuData.ui_id;
|
|
33311
|
-
|
|
33312
|
-
$(val).data().xuPanelData.xu_panel_xu_ui_id = (nodeP.xu_tree_id || nodeP.id) + '-' + _container_ds?.currentRecordId;
|
|
33313
|
-
$(val).data().xuPanelData.node = nodeP;
|
|
33314
|
-
$(val).data().xuPanelData.$panel_div = $panel_div.clone(true);
|
|
33315
|
-
});
|
|
33316
|
-
};
|
|
33317
|
-
set_xuPanelData_to_the_new_rendered_items();
|
|
33318
|
-
|
|
33319
|
-
if ($old_panel_div?.length) {
|
|
33320
|
-
$($old_panel_div[0]).after($wrapper.children());
|
|
33321
|
-
} else {
|
|
33322
|
-
$.each($wrapper.children(), function (key, child) {
|
|
33323
|
-
$.each($container.children(), function (key, elm) {
|
|
33324
|
-
if ($(elm)?.data()?.xuData && $(elm)?.data()?.xuData?.elem_key === $(child)?.data()?.xuData?.elem_key) {
|
|
33325
|
-
$(elm).remove();
|
|
33326
|
-
}
|
|
33327
|
-
});
|
|
33328
|
-
$container.append($(child));
|
|
33329
|
-
});
|
|
33330
|
-
}
|
|
33331
|
-
|
|
33332
|
-
if (!$wrapper.data()?.xuData?.dsSession) return;
|
|
33333
|
-
|
|
33334
|
-
if ($old_panel_div?.length) {
|
|
33335
|
-
$container.parent().data().xuData.paramsP.dsSessionP = _ds.parentDataSourceNo; // set the new ds when panel replaced
|
|
33336
|
-
} else {
|
|
33337
|
-
$container.data().xuData.paramsP.dsSessionP = _ds.parentDataSourceNo; // set the new ds when panel replaced
|
|
33338
|
-
}
|
|
33339
|
-
|
|
33340
|
-
if ($old_panel_div?.length) {
|
|
33341
|
-
$old_panel_div.remove();
|
|
33342
|
-
}
|
|
33343
|
-
return jobNoP;
|
|
33344
|
-
};
|
|
33345
|
-
|
|
33346
|
-
const generate_xu_ui_id = async function (SESSION_ID, nodeP, $container, paramsP, keyP) {
|
|
33347
|
-
const _paramsP = _.cloneDeep(paramsP);
|
|
33348
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
|
|
33349
|
-
|
|
33350
|
-
const currentRecordId = $container?.data?.()?.xuData?.recordid || (_ds ? _ds.currentRecordId : '');
|
|
33351
|
-
const key_path = `${$container?.data()?.xuData?.key_path || '0'}-${keyP || '0'}`;
|
|
33352
|
-
const elem_key = `${nodeP.xu_tree_id || nodeP.id}-${key_path}-${currentRecordId}`;
|
|
33353
|
-
let ui_id = `${nodeP.id}-${elem_key}-${_paramsP?.dsSessionP?.toString() || ''}`; //nodeP.xu_tree_id ||
|
|
33354
|
-
|
|
33355
|
-
const new_ui_id = await func.common.sha256(ui_id);
|
|
33356
|
-
return new_ui_id;
|
|
33357
|
-
};
|
|
33358
|
-
|
|
33359
|
-
func.UI.screen.create_container = async function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str, is_placeholder) {
|
|
33360
|
-
const _paramsP = _.cloneDeep(paramsP);
|
|
33361
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
|
|
33362
|
-
var $appendTo = $container;
|
|
33363
|
-
if ($appendToP) $appendTo = $appendToP;
|
|
33364
|
-
if (!$appendTo || !$appendTo.length) return null; // screen closed or not exist abort build
|
|
33365
|
-
var div = 'div';
|
|
33366
|
-
if (div_typeP) div = div_typeP;
|
|
33367
|
-
var items = [];
|
|
33368
|
-
if (nodeP.children)
|
|
33369
|
-
items = nodeP.children.map(function (val) {
|
|
33370
|
-
return val.xu_tree_id || val.id;
|
|
33371
|
-
});
|
|
33372
|
-
var currentRecordId = $container?.data?.()?.xuData?.recordid || (_ds ? _ds.currentRecordId : '');
|
|
33373
|
-
// var xu_id = (glb.screen_num++).toString();
|
|
33374
|
-
// xu_id = xu_id += '_' + currentRecordId;
|
|
33375
|
-
|
|
33376
|
-
try {
|
|
33377
|
-
const key_path = `${$container?.data()?.xuData?.key_path || '0'}-${keyP || '0'}`;
|
|
33378
|
-
const elem_key = `${nodeP.xu_tree_id || nodeP.id}-${key_path}-${currentRecordId}`;
|
|
33379
|
-
// let ui_id = `${nodeP.id}-${elem_key}-${_paramsP?.dsSessionP?.toString() || ''}`; //nodeP.xu_tree_id ||
|
|
33380
|
-
|
|
33381
|
-
/////////////////////////////////
|
|
33382
|
-
|
|
33383
|
-
var $div;
|
|
33384
|
-
|
|
33385
|
-
if (div === 'svg') {
|
|
33386
|
-
const draw_svg = function (element) {
|
|
33387
|
-
const get_tag_str = function (element, prop, val) {
|
|
33388
|
-
let class_str = '';
|
|
33389
|
-
let attr_str = '';
|
|
33390
|
-
for (const [key, val] of Object.entries(prop)) {
|
|
33391
|
-
if (key.substr(0, 2) !== 'xu') {
|
|
33392
|
-
attr_str += ` ${key}="${val}" `;
|
|
33393
|
-
}
|
|
33394
|
-
}
|
|
33395
|
-
if (element === 'svg') {
|
|
33396
|
-
return `<${element} ${attr_str} > `;
|
|
33397
|
-
}
|
|
33398
|
-
let ret = '';
|
|
33399
|
-
if (val?.children?.length) {
|
|
33400
|
-
ret = iterate_svg(val);
|
|
33401
|
-
}
|
|
33402
|
-
|
|
33403
|
-
return `<${element} ${class_str} ${attr_str} > ${ret} </${element}>`;
|
|
33404
|
-
};
|
|
33405
|
-
let svg_str = get_tag_str(element, prop);
|
|
33406
|
-
let inner_str = '';
|
|
33407
|
-
const iterate_svg = function (node) {
|
|
33408
|
-
let ret = '';
|
|
33409
|
-
if (node.children) {
|
|
33410
|
-
for (let val of node.children) {
|
|
33411
|
-
let prop = val.attributes;
|
|
33412
|
-
ret += get_tag_str(val.tagName, prop, val);
|
|
33413
|
-
}
|
|
33414
|
-
}
|
|
33415
|
-
return ret;
|
|
33416
|
-
};
|
|
33417
|
-
inner_str = iterate_svg(nodeP);
|
|
33418
|
-
|
|
33419
|
-
$div = $(svg_str + inner_str + '</svg>').appendTo($appendTo);
|
|
33420
|
-
};
|
|
33421
|
-
|
|
33422
|
-
draw_svg(div_typeP);
|
|
33423
|
-
} else {
|
|
33424
|
-
$div = $(`<${div} ${attr_str ? attr_str : ''}>`);
|
|
33425
|
-
}
|
|
33426
|
-
|
|
33427
|
-
// // Returns a 32-bit unsigned integer hash of a string (FNV-1a)
|
|
33428
|
-
// function hash32(str) {
|
|
33429
|
-
// let h = 0x811c9dc5; // FNV offset basis
|
|
33430
|
-
// for (let i = 0; i < str.length; i++) {
|
|
33431
|
-
// h ^= str.charCodeAt(i);
|
|
33432
|
-
// // multiply by FNV prime (2^24 + 2^8 + 0x93) with 32-bit overflow
|
|
33433
|
-
// h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24);
|
|
33434
|
-
// }
|
|
33435
|
-
// // Convert to unsigned 32-bit
|
|
33436
|
-
// return h >>> 0;
|
|
33437
|
-
// }
|
|
33438
|
-
|
|
33439
|
-
// function hash32hex(str) {
|
|
33440
|
-
// return (hash32(str) >>> 0).toString(16).padStart(8, '0');
|
|
33441
|
-
// }
|
|
33442
|
-
|
|
33443
|
-
// const new_ui_id = hash32hex(ui_id);
|
|
33444
|
-
// const new_ui_id = await func.common.sha256(ui_id);
|
|
33445
|
-
const new_ui_id = await generate_xu_ui_id(SESSION_ID, nodeP, $container, paramsP, keyP);
|
|
33446
|
-
|
|
33447
|
-
$div
|
|
33448
|
-
.attr('xu-ui-id', new_ui_id)
|
|
33449
|
-
// .attr('xu-node-id', nodeP.id)
|
|
33450
|
-
.data({
|
|
33451
|
-
xuData: {
|
|
33452
|
-
prog_id: _paramsP.prog_id,
|
|
33453
|
-
nodeid: nodeP.id,
|
|
33454
|
-
ui_type: nodeP.tagName,
|
|
33455
|
-
// xu_id,
|
|
33456
|
-
recordid: currentRecordId,
|
|
33457
|
-
paramsP: _paramsP,
|
|
33458
|
-
key: keyP,
|
|
33459
|
-
key_path, //:($container?.data()?.xuData?.key || "0") + "-" + (keyP || "0"),
|
|
33460
|
-
screenId: _paramsP.screenId,
|
|
33461
|
-
parent_container: $container?.attr('id'),
|
|
33462
|
-
elem_key,
|
|
33463
|
-
properties: prop,
|
|
33464
|
-
node: nodeP,
|
|
33465
|
-
node_org: _.cloneDeep(nodeP),
|
|
33466
|
-
is_panelP: _paramsP.is_panelP,
|
|
33467
|
-
ui_id: new_ui_id,
|
|
33468
|
-
elem_prop: elem_propP,
|
|
33469
|
-
debug_info: {
|
|
33470
|
-
id: nodeP.id,
|
|
33471
|
-
parent_id: $container?.data()?.xuData?.ui_id,
|
|
33472
|
-
items: items,
|
|
33473
|
-
},
|
|
33474
|
-
parent_node: parent_nodeP,
|
|
33475
|
-
currentRecordId: currentRecordId,
|
|
33476
|
-
$root_container: $root_container,
|
|
33477
|
-
parent_element_ui_id: $container?.data()?.xuData?.ui_id,
|
|
33478
|
-
},
|
|
33479
|
-
xuAttributes: {},
|
|
33480
|
-
});
|
|
33481
|
-
if (is_placeholder) {
|
|
33482
|
-
$div.addClass('display_none');
|
|
33483
|
-
}
|
|
33484
|
-
|
|
33485
|
-
if (div_typeP !== 'svg') {
|
|
33486
|
-
$div.appendTo($appendTo);
|
|
33487
|
-
}
|
|
33488
|
-
} catch (e) {
|
|
33489
|
-
console.error(e);
|
|
33490
|
-
}
|
|
33491
|
-
|
|
33492
|
-
if (parent_infoP?.iterate_info) {
|
|
33493
|
-
$div.data().xuData.iterate_info = parent_infoP.iterate_info;
|
|
33494
|
-
}
|
|
33495
|
-
|
|
33496
|
-
if (classP) $div.addClass(classP);
|
|
33497
|
-
|
|
33498
|
-
return $div;
|
|
33499
|
-
};
|
|
33500
|
-
func.UI.screen.execute_screen_ready_events = async function (SESSION_ID, paramsP, sourceP, $div, jobNoP, $div_objP) {
|
|
33501
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
33502
|
-
if (!_ds) return;
|
|
33503
|
-
var viewEventExec_arr = [];
|
|
33504
|
-
const execute_view_events = async function (sourceP) {
|
|
33505
|
-
for await (const val of viewEventExec_arr) {
|
|
33506
|
-
cond = val.eventInfo.data.enabled;
|
|
33507
|
-
if (val.expression) {
|
|
33508
|
-
expCond = await func.expression.get(SESSION_ID, val.expression, paramsP.dsSessionP, 'condition', paramsP.rowIdP); // execute expression
|
|
33509
|
-
cond = expCond.result;
|
|
33510
|
-
}
|
|
33511
|
-
if (cond) {
|
|
33512
|
-
await func.events.execute(
|
|
33513
|
-
SESSION_ID,
|
|
33514
|
-
null,
|
|
33515
|
-
val.eventId,
|
|
33516
|
-
val.triggerId,
|
|
33517
|
-
val.eventInfo.data.action,
|
|
33518
|
-
val.eventInfo.data.name,
|
|
33519
|
-
null,
|
|
33520
|
-
null,
|
|
33521
|
-
null,
|
|
33522
|
-
null,
|
|
33523
|
-
val.eventInfo.data.action, //val.eventInfo[4]
|
|
33524
|
-
null,
|
|
33525
|
-
paramsP.dsSessionP,
|
|
33526
|
-
val.eventId,
|
|
33527
|
-
sourceP + ' event',
|
|
33528
|
-
true,
|
|
33529
|
-
null,
|
|
33530
|
-
null,
|
|
33531
|
-
paramsP.dsSessionP,
|
|
33532
|
-
null,
|
|
33533
|
-
null,
|
|
33534
|
-
val.eventInfo, // val.eventInfo[8],
|
|
33535
|
-
null,
|
|
33536
|
-
null,
|
|
33537
|
-
_ds.prog_id,
|
|
33538
|
-
_ds.nodeId,
|
|
33539
|
-
_ds.parentDataSourceNo,
|
|
33540
|
-
$div,
|
|
33541
|
-
);
|
|
33542
|
-
|
|
33543
|
-
// update changed values to screen added 18/09/13
|
|
33544
|
-
var fields_to_refresh = [];
|
|
33545
|
-
try {
|
|
33546
|
-
var current_record_id = _ds.currentRecordId;
|
|
33547
|
-
} catch (e) {
|
|
33548
|
-
console.error(e);
|
|
33549
|
-
}
|
|
33550
|
-
|
|
33551
|
-
if (_ds?.data_feed?.form_fields_changed?.[current_record_id]) {
|
|
33552
|
-
$.each(_ds.data_feed.form_fields_changed[current_record_id], function (key, val) {
|
|
33553
|
-
fields_to_refresh.push(key);
|
|
33554
|
-
});
|
|
33555
|
-
|
|
33556
|
-
var containerId = _ds.containerId;
|
|
33557
|
-
var $container = $('#' + containerId);
|
|
33558
|
-
if ($container?.data()?.xuData?.is_mobile_modal || $container?.data()?.xuData?.params?.is_mobile_page) {
|
|
33559
|
-
await func.UI.screen.refresh_container(SESSION_ID, 'init', fields_to_refresh, $container, paramsP.dsSessionP, null);
|
|
33560
|
-
} else {
|
|
33561
|
-
$container.trigger(containerId + '.refresh', ['init', fields_to_refresh]);
|
|
33562
|
-
}
|
|
33563
|
-
|
|
33564
|
-
if ($div_objP) {
|
|
33565
|
-
await func.UI.screen.refresh_container(SESSION_ID, 'init', fields_to_refresh, $div_objP, paramsP.dsSessionP, null);
|
|
33566
|
-
}
|
|
33567
|
-
}
|
|
33568
|
-
}
|
|
33569
|
-
continue;
|
|
33570
|
-
}
|
|
33571
|
-
};
|
|
33572
|
-
const get_view_events_count = async function (typeP) {
|
|
33573
|
-
const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
33574
|
-
viewEventExec_arr = [];
|
|
33575
|
-
|
|
33576
|
-
if (!_prog.progEvents || _.isEmpty(_prog.progEvents)) {
|
|
33577
|
-
return 0;
|
|
33578
|
-
}
|
|
33579
|
-
for await (const event_obj of _prog.progEvents) {
|
|
33580
|
-
if (event_obj.data.type !== typeP) continue;
|
|
33581
|
-
|
|
33582
|
-
if (_.isEmpty(event_obj.workflow)) continue;
|
|
33583
|
-
|
|
33584
|
-
if (event_obj.data.condition) {
|
|
33585
|
-
let res = await func.expression.get(SESSION_ID, event_obj.data.condition, paramsP.dsSessionP, 'condition', paramsP.rowIdP, null, null, null, null, event_obj);
|
|
33586
|
-
if (!res.result) {
|
|
33587
|
-
continue;
|
|
33588
|
-
}
|
|
33589
|
-
}
|
|
33590
|
-
|
|
33591
|
-
for await (const trigger_obj of event_obj.workflow) {
|
|
33592
|
-
var expression = undefined;
|
|
33593
|
-
var cond = undefined;
|
|
33594
|
-
if (!trigger_obj.data.enabled) {
|
|
33595
|
-
continue;
|
|
33596
|
-
}
|
|
33597
|
-
cond = true;
|
|
33598
|
-
if (trigger_obj.props.condition) expression = trigger_obj.props.condition;
|
|
33599
|
-
var expCond = {};
|
|
33600
|
-
if (expression) {
|
|
33601
|
-
expCond = await func.expression.get(SESSION_ID, expression, paramsP.dsSessionP, 'condition', paramsP.rowIdP, trigger_obj.data.type); // execute expression
|
|
33602
|
-
cond = expCond.result;
|
|
33603
|
-
expCond.conditional = true;
|
|
33604
|
-
}
|
|
33605
|
-
|
|
33606
|
-
if (!trigger_obj.data.action) {
|
|
33607
|
-
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.viewSourceDesc} reason: missing action`, 'E');
|
|
33608
|
-
break;
|
|
33609
|
-
}
|
|
33610
|
-
if (!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) && !trigger_obj.data.name?.prog) {
|
|
33611
|
-
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.viewSourceDesc} reason: missing reference`, 'E');
|
|
33612
|
-
break;
|
|
33613
|
-
}
|
|
33614
|
-
|
|
33615
|
-
viewEventExec_arr.push({
|
|
33616
|
-
eventInfo: trigger_obj,
|
|
33617
|
-
eventId: event_obj.id,
|
|
33618
|
-
triggerId: trigger_obj.id,
|
|
33619
|
-
expression: expression,
|
|
33620
|
-
});
|
|
33621
|
-
}
|
|
33622
|
-
}
|
|
33623
|
-
return viewEventExec_arr.length;
|
|
33624
|
-
};
|
|
33625
|
-
try {
|
|
33626
|
-
let count = await get_view_events_count('screen_ready');
|
|
33627
|
-
|
|
33628
|
-
if (!count) return;
|
|
33629
|
-
return await execute_view_events(sourceP);
|
|
33630
|
-
} catch (error) {
|
|
33631
|
-
debugger;
|
|
33632
|
-
}
|
|
33633
|
-
};
|
|
33634
|
-
func.UI.screen.screen_loading_done = async function (SESSION_ID, paramsP, $div, jobNoP) {
|
|
33635
|
-
// console.log($div.attr('xu-ui-id'));
|
|
33636
|
-
|
|
33637
|
-
// await
|
|
33638
|
-
let retries = 0;
|
|
33639
|
-
let interval = setInterval(() => {
|
|
33640
|
-
if (!$(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-ui-id=${$div.attr('xu-ui-id')}]`).length && !$(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-panel-wrapper-id=${$div.attr('xu-ui-id')}]`).length && !$div.attr('xu-ui-id') && $div.attr('xu-ui-id')) {
|
|
33641
|
-
retries++;
|
|
33642
|
-
if (retries > 100) {
|
|
33643
|
-
console.warn('deadlock detected for screen ready');
|
|
33644
|
-
} else {
|
|
33645
|
-
return $div;
|
|
33646
|
-
}
|
|
33647
|
-
}
|
|
33648
|
-
|
|
33649
|
-
clearInterval(interval);
|
|
33650
|
-
|
|
33651
|
-
func.UI.screen.execute_screen_ready_events(SESSION_ID, paramsP, paramsP.screenInfo.properties?.renderType, $div, jobNoP);
|
|
33652
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
33653
|
-
func.events.delete_job(SESSION_ID, jobNoP);
|
|
33654
|
-
func.UI.utils.screen_blocker(false, paramsP.prog_id + (paramsP.sourceScreenP ? '_' + paramsP.sourceScreenP : ''));
|
|
33655
|
-
if (_session.prog_id === paramsP.prog_id) {
|
|
33656
|
-
_session.system_ready = true;
|
|
33657
|
-
if (_session.engine_mode === 'live_preview' && STUDIO_PEER_CONN_SEND_METHOD) {
|
|
33658
|
-
STUDIO_PEER_CONN_SEND_METHOD({
|
|
33659
|
-
service: 'system_ready',
|
|
33660
|
-
data: {},
|
|
33661
|
-
id: STUDIO_PEER.id,
|
|
33662
|
-
source: 'runtime',
|
|
33663
|
-
session_id: SESSION_ID,
|
|
33664
|
-
app_id: _session.app_id,
|
|
33665
|
-
gtp_token: _session.gtp_token,
|
|
33666
|
-
app_token: _session.app_token,
|
|
33667
|
-
});
|
|
33668
|
-
// }
|
|
33669
|
-
}
|
|
33670
|
-
}
|
|
33671
|
-
}, 100);
|
|
33672
|
-
|
|
33673
|
-
return $div;
|
|
33674
|
-
};
|
|
33675
|
-
|
|
33676
|
-
func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $root_container) {
|
|
33677
|
-
if (!is_skeleton) {
|
|
33678
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
33679
|
-
var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
33680
|
-
}
|
|
33681
|
-
var prop;
|
|
33682
|
-
try {
|
|
33683
|
-
prop = nodeP.attributes;
|
|
33684
|
-
} catch (error) {
|
|
33685
|
-
// debugger;
|
|
33686
|
-
}
|
|
33687
|
-
|
|
33688
|
-
///////////
|
|
33689
|
-
var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
|
|
33690
|
-
|
|
33691
|
-
const get_element_info = function () {
|
|
33692
|
-
var ret = {};
|
|
33693
|
-
let currentRecordId = _ds?.currentRecordId || '';
|
|
33694
|
-
|
|
33695
|
-
let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
|
|
33696
|
-
|
|
33697
|
-
$.each($div, function (key, val) {
|
|
33698
|
-
if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
|
|
33699
|
-
ret = {
|
|
33700
|
-
div: $div,
|
|
33701
|
-
};
|
|
33702
|
-
}
|
|
33703
|
-
});
|
|
33704
|
-
|
|
33705
|
-
return ret;
|
|
33706
|
-
};
|
|
33707
|
-
|
|
33708
|
-
const init = async function () {
|
|
33709
|
-
var ret = true;
|
|
33710
|
-
if (!nodeP) ret = false;
|
|
33711
|
-
return ret;
|
|
33712
|
-
};
|
|
33713
|
-
const debug = function (is_errorP, error_descP) {
|
|
33714
|
-
func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
|
|
33715
|
-
module: 'gui',
|
|
33716
|
-
action: 'init',
|
|
33717
|
-
prop: nodeP.id,
|
|
33718
|
-
details: error_descP,
|
|
33719
|
-
result: null,
|
|
33720
|
-
error: is_errorP,
|
|
33721
|
-
source: _ds?.tree_obj?.menuName || '',
|
|
33722
|
-
fields: null,
|
|
33723
|
-
type: null,
|
|
33724
|
-
prog_id: paramsP.prog_id,
|
|
33725
|
-
dsSession: null,
|
|
33726
|
-
});
|
|
33727
|
-
};
|
|
33728
|
-
|
|
33729
|
-
const open_modal = async function ($div) {
|
|
33730
|
-
const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
|
|
33731
|
-
var xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
33732
|
-
if (!xu_modal_controller) {
|
|
33733
|
-
func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
|
|
33734
|
-
xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
33735
|
-
}
|
|
33736
|
-
|
|
33737
|
-
var controller_params = $(xu_modal_controller).data('xuControllerParams');
|
|
33738
|
-
|
|
33739
|
-
if (!controller_params) {
|
|
33740
|
-
controller_params = {};
|
|
33741
|
-
}
|
|
33742
|
-
|
|
33743
|
-
var params = {
|
|
33744
|
-
menuTitle: paramsP.screenInfo.properties?.menuTitle,
|
|
33745
|
-
screenId: paramsP.screenId,
|
|
33746
|
-
$dialogDiv: $div.children(),
|
|
33747
|
-
$container: $container,
|
|
33748
|
-
dsSession: paramsP.dsSessionP,
|
|
33749
|
-
};
|
|
33750
|
-
|
|
33751
|
-
controller_params[modal_id] = params;
|
|
33752
|
-
|
|
33753
|
-
$(xu_modal_controller).data('xuControllerParams', controller_params);
|
|
33754
|
-
const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
|
|
33755
|
-
|
|
33756
|
-
if (!APP_MODAL_OBJ[modal_id]) {
|
|
33757
|
-
const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
|
|
33758
|
-
APP_MODAL_OBJ[modal_id] = modal;
|
|
33759
|
-
} else {
|
|
33760
|
-
$(modal_id).empty();
|
|
33761
|
-
}
|
|
33762
|
-
await modalController.init(SESSION_ID, modal_id);
|
|
33763
|
-
|
|
33764
|
-
return $div;
|
|
33765
|
-
};
|
|
33766
|
-
|
|
33767
|
-
const close_modal = async function (modal_id) {
|
|
33768
|
-
delete APP_MODAL_OBJ[modal_id];
|
|
33769
|
-
const xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
33770
|
-
var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
|
|
33771
|
-
if (params && params.$container) {
|
|
33772
|
-
await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
|
|
33773
|
-
func.datasource.clean_all(SESSION_ID, params.dsSession);
|
|
33774
|
-
}
|
|
33775
|
-
};
|
|
33776
|
-
|
|
33777
|
-
const close_all_modals = function () {
|
|
33778
|
-
$.each(APP_MODAL_OBJ, function (key, val) {
|
|
33779
|
-
if (val) {
|
|
33780
|
-
// close_modal(key);
|
|
33781
|
-
UI_FRAMEWORK_PLUGIN.modal.close(key);
|
|
33782
|
-
}
|
|
33783
|
-
});
|
|
33784
|
-
};
|
|
33785
|
-
|
|
33786
|
-
const open_popover = async function ($div) {
|
|
33787
|
-
const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
|
|
33788
|
-
|
|
33789
|
-
$(xu_popover_controller).data('xuControllerParams', {
|
|
33790
|
-
menuTitle: paramsP.screenInfo.properties?.menuTitle,
|
|
33791
|
-
screenId: paramsP.screenId,
|
|
33792
|
-
$dialogDiv: $div.children(),
|
|
33793
|
-
$container: $container,
|
|
33794
|
-
});
|
|
33795
|
-
const popover = new UI_FRAMEWORK_PLUGIN.popover(
|
|
33796
|
-
SESSION_ID,
|
|
33797
|
-
// ELEMENT_CLICK_EVENT,
|
|
33798
|
-
// props
|
|
33799
|
-
);
|
|
33800
|
-
await popover.open(SESSION_ID);
|
|
33801
|
-
CURRENT_APP_POPOVER = popover;
|
|
33802
|
-
|
|
33803
|
-
return;
|
|
33804
|
-
popoverController
|
|
33805
|
-
.create({
|
|
33806
|
-
component: 'xu-popover-content-' + SESSION_ID,
|
|
33807
|
-
event: ELEMENT_CLICK_EVENT,
|
|
33808
|
-
translucent: true,
|
|
33809
|
-
})
|
|
33810
|
-
.then((modal) => {
|
|
33811
|
-
modal.present().then(() => {
|
|
33812
|
-
CURRENT_APP_POPOVER = modal;
|
|
33813
|
-
|
|
33814
|
-
if (callbackP) callbackP($div);
|
|
33815
|
-
});
|
|
33816
|
-
});
|
|
33817
|
-
};
|
|
33818
|
-
const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
|
|
33819
|
-
if (!is_mobile && nodeP.busy) return;
|
|
33820
|
-
nodeP.busy = true;
|
|
33821
|
-
const done = async function ($divP) {
|
|
33822
|
-
setTimeout(function () {
|
|
33823
|
-
nodeP.busy = false;
|
|
33824
|
-
}, 1000);
|
|
33825
|
-
|
|
33826
|
-
return $divP;
|
|
33827
|
-
};
|
|
33828
|
-
if (!nodeP || !nodeP.children) {
|
|
33829
|
-
return await done($divP);
|
|
33830
|
-
}
|
|
33831
|
-
|
|
33832
|
-
if (before_record_function) {
|
|
33833
|
-
await before_record_function();
|
|
33834
|
-
}
|
|
33835
|
-
if (nodeP?.children?.length) {
|
|
33836
|
-
let node_promises = [];
|
|
33837
|
-
for (const [key, val] of Object.entries(nodeP.children)) {
|
|
33838
|
-
node_promises.push(
|
|
33839
|
-
new Promise(async (resolve, reject) => {
|
|
33840
|
-
const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $divP, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
|
|
33841
|
-
|
|
33842
|
-
resolve();
|
|
33843
|
-
}),
|
|
33844
|
-
);
|
|
33845
|
-
}
|
|
33846
|
-
await Promise.all(node_promises);
|
|
33847
|
-
}
|
|
33848
|
-
return await done($divP);
|
|
33849
|
-
};
|
|
33850
|
-
|
|
33851
|
-
// const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
|
|
33852
|
-
// if (!is_mobile && nodeP.busy) return;
|
|
33853
|
-
// nodeP.busy = true;
|
|
33854
|
-
// const done = async function ($divP) {
|
|
33855
|
-
// setTimeout(function () {
|
|
33856
|
-
// nodeP.busy = false;
|
|
33857
|
-
// }, 1000);
|
|
33858
|
-
|
|
33859
|
-
// return $divP;
|
|
33860
|
-
// };
|
|
33861
|
-
// if (!nodeP || !nodeP.children) {
|
|
33862
|
-
// return await done($divP);
|
|
33863
|
-
// }
|
|
33864
|
-
|
|
33865
|
-
// if (before_record_function) {
|
|
33866
|
-
// await before_record_function();
|
|
33867
|
-
// }
|
|
33868
|
-
// if (nodeP?.children?.length) {
|
|
33869
|
-
// for await (const [key, val] of Object.entries(nodeP.children)) {
|
|
33870
|
-
// const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $divP, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
|
|
33871
|
-
// }
|
|
33872
|
-
// }
|
|
33873
|
-
// return await done($divP);
|
|
33874
|
-
// };
|
|
33875
|
-
|
|
33876
|
-
const _$ = function ($elm) {
|
|
33877
|
-
try {
|
|
33878
|
-
const id = $elm.attr('xu-ui-id');
|
|
33879
|
-
if (!id || !glb.DEBUG_MODE) return $elm;
|
|
33880
|
-
const $el = $(`[xu-ui-id="${id}"]`);
|
|
33881
|
-
|
|
33882
|
-
if ($el.length > 1) {
|
|
33883
|
-
console.warn('Multiple elements for xu-ui-id: ' + id, $el);
|
|
33884
|
-
}
|
|
33885
|
-
|
|
33886
|
-
return $($el[0]);
|
|
33887
|
-
} catch (e) {
|
|
33888
|
-
console.error(e);
|
|
33889
|
-
}
|
|
33890
|
-
};
|
|
33891
|
-
|
|
33892
|
-
const hover_in = function ($div, e) {
|
|
33893
|
-
if (is_skeleton || (e && (EXP_BUSY || UI_WORKER_OBJ.jobs.length))) return;
|
|
33894
|
-
CLIENT_ACTIVITY_TS = Date.now();
|
|
33895
|
-
if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
|
|
33896
|
-
if (!_ds) return;
|
|
33897
|
-
///////// SET Attributes///////////
|
|
33898
|
-
let attributes = {};
|
|
33899
|
-
$.each($div[0].attributes, function (index, attr) {
|
|
33900
|
-
attributes[attr.name] = attr.value;
|
|
33901
|
-
});
|
|
33902
|
-
|
|
33903
|
-
_session.DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
|
|
33904
|
-
//////////////////////////////////
|
|
33905
|
-
if (!$div.data()?.xuData) return;
|
|
33906
|
-
const _iterate_info = $div.data().xuData.iterate_info;
|
|
33907
|
-
if (_iterate_info) {
|
|
33908
|
-
if (_iterate_info.is_key_dynamic_field) {
|
|
33909
|
-
_ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
|
|
33910
|
-
} else {
|
|
33911
|
-
try {
|
|
33912
|
-
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
33913
|
-
_ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
|
|
33914
|
-
} catch (err) {
|
|
33915
|
-
console.error(err);
|
|
33916
|
-
}
|
|
33917
|
-
}
|
|
33918
|
-
|
|
33919
|
-
if (_iterate_info.is_val_dynamic_field) {
|
|
33920
|
-
_ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
|
|
33921
|
-
} else {
|
|
33922
|
-
try {
|
|
33923
|
-
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
33924
|
-
_ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
|
|
33925
|
-
} catch (err) {
|
|
33926
|
-
console.error(err);
|
|
33927
|
-
}
|
|
33928
|
-
}
|
|
33929
|
-
}
|
|
33930
|
-
|
|
33931
|
-
if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
|
|
33932
|
-
func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
|
|
33933
|
-
}
|
|
33934
|
-
|
|
33935
|
-
const set_value = function (field_id, value) {
|
|
33936
|
-
var currentRecordId = _$($div).data().xuData.currentRecordId;
|
|
33937
|
-
|
|
33938
|
-
func.UI.worker.add_to_queue(
|
|
33939
|
-
SESSION_ID,
|
|
33940
|
-
'gui event',
|
|
33941
|
-
'update_datasource',
|
|
33942
|
-
{
|
|
33943
|
-
currentRecordId,
|
|
33944
|
-
field_id,
|
|
33945
|
-
field_value: value,
|
|
33946
|
-
},
|
|
33947
|
-
null,
|
|
33948
|
-
null,
|
|
33949
|
-
paramsP.dsSessionP,
|
|
33950
|
-
);
|
|
33951
|
-
};
|
|
33952
|
-
|
|
33953
|
-
if ($div?.data()?.iterate_info) {
|
|
33954
|
-
var data = $div.data().xuData.iterate_info;
|
|
33955
|
-
if (data.iterator_key) {
|
|
33956
|
-
set_value(data.iterator_key, data._key);
|
|
33957
|
-
}
|
|
33958
|
-
if (data.iterator_val) {
|
|
33959
|
-
set_value(data.iterator_val, data._val);
|
|
33960
|
-
}
|
|
33961
|
-
}
|
|
33962
|
-
};
|
|
33963
|
-
const hover_out = function () {
|
|
33964
|
-
if (is_skeleton) return;
|
|
33965
|
-
|
|
33966
|
-
CLIENT_ACTIVITY_TS = Date.now();
|
|
33967
|
-
if (_$($container)?.data()?.xuData?.debug_info) {
|
|
33968
|
-
_$($container).data().xuData.debug_info.hover_item = null;
|
|
33969
|
-
}
|
|
33970
|
-
if (_ds?.data_system) {
|
|
33971
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
|
|
33972
|
-
}
|
|
33973
|
-
};
|
|
33974
|
-
const render_screen_type = async function ($div) {
|
|
33975
|
-
const set_call_screen_properties_values = async function (ui_framework) {
|
|
33976
|
-
params.properties = {};
|
|
33977
|
-
const get_values = async function (property) {
|
|
33978
|
-
var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
|
|
33979
|
-
if (paramsP?.call_screen_propertiesP) {
|
|
33980
|
-
if (paramsP.call_screen_propertiesP?.[property]) {
|
|
33981
|
-
property_value = paramsP.call_screen_propertiesP[property];
|
|
33982
|
-
}
|
|
33983
|
-
if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
|
|
33984
|
-
property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
|
|
33985
|
-
}
|
|
33986
|
-
}
|
|
33987
|
-
return property_value;
|
|
33988
|
-
};
|
|
33989
|
-
params.properties['name'] = await get_values('menuTitle');
|
|
33990
|
-
if (await ui_framework?.properties()) {
|
|
33991
|
-
for await (const [key, val] of Object.entries(await ui_framework.properties())) {
|
|
33992
|
-
params.properties[key] = await get_values(key);
|
|
33993
|
-
}
|
|
33994
|
-
}
|
|
33995
|
-
};
|
|
33996
|
-
|
|
33997
|
-
var $div_content = $div.children();
|
|
33998
|
-
|
|
33999
|
-
$.each($div_content, function (key, val) {
|
|
34000
|
-
if (!$(val)?.data()?.xuData?.parent_container) {
|
|
34001
|
-
return true;
|
|
34002
|
-
}
|
|
34003
|
-
$(val).data().xuData.parent_container = $div.data().xuData.parent_container;
|
|
34004
|
-
});
|
|
34005
|
-
|
|
34006
|
-
let $ret = $div;
|
|
34007
|
-
var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
|
|
34008
|
-
var params;
|
|
34009
|
-
switch (paramsP.screen_type) {
|
|
34010
|
-
case 'modal':
|
|
34011
|
-
const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
|
|
34012
|
-
var xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
34013
|
-
if (!xu_modal_controller) {
|
|
34014
|
-
func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
|
|
34015
|
-
xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
34016
|
-
}
|
|
34017
|
-
|
|
34018
|
-
var controller_params = $(xu_modal_controller).data('xuControllerParams');
|
|
34019
|
-
|
|
34020
|
-
if (!controller_params) {
|
|
34021
|
-
controller_params = {};
|
|
34022
|
-
}
|
|
34023
|
-
|
|
34024
|
-
params = {
|
|
34025
|
-
screenId: paramsP.screenId,
|
|
34026
|
-
$dialogDiv: $div.children(),
|
|
34027
|
-
$container: $container,
|
|
34028
|
-
dsSession: paramsP.dsSessionP,
|
|
34029
|
-
modal_id,
|
|
34030
|
-
screenInfo: paramsP.screenInfo,
|
|
34031
|
-
close_callback: close_modal,
|
|
34032
|
-
paramsP,
|
|
34033
|
-
};
|
|
34034
|
-
|
|
34035
|
-
controller_params[modal_id] = params;
|
|
34036
|
-
|
|
34037
|
-
$(xu_modal_controller).data('xuControllerParams', controller_params);
|
|
34038
|
-
const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
|
|
34039
|
-
await set_call_screen_properties_values(modalController);
|
|
34040
|
-
if (!APP_MODAL_OBJ[modal_id]) {
|
|
34041
|
-
const modal = await modalController.create(params);
|
|
34042
|
-
|
|
34043
|
-
APP_MODAL_OBJ[modal_id] = modal;
|
|
34044
|
-
} else {
|
|
34045
|
-
$(modal_id).empty();
|
|
34046
|
-
}
|
|
34047
|
-
|
|
34048
|
-
await modalController.init(params);
|
|
34049
|
-
|
|
34050
|
-
break;
|
|
34051
|
-
|
|
34052
|
-
case 'popover':
|
|
34053
|
-
// open_popover($div);
|
|
34054
|
-
|
|
34055
|
-
const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
|
|
34056
|
-
params = {
|
|
34057
|
-
menuTitle: paramsP.screenInfo.properties?.menuTitle,
|
|
34058
|
-
screenId: paramsP.screenId,
|
|
34059
|
-
$dialogDiv: $div.children(),
|
|
34060
|
-
$container: $container,
|
|
34061
|
-
};
|
|
34062
|
-
|
|
34063
|
-
$(xu_popover_controller).data('xuControllerParams', params);
|
|
34064
|
-
const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
|
|
34065
|
-
await set_call_screen_properties_values(popover);
|
|
34066
|
-
await popover.open(params);
|
|
34067
|
-
CURRENT_APP_POPOVER = popover;
|
|
34068
|
-
|
|
34069
|
-
func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
|
|
34070
|
-
break;
|
|
34071
|
-
|
|
34072
|
-
case 'page':
|
|
34073
|
-
const nav = $nav[0];
|
|
34074
|
-
|
|
34075
|
-
params = {
|
|
34076
|
-
div: $div_content,
|
|
34077
|
-
name: paramsP.screenInfo.properties?.menuTitle,
|
|
34078
|
-
screenId: paramsP.screenId,
|
|
34079
|
-
$container: $container,
|
|
34080
|
-
dsSession: paramsP.dsSessionP,
|
|
34081
|
-
SESSION_ID,
|
|
34082
|
-
nav,
|
|
34083
|
-
paramsP,
|
|
34084
|
-
};
|
|
34085
|
-
|
|
34086
|
-
var component_name = 'xu-page-component-' + paramsP.dsSessionP;
|
|
34087
|
-
if (!$(nav).data().xuData.nav_params) {
|
|
34088
|
-
$(nav).data().xuData.nav_params = {};
|
|
34089
|
-
}
|
|
34090
|
-
|
|
34091
|
-
//restore validate
|
|
34092
|
-
if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
|
|
34093
|
-
params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
|
|
34094
|
-
}
|
|
34095
|
-
|
|
34096
|
-
if (!$(nav)?.data()?.xuData) return;
|
|
34097
|
-
$(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
|
|
34098
|
-
if (!$(component_name).length) {
|
|
34099
|
-
await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
|
|
34100
|
-
const page = new UI_FRAMEWORK_PLUGIN.page();
|
|
34101
|
-
await set_call_screen_properties_values(page);
|
|
34102
|
-
await page.create(params);
|
|
34103
|
-
await page.init(params);
|
|
34104
|
-
nav.push(component_name, { params });
|
|
34105
|
-
} else {
|
|
34106
|
-
debugger;
|
|
34107
|
-
$(component_name).empty();
|
|
34108
|
-
|
|
34109
|
-
await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
|
|
34110
|
-
}
|
|
34111
|
-
$div.data().xuData.paramsP = $container.data().xuData.paramsP;
|
|
34112
|
-
break;
|
|
34113
|
-
|
|
34114
|
-
case 'panel':
|
|
34115
|
-
$container.append($div_content);
|
|
34116
|
-
$ret = $container;
|
|
34117
|
-
break;
|
|
34118
|
-
|
|
34119
|
-
default: // set data to nav to use in the component
|
|
34120
|
-
if ($nav && $nav.length) {
|
|
34121
|
-
// refresh made
|
|
34122
|
-
} else {
|
|
34123
|
-
$nav = $('<xu-nav>'); //.attr('xu-ui-id', SESSION_ID);
|
|
34124
|
-
$container.append($nav);
|
|
34125
|
-
func.UI.component.init_xu_nav($container, $nav);
|
|
34126
|
-
}
|
|
34127
|
-
|
|
34128
|
-
$nav.data().xuData.$div = $div_content;
|
|
34129
|
-
|
|
34130
|
-
await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
|
|
34131
|
-
$ret = $container;
|
|
34132
|
-
break;
|
|
34133
|
-
}
|
|
34134
|
-
return $ret;
|
|
34135
|
-
};
|
|
34136
|
-
|
|
34137
|
-
if (!(await init())) return;
|
|
34138
|
-
debug();
|
|
34139
|
-
const fx = {
|
|
34140
|
-
widget: async function () {
|
|
34141
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
34142
|
-
|
|
34143
|
-
var exist_elm_obj = get_element_info();
|
|
34144
|
-
var $div = exist_elm_obj.div;
|
|
34145
|
-
if (!exist_elm_obj.div) {
|
|
34146
|
-
$div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, 'widget_wrapper', null, null, null, null);
|
|
34147
|
-
|
|
34148
|
-
//////////////////////////
|
|
34149
|
-
|
|
34150
|
-
let plugin_name = prop['xu-widget'],
|
|
34151
|
-
method = prop['xu-method'],
|
|
34152
|
-
dsP = paramsP.dsSessionP,
|
|
34153
|
-
propsP = prop,
|
|
34154
|
-
sourceP = 'widgets';
|
|
34155
|
-
|
|
34156
|
-
// const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
|
|
34157
|
-
// var obj = _.clone(docP);
|
|
34158
|
-
// obj.date = await func.utils.get_dateTime(
|
|
34159
|
-
// SESSION_ID,
|
|
34160
|
-
// "SYS_DATE",
|
|
34161
|
-
// docP.date
|
|
34162
|
-
// );
|
|
34163
|
-
// obj.time = await func.utils.get_dateTime(
|
|
34164
|
-
// SESSION_ID,
|
|
34165
|
-
// "SYS_TIME",
|
|
34166
|
-
// docP.date
|
|
34167
|
-
// );
|
|
34168
|
-
|
|
34169
|
-
// var datasource_changes = {
|
|
34170
|
-
// [0]: {
|
|
34171
|
-
// ["data_system"]: {
|
|
34172
|
-
// ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
|
|
34173
|
-
// },
|
|
34174
|
-
// },
|
|
34175
|
-
// };
|
|
34176
|
-
// await func.datasource.update(SESSION_ID, datasource_changes);
|
|
34177
|
-
// };
|
|
34178
|
-
const call_plugin_api = async function (plugin_nameP, dataP) {
|
|
34179
|
-
return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
|
|
34180
|
-
};
|
|
34181
|
-
const report_error = function (descP, warn) {
|
|
34182
|
-
func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
|
|
34183
|
-
module: 'widgets',
|
|
34184
|
-
action: 'Init',
|
|
34185
|
-
source: sourceP,
|
|
34186
|
-
prop: descP,
|
|
34187
|
-
details: descP,
|
|
34188
|
-
result: null,
|
|
34189
|
-
error: warn ? false : true,
|
|
34190
|
-
fields: null,
|
|
34191
|
-
type: 'widgets',
|
|
34192
|
-
prog_id: _session.DS_GLB[dsP].prog_id,
|
|
34193
|
-
});
|
|
34194
|
-
};
|
|
34195
|
-
const get_fields_data = async function (fields, props) {
|
|
34196
|
-
const report_error = function (descP, warn) {
|
|
34197
|
-
func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
|
|
34198
|
-
module: 'widgets',
|
|
34199
|
-
action: 'Init',
|
|
34200
|
-
source: sourceP,
|
|
34201
|
-
prop: descP,
|
|
34202
|
-
details: descP,
|
|
34203
|
-
result: null,
|
|
34204
|
-
error: warn ? false : true,
|
|
34205
|
-
fields: null,
|
|
34206
|
-
type: 'widgets',
|
|
34207
|
-
prog_id: _session.DS_GLB[dsP].prog_id,
|
|
34208
|
-
});
|
|
34209
|
-
};
|
|
34210
|
-
const get_property_value = async function (fieldIdP, val) {
|
|
34211
|
-
if (!val) return;
|
|
34212
|
-
var value = fieldIdP in props ? props[fieldIdP] : typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue;
|
|
34213
|
-
if (val.render === 'eventId') {
|
|
34214
|
-
value = props?.[fieldIdP]?.event;
|
|
34215
|
-
}
|
|
34216
|
-
|
|
34217
|
-
if (props[`xu-exp:${fieldIdP}`]) {
|
|
34218
|
-
value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
|
|
34219
|
-
}
|
|
34220
|
-
|
|
34221
|
-
return func.common.get_cast_val(
|
|
34222
|
-
SESSION_ID,
|
|
34223
|
-
'widgets',
|
|
34224
|
-
fieldIdP,
|
|
34225
|
-
val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
|
|
34226
|
-
value,
|
|
34227
|
-
null,
|
|
34228
|
-
);
|
|
34229
|
-
};
|
|
34230
|
-
var data_obj = {};
|
|
34231
|
-
var return_code = 1;
|
|
34232
|
-
// $.each(fields, function (key, val) {
|
|
34233
|
-
for await (const [key, val] of Object.entries(fields)) {
|
|
34234
|
-
data_obj[key] = await get_property_value(key, val);
|
|
34235
|
-
if (!data_obj[key] && val.mandatory) {
|
|
34236
|
-
return_code = -1;
|
|
34237
|
-
report_error(`${key} is a mandatory field.`);
|
|
34238
|
-
break;
|
|
34239
|
-
}
|
|
34240
|
-
// console.log(val);
|
|
34241
|
-
}
|
|
34242
|
-
for await (const key of ['xu-bind']) {
|
|
34243
|
-
data_obj[key] = await get_property_value(key, props[key]);
|
|
34244
|
-
}
|
|
34245
|
-
|
|
34246
|
-
return { code: return_code, data: data_obj };
|
|
34247
|
-
};
|
|
34248
|
-
|
|
34249
|
-
const load_css_style = function () {
|
|
34250
|
-
const get_css_path = function (resource) {
|
|
34251
|
-
if (_session.worker_type === 'Dev') {
|
|
34252
|
-
return `../../plugins/${plugin_name}/${resource}`;
|
|
34253
|
-
}
|
|
34254
|
-
return `https://${_session.domain}/plugins/${plugin_name}/${APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest[resource].dist ? 'dist/' : ''}${resource}?gtp_token=${_session.gtp_token}&app_id=${_session.app_id}`;
|
|
34255
|
-
};
|
|
34256
|
-
let path = get_css_path('style.css');
|
|
34257
|
-
func.utils.load_css_on_demand(path);
|
|
34258
|
-
};
|
|
34259
|
-
|
|
34260
|
-
const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
|
|
34261
|
-
const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
|
|
34262
|
-
const methods = index.methods;
|
|
34263
|
-
if (methods && !methods[method]) {
|
|
34264
|
-
return report_error('method not found');
|
|
34265
|
-
}
|
|
34266
|
-
|
|
34267
|
-
const fields_ret = await get_fields_data(methods[method].fields, propsP);
|
|
34268
|
-
if (fields_ret.code < 0) {
|
|
34269
|
-
return report_error(fields_ret.data);
|
|
34270
|
-
}
|
|
34271
|
-
const fields = fields_ret.data;
|
|
34272
|
-
|
|
34273
|
-
let exclude_attributes = [];
|
|
34274
|
-
for await (const [key, val] of Object.entries(propsP)) {
|
|
34275
|
-
if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
|
|
34276
|
-
exclude_attributes.push(key);
|
|
34277
|
-
}
|
|
34278
|
-
}
|
|
34279
|
-
|
|
34280
|
-
let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true, exclude_attributes);
|
|
34281
|
-
|
|
34282
|
-
$div.addClass('widget_wrapper'); // class get override in set_attributes_new
|
|
34283
|
-
|
|
34284
|
-
if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
|
|
34285
|
-
return report_error(`plugin ${plugin_name} not found`);
|
|
34286
|
-
}
|
|
34287
|
-
|
|
34288
|
-
if (APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest['style.css'].exist) {
|
|
34289
|
-
load_css_style();
|
|
34290
|
-
}
|
|
34291
|
-
|
|
34292
|
-
const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
|
|
34293
|
-
if (plugin_setup_ret.code < 0) {
|
|
34294
|
-
return report_error(plugin_setup_ret);
|
|
34295
|
-
}
|
|
34296
|
-
|
|
34297
|
-
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
34298
|
-
func,
|
|
34299
|
-
glb,
|
|
34300
|
-
SESSION_OBJ,
|
|
34301
|
-
SESSION_ID,
|
|
34302
|
-
APP_OBJ,
|
|
34303
|
-
dsSession: paramsP.dsSessionP,
|
|
34304
|
-
job_id: jobNoP,
|
|
34305
|
-
});
|
|
34306
|
-
|
|
34307
|
-
const params = {
|
|
34308
|
-
SESSION_ID,
|
|
34309
|
-
method,
|
|
34310
|
-
_session,
|
|
34311
|
-
dsP,
|
|
34312
|
-
sourceP,
|
|
34313
|
-
propsP,
|
|
34314
|
-
plugin_name,
|
|
34315
|
-
$containerP: $div,
|
|
34316
|
-
plugin_setup: plugin_setup_ret.data,
|
|
34317
|
-
|
|
34318
|
-
report_error,
|
|
34319
|
-
call_plugin_api,
|
|
34320
|
-
// set_SYS_GLOBAL_OBJ_WIDGET_INFO,
|
|
34321
|
-
api_utils,
|
|
34322
|
-
};
|
|
34323
|
-
|
|
34324
|
-
const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
|
|
34325
|
-
|
|
34326
|
-
if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
|
|
34327
|
-
const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
|
|
34328
|
-
func.utils.load_css_on_demand(plugin_runtime_css_url);
|
|
34329
|
-
}
|
|
34330
|
-
|
|
34331
|
-
if (!fx[method]) {
|
|
34332
|
-
throw `Method: ${method} does not exist`;
|
|
34333
|
-
}
|
|
34334
|
-
try {
|
|
34335
|
-
await fx[method](fields, params);
|
|
34336
|
-
} catch (err) {
|
|
34337
|
-
func.utils.debug_report(SESSION_ID, `${plugin_name} widget`, err.message, 'E');
|
|
34338
|
-
}
|
|
34339
|
-
}
|
|
34340
|
-
return $div;
|
|
34341
|
-
},
|
|
34342
|
-
[`xu-single-view`]: async function () {
|
|
34343
|
-
var exist_elm_obj = get_element_info();
|
|
34344
|
-
var $div = exist_elm_obj.div;
|
|
34345
|
-
|
|
34346
|
-
if (!exist_elm_obj.div) {
|
|
34347
|
-
var $wrapper = $('<div>');
|
|
34348
|
-
$div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, 'div', $wrapper, '');
|
|
34349
|
-
|
|
34350
|
-
if (!$div) return;
|
|
34351
|
-
|
|
34352
|
-
if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
|
|
34353
|
-
close_all_modals();
|
|
34354
|
-
}
|
|
34355
|
-
|
|
34356
|
-
$div.hover(
|
|
34357
|
-
function (e) {
|
|
34358
|
-
hover_in();
|
|
34359
|
-
// func.UI.screen.hover_in(SESSION_ID, null, $container, paramsP, is_skeleton);
|
|
34360
|
-
},
|
|
34361
|
-
function (e) {
|
|
34362
|
-
// func.UI.screen.hover_out(SESSION_ID, $container, is_skeleton, paramsP);
|
|
34363
|
-
hover_out();
|
|
34364
|
-
},
|
|
34365
|
-
);
|
|
34366
|
-
}
|
|
34367
|
-
|
|
34368
|
-
const ret = await iterate_child($div, nodeP, null, $div);
|
|
34369
|
-
if (_.isEmpty($container.data().xuAttributes)) {
|
|
34370
|
-
await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
|
|
34371
|
-
}
|
|
34372
|
-
|
|
34373
|
-
$.each($div.data().xuData, function (key, val) {
|
|
34374
|
-
$container.data().xuData[key] = _.cloneDeep(val);
|
|
34375
|
-
});
|
|
34376
|
-
$.each($div.data().xuAttributes, function (key, val) {
|
|
34377
|
-
$container.data().xuAttributes[key] = _.cloneDeep(val);
|
|
34378
|
-
});
|
|
34379
|
-
|
|
34380
|
-
return await render_screen_type($div);
|
|
34381
|
-
},
|
|
34382
|
-
[`xu-multi-view`]: async function () {
|
|
34383
|
-
var $div = $container;
|
|
34384
|
-
|
|
34385
|
-
if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
|
|
34386
|
-
$div.data().xuData.node = nodeP;
|
|
34387
|
-
}
|
|
34388
|
-
|
|
34389
|
-
if (!$div.data().xuData.debug_info) {
|
|
34390
|
-
$div.data().xuData.debug_info = {
|
|
34391
|
-
id: nodeP.id,
|
|
34392
|
-
parent_id: $container.data().xuData.ui_id,
|
|
34393
|
-
};
|
|
34394
|
-
}
|
|
34395
|
-
|
|
34396
|
-
const done = async function (continuous_idx) {
|
|
34397
|
-
// const do_callback = async function ($div) {
|
|
34398
|
-
// // if ($root_container.data().xuData.progress_bar_circle) {
|
|
34399
|
-
// // setTimeout(function () {
|
|
34400
|
-
// // $.each(
|
|
34401
|
-
// // $root_container.data().xuData.progress_bar_circle,
|
|
34402
|
-
// // function (key, val) {
|
|
34403
|
-
// // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
|
|
34404
|
-
// // }
|
|
34405
|
-
// // );
|
|
34406
|
-
// // }, 2000);
|
|
34407
|
-
// // }
|
|
34408
|
-
|
|
34409
|
-
// if (paramsP.screenInfo.properties?.rtl) {
|
|
34410
|
-
// $div_content.attr('dir', 'rtl');
|
|
34411
|
-
// }
|
|
34412
|
-
|
|
34413
|
-
// return $div;
|
|
34414
|
-
// };
|
|
34415
|
-
await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
|
|
34416
|
-
|
|
34417
|
-
return await render_screen_type($div);
|
|
34418
|
-
};
|
|
34419
|
-
|
|
34420
|
-
if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
|
|
34421
|
-
close_all_modals();
|
|
34422
|
-
}
|
|
34423
|
-
|
|
34424
|
-
const empty_result = async function () {
|
|
34425
|
-
// var content = prop.empty_result_content || '';
|
|
34426
|
-
|
|
34427
|
-
// var res = await func.expression.get(
|
|
34428
|
-
// SESSION_ID,
|
|
34429
|
-
// content, // prop["xu-exp:empty_result_content"],
|
|
34430
|
-
// paramsP.dsSessionP,
|
|
34431
|
-
// 'empty_result_content_EXP',
|
|
34432
|
-
// _ds.currentRecordId,
|
|
34433
|
-
// );
|
|
34434
|
-
// content = res.result;
|
|
34435
|
-
|
|
34436
|
-
// let empty_result_node = {
|
|
34437
|
-
// type: 'element',
|
|
34438
|
-
// id: crypto.randomUUID(),
|
|
34439
|
-
// content,
|
|
34440
|
-
// // : content || (typeof content === "undefined" && "Empty results"),
|
|
34441
|
-
// tagName: 'div',
|
|
34442
|
-
// attributes: {},
|
|
34443
|
-
// children: [],
|
|
34444
|
-
// };
|
|
34445
|
-
|
|
34446
|
-
// const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $container, empty_result_node, parent_infoP, paramsP, jobNoP, null, 0, null, nodeP, null, $root_container);
|
|
34447
|
-
await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
|
|
34448
|
-
return await done(null);
|
|
34449
|
-
};
|
|
34450
|
-
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
34451
|
-
|
|
34452
|
-
var continuous_idx = null;
|
|
34453
|
-
|
|
34454
|
-
if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
|
|
34455
|
-
return await empty_result();
|
|
34456
|
-
}
|
|
34457
|
-
|
|
34458
|
-
var i = 0;
|
|
34459
|
-
for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
|
|
34460
|
-
var node = JSON.parse(JSON.stringify(nodeP));
|
|
34461
|
-
|
|
34462
|
-
_ds.currentRecordId = val._ROWID;
|
|
34463
|
-
const ret = await iterate_child($div, node, { continuous_idx }, $root_container);
|
|
34464
|
-
|
|
34465
|
-
if (_.isEmpty($container.data().xuAttributes)) {
|
|
34466
|
-
await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
|
|
34467
|
-
}
|
|
34468
|
-
}
|
|
34469
|
-
|
|
34470
|
-
return await done(continuous_idx);
|
|
34471
|
-
},
|
|
34472
|
-
[`xu-panel`]: async function () {
|
|
34473
|
-
const done = async function ($new_div) {
|
|
34474
|
-
if (!$container.data()?.xuData?.paramsP) {
|
|
34475
|
-
return $container;
|
|
34476
|
-
}
|
|
34477
|
-
var $div_items = $div.data().xuData.node.children;
|
|
34478
|
-
|
|
34479
|
-
await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
|
|
34480
|
-
|
|
34481
|
-
// TO FIX should be timeout
|
|
34482
|
-
$container.data().xuData.node.children = $div_items;
|
|
34483
|
-
|
|
34484
|
-
return $container;
|
|
34485
|
-
};
|
|
34486
|
-
|
|
34487
|
-
var $wrapper = $('<div>');
|
|
34488
|
-
$div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, null, $wrapper, '');
|
|
34489
|
-
|
|
34490
|
-
let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div.clone(true), true, undefined, refreshed_ds);
|
|
34491
|
-
if (ret.abort) {
|
|
34492
|
-
// render N
|
|
34493
|
-
return (ret.$new_div = $('<template>').append($div));
|
|
34494
|
-
}
|
|
34495
|
-
|
|
34496
|
-
let $ret_panel_div = ret.$new_div;
|
|
34497
|
-
|
|
34498
|
-
if (!$ret_panel_div?.children()?.length) {
|
|
34499
|
-
////// render default children tree
|
|
34500
|
-
if (nodeP.children.length) {
|
|
34501
|
-
$ret_panel_div = await func.UI.screen.render_ui_tree(SESSION_ID, $container, nodeP.children[0], parent_infoP, paramsP, jobNoP, null, 0, null, nodeP, null, $root_container);
|
|
34502
|
-
}
|
|
34503
|
-
}
|
|
34504
|
-
|
|
34505
|
-
let ret_done = await done($ret_panel_div);
|
|
34506
|
-
|
|
34507
|
-
return ret_done;
|
|
34508
|
-
},
|
|
34509
|
-
};
|
|
34510
|
-
|
|
34511
|
-
const draw_html_element_org = async function (element) {
|
|
34512
|
-
const done = async function (ret = {}) {
|
|
34513
|
-
return $div;
|
|
34514
|
-
};
|
|
34515
|
-
if (!element || element === 'script') return await done();
|
|
34516
|
-
let str = '';
|
|
34517
|
-
|
|
34518
|
-
var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
|
|
34519
|
-
|
|
34520
|
-
$div.hover(
|
|
34521
|
-
function (e) {
|
|
34522
|
-
hover_in($div, e);
|
|
34523
|
-
},
|
|
34524
|
-
function (e) {
|
|
34525
|
-
hover_out();
|
|
34526
|
-
},
|
|
34527
|
-
);
|
|
34528
|
-
if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
|
|
34529
|
-
$div.on('click contextmenu', function (e) {
|
|
34530
|
-
hover_in($div, e);
|
|
34531
|
-
});
|
|
34532
|
-
}
|
|
34533
|
-
|
|
34534
|
-
// let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $container, nodeP, $div, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
|
|
34535
|
-
let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
|
|
34536
|
-
if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
|
|
34537
|
-
return await done(ret);
|
|
34538
|
-
}
|
|
34539
|
-
// check if iterator made to prevent children render
|
|
34540
|
-
|
|
34541
|
-
if (nodeP?.attributes?.['xu-viewport'] == 'true') {
|
|
34542
|
-
// const xu_viewport = async function () {
|
|
34543
|
-
// const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
|
|
34544
|
-
// const container_id = $container.attr('xu-ui-id');
|
|
34545
|
-
// if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
|
|
34546
|
-
// UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
|
|
34547
|
-
// await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34548
|
-
// } else {
|
|
34549
|
-
// $div.remove();
|
|
34550
|
-
// }
|
|
34551
|
-
// UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
|
|
34552
|
-
|
|
34553
|
-
// // if (!$div.children().length) {
|
|
34554
|
-
// // // render the first element to determine height
|
|
34555
|
-
// // await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34556
|
-
// // // hover_in($div);
|
|
34557
|
-
// // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
|
|
34558
|
-
// // } else {
|
|
34559
|
-
// // }
|
|
34560
|
-
// };
|
|
34561
|
-
const xu_viewport = function () {
|
|
34562
|
-
const observer_inViewport = new IntersectionObserver(
|
|
34563
|
-
function (entries) {
|
|
34564
|
-
entries.forEach((entry) => {
|
|
34565
|
-
if (entry.isIntersecting) {
|
|
34566
|
-
$(entry.target).trigger('inViewport');
|
|
34567
|
-
|
|
34568
|
-
// Optional: stop observing once triggered
|
|
34569
|
-
observer_inViewport.unobserve(entry.target);
|
|
34570
|
-
}
|
|
34571
|
-
});
|
|
34572
|
-
},
|
|
34573
|
-
{
|
|
34574
|
-
threshold: 0.1, // Trigger when 10% of element is visible
|
|
34575
|
-
},
|
|
34576
|
-
);
|
|
34577
|
-
|
|
34578
|
-
const observer_outViewport = new IntersectionObserver(
|
|
34579
|
-
function (entries) {
|
|
34580
|
-
entries.forEach((entry) => {
|
|
34581
|
-
if (!entry.isIntersecting) {
|
|
34582
|
-
// Element is OUT of viewport - trigger custom event
|
|
34583
|
-
$(entry.target).trigger('outViewport');
|
|
34584
|
-
|
|
34585
|
-
// Optional: stop observing once triggered
|
|
34586
|
-
// observer_outViewport.unobserve(entry.target);
|
|
34587
|
-
}
|
|
34588
|
-
});
|
|
34589
|
-
},
|
|
34590
|
-
{
|
|
34591
|
-
threshold: 0, // Trigger when element is completely out of view
|
|
34592
|
-
},
|
|
34593
|
-
);
|
|
34594
|
-
|
|
34595
|
-
let ui_job_id;
|
|
34596
|
-
$div.on('inViewport', function () {
|
|
34597
|
-
if ($div.children().length) {
|
|
34598
|
-
$div.removeClass('skeleton');
|
|
34599
|
-
return;
|
|
34600
|
-
}
|
|
34601
|
-
|
|
34602
|
-
// if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
|
|
34603
|
-
// $div[0].style.removeProperty('height');
|
|
34604
|
-
// $div.removeClass('skeleton');
|
|
34605
|
-
// $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
|
|
34606
|
-
// } else {
|
|
34607
|
-
hover_in($div);
|
|
34608
|
-
ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container }, null, null, paramsP.dsSessionP);
|
|
34609
|
-
// }
|
|
34610
|
-
observer_outViewport.observe($div[0]);
|
|
34611
|
-
});
|
|
34612
|
-
|
|
34613
|
-
$div.on('outViewport', function () {
|
|
34614
|
-
func.UI.worker.delete_job(SESSION_ID, ui_job_id);
|
|
34615
|
-
|
|
34616
|
-
if ($div.children().length) {
|
|
34617
|
-
// UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
|
|
34618
|
-
$div.empty();
|
|
34619
|
-
const height = $div?.data()?.xuData?.viewport_height || 10;
|
|
34620
|
-
if (typeof height !== 'undefined') {
|
|
34621
|
-
$div.css('height', height);
|
|
34622
|
-
}
|
|
34623
|
-
}
|
|
34624
|
-
// $div.addClass('skeleton');
|
|
34625
|
-
observer_inViewport.observe($div[0]);
|
|
34626
|
-
});
|
|
34627
|
-
$div.addClass('skeleton');
|
|
34628
|
-
observer_inViewport.observe($div[0]);
|
|
34629
|
-
};
|
|
34630
|
-
xu_viewport();
|
|
34631
|
-
} else {
|
|
34632
|
-
await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34633
|
-
}
|
|
34634
|
-
|
|
34635
|
-
// const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
|
|
34636
|
-
return await done(ret);
|
|
34637
|
-
};
|
|
34638
|
-
|
|
34639
|
-
const draw_html_element = async function (element) {
|
|
34640
|
-
const done = async function (ret = {}) {
|
|
34641
|
-
const xu_ui_id = $div.attr('xu-ui-id');
|
|
34642
|
-
$div.removeClass('display_none');
|
|
34643
|
-
if (ret.has_xu_exp_render_attribute) {
|
|
34644
|
-
// $div.css('display', 'unset');
|
|
34645
|
-
|
|
34646
|
-
const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($div.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
|
|
34647
|
-
const _$div = $div.clone(true);
|
|
34648
|
-
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: _$div, paramsP, data: _$div.data() };
|
|
34649
|
-
nodeP.xu_render_xu_ui_id = xu_ui_id;
|
|
34650
|
-
nodeP.xu_render_cache_id = xu_render_cache_id;
|
|
34651
|
-
|
|
34652
|
-
if (ret.xu_render_background_processing) {
|
|
34653
|
-
temp_$div.remove();
|
|
34654
|
-
// $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
|
|
34655
|
-
return $div;
|
|
34656
|
-
} else {
|
|
34657
|
-
// $div.css('display', 'unset');
|
|
34658
|
-
temp_$div.replaceWith($div);
|
|
34659
|
-
return $div;
|
|
34660
|
-
}
|
|
34661
|
-
} else {
|
|
34662
|
-
if (ret.has_xu_render_attribute) {
|
|
34663
|
-
temp_$div.remove();
|
|
34664
|
-
return $div;
|
|
34665
|
-
}
|
|
34666
|
-
// $div.css('display', 'unset');
|
|
34667
|
-
temp_$div.replaceWith($div);
|
|
34668
|
-
return $div;
|
|
34669
|
-
}
|
|
34670
|
-
};
|
|
34671
|
-
if (!element || element === 'script') return await done();
|
|
34672
|
-
let str = '';
|
|
34673
|
-
|
|
34674
|
-
var temp_$div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str, true);
|
|
34675
|
-
|
|
34676
|
-
let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
|
|
34677
|
-
let $div = temp_$div.clone(true);
|
|
34678
|
-
|
|
34679
|
-
// $div.css('display', 'none');
|
|
34680
|
-
|
|
34681
|
-
$div.hover(
|
|
34682
|
-
function (e) {
|
|
34683
|
-
hover_in($div, e);
|
|
34684
|
-
},
|
|
34685
|
-
function (e) {
|
|
34686
|
-
hover_out();
|
|
34687
|
-
},
|
|
34688
|
-
);
|
|
34689
|
-
if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
|
|
34690
|
-
$div.on('click contextmenu', function (e) {
|
|
34691
|
-
hover_in($div, e);
|
|
34692
|
-
});
|
|
34693
|
-
}
|
|
34694
|
-
|
|
34695
|
-
let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, temp_$container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
|
|
34696
|
-
if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
|
|
34697
|
-
return await done(ret);
|
|
34698
|
-
}
|
|
34699
|
-
// check if iterator made to prevent children render
|
|
34700
|
-
|
|
34701
|
-
if (nodeP?.attributes?.['xu-viewport'] == 'true') {
|
|
34702
|
-
// const xu_viewport = async function () {
|
|
34703
|
-
// const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
|
|
34704
|
-
// const container_id = $container.attr('xu-ui-id');
|
|
34705
|
-
// if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
|
|
34706
|
-
// UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
|
|
34707
|
-
// await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34708
|
-
// } else {
|
|
34709
|
-
// $div.remove();
|
|
34710
|
-
// }
|
|
34711
|
-
// UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
|
|
34712
|
-
|
|
34713
|
-
// // if (!$div.children().length) {
|
|
34714
|
-
// // // render the first element to determine height
|
|
34715
|
-
// // await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34716
|
-
// // // hover_in($div);
|
|
34717
|
-
// // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
|
|
34718
|
-
// // } else {
|
|
34719
|
-
// // }
|
|
34720
|
-
// };
|
|
34721
|
-
const xu_viewport = function () {
|
|
34722
|
-
const observer_inViewport = new IntersectionObserver(
|
|
34723
|
-
function (entries) {
|
|
34724
|
-
entries.forEach((entry) => {
|
|
34725
|
-
if (entry.isIntersecting) {
|
|
34726
|
-
$(entry.target).trigger('inViewport');
|
|
34727
|
-
|
|
34728
|
-
// Optional: stop observing once triggered
|
|
34729
|
-
observer_inViewport.unobserve(entry.target);
|
|
34730
|
-
}
|
|
34731
|
-
});
|
|
34732
|
-
},
|
|
34733
|
-
{
|
|
34734
|
-
threshold: 0.1, // Trigger when 10% of element is visible
|
|
34735
|
-
},
|
|
34736
|
-
);
|
|
34737
|
-
|
|
34738
|
-
const observer_outViewport = new IntersectionObserver(
|
|
34739
|
-
function (entries) {
|
|
34740
|
-
entries.forEach((entry) => {
|
|
34741
|
-
if (!entry.isIntersecting) {
|
|
34742
|
-
// Element is OUT of viewport - trigger custom event
|
|
34743
|
-
$(entry.target).trigger('outViewport');
|
|
34744
|
-
|
|
34745
|
-
// Optional: stop observing once triggered
|
|
34746
|
-
// observer_outViewport.unobserve(entry.target);
|
|
34747
|
-
}
|
|
34748
|
-
});
|
|
34749
|
-
},
|
|
34750
|
-
{
|
|
34751
|
-
threshold: 0, // Trigger when element is completely out of view
|
|
34752
|
-
},
|
|
34753
|
-
);
|
|
34754
|
-
|
|
34755
|
-
let ui_job_id;
|
|
34756
|
-
$div.on('inViewport', function () {
|
|
34757
|
-
if ($div.children().length) {
|
|
34758
|
-
$div.removeClass('skeleton');
|
|
34759
|
-
return;
|
|
34760
|
-
}
|
|
34761
|
-
|
|
34762
|
-
// if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
|
|
34763
|
-
// $div[0].style.removeProperty('height');
|
|
34764
|
-
// $div.removeClass('skeleton');
|
|
34765
|
-
// $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
|
|
34766
|
-
// } else {
|
|
34767
|
-
hover_in($div);
|
|
34768
|
-
ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, temp_$container }, null, null, paramsP.dsSessionP);
|
|
34769
|
-
// }
|
|
34770
|
-
observer_outViewport.observe($div[0]);
|
|
34771
|
-
});
|
|
34772
|
-
|
|
34773
|
-
$div.on('outViewport', function () {
|
|
34774
|
-
func.UI.worker.delete_job(SESSION_ID, ui_job_id);
|
|
34775
|
-
|
|
34776
|
-
if ($div.children().length) {
|
|
34777
|
-
// UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
|
|
34778
|
-
$div.empty();
|
|
34779
|
-
const height = $div?.data()?.xuData?.viewport_height || 10;
|
|
34780
|
-
if (typeof height !== 'undefined') {
|
|
34781
|
-
$div.css('height', height);
|
|
34782
|
-
}
|
|
34783
|
-
}
|
|
34784
|
-
// $div.addClass('skeleton');
|
|
34785
|
-
observer_inViewport.observe($div[0]);
|
|
34786
|
-
});
|
|
34787
|
-
$div.addClass('skeleton');
|
|
34788
|
-
observer_inViewport.observe($div[0]);
|
|
34789
|
-
};
|
|
34790
|
-
xu_viewport();
|
|
34791
|
-
} else {
|
|
34792
|
-
// if (ret.xu_render_background_processing) {
|
|
34793
|
-
// // let temp_$div = $div.clone(true);
|
|
34794
|
-
// iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34795
|
-
// } else {
|
|
34796
|
-
// await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34797
|
-
// }
|
|
34798
|
-
if (!ret.xu_render_background_processing) {
|
|
34799
|
-
iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34800
|
-
}
|
|
34801
|
-
}
|
|
34802
|
-
|
|
34803
|
-
// const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
|
|
34804
|
-
return await done(ret);
|
|
34805
|
-
};
|
|
34806
|
-
|
|
34807
|
-
if (nodeP.content && nodeP.attributes) {
|
|
34808
|
-
nodeP.attributes['xu-content'] = nodeP.content;
|
|
34809
|
-
}
|
|
34810
|
-
|
|
34811
|
-
if (nodeP.tagName === 'xu-widget') {
|
|
34812
|
-
if (is_skeleton) return;
|
|
34813
|
-
return await fx['widget']();
|
|
34814
|
-
}
|
|
34815
|
-
if (fx[nodeP.tagName]) {
|
|
34816
|
-
return await fx[nodeP.tagName]();
|
|
34817
|
-
}
|
|
34818
|
-
// const xu_viewport = async function () {
|
|
34819
|
-
// const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
|
|
34820
|
-
// const container_id = $container.attr('xu-ui-id');
|
|
34821
|
-
// if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
|
|
34822
|
-
// UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
|
|
34823
|
-
// await iterate_child($div, nodeP, parent_infoP, $root_container);
|
|
34824
|
-
// }
|
|
34825
|
-
// UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
|
|
34826
|
-
// };
|
|
34827
|
-
|
|
34828
|
-
// if (nodeP?.attributes?.['xu-viewport'] == 'true') {
|
|
34829
|
-
// return await xu_viewport();
|
|
34830
|
-
// } else {
|
|
34831
|
-
if (!glb.new_xu_render) {
|
|
34832
|
-
return await draw_html_element_org(nodeP.tagName);
|
|
34833
|
-
}
|
|
34834
|
-
return await draw_html_element(nodeP.tagName);
|
|
34835
|
-
|
|
34836
|
-
// }
|
|
34837
|
-
};
|
|
34838
|
-
|
|
34839
|
-
func.UI.screen.refresh_document_changes_for_realtime_update = async function (SESSION_ID, doc_change) {
|
|
34840
|
-
let _session = SESSION_OBJ[SESSION_ID];
|
|
34841
|
-
for (const [key, _ds] of Object.entries(_session.DS_GLB)) {
|
|
34842
|
-
let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
34843
|
-
if (prog_obj?.progDataSource?.dataSourceRealtime && prog_obj?.progDataSource?.dataSourceTableId === doc_change.table_id) {
|
|
34844
|
-
try {
|
|
34845
|
-
// disabled in purpose to support create row
|
|
34846
|
-
|
|
34847
|
-
if (!_ds.screen_params) continue;
|
|
34848
|
-
if (_ds.screen_params.is_panelP) {
|
|
34849
|
-
func.UI.screen.refresh_screen(SESSION_ID, null, key);
|
|
34850
|
-
} else {
|
|
34851
|
-
func.action.execute(SESSION_ID, 'act_refresh', _ds, null, null);
|
|
34852
|
-
}
|
|
34853
|
-
} catch (err) {
|
|
34854
|
-
// console.error(err);
|
|
34855
|
-
}
|
|
34856
|
-
}
|
|
34857
|
-
}
|
|
34858
|
-
|
|
34859
|
-
if (glb.new_xu_render) {
|
|
34860
|
-
for (const [ui_cache_key, ui_cache_val] of Object.entries(UI_WORKER_OBJ.xu_render_cache)) {
|
|
34861
|
-
let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, ui_cache_val.paramsP.prog_id);
|
|
34862
|
-
if (prog_obj?.progDataSource?.dataSourceTableId === doc_change.table_id) {
|
|
34863
|
-
ui_cache_val.$div = null;
|
|
34864
|
-
}
|
|
34865
|
-
}
|
|
34866
|
-
}
|
|
34867
|
-
};
|
|
34868
|
-
|
|
34869
|
-
const get_parent_ds_fields = function (SESSION_ID, dsSessionP) {
|
|
34870
|
-
var _session = SESSION_OBJ[SESSION_ID];
|
|
34871
|
-
var _ds = _session.DS_GLB[dsSessionP];
|
|
34872
|
-
|
|
34873
|
-
const idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
34874
|
-
const data = _ds.data_feed.rows[idx];
|
|
34875
|
-
|
|
34876
|
-
let obj = {};
|
|
34877
|
-
|
|
34878
|
-
if (typeof _ds.parentDataSourceNo !== 'undefined') {
|
|
34879
|
-
obj = get_parent_ds_fields(SESSION_ID, _ds.parentDataSourceNo);
|
|
34880
|
-
}
|
|
34881
|
-
|
|
34882
|
-
return { ...data, ...obj };
|
|
34883
|
-
};
|
|
34884
|
-
|
|
34885
|
-
const get_xu_render_cache_str = async function (SESSION_ID, dsSessionP, exclude_vars = []) {
|
|
34886
|
-
const fields_obj = get_parent_ds_fields(SESSION_ID, dsSessionP);
|
|
34887
|
-
|
|
34888
|
-
let str = '';
|
|
34889
|
-
|
|
34890
|
-
for (const [key, val] of Object.entries(fields_obj)) {
|
|
34891
|
-
if (exclude_vars.includes(key)) continue;
|
|
34892
|
-
str += typeof val !== 'undefined' ? JSON.stringify(val) : '';
|
|
34893
|
-
}
|
|
34894
|
-
|
|
34895
|
-
return 'C-' + (await func.common.sha256(str));
|
|
34896
|
-
};
|
|
34897
|
-
func.UI.component = {};
|
|
30955
|
+
func.UI.component = {};
|
|
34898
30956
|
|
|
34899
30957
|
func.UI.component.create_app_modal_component = function (
|
|
34900
30958
|
SESSION_ID,
|