@xuda.io/runtime-bundle 1.0.612 → 1.0.613
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.
- package/js/xuda-runtime-bundle.js +1416 -1
- package/js/xuda-runtime-slim.js +1416 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -13212,7 +13212,1422 @@ func.UI.screen.set_attributes_new = async function (SESSION_ID, is_skeleton, $ro
|
|
|
13212
13212
|
},
|
|
13213
13213
|
props: {},
|
|
13214
13214
|
},
|
|
13215
|
-
],
|
|
13215
|
+
],
|
|
13216
|
+
},
|
|
13217
|
+
];
|
|
13218
|
+
delete nodeP.attributes[key];
|
|
13219
|
+
}
|
|
13220
|
+
}
|
|
13221
|
+
|
|
13222
|
+
for (let [key, val] of Object.entries(nodeP.attributes)) {
|
|
13223
|
+
// FIX STATIC DEFAULTS
|
|
13224
|
+
val = func.UI.screen.fix_val_defaults(key, val);
|
|
13225
|
+
|
|
13226
|
+
// REMOVE UNDEFINED or NULL ATTRIBUTES
|
|
13227
|
+
if (typeof val === 'undefined' || val === null) {
|
|
13228
|
+
delete nodeP.attributes[key];
|
|
13229
|
+
}
|
|
13230
|
+
|
|
13231
|
+
// REMOVE ATTRIBUTES WITH EMPTY VALUES
|
|
13232
|
+
if (glb.solid_attributes.includes(key) && !val) {
|
|
13233
|
+
delete nodeP.attributes[key];
|
|
13234
|
+
}
|
|
13235
|
+
}
|
|
13236
|
+
|
|
13237
|
+
// BEFORE
|
|
13238
|
+
|
|
13239
|
+
for await (const [key, attr] of Object.entries(glb.run_xu_before)) {
|
|
13240
|
+
if (_ret.abort) break;
|
|
13241
|
+
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) {
|
|
13242
|
+
continue;
|
|
13243
|
+
}
|
|
13244
|
+
|
|
13245
|
+
if (!nodeP.attributes || !nodeP.attributes[attr] & !nodeP.attributes[`xu-exp:${attr}`]) {
|
|
13246
|
+
continue;
|
|
13247
|
+
}
|
|
13248
|
+
|
|
13249
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
13250
|
+
SESSION_ID,
|
|
13251
|
+
is_skeleton,
|
|
13252
|
+
$root_container,
|
|
13253
|
+
nodeP,
|
|
13254
|
+
$container,
|
|
13255
|
+
paramsP,
|
|
13256
|
+
parent_infoP,
|
|
13257
|
+
jobNoP,
|
|
13258
|
+
keyP,
|
|
13259
|
+
parent_nodeP,
|
|
13260
|
+
attr,
|
|
13261
|
+
$elm,
|
|
13262
|
+
{
|
|
13263
|
+
key: attr,
|
|
13264
|
+
// value: _value,
|
|
13265
|
+
value: (await get_xuExp(attr)) || nodeP.attributes[attr],
|
|
13266
|
+
},
|
|
13267
|
+
is_init,
|
|
13268
|
+
);
|
|
13269
|
+
_ret = _.assignIn(_ret, ret);
|
|
13270
|
+
}
|
|
13271
|
+
|
|
13272
|
+
// ALL
|
|
13273
|
+
|
|
13274
|
+
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
13275
|
+
if (_ret.abort) break;
|
|
13276
|
+
if (glb.html5_events_handler.includes(key) || execute_attributes.includes(key)) {
|
|
13277
|
+
continue;
|
|
13278
|
+
}
|
|
13279
|
+
|
|
13280
|
+
const new_key = key.split(':')[0]; // break expression
|
|
13281
|
+
if (
|
|
13282
|
+
nodeP.tagName !== 'xu-panel' &&
|
|
13283
|
+
nodeP.tagName !== 'xu-teleport' && // nodeP.tagName.substr(0, 3) !== "xu-" &&
|
|
13284
|
+
(new_key.substr(0, 2) !== 'xu' || new_key.substr(2, 1) !== '-')
|
|
13285
|
+
) {
|
|
13286
|
+
// handle common html attributes
|
|
13287
|
+
try {
|
|
13288
|
+
$elm.get(0).setAttribute(key, val);
|
|
13289
|
+
} catch (err) {
|
|
13290
|
+
console.error(err.message);
|
|
13291
|
+
}
|
|
13292
|
+
|
|
13293
|
+
continue;
|
|
13294
|
+
}
|
|
13295
|
+
// handle xu attributes
|
|
13296
|
+
try {
|
|
13297
|
+
$elm.data().xuAttributes[key] = val;
|
|
13298
|
+
} catch (error) {
|
|
13299
|
+
debugger;
|
|
13300
|
+
console.error(error);
|
|
13301
|
+
}
|
|
13302
|
+
|
|
13303
|
+
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)) {
|
|
13304
|
+
continue;
|
|
13305
|
+
}
|
|
13306
|
+
|
|
13307
|
+
if (new_key === 'xu-on') {
|
|
13308
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
13309
|
+
SESSION_ID,
|
|
13310
|
+
is_skeleton,
|
|
13311
|
+
$root_container,
|
|
13312
|
+
nodeP,
|
|
13313
|
+
$container,
|
|
13314
|
+
paramsP,
|
|
13315
|
+
parent_infoP,
|
|
13316
|
+
jobNoP,
|
|
13317
|
+
keyP,
|
|
13318
|
+
parent_nodeP,
|
|
13319
|
+
'xu-on',
|
|
13320
|
+
$elm,
|
|
13321
|
+
{
|
|
13322
|
+
key: key,
|
|
13323
|
+
value: (await get_xuExp(new_key)) || val,
|
|
13324
|
+
},
|
|
13325
|
+
is_init,
|
|
13326
|
+
refreshed_ds,
|
|
13327
|
+
);
|
|
13328
|
+
_ret = _.assignIn(_ret, ret);
|
|
13329
|
+
continue;
|
|
13330
|
+
}
|
|
13331
|
+
|
|
13332
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
13333
|
+
SESSION_ID,
|
|
13334
|
+
is_skeleton,
|
|
13335
|
+
$root_container,
|
|
13336
|
+
nodeP,
|
|
13337
|
+
$container,
|
|
13338
|
+
paramsP,
|
|
13339
|
+
parent_infoP,
|
|
13340
|
+
jobNoP,
|
|
13341
|
+
keyP,
|
|
13342
|
+
parent_nodeP,
|
|
13343
|
+
new_key,
|
|
13344
|
+
$elm,
|
|
13345
|
+
{
|
|
13346
|
+
key: key,
|
|
13347
|
+
value: (await get_xuExp(new_key)) || val,
|
|
13348
|
+
},
|
|
13349
|
+
is_init,
|
|
13350
|
+
refreshed_ds,
|
|
13351
|
+
);
|
|
13352
|
+
|
|
13353
|
+
_ret = _.assignIn(_ret, ret);
|
|
13354
|
+
}
|
|
13355
|
+
|
|
13356
|
+
// EXP for
|
|
13357
|
+
|
|
13358
|
+
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
13359
|
+
if (_ret.abort) break;
|
|
13360
|
+
|
|
13361
|
+
const attr = key.split('xu-exp:')[1];
|
|
13362
|
+
|
|
13363
|
+
if (!attr) {
|
|
13364
|
+
continue;
|
|
13365
|
+
}
|
|
13366
|
+
|
|
13367
|
+
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
|
|
13368
|
+
|
|
13369
|
+
if (done_exp.includes(key)) {
|
|
13370
|
+
continue;
|
|
13371
|
+
}
|
|
13372
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
13373
|
+
SESSION_ID,
|
|
13374
|
+
is_skeleton,
|
|
13375
|
+
$root_container,
|
|
13376
|
+
nodeP,
|
|
13377
|
+
$container,
|
|
13378
|
+
paramsP,
|
|
13379
|
+
parent_infoP,
|
|
13380
|
+
jobNoP,
|
|
13381
|
+
keyP,
|
|
13382
|
+
parent_nodeP,
|
|
13383
|
+
'xu-exp',
|
|
13384
|
+
$elm,
|
|
13385
|
+
{
|
|
13386
|
+
key: attr,
|
|
13387
|
+
value: val,
|
|
13388
|
+
},
|
|
13389
|
+
true,
|
|
13390
|
+
refreshed_ds,
|
|
13391
|
+
);
|
|
13392
|
+
_ret = _.assignIn(_ret, ret);
|
|
13393
|
+
}
|
|
13394
|
+
|
|
13395
|
+
// AFTER
|
|
13396
|
+
|
|
13397
|
+
for await (const [key, attr] of Object.entries(glb.run_xu_after)) {
|
|
13398
|
+
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
|
|
13399
|
+
|
|
13400
|
+
if (!nodeP.attributes || !nodeP.attributes[attr] & !nodeP.attributes[`xu-exp:${attr}`]) continue;
|
|
13401
|
+
|
|
13402
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
13403
|
+
SESSION_ID,
|
|
13404
|
+
is_skeleton,
|
|
13405
|
+
$root_container,
|
|
13406
|
+
nodeP,
|
|
13407
|
+
$container,
|
|
13408
|
+
paramsP,
|
|
13409
|
+
parent_infoP,
|
|
13410
|
+
jobNoP,
|
|
13411
|
+
keyP,
|
|
13412
|
+
parent_nodeP,
|
|
13413
|
+
attr,
|
|
13414
|
+
$elm,
|
|
13415
|
+
{
|
|
13416
|
+
key: attr,
|
|
13417
|
+
value: (await get_xuExp(attr)) || nodeP.attributes[attr],
|
|
13418
|
+
},
|
|
13419
|
+
is_init,
|
|
13420
|
+
refreshed_ds,
|
|
13421
|
+
);
|
|
13422
|
+
_ret = _.assignIn(_ret, ret);
|
|
13423
|
+
}
|
|
13424
|
+
|
|
13425
|
+
// REGISTER EVENTS ATTRIBUTES
|
|
13426
|
+
|
|
13427
|
+
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
13428
|
+
if (!glb.html5_events_handler.includes(key)) break;
|
|
13429
|
+
$elm.attr(key, await get_xuExp(key)) || val;
|
|
13430
|
+
}
|
|
13431
|
+
|
|
13432
|
+
return _ret;
|
|
13433
|
+
};
|
|
13434
|
+
|
|
13435
|
+
func.UI.screen.panel_post_render_handler = async function (
|
|
13436
|
+
SESSION_ID,
|
|
13437
|
+
$container, // the parent program container
|
|
13438
|
+
$wrapper, // the wrapper element contains the rendered panel elements e.g: xu-single-view
|
|
13439
|
+
nodeP, // the xu-panel node
|
|
13440
|
+
$panel_div, // the panel div
|
|
13441
|
+
jobNoP,
|
|
13442
|
+
) {
|
|
13443
|
+
const _container_ds = SESSION_OBJ[SESSION_ID].DS_GLB[$container.data().xuData.paramsP.dsSessionP];
|
|
13444
|
+
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[$wrapper.data().xuData.paramsP.dsSessionP];
|
|
13445
|
+
const find_old_panels_elements = function () {
|
|
13446
|
+
return func.UI.utils.find_in_element_data('xuPanelData', $container.parent(), 'xu-ui-id', $container.data()?.xuPanelData?.xu_panel_xu_ui_id);
|
|
13447
|
+
};
|
|
13448
|
+
var $old_panel_div = find_old_panels_elements();
|
|
13449
|
+
const set_xuPanelData_to_the_new_rendered_items = () => {
|
|
13450
|
+
$container.data().xuPanelWrapper = { isWrapper: true, panelXuAttributes: _.clone($wrapper.data().xuAttributes), panelDivData: _.clone($wrapper.data()) };
|
|
13451
|
+
$container.attr('xu-panel-wrapper-id', $wrapper.attr('xu-ui-id'));
|
|
13452
|
+
$.each($wrapper.children(), function (key, val) {
|
|
13453
|
+
if (!$(val).data().xuPanelData) {
|
|
13454
|
+
$(val).data().xuPanelData = {};
|
|
13455
|
+
}
|
|
13456
|
+
$(val).data().xuPanelData.parent_element_ui_id = $old_panel_div?.length ? $container.parent().data().xuData.ui_id : $container.data().xuData.ui_id;
|
|
13457
|
+
|
|
13458
|
+
$(val).data().xuPanelData.xu_panel_xu_ui_id = (nodeP.xu_tree_id || nodeP.id) + '-' + _container_ds?.currentRecordId;
|
|
13459
|
+
$(val).data().xuPanelData.node = nodeP;
|
|
13460
|
+
$(val).data().xuPanelData.$panel_div = $panel_div.clone(true);
|
|
13461
|
+
});
|
|
13462
|
+
};
|
|
13463
|
+
set_xuPanelData_to_the_new_rendered_items();
|
|
13464
|
+
|
|
13465
|
+
if ($old_panel_div?.length) {
|
|
13466
|
+
$($old_panel_div[0]).after($wrapper.children());
|
|
13467
|
+
} else {
|
|
13468
|
+
$.each($wrapper.children(), function (key, child) {
|
|
13469
|
+
$.each($container.children(), function (key, elm) {
|
|
13470
|
+
if ($(elm)?.data()?.xuData && $(elm)?.data()?.xuData?.elem_key === $(child)?.data()?.xuData?.elem_key) {
|
|
13471
|
+
$(elm).remove();
|
|
13472
|
+
}
|
|
13473
|
+
});
|
|
13474
|
+
$container.append($(child));
|
|
13475
|
+
});
|
|
13476
|
+
}
|
|
13477
|
+
|
|
13478
|
+
if (!$wrapper.data()?.xuData?.dsSession) return;
|
|
13479
|
+
|
|
13480
|
+
if ($old_panel_div?.length) {
|
|
13481
|
+
$container.parent().data().xuData.paramsP.dsSessionP = _ds.parentDataSourceNo; // set the new ds when panel replaced
|
|
13482
|
+
} else {
|
|
13483
|
+
$container.data().xuData.paramsP.dsSessionP = _ds.parentDataSourceNo; // set the new ds when panel replaced
|
|
13484
|
+
}
|
|
13485
|
+
|
|
13486
|
+
if ($old_panel_div?.length) {
|
|
13487
|
+
$old_panel_div.remove();
|
|
13488
|
+
}
|
|
13489
|
+
return jobNoP;
|
|
13490
|
+
};
|
|
13491
|
+
|
|
13492
|
+
func.UI.screen.create_container = function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str) {
|
|
13493
|
+
const _paramsP = _.cloneDeep(paramsP);
|
|
13494
|
+
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
|
|
13495
|
+
var $appendTo = $container;
|
|
13496
|
+
if ($appendToP) $appendTo = $appendToP;
|
|
13497
|
+
if (!$appendTo || !$appendTo.length) return null; // screen closed or not exist abort build
|
|
13498
|
+
var div = 'div';
|
|
13499
|
+
if (div_typeP) div = div_typeP;
|
|
13500
|
+
var items = [];
|
|
13501
|
+
if (nodeP.children)
|
|
13502
|
+
items = nodeP.children.map(function (val) {
|
|
13503
|
+
return val.xu_tree_id || val.id;
|
|
13504
|
+
});
|
|
13505
|
+
var currentRecordId = _ds ? _ds.currentRecordId : '';
|
|
13506
|
+
var xu_id = (glb.screen_num++).toString();
|
|
13507
|
+
xu_id = xu_id += '_' + currentRecordId;
|
|
13508
|
+
|
|
13509
|
+
try {
|
|
13510
|
+
const key_path = `${$container?.data()?.xuData?.key_path || '0'}-${keyP || '0'}`;
|
|
13511
|
+
const elem_key = `${nodeP.xu_tree_id || nodeP.id}-${key_path}-${currentRecordId}`;
|
|
13512
|
+
let ui_id = `${nodeP.id}-${elem_key}-${_paramsP?.dsSessionP?.toString() || ''}`; //nodeP.xu_tree_id ||
|
|
13513
|
+
|
|
13514
|
+
/////////////////////////////////
|
|
13515
|
+
|
|
13516
|
+
var $div;
|
|
13517
|
+
if (div === 'svg') {
|
|
13518
|
+
const draw_svg = function (element) {
|
|
13519
|
+
const get_tag_str = function (element, prop, val) {
|
|
13520
|
+
let class_str = '';
|
|
13521
|
+
let attr_str = '';
|
|
13522
|
+
for (const [key, val] of Object.entries(prop)) {
|
|
13523
|
+
if (key.substr(0, 2) !== 'xu') {
|
|
13524
|
+
attr_str += ` ${key}="${val}" `;
|
|
13525
|
+
}
|
|
13526
|
+
}
|
|
13527
|
+
if (element === 'svg') {
|
|
13528
|
+
return `<${element} ${attr_str} > `;
|
|
13529
|
+
}
|
|
13530
|
+
let ret = '';
|
|
13531
|
+
if (val?.children?.length) {
|
|
13532
|
+
ret = iterate_svg(val);
|
|
13533
|
+
}
|
|
13534
|
+
|
|
13535
|
+
return `<${element} ${class_str} ${attr_str} > ${ret} </${element}>`;
|
|
13536
|
+
};
|
|
13537
|
+
let svg_str = get_tag_str(element, prop);
|
|
13538
|
+
let inner_str = '';
|
|
13539
|
+
const iterate_svg = function (node) {
|
|
13540
|
+
let ret = '';
|
|
13541
|
+
if (node.children) {
|
|
13542
|
+
for (let val of node.children) {
|
|
13543
|
+
let prop = val.attributes;
|
|
13544
|
+
ret += get_tag_str(val.tagName, prop, val);
|
|
13545
|
+
}
|
|
13546
|
+
}
|
|
13547
|
+
return ret;
|
|
13548
|
+
};
|
|
13549
|
+
inner_str = iterate_svg(nodeP);
|
|
13550
|
+
|
|
13551
|
+
$div = $(svg_str + inner_str + '</svg>').appendTo($appendTo);
|
|
13552
|
+
};
|
|
13553
|
+
|
|
13554
|
+
draw_svg(div_typeP);
|
|
13555
|
+
} else {
|
|
13556
|
+
$div = $(`<${div} ${attr_str ? attr_str : ''}>`);
|
|
13557
|
+
}
|
|
13558
|
+
// const svgNS = "http://www.w3.org/2000/svg";
|
|
13559
|
+
// // $div = $(document.createElementNS(svgNS, "svg"));
|
|
13560
|
+
// $div = $(`<${div} ${attr_str ? attr_str : ""} ${svg_attributes_str}>`);
|
|
13561
|
+
// } else {
|
|
13562
|
+
// $div = $(`<${div} ${attr_str ? attr_str : ""}>`);
|
|
13563
|
+
$div.attr('xu-ui-id', ui_id).data({
|
|
13564
|
+
xuData: {
|
|
13565
|
+
prog_id: _paramsP.prog_id,
|
|
13566
|
+
nodeid: nodeP.id,
|
|
13567
|
+
ui_type: nodeP.tagName,
|
|
13568
|
+
xu_id,
|
|
13569
|
+
recordid: currentRecordId,
|
|
13570
|
+
paramsP: _paramsP,
|
|
13571
|
+
key: keyP,
|
|
13572
|
+
key_path, //:($container?.data()?.xuData?.key || "0") + "-" + (keyP || "0"),
|
|
13573
|
+
screenId: _paramsP.screenId,
|
|
13574
|
+
parent_container: $container?.attr('id'),
|
|
13575
|
+
elem_key,
|
|
13576
|
+
properties: prop,
|
|
13577
|
+
node: nodeP,
|
|
13578
|
+
node_org: _.cloneDeep(nodeP),
|
|
13579
|
+
is_panelP: _paramsP.is_panelP,
|
|
13580
|
+
ui_id,
|
|
13581
|
+
elem_prop: elem_propP,
|
|
13582
|
+
debug_info: {
|
|
13583
|
+
id: nodeP.id,
|
|
13584
|
+
parent_id: $container?.data()?.xuData?.ui_id,
|
|
13585
|
+
items: items,
|
|
13586
|
+
},
|
|
13587
|
+
parent_node: parent_nodeP,
|
|
13588
|
+
currentRecordId: currentRecordId,
|
|
13589
|
+
$root_container: $root_container,
|
|
13590
|
+
parent_element_ui_id: $container?.data()?.xuData?.ui_id,
|
|
13591
|
+
},
|
|
13592
|
+
xuAttributes: {},
|
|
13593
|
+
});
|
|
13594
|
+
|
|
13595
|
+
if (div_typeP !== 'svg') {
|
|
13596
|
+
$div.appendTo($appendTo);
|
|
13597
|
+
}
|
|
13598
|
+
} catch (e) {
|
|
13599
|
+
console.error(e);
|
|
13600
|
+
}
|
|
13601
|
+
|
|
13602
|
+
if (parent_infoP?.iterate_info) {
|
|
13603
|
+
$div.data().xuData.iterate_info = parent_infoP.iterate_info;
|
|
13604
|
+
}
|
|
13605
|
+
|
|
13606
|
+
if (classP) $div.addClass(classP);
|
|
13607
|
+
|
|
13608
|
+
return $div;
|
|
13609
|
+
};
|
|
13610
|
+
func.UI.screen.execute_screen_ready_events = async function (SESSION_ID, paramsP, sourceP, $div, jobNoP, $div_objP) {
|
|
13611
|
+
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
13612
|
+
if (!_ds) return;
|
|
13613
|
+
var viewEventExec_arr = [];
|
|
13614
|
+
const execute_view_events = async function (sourceP) {
|
|
13615
|
+
for await (const val of viewEventExec_arr) {
|
|
13616
|
+
cond = val.eventInfo.data.enabled;
|
|
13617
|
+
if (val.expression) {
|
|
13618
|
+
expCond = await func.expression.get(SESSION_ID, val.expression, paramsP.dsSessionP, 'condition', paramsP.rowIdP); // execute expression
|
|
13619
|
+
cond = expCond.result;
|
|
13620
|
+
}
|
|
13621
|
+
if (cond) {
|
|
13622
|
+
await func.events.execute(
|
|
13623
|
+
SESSION_ID,
|
|
13624
|
+
null,
|
|
13625
|
+
val.eventId,
|
|
13626
|
+
val.triggerId,
|
|
13627
|
+
val.eventInfo.data.action,
|
|
13628
|
+
val.eventInfo.data.name,
|
|
13629
|
+
null,
|
|
13630
|
+
null,
|
|
13631
|
+
null,
|
|
13632
|
+
null,
|
|
13633
|
+
val.eventInfo.data.action, //val.eventInfo[4]
|
|
13634
|
+
null,
|
|
13635
|
+
paramsP.dsSessionP,
|
|
13636
|
+
val.eventId,
|
|
13637
|
+
sourceP + ' event',
|
|
13638
|
+
true,
|
|
13639
|
+
null,
|
|
13640
|
+
null,
|
|
13641
|
+
paramsP.dsSessionP,
|
|
13642
|
+
null,
|
|
13643
|
+
null,
|
|
13644
|
+
val.eventInfo, // val.eventInfo[8],
|
|
13645
|
+
null,
|
|
13646
|
+
null,
|
|
13647
|
+
null,
|
|
13648
|
+
_ds.prog_id,
|
|
13649
|
+
_ds.nodeId,
|
|
13650
|
+
_ds.parentDataSourceNo,
|
|
13651
|
+
$div,
|
|
13652
|
+
);
|
|
13653
|
+
|
|
13654
|
+
// update changed values to screen added 18/09/13
|
|
13655
|
+
var fields_to_refresh = [];
|
|
13656
|
+
try {
|
|
13657
|
+
var current_record_id = _ds.currentRecordId;
|
|
13658
|
+
} catch (e) {
|
|
13659
|
+
console.error(e);
|
|
13660
|
+
}
|
|
13661
|
+
|
|
13662
|
+
if (_ds?.data_feed?.form_fields_changed?.[current_record_id]) {
|
|
13663
|
+
$.each(_ds.data_feed.form_fields_changed[current_record_id], function (key, val) {
|
|
13664
|
+
fields_to_refresh.push(key);
|
|
13665
|
+
});
|
|
13666
|
+
|
|
13667
|
+
var containerId = _ds.containerId;
|
|
13668
|
+
var $container = $('#' + containerId);
|
|
13669
|
+
if ($container?.data()?.xuData?.is_mobile_modal || $container?.data()?.xuData?.params?.is_mobile_page) {
|
|
13670
|
+
await func.UI.screen.refresh_container(SESSION_ID, 'init', fields_to_refresh, $container, paramsP.dsSessionP, null);
|
|
13671
|
+
} else {
|
|
13672
|
+
$container.trigger(containerId + '.refresh', ['init', fields_to_refresh]);
|
|
13673
|
+
}
|
|
13674
|
+
|
|
13675
|
+
if ($div_objP) {
|
|
13676
|
+
await func.UI.screen.refresh_container(SESSION_ID, 'init', fields_to_refresh, $div_objP, paramsP.dsSessionP, null);
|
|
13677
|
+
}
|
|
13678
|
+
}
|
|
13679
|
+
}
|
|
13680
|
+
continue;
|
|
13681
|
+
}
|
|
13682
|
+
};
|
|
13683
|
+
const get_view_events_count = async function (typeP) {
|
|
13684
|
+
const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
13685
|
+
viewEventExec_arr = [];
|
|
13686
|
+
|
|
13687
|
+
if (!_prog.progEvents || _.isEmpty(_prog.progEvents)) {
|
|
13688
|
+
return 0;
|
|
13689
|
+
}
|
|
13690
|
+
for await (const event_obj of _prog.progEvents) {
|
|
13691
|
+
if (event_obj.data.type !== typeP) continue;
|
|
13692
|
+
|
|
13693
|
+
if (_.isEmpty(event_obj.triggers)) continue;
|
|
13694
|
+
|
|
13695
|
+
if (event_obj.data.condition) {
|
|
13696
|
+
let res = await func.expression.get(SESSION_ID, event_obj.data.condition, paramsP.dsSessionP, 'condition', paramsP.rowIdP, null, null, null, null, event_obj);
|
|
13697
|
+
if (!res.result) {
|
|
13698
|
+
continue;
|
|
13699
|
+
}
|
|
13700
|
+
}
|
|
13701
|
+
|
|
13702
|
+
for await (const trigger_obj of event_obj.triggers) {
|
|
13703
|
+
var expression = undefined;
|
|
13704
|
+
var cond = undefined;
|
|
13705
|
+
if (!trigger_obj.data.enabled) {
|
|
13706
|
+
continue;
|
|
13707
|
+
}
|
|
13708
|
+
cond = true;
|
|
13709
|
+
if (trigger_obj.props.condition) expression = trigger_obj.props.condition;
|
|
13710
|
+
var expCond = {};
|
|
13711
|
+
if (expression) {
|
|
13712
|
+
expCond = await func.expression.get(SESSION_ID, expression, paramsP.dsSessionP, 'condition', paramsP.rowIdP, trigger_obj.data.type); // execute expression
|
|
13713
|
+
cond = expCond.result;
|
|
13714
|
+
expCond.conditional = true;
|
|
13715
|
+
}
|
|
13716
|
+
|
|
13717
|
+
if (!trigger_obj.data.action) {
|
|
13718
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.viewSourceDesc} reason: missing action`, 'E');
|
|
13719
|
+
break;
|
|
13720
|
+
}
|
|
13721
|
+
if (!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) && !trigger_obj.data.name?.prog) {
|
|
13722
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.viewSourceDesc} reason: missing reference`, 'E');
|
|
13723
|
+
break;
|
|
13724
|
+
}
|
|
13725
|
+
|
|
13726
|
+
viewEventExec_arr.push({
|
|
13727
|
+
eventInfo: trigger_obj,
|
|
13728
|
+
eventId: event_obj.id,
|
|
13729
|
+
triggerId: trigger_obj.id,
|
|
13730
|
+
expression: expression,
|
|
13731
|
+
});
|
|
13732
|
+
}
|
|
13733
|
+
}
|
|
13734
|
+
return viewEventExec_arr.length;
|
|
13735
|
+
};
|
|
13736
|
+
|
|
13737
|
+
let count = await get_view_events_count('screen_ready');
|
|
13738
|
+
if (!count) return;
|
|
13739
|
+
return await execute_view_events(sourceP);
|
|
13740
|
+
};
|
|
13741
|
+
func.UI.screen.screen_loading_done = async function (SESSION_ID, paramsP, $div, jobNoP) {
|
|
13742
|
+
// await
|
|
13743
|
+
func.UI.screen.execute_screen_ready_events(SESSION_ID, paramsP, paramsP.screenInfo.properties?.renderType, $div, jobNoP);
|
|
13744
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
13745
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
13746
|
+
func.UI.utils.screen_blocker(false, paramsP.prog_id + (paramsP.sourceScreenP ? '_' + paramsP.sourceScreenP : ''));
|
|
13747
|
+
if (_session.prog_id === paramsP.prog_id) {
|
|
13748
|
+
_session.system_ready = true;
|
|
13749
|
+
if (_session.engine_mode === 'live_preview' && STUDIO_PEER_CONN_SEND_METHOD) {
|
|
13750
|
+
STUDIO_PEER_CONN_SEND_METHOD({
|
|
13751
|
+
service: 'system_ready',
|
|
13752
|
+
data: {},
|
|
13753
|
+
id: STUDIO_PEER.id,
|
|
13754
|
+
source: 'runtime',
|
|
13755
|
+
session_id: SESSION_ID,
|
|
13756
|
+
app_id: _session.app_id,
|
|
13757
|
+
gtp_token: _session.gtp_token,
|
|
13758
|
+
app_token: _session.app_token,
|
|
13759
|
+
});
|
|
13760
|
+
// }
|
|
13761
|
+
}
|
|
13762
|
+
}
|
|
13763
|
+
|
|
13764
|
+
return $div;
|
|
13765
|
+
};
|
|
13766
|
+
|
|
13767
|
+
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) {
|
|
13768
|
+
if (!is_skeleton) {
|
|
13769
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
13770
|
+
var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
13771
|
+
}
|
|
13772
|
+
var prop;
|
|
13773
|
+
try {
|
|
13774
|
+
prop = nodeP.attributes;
|
|
13775
|
+
} catch (error) {
|
|
13776
|
+
// debugger;
|
|
13777
|
+
}
|
|
13778
|
+
|
|
13779
|
+
var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
|
|
13780
|
+
|
|
13781
|
+
var get_element_info = function () {
|
|
13782
|
+
var ret = {};
|
|
13783
|
+
let currentRecordId = _ds?.currentRecordId || '';
|
|
13784
|
+
|
|
13785
|
+
let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
|
|
13786
|
+
|
|
13787
|
+
$.each($div, function (key, val) {
|
|
13788
|
+
if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
|
|
13789
|
+
ret = {
|
|
13790
|
+
div: $div,
|
|
13791
|
+
};
|
|
13792
|
+
}
|
|
13793
|
+
});
|
|
13794
|
+
|
|
13795
|
+
return ret;
|
|
13796
|
+
};
|
|
13797
|
+
|
|
13798
|
+
const init = async function () {
|
|
13799
|
+
var ret = true;
|
|
13800
|
+
if (!nodeP) ret = false;
|
|
13801
|
+
return ret;
|
|
13802
|
+
};
|
|
13803
|
+
const debug = function (is_errorP, error_descP) {
|
|
13804
|
+
func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
|
|
13805
|
+
module: 'gui',
|
|
13806
|
+
action: 'init',
|
|
13807
|
+
prop: nodeP.id,
|
|
13808
|
+
details: error_descP,
|
|
13809
|
+
result: null,
|
|
13810
|
+
error: is_errorP,
|
|
13811
|
+
source: _ds?.tree_obj?.menuName || '',
|
|
13812
|
+
fields: null,
|
|
13813
|
+
type: null,
|
|
13814
|
+
prog_id: paramsP.prog_id,
|
|
13815
|
+
dsSession: null,
|
|
13816
|
+
});
|
|
13817
|
+
};
|
|
13818
|
+
|
|
13819
|
+
const open_modal = async function ($div) {
|
|
13820
|
+
const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
|
|
13821
|
+
var xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
13822
|
+
if (!xu_modal_controller) {
|
|
13823
|
+
func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
|
|
13824
|
+
xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
13825
|
+
}
|
|
13826
|
+
|
|
13827
|
+
var controller_params = $(xu_modal_controller).data('xuControllerParams');
|
|
13828
|
+
|
|
13829
|
+
if (!controller_params) {
|
|
13830
|
+
controller_params = {};
|
|
13831
|
+
}
|
|
13832
|
+
|
|
13833
|
+
var params = {
|
|
13834
|
+
menuTitle: paramsP.screenInfo.properties?.menuTitle,
|
|
13835
|
+
screenId: paramsP.screenId,
|
|
13836
|
+
$dialogDiv: $div.children(),
|
|
13837
|
+
$container: $container,
|
|
13838
|
+
dsSession: paramsP.dsSessionP,
|
|
13839
|
+
};
|
|
13840
|
+
|
|
13841
|
+
controller_params[modal_id] = params;
|
|
13842
|
+
|
|
13843
|
+
$(xu_modal_controller).data('xuControllerParams', controller_params);
|
|
13844
|
+
const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
|
|
13845
|
+
|
|
13846
|
+
if (!APP_MODAL_OBJ[modal_id]) {
|
|
13847
|
+
const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
|
|
13848
|
+
APP_MODAL_OBJ[modal_id] = modal;
|
|
13849
|
+
} else {
|
|
13850
|
+
$(modal_id).empty();
|
|
13851
|
+
}
|
|
13852
|
+
await modalController.init(SESSION_ID, modal_id);
|
|
13853
|
+
|
|
13854
|
+
return $div;
|
|
13855
|
+
};
|
|
13856
|
+
|
|
13857
|
+
const close_modal = async function (modal_id) {
|
|
13858
|
+
delete APP_MODAL_OBJ[modal_id];
|
|
13859
|
+
const xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
13860
|
+
var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
|
|
13861
|
+
if (params && params.$container) {
|
|
13862
|
+
await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
|
|
13863
|
+
func.datasource.clean_all(SESSION_ID, params.dsSession);
|
|
13864
|
+
}
|
|
13865
|
+
};
|
|
13866
|
+
|
|
13867
|
+
const close_all_modals = function () {
|
|
13868
|
+
$.each(APP_MODAL_OBJ, function (key, val) {
|
|
13869
|
+
if (val) {
|
|
13870
|
+
// close_modal(key);
|
|
13871
|
+
UI_FRAMEWORK_PLUGIN.modal.close(key);
|
|
13872
|
+
}
|
|
13873
|
+
});
|
|
13874
|
+
};
|
|
13875
|
+
|
|
13876
|
+
const open_popover = async function ($div) {
|
|
13877
|
+
const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
|
|
13878
|
+
|
|
13879
|
+
$(xu_popover_controller).data('xuControllerParams', {
|
|
13880
|
+
menuTitle: paramsP.screenInfo.properties?.menuTitle,
|
|
13881
|
+
screenId: paramsP.screenId,
|
|
13882
|
+
$dialogDiv: $div.children(),
|
|
13883
|
+
$container: $container,
|
|
13884
|
+
});
|
|
13885
|
+
const popover = new UI_FRAMEWORK_PLUGIN.popover(
|
|
13886
|
+
SESSION_ID,
|
|
13887
|
+
// ELEMENT_CLICK_EVENT,
|
|
13888
|
+
// props
|
|
13889
|
+
);
|
|
13890
|
+
await popover.open(SESSION_ID);
|
|
13891
|
+
CURRENT_APP_POPOVER = popover;
|
|
13892
|
+
|
|
13893
|
+
return;
|
|
13894
|
+
popoverController
|
|
13895
|
+
.create({
|
|
13896
|
+
component: 'xu-popover-content-' + SESSION_ID,
|
|
13897
|
+
event: ELEMENT_CLICK_EVENT,
|
|
13898
|
+
translucent: true,
|
|
13899
|
+
})
|
|
13900
|
+
.then((modal) => {
|
|
13901
|
+
modal.present().then(() => {
|
|
13902
|
+
CURRENT_APP_POPOVER = modal;
|
|
13903
|
+
|
|
13904
|
+
if (callbackP) callbackP($div);
|
|
13905
|
+
});
|
|
13906
|
+
});
|
|
13907
|
+
};
|
|
13908
|
+
const iterate_child = async function ($divP, nodeP, parent_infoP, countP, $root_container, before_record_function) {
|
|
13909
|
+
if (!is_mobile && nodeP.busy) return;
|
|
13910
|
+
nodeP.busy = true;
|
|
13911
|
+
const done = async function ($divP) {
|
|
13912
|
+
setTimeout(function () {
|
|
13913
|
+
nodeP.busy = false;
|
|
13914
|
+
}, 1000);
|
|
13915
|
+
|
|
13916
|
+
return $divP;
|
|
13917
|
+
};
|
|
13918
|
+
if (!nodeP || !nodeP.children) {
|
|
13919
|
+
return await done($divP);
|
|
13920
|
+
}
|
|
13921
|
+
|
|
13922
|
+
if (before_record_function) {
|
|
13923
|
+
await before_record_function();
|
|
13924
|
+
}
|
|
13925
|
+
if (nodeP?.children?.length) {
|
|
13926
|
+
for await (const [key, val] of Object.entries(nodeP.children)) {
|
|
13927
|
+
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);
|
|
13928
|
+
}
|
|
13929
|
+
}
|
|
13930
|
+
return await done($divP);
|
|
13931
|
+
};
|
|
13932
|
+
|
|
13933
|
+
const _$ = function ($elm) {
|
|
13934
|
+
try {
|
|
13935
|
+
const id = $elm.attr('xu-ui-id');
|
|
13936
|
+
if (!id) return $elm;
|
|
13937
|
+
const $el = $(`[xu-ui-id="${id}"]`); // $("#" + id);
|
|
13938
|
+
|
|
13939
|
+
if ($el.length > 1) {
|
|
13940
|
+
console.warn('Multiple elements for xu-ui-id: ' + id, $el);
|
|
13941
|
+
}
|
|
13942
|
+
|
|
13943
|
+
return $($el[0]);
|
|
13944
|
+
} catch (e) {
|
|
13945
|
+
console.error(e);
|
|
13946
|
+
}
|
|
13947
|
+
};
|
|
13948
|
+
|
|
13949
|
+
const hover_in = function ($div) {
|
|
13950
|
+
if (is_skeleton) return;
|
|
13951
|
+
CLIENT_ACTIVITY_TS = Date.now();
|
|
13952
|
+
if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
|
|
13953
|
+
if (!_ds) return;
|
|
13954
|
+
///////// SET Attributes///////////
|
|
13955
|
+
let attributes = {};
|
|
13956
|
+
$.each($div[0].attributes, function (index, attr) {
|
|
13957
|
+
attributes[attr.name] = attr.value;
|
|
13958
|
+
});
|
|
13959
|
+
|
|
13960
|
+
SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
|
|
13961
|
+
//////////////////////////////////
|
|
13962
|
+
if (!$div.data()?.xuData) return;
|
|
13963
|
+
const _iterate_info = $div.data().xuData.iterate_info;
|
|
13964
|
+
if (_iterate_info) {
|
|
13965
|
+
if (_iterate_info.is_key_dynamic_field) {
|
|
13966
|
+
_ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
|
|
13967
|
+
} else {
|
|
13968
|
+
try {
|
|
13969
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
13970
|
+
_ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
|
|
13971
|
+
} catch (err) {
|
|
13972
|
+
console.error(err);
|
|
13973
|
+
}
|
|
13974
|
+
}
|
|
13975
|
+
|
|
13976
|
+
if (_iterate_info.is_val_dynamic_field) {
|
|
13977
|
+
_ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
|
|
13978
|
+
} else {
|
|
13979
|
+
try {
|
|
13980
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
13981
|
+
_ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
|
|
13982
|
+
} catch (err) {
|
|
13983
|
+
console.error(err);
|
|
13984
|
+
}
|
|
13985
|
+
}
|
|
13986
|
+
}
|
|
13987
|
+
|
|
13988
|
+
if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
|
|
13989
|
+
func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
|
|
13990
|
+
}
|
|
13991
|
+
|
|
13992
|
+
const set_value = function (field_id, value) {
|
|
13993
|
+
var currentRecordId = _$($div).data().xuData.currentRecordId;
|
|
13994
|
+
|
|
13995
|
+
func.UI.worker.add_to_queue(
|
|
13996
|
+
SESSION_ID,
|
|
13997
|
+
'gui event',
|
|
13998
|
+
'update_datasource',
|
|
13999
|
+
{
|
|
14000
|
+
currentRecordId,
|
|
14001
|
+
field_id,
|
|
14002
|
+
field_value: value,
|
|
14003
|
+
},
|
|
14004
|
+
null,
|
|
14005
|
+
null,
|
|
14006
|
+
paramsP.dsSessionP,
|
|
14007
|
+
);
|
|
14008
|
+
};
|
|
14009
|
+
|
|
14010
|
+
if ($div?.data()?.iterate_info) {
|
|
14011
|
+
var data = $div.data().xuData.iterate_info;
|
|
14012
|
+
if (data.iterator_key) {
|
|
14013
|
+
set_value(data.iterator_key, data._key);
|
|
14014
|
+
}
|
|
14015
|
+
if (data.iterator_val) {
|
|
14016
|
+
set_value(data.iterator_val, data._val);
|
|
14017
|
+
}
|
|
14018
|
+
}
|
|
14019
|
+
};
|
|
14020
|
+
const hover_out = function () {
|
|
14021
|
+
if (is_skeleton) return;
|
|
14022
|
+
|
|
14023
|
+
CLIENT_ACTIVITY_TS = Date.now();
|
|
14024
|
+
if (_$($container)?.data()?.xuData?.debug_info) {
|
|
14025
|
+
_$($container).data().xuData.debug_info.hover_item = null;
|
|
14026
|
+
}
|
|
14027
|
+
if (_ds?.data_system) {
|
|
14028
|
+
SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
|
|
14029
|
+
}
|
|
14030
|
+
};
|
|
14031
|
+
const render_screen_type = async function ($div) {
|
|
14032
|
+
const set_call_screen_properties_values = async function (ui_framework) {
|
|
14033
|
+
params.properties = {};
|
|
14034
|
+
const get_values = async function (property) {
|
|
14035
|
+
var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
|
|
14036
|
+
if (paramsP?.call_screen_propertiesP) {
|
|
14037
|
+
if (paramsP.call_screen_propertiesP?.[property]) {
|
|
14038
|
+
property_value = paramsP.call_screen_propertiesP[property];
|
|
14039
|
+
}
|
|
14040
|
+
if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
|
|
14041
|
+
property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
|
|
14042
|
+
}
|
|
14043
|
+
}
|
|
14044
|
+
return property_value;
|
|
14045
|
+
};
|
|
14046
|
+
params.properties['name'] = await get_values('menuTitle');
|
|
14047
|
+
if (await ui_framework?.properties()) {
|
|
14048
|
+
for await (const [key, val] of Object.entries(await ui_framework.properties())) {
|
|
14049
|
+
params.properties[key] = await get_values(key);
|
|
14050
|
+
}
|
|
14051
|
+
}
|
|
14052
|
+
};
|
|
14053
|
+
|
|
14054
|
+
var $div_content = $div.children();
|
|
14055
|
+
|
|
14056
|
+
$.each($div_content, function (key, val) {
|
|
14057
|
+
if (!$(val)?.data()?.xuData?.parent_container) {
|
|
14058
|
+
return true;
|
|
14059
|
+
}
|
|
14060
|
+
$(val).data().xuData.parent_container = $div.data().xuData.parent_container;
|
|
14061
|
+
});
|
|
14062
|
+
|
|
14063
|
+
let $ret = $div;
|
|
14064
|
+
var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
|
|
14065
|
+
var params;
|
|
14066
|
+
switch (paramsP.screen_type) {
|
|
14067
|
+
case 'modal':
|
|
14068
|
+
const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
|
|
14069
|
+
var xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
14070
|
+
if (!xu_modal_controller) {
|
|
14071
|
+
func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
|
|
14072
|
+
xu_modal_controller = document.querySelector('xu-modal-controller');
|
|
14073
|
+
}
|
|
14074
|
+
|
|
14075
|
+
var controller_params = $(xu_modal_controller).data('xuControllerParams');
|
|
14076
|
+
|
|
14077
|
+
if (!controller_params) {
|
|
14078
|
+
controller_params = {};
|
|
14079
|
+
}
|
|
14080
|
+
|
|
14081
|
+
params = {
|
|
14082
|
+
screenId: paramsP.screenId,
|
|
14083
|
+
$dialogDiv: $div.children(),
|
|
14084
|
+
$container: $container,
|
|
14085
|
+
dsSession: paramsP.dsSessionP,
|
|
14086
|
+
modal_id,
|
|
14087
|
+
screenInfo: paramsP.screenInfo,
|
|
14088
|
+
close_callback: close_modal,
|
|
14089
|
+
paramsP,
|
|
14090
|
+
};
|
|
14091
|
+
|
|
14092
|
+
controller_params[modal_id] = params;
|
|
14093
|
+
|
|
14094
|
+
$(xu_modal_controller).data('xuControllerParams', controller_params);
|
|
14095
|
+
const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
|
|
14096
|
+
await set_call_screen_properties_values(modalController);
|
|
14097
|
+
if (!APP_MODAL_OBJ[modal_id]) {
|
|
14098
|
+
const modal = await modalController.create(params);
|
|
14099
|
+
|
|
14100
|
+
APP_MODAL_OBJ[modal_id] = modal;
|
|
14101
|
+
} else {
|
|
14102
|
+
$(modal_id).empty();
|
|
14103
|
+
}
|
|
14104
|
+
|
|
14105
|
+
await modalController.init(params);
|
|
14106
|
+
|
|
14107
|
+
break;
|
|
14108
|
+
|
|
14109
|
+
case 'popover':
|
|
14110
|
+
// open_popover($div);
|
|
14111
|
+
|
|
14112
|
+
const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
|
|
14113
|
+
params = {
|
|
14114
|
+
menuTitle: paramsP.screenInfo.properties?.menuTitle,
|
|
14115
|
+
screenId: paramsP.screenId,
|
|
14116
|
+
$dialogDiv: $div.children(),
|
|
14117
|
+
$container: $container,
|
|
14118
|
+
};
|
|
14119
|
+
|
|
14120
|
+
$(xu_popover_controller).data('xuControllerParams', params);
|
|
14121
|
+
const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
|
|
14122
|
+
await set_call_screen_properties_values(popover);
|
|
14123
|
+
await popover.open(params);
|
|
14124
|
+
CURRENT_APP_POPOVER = popover;
|
|
14125
|
+
|
|
14126
|
+
func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
|
|
14127
|
+
break;
|
|
14128
|
+
|
|
14129
|
+
case 'page':
|
|
14130
|
+
const nav = $nav[0];
|
|
14131
|
+
|
|
14132
|
+
params = {
|
|
14133
|
+
div: $div_content,
|
|
14134
|
+
name: paramsP.screenInfo.properties?.menuTitle,
|
|
14135
|
+
screenId: paramsP.screenId,
|
|
14136
|
+
$container: $container,
|
|
14137
|
+
dsSession: paramsP.dsSessionP,
|
|
14138
|
+
SESSION_ID,
|
|
14139
|
+
nav,
|
|
14140
|
+
paramsP,
|
|
14141
|
+
};
|
|
14142
|
+
|
|
14143
|
+
var component_name = 'xu-page-component-' + paramsP.dsSessionP;
|
|
14144
|
+
if (!$(nav).data().xuData.nav_params) {
|
|
14145
|
+
$(nav).data().xuData.nav_params = {};
|
|
14146
|
+
}
|
|
14147
|
+
|
|
14148
|
+
//restore validate
|
|
14149
|
+
if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
|
|
14150
|
+
params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
|
|
14151
|
+
}
|
|
14152
|
+
|
|
14153
|
+
if (!$(nav)?.data()?.xuData) return;
|
|
14154
|
+
$(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
|
|
14155
|
+
if (!$(component_name).length) {
|
|
14156
|
+
await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
|
|
14157
|
+
const page = new UI_FRAMEWORK_PLUGIN.page();
|
|
14158
|
+
await set_call_screen_properties_values(page);
|
|
14159
|
+
await page.create(params);
|
|
14160
|
+
await page.init(params);
|
|
14161
|
+
nav.push(component_name, { params });
|
|
14162
|
+
} else {
|
|
14163
|
+
debugger;
|
|
14164
|
+
$(component_name).empty();
|
|
14165
|
+
|
|
14166
|
+
await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
|
|
14167
|
+
}
|
|
14168
|
+
$div.data().xuData.paramsP = $container.data().xuData.paramsP;
|
|
14169
|
+
break;
|
|
14170
|
+
|
|
14171
|
+
case 'panel':
|
|
14172
|
+
$container.append($div_content);
|
|
14173
|
+
$ret = $container;
|
|
14174
|
+
break;
|
|
14175
|
+
|
|
14176
|
+
default: // set data to nav to use in the component
|
|
14177
|
+
if ($nav && $nav.length) {
|
|
14178
|
+
// refresh made
|
|
14179
|
+
} else {
|
|
14180
|
+
$nav = $('<xu-nav>');
|
|
14181
|
+
$container.append($nav);
|
|
14182
|
+
func.UI.component.init_xu_nav($container, $nav);
|
|
14183
|
+
}
|
|
14184
|
+
|
|
14185
|
+
$nav.data().xuData.$div = $div_content;
|
|
14186
|
+
|
|
14187
|
+
await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
|
|
14188
|
+
$ret = $container;
|
|
14189
|
+
break;
|
|
14190
|
+
}
|
|
14191
|
+
return $ret;
|
|
14192
|
+
};
|
|
14193
|
+
|
|
14194
|
+
if (!(await init())) return;
|
|
14195
|
+
debug();
|
|
14196
|
+
const fx = {
|
|
14197
|
+
widget: async function () {
|
|
14198
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
14199
|
+
|
|
14200
|
+
var exist_elm_obj = get_element_info();
|
|
14201
|
+
var $div = exist_elm_obj.div;
|
|
14202
|
+
if (!exist_elm_obj.div) {
|
|
14203
|
+
$div = 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);
|
|
14204
|
+
|
|
14205
|
+
//////////////////////////
|
|
14206
|
+
|
|
14207
|
+
let plugin_name = prop['xu-widget'],
|
|
14208
|
+
method = prop['xu-method'],
|
|
14209
|
+
dsP = paramsP.dsSessionP,
|
|
14210
|
+
propsP = prop,
|
|
14211
|
+
sourceP = 'widgets';
|
|
14212
|
+
|
|
14213
|
+
// const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
|
|
14214
|
+
// var obj = _.clone(docP);
|
|
14215
|
+
// obj.date = await func.utils.get_dateTime(
|
|
14216
|
+
// SESSION_ID,
|
|
14217
|
+
// "SYS_DATE",
|
|
14218
|
+
// docP.date
|
|
14219
|
+
// );
|
|
14220
|
+
// obj.time = await func.utils.get_dateTime(
|
|
14221
|
+
// SESSION_ID,
|
|
14222
|
+
// "SYS_TIME",
|
|
14223
|
+
// docP.date
|
|
14224
|
+
// );
|
|
14225
|
+
|
|
14226
|
+
// var datasource_changes = {
|
|
14227
|
+
// [0]: {
|
|
14228
|
+
// ["data_system"]: {
|
|
14229
|
+
// ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
|
|
14230
|
+
// },
|
|
14231
|
+
// },
|
|
14232
|
+
// };
|
|
14233
|
+
// await func.datasource.update(SESSION_ID, datasource_changes);
|
|
14234
|
+
// };
|
|
14235
|
+
const call_plugin_api = async function (plugin_nameP, dataP) {
|
|
14236
|
+
return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
|
|
14237
|
+
};
|
|
14238
|
+
const report_error = function (descP, warn) {
|
|
14239
|
+
func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
|
|
14240
|
+
module: 'widgets',
|
|
14241
|
+
action: 'Init',
|
|
14242
|
+
source: sourceP,
|
|
14243
|
+
prop: descP,
|
|
14244
|
+
details: descP,
|
|
14245
|
+
result: null,
|
|
14246
|
+
error: warn ? false : true,
|
|
14247
|
+
fields: null,
|
|
14248
|
+
type: 'widgets',
|
|
14249
|
+
prog_id: _session.DS_GLB[dsP].prog_id,
|
|
14250
|
+
});
|
|
14251
|
+
};
|
|
14252
|
+
const get_fields_data = async function (fields, props) {
|
|
14253
|
+
const report_error = function (descP, warn) {
|
|
14254
|
+
func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
|
|
14255
|
+
module: 'widgets',
|
|
14256
|
+
action: 'Init',
|
|
14257
|
+
source: sourceP,
|
|
14258
|
+
prop: descP,
|
|
14259
|
+
details: descP,
|
|
14260
|
+
result: null,
|
|
14261
|
+
error: warn ? false : true,
|
|
14262
|
+
fields: null,
|
|
14263
|
+
type: 'widgets',
|
|
14264
|
+
prog_id: _session.DS_GLB[dsP].prog_id,
|
|
14265
|
+
});
|
|
14266
|
+
};
|
|
14267
|
+
const get_property_value = async function (fieldIdP, val) {
|
|
14268
|
+
if (!val) return;
|
|
14269
|
+
var value = props[fieldIdP] || (typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue);
|
|
14270
|
+
if (val.render === 'eventId') {
|
|
14271
|
+
value = props?.[fieldIdP]?.event;
|
|
14272
|
+
}
|
|
14273
|
+
|
|
14274
|
+
if (props[`xu-exp:${fieldIdP}`]) {
|
|
14275
|
+
value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
|
|
14276
|
+
}
|
|
14277
|
+
|
|
14278
|
+
return func.common.get_cast_val(
|
|
14279
|
+
SESSION_ID,
|
|
14280
|
+
'widgets',
|
|
14281
|
+
fieldIdP,
|
|
14282
|
+
val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
|
|
14283
|
+
value,
|
|
14284
|
+
null,
|
|
14285
|
+
);
|
|
14286
|
+
};
|
|
14287
|
+
var data_obj = {};
|
|
14288
|
+
var return_code = 1;
|
|
14289
|
+
// $.each(fields, function (key, val) {
|
|
14290
|
+
for await (const [key, val] of Object.entries(fields)) {
|
|
14291
|
+
data_obj[key] = await get_property_value(key, val);
|
|
14292
|
+
if (!data_obj[key] && val.mandatory) {
|
|
14293
|
+
return_code = -1;
|
|
14294
|
+
report_error(`${key} is a mandatory field.`);
|
|
14295
|
+
break;
|
|
14296
|
+
}
|
|
14297
|
+
// console.log(val);
|
|
14298
|
+
}
|
|
14299
|
+
for await (const key of ['xu-bind']) {
|
|
14300
|
+
data_obj[key] = await get_property_value(key, props[key]);
|
|
14301
|
+
}
|
|
14302
|
+
|
|
14303
|
+
return { code: return_code, data: data_obj };
|
|
14304
|
+
};
|
|
14305
|
+
|
|
14306
|
+
const load_css_style = function () {
|
|
14307
|
+
let path = get_path('style.css');
|
|
14308
|
+
func.utils.load_css_on_demand(path);
|
|
14309
|
+
};
|
|
14310
|
+
|
|
14311
|
+
const get_path = function (resource) {
|
|
14312
|
+
if (_session.worker_type === 'Dev') {
|
|
14313
|
+
return `../../plugins/${plugin_name}/${resource}`;
|
|
14314
|
+
}
|
|
14315
|
+
return `https://${_session.domain}/plugins/${plugin_name}/${resource}?gtp_token=${_session.gtp_token}&app_id=${_session.app_id}`;
|
|
14316
|
+
};
|
|
14317
|
+
const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
|
|
14318
|
+
const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
|
|
14319
|
+
const methods = index.methods;
|
|
14320
|
+
if (methods && !methods[method]) {
|
|
14321
|
+
return report_error('method not found');
|
|
14322
|
+
}
|
|
14323
|
+
|
|
14324
|
+
const fields_ret = await get_fields_data(methods[method].fields, propsP);
|
|
14325
|
+
if (fields_ret.code < 0) {
|
|
14326
|
+
return report_error(fields_ret.data);
|
|
14327
|
+
}
|
|
14328
|
+
const fields = fields_ret.data;
|
|
14329
|
+
|
|
14330
|
+
let exclude_attributes = [];
|
|
14331
|
+
for await (const [key, val] of Object.entries(propsP)) {
|
|
14332
|
+
if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
|
|
14333
|
+
exclude_attributes.push(key);
|
|
14334
|
+
}
|
|
14335
|
+
}
|
|
14336
|
+
|
|
14337
|
+
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);
|
|
14338
|
+
|
|
14339
|
+
$div.addClass('widget_wrapper'); // class get override in set_attributes_new
|
|
14340
|
+
|
|
14341
|
+
if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
|
|
14342
|
+
return report_error(`plugin ${plugin_name} not found`);
|
|
14343
|
+
}
|
|
14344
|
+
|
|
14345
|
+
if (APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest['style.css'].exist) {
|
|
14346
|
+
load_css_style();
|
|
14347
|
+
}
|
|
14348
|
+
|
|
14349
|
+
const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
|
|
14350
|
+
if (plugin_setup_ret.code < 0) {
|
|
14351
|
+
return report_error(plugin_setup_ret);
|
|
14352
|
+
}
|
|
14353
|
+
|
|
14354
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
14355
|
+
func,
|
|
14356
|
+
glb,
|
|
14357
|
+
SESSION_OBJ,
|
|
14358
|
+
SESSION_ID,
|
|
14359
|
+
APP_OBJ,
|
|
14360
|
+
dsSession: paramsP.dsSessionP,
|
|
14361
|
+
job_id: jobNoP,
|
|
14362
|
+
});
|
|
14363
|
+
|
|
14364
|
+
const params = {
|
|
14365
|
+
SESSION_ID,
|
|
14366
|
+
method,
|
|
14367
|
+
_session,
|
|
14368
|
+
dsP,
|
|
14369
|
+
sourceP,
|
|
14370
|
+
propsP,
|
|
14371
|
+
plugin_name,
|
|
14372
|
+
$containerP: $div,
|
|
14373
|
+
plugin_setup: plugin_setup_ret.data,
|
|
14374
|
+
|
|
14375
|
+
report_error,
|
|
14376
|
+
call_plugin_api,
|
|
14377
|
+
// set_SYS_GLOBAL_OBJ_WIDGET_INFO,
|
|
14378
|
+
api_utils,
|
|
14379
|
+
};
|
|
14380
|
+
|
|
14381
|
+
const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
|
|
14382
|
+
|
|
14383
|
+
if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
|
|
14384
|
+
const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
|
|
14385
|
+
func.utils.load_css_on_demand(plugin_runtime_css_url);
|
|
14386
|
+
}
|
|
14387
|
+
|
|
14388
|
+
if (!fx[method]) {
|
|
14389
|
+
throw `Method: ${method} does not exist`;
|
|
14390
|
+
}
|
|
14391
|
+
try {
|
|
14392
|
+
await fx[method](fields, params);
|
|
14393
|
+
} catch (err) {
|
|
14394
|
+
func.utils.debug_report(SESSION_ID, `${plugin_name} widget`, err.message, 'E');
|
|
14395
|
+
}
|
|
14396
|
+
}
|
|
14397
|
+
return $div;
|
|
14398
|
+
},
|
|
14399
|
+
[`xu-single-view`]: async function () {
|
|
14400
|
+
var exist_elm_obj = get_element_info();
|
|
14401
|
+
var $div = exist_elm_obj.div;
|
|
14402
|
+
|
|
14403
|
+
if (!exist_elm_obj.div) {
|
|
14404
|
+
var $wrapper = $('<div>');
|
|
14405
|
+
$div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, 'div', $wrapper, '');
|
|
14406
|
+
|
|
14407
|
+
if (!$div) return;
|
|
14408
|
+
|
|
14409
|
+
if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
|
|
14410
|
+
close_all_modals();
|
|
14411
|
+
}
|
|
14412
|
+
|
|
14413
|
+
$div.hover(
|
|
14414
|
+
function (e) {
|
|
14415
|
+
hover_in();
|
|
14416
|
+
},
|
|
14417
|
+
function (e) {
|
|
14418
|
+
hover_out();
|
|
14419
|
+
},
|
|
14420
|
+
);
|
|
14421
|
+
}
|
|
14422
|
+
|
|
14423
|
+
const ret = await iterate_child($div, nodeP, null, null, $div);
|
|
14424
|
+
if (_.isEmpty($container.data().xuAttributes)) {
|
|
14425
|
+
await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
|
|
14426
|
+
}
|
|
14427
|
+
|
|
14428
|
+
$.each($div.data().xuData, function (key, val) {
|
|
14429
|
+
$container.data().xuData[key] = _.cloneDeep(val);
|
|
14430
|
+
});
|
|
14431
|
+
$.each($div.data().xuAttributes, function (key, val) {
|
|
14432
|
+
$container.data().xuAttributes[key] = _.cloneDeep(val);
|
|
14433
|
+
});
|
|
14434
|
+
|
|
14435
|
+
return await render_screen_type($div);
|
|
14436
|
+
},
|
|
14437
|
+
[`xu-multi-view`]: async function () {
|
|
14438
|
+
var $div = $container;
|
|
14439
|
+
|
|
14440
|
+
if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
|
|
14441
|
+
$div.data().xuData.node = nodeP;
|
|
14442
|
+
}
|
|
14443
|
+
|
|
14444
|
+
if (!$div.data().xuData.debug_info) {
|
|
14445
|
+
$div.data().xuData.debug_info = {
|
|
14446
|
+
id: nodeP.id,
|
|
14447
|
+
parent_id: $container.data().xuData.ui_id,
|
|
14448
|
+
};
|
|
14449
|
+
}
|
|
14450
|
+
|
|
14451
|
+
const done = async function (continuous_idx) {
|
|
14452
|
+
// const do_callback = async function ($div) {
|
|
14453
|
+
// // if ($root_container.data().xuData.progress_bar_circle) {
|
|
14454
|
+
// // setTimeout(function () {
|
|
14455
|
+
// // $.each(
|
|
14456
|
+
// // $root_container.data().xuData.progress_bar_circle,
|
|
14457
|
+
// // function (key, val) {
|
|
14458
|
+
// // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
|
|
14459
|
+
// // }
|
|
14460
|
+
// // );
|
|
14461
|
+
// // }, 2000);
|
|
14462
|
+
// // }
|
|
14463
|
+
|
|
14464
|
+
// if (paramsP.screenInfo.properties?.rtl) {
|
|
14465
|
+
// $div_content.attr('dir', 'rtl');
|
|
14466
|
+
// }
|
|
14467
|
+
|
|
14468
|
+
// return $div;
|
|
14469
|
+
// };
|
|
14470
|
+
await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
|
|
14471
|
+
|
|
14472
|
+
return await render_screen_type($div);
|
|
14473
|
+
};
|
|
14474
|
+
|
|
14475
|
+
if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
|
|
14476
|
+
close_all_modals();
|
|
14477
|
+
}
|
|
14478
|
+
|
|
14479
|
+
const empty_result = async function () {
|
|
14480
|
+
var content = prop.empty_result_content || '';
|
|
14481
|
+
|
|
14482
|
+
var res = await func.expression.get(
|
|
14483
|
+
SESSION_ID,
|
|
14484
|
+
content, // prop["xu-exp:empty_result_content"],
|
|
14485
|
+
paramsP.dsSessionP,
|
|
14486
|
+
'empty_result_content_EXP',
|
|
14487
|
+
_ds.currentRecordId,
|
|
14488
|
+
);
|
|
14489
|
+
content = res.result;
|
|
14490
|
+
// }
|
|
14491
|
+
|
|
14492
|
+
let empty_result_node = {
|
|
14493
|
+
type: 'element',
|
|
14494
|
+
id: crypto.randomUUID(),
|
|
14495
|
+
content,
|
|
14496
|
+
// : content || (typeof content === "undefined" && "Empty results"),
|
|
14497
|
+
tagName: 'div',
|
|
14498
|
+
attributes: {},
|
|
14499
|
+
children: [],
|
|
14500
|
+
};
|
|
14501
|
+
|
|
14502
|
+
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);
|
|
14503
|
+
await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
|
|
14504
|
+
return await done(null);
|
|
14505
|
+
};
|
|
14506
|
+
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
14507
|
+
|
|
14508
|
+
var continuous_idx = null;
|
|
14509
|
+
|
|
14510
|
+
if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
|
|
14511
|
+
return await empty_result();
|
|
14512
|
+
}
|
|
14513
|
+
|
|
14514
|
+
var i = 0;
|
|
14515
|
+
for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
|
|
14516
|
+
var node = JSON.parse(JSON.stringify(nodeP));
|
|
14517
|
+
|
|
14518
|
+
_ds.currentRecordId = val._ROWID;
|
|
14519
|
+
const ret = await iterate_child($div, node, { continuous_idx }, null, $root_container);
|
|
14520
|
+
|
|
14521
|
+
if (_.isEmpty($container.data().xuAttributes)) {
|
|
14522
|
+
await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
|
|
14523
|
+
}
|
|
14524
|
+
}
|
|
14525
|
+
|
|
14526
|
+
return await done(continuous_idx);
|
|
14527
|
+
},
|
|
14528
|
+
[`xu-panel`]: async function () {
|
|
14529
|
+
const done = async function ($new_div) {
|
|
14530
|
+
if (!$container.data()?.xuData?.paramsP) {
|
|
14531
|
+
return $container;
|
|
14532
|
+
}
|
|
14533
|
+
var $div_items = $div.data().xuData.node.children;
|
|
14534
|
+
|
|
14535
|
+
await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
|
|
14536
|
+
|
|
14537
|
+
// TO FIX should be timeout
|
|
14538
|
+
$container.data().xuData.node.children = $div_items;
|
|
14539
|
+
|
|
14540
|
+
return $container;
|
|
14541
|
+
};
|
|
14542
|
+
|
|
14543
|
+
var $wrapper = $('<div>');
|
|
14544
|
+
$div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, null, $wrapper, '');
|
|
14545
|
+
|
|
14546
|
+
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);
|
|
14547
|
+
if (ret.abort) {
|
|
14548
|
+
// // program null
|
|
14549
|
+
// if (ret.program_null) {
|
|
14550
|
+
// return render_screen_type($div);
|
|
14551
|
+
// }
|
|
14552
|
+
|
|
14553
|
+
// render N
|
|
14554
|
+
return (ret.$new_div = $('<template>').append($div));
|
|
14555
|
+
|
|
14556
|
+
// ret.$new_div = $("<template>").append($div);
|
|
14557
|
+
}
|
|
14558
|
+
let ret_done = await done(ret.$new_div);
|
|
14559
|
+
return ret_done;
|
|
14560
|
+
},
|
|
14561
|
+
};
|
|
14562
|
+
|
|
14563
|
+
const draw_html_element = async function (element) {
|
|
14564
|
+
const done = async function () {
|
|
14565
|
+
return $div;
|
|
14566
|
+
};
|
|
14567
|
+
if (!element || element === 'script') return await done();
|
|
14568
|
+
let str = '';
|
|
14569
|
+
|
|
14570
|
+
var $div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
|
|
14571
|
+
|
|
14572
|
+
$div.hover(
|
|
14573
|
+
function (e) {
|
|
14574
|
+
hover_in($div);
|
|
14575
|
+
},
|
|
14576
|
+
function (e) {
|
|
14577
|
+
hover_out();
|
|
14578
|
+
},
|
|
14579
|
+
);
|
|
14580
|
+
|
|
14581
|
+
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);
|
|
14582
|
+
if (ret.abort) return await done();
|
|
14583
|
+
// check if iterator made to prevent children render
|
|
14584
|
+
|
|
14585
|
+
const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
|
|
14586
|
+
return await done();
|
|
14587
|
+
};
|
|
14588
|
+
|
|
14589
|
+
if (nodeP.content && nodeP.attributes) {
|
|
14590
|
+
nodeP.attributes['xu-content'] = nodeP.content;
|
|
14591
|
+
}
|
|
14592
|
+
if (nodeP.tagName === 'xu-widget') {
|
|
14593
|
+
if (is_skeleton) return;
|
|
14594
|
+
return await fx['widget']();
|
|
14595
|
+
}
|
|
14596
|
+
if (fx[nodeP.tagName]) {
|
|
14597
|
+
return await fx[nodeP.tagName]();
|
|
14598
|
+
}
|
|
14599
|
+
|
|
14600
|
+
return await draw_html_element(nodeP.tagName);
|
|
14601
|
+
};
|
|
14602
|
+
|
|
14603
|
+
func.UI.screen.refresh_document_changes_for_realtime_update = async function (SESSION_ID, doc_change) {
|
|
14604
|
+
let _session = SESSION_OBJ[SESSION_ID];
|
|
14605
|
+
for (const [key, _ds] of Object.entries(_session.DS_GLB)) {
|
|
14606
|
+
let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
14607
|
+
if (prog_obj?.progDataSource?.dataSourceRealtime && prog_obj?.progDataSource?.dataSourceTableId === doc_change.table_id) {
|
|
14608
|
+
try {
|
|
14609
|
+
// disabled in purpose to support create row
|
|
14610
|
+
|
|
14611
|
+
// const row_idx = func.common.find_ROWID_idx(_ds, doc_change.row_id);
|
|
14612
|
+
|
|
14613
|
+
// console.log(
|
|
14614
|
+
// "refresh_document_changes_for_realtime_update",
|
|
14615
|
+
// _ds.data_feed.rows[row_idx]
|
|
14616
|
+
// );
|
|
14617
|
+
|
|
14618
|
+
if (!_ds.screen_params) continue;
|
|
14619
|
+
if (_ds.screen_params.is_panelP) {
|
|
14620
|
+
func.UI.screen.refresh_screen(SESSION_ID, null, key);
|
|
14621
|
+
} else {
|
|
14622
|
+
func.action.execute(SESSION_ID, 'act_refresh', _ds, null, null);
|
|
14623
|
+
}
|
|
14624
|
+
} catch (err) {
|
|
14625
|
+
// console.error(err);
|
|
14626
|
+
}
|
|
14627
|
+
}
|
|
14628
|
+
}
|
|
14629
|
+
};
|
|
14630
|
+
func.UI.component = {};
|
|
13216
14631
|
|
|
13217
14632
|
func.UI.component.create_app_modal_component = function (
|
|
13218
14633
|
SESSION_ID,
|