@xuda.io/runtime-bundle 1.0.1250 → 1.0.1252

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.
@@ -24676,27 +24676,40 @@ func.common.get_data_from_websocket = async function (SESSION_ID, serviceP, data
24676
24676
  });
24677
24677
  };
24678
24678
 
24679
- func.common.sha256 = async function (inputString) {
24680
- // 1. Create a hash buffer from the input string using SHA-256.
24681
- // This part remains the same as it provides a strong, unique cryptographic starting point.
24682
- const buffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(inputString));
24683
-
24684
- // 2. Interpret the first 8 bytes (64 bits) of the hash as one big number.
24685
- const view = new DataView(buffer);
24686
- const bigInt = view.getBigUint64(0, false); // `false` for big-endian
24687
-
24688
- // 3. Convert the BigInt to a Base36 string.
24689
- // The .toString(36) method handles the conversion to an alphanumeric representation (0-9, a-z).
24690
- const base36Hash = bigInt.toString(36);
24691
-
24692
- // 4. Take the first 10 characters. If it's shorter, it will just return the whole string.
24693
- // For a 64-bit integer, the Base36 representation will be about 13 characters long,
24694
- // so slicing is a reliable way to get a fixed length.
24695
- const shortHash = base36Hash.slice(0, 10);
24696
-
24697
- // 5. Pad the start in the unlikely case the hash is shorter than 10 characters.
24698
- // This ensures the output is always exactly 10 characters long.
24699
- return shortHash.padStart(10, '0');
24679
+ // func.common.sha256 = async function (inputString) {
24680
+ // // 1. Create a hash buffer from the input string using SHA-256.
24681
+ // // This part remains the same as it provides a strong, unique cryptographic starting point.
24682
+ // const buffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(inputString));
24683
+
24684
+ // // 2. Interpret the first 8 bytes (64 bits) of the hash as one big number.
24685
+ // const view = new DataView(buffer);
24686
+ // const bigInt = view.getBigUint64(0, false); // `false` for big-endian
24687
+
24688
+ // // 3. Convert the BigInt to a Base36 string.
24689
+ // // The .toString(36) method handles the conversion to an alphanumeric representation (0-9, a-z).
24690
+ // const base36Hash = bigInt.toString(36);
24691
+
24692
+ // // 4. Take the first 10 characters. If it's shorter, it will just return the whole string.
24693
+ // // For a 64-bit integer, the Base36 representation will be about 13 characters long,
24694
+ // // so slicing is a reliable way to get a fixed length.
24695
+ // const shortHash = base36Hash.slice(0, 10);
24696
+
24697
+ // // 5. Pad the start in the unlikely case the hash is shorter than 10 characters.
24698
+ // // This ensures the output is always exactly 10 characters long.
24699
+ // return shortHash.padStart(10, '0');
24700
+ // };
24701
+
24702
+ func.common.fastHash = function (inputString) {
24703
+ let hash = 0x811c9dc5; // FNV offset basis
24704
+
24705
+ for (let i = 0; i < inputString.length; i++) {
24706
+ hash ^= inputString.charCodeAt(i);
24707
+ // FNV prime multiplication with 32-bit overflow
24708
+ hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
24709
+ }
24710
+
24711
+ // Convert to base36 and pad to 10 characters
24712
+ return ((hash >>> 0).toString(36) + '0000000000').slice(0, 10);
24700
24713
  };
24701
24714
 
24702
24715
  glb.new_xu_render = false;
@@ -34964,353 +34977,1451 @@ func.UI.screen.screen_loading_done = async function (SESSION_ID, paramsP, $div,
34964
34977
  return $div;
34965
34978
  };
34966
34979
 
34967
- 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) {
34968
- if (!is_skeleton) {
34969
- var _session = SESSION_OBJ[SESSION_ID];
34970
- var _ds = _session.DS_GLB[paramsP.dsSessionP];
34971
- }
34972
- var prop;
34973
- try {
34974
- prop = nodeP.attributes;
34975
- } catch (error) {
34976
- // debugger;
34977
- }
34980
+ // 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) {
34981
+ // if (!is_skeleton) {
34982
+ // var _session = SESSION_OBJ[SESSION_ID];
34983
+ // var _ds = _session.DS_GLB[paramsP.dsSessionP];
34984
+ // }
34985
+ // var prop;
34986
+ // try {
34987
+ // prop = nodeP.attributes;
34988
+ // } catch (error) {
34989
+ // // debugger;
34990
+ // }
34978
34991
 
34979
- ///////////
34980
- var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
34992
+ // ///////////
34993
+ // var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
34981
34994
 
34982
- const get_element_info = function () {
34983
- var ret = {};
34984
- let currentRecordId = _ds?.currentRecordId || '';
34995
+ // const get_element_info = function () {
34996
+ // var ret = {};
34997
+ // let currentRecordId = _ds?.currentRecordId || '';
34985
34998
 
34986
- let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
34999
+ // let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
34987
35000
 
34988
- $.each($div, function (key, val) {
34989
- if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
34990
- ret = {
34991
- div: $div,
34992
- };
34993
- }
34994
- });
35001
+ // $.each($div, function (key, val) {
35002
+ // if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
35003
+ // ret = {
35004
+ // div: $div,
35005
+ // };
35006
+ // }
35007
+ // });
34995
35008
 
34996
- return ret;
34997
- };
35009
+ // return ret;
35010
+ // };
34998
35011
 
34999
- const init = async function () {
35000
- var ret = true;
35001
- if (!nodeP) ret = false;
35002
- return ret;
35003
- };
35004
- const debug = function (is_errorP, error_descP) {
35005
- func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
35006
- module: 'gui',
35007
- action: 'init',
35008
- prop: nodeP.id,
35009
- details: error_descP,
35010
- result: null,
35011
- error: is_errorP,
35012
- source: _ds?.tree_obj?.menuName || '',
35013
- fields: null,
35014
- type: null,
35015
- prog_id: paramsP.prog_id,
35016
- dsSession: null,
35017
- });
35018
- };
35012
+ // const init = async function () {
35013
+ // var ret = true;
35014
+ // if (!nodeP) ret = false;
35015
+ // return ret;
35016
+ // };
35017
+ // const debug = function (is_errorP, error_descP) {
35018
+ // func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
35019
+ // module: 'gui',
35020
+ // action: 'init',
35021
+ // prop: nodeP.id,
35022
+ // details: error_descP,
35023
+ // result: null,
35024
+ // error: is_errorP,
35025
+ // source: _ds?.tree_obj?.menuName || '',
35026
+ // fields: null,
35027
+ // type: null,
35028
+ // prog_id: paramsP.prog_id,
35029
+ // dsSession: null,
35030
+ // });
35031
+ // };
35019
35032
 
35020
- const open_modal = async function ($div) {
35021
- const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35022
- var xu_modal_controller = document.querySelector('xu-modal-controller');
35023
- if (!xu_modal_controller) {
35024
- func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35025
- xu_modal_controller = document.querySelector('xu-modal-controller');
35026
- }
35033
+ // const open_modal = async function ($div) {
35034
+ // const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35035
+ // var xu_modal_controller = document.querySelector('xu-modal-controller');
35036
+ // if (!xu_modal_controller) {
35037
+ // func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35038
+ // xu_modal_controller = document.querySelector('xu-modal-controller');
35039
+ // }
35027
35040
 
35028
- var controller_params = $(xu_modal_controller).data('xuControllerParams');
35041
+ // var controller_params = $(xu_modal_controller).data('xuControllerParams');
35029
35042
 
35030
- if (!controller_params) {
35031
- controller_params = {};
35032
- }
35043
+ // if (!controller_params) {
35044
+ // controller_params = {};
35045
+ // }
35033
35046
 
35034
- var params = {
35035
- menuTitle: paramsP.screenInfo.properties?.menuTitle,
35036
- screenId: paramsP.screenId,
35037
- $dialogDiv: $div.children(),
35038
- $container: $container,
35039
- dsSession: paramsP.dsSessionP,
35040
- };
35047
+ // var params = {
35048
+ // menuTitle: paramsP.screenInfo.properties?.menuTitle,
35049
+ // screenId: paramsP.screenId,
35050
+ // $dialogDiv: $div.children(),
35051
+ // $container: $container,
35052
+ // dsSession: paramsP.dsSessionP,
35053
+ // };
35041
35054
 
35042
- controller_params[modal_id] = params;
35055
+ // controller_params[modal_id] = params;
35043
35056
 
35044
- $(xu_modal_controller).data('xuControllerParams', controller_params);
35045
- const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35057
+ // $(xu_modal_controller).data('xuControllerParams', controller_params);
35058
+ // const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35046
35059
 
35047
- if (!APP_MODAL_OBJ[modal_id]) {
35048
- const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
35049
- APP_MODAL_OBJ[modal_id] = modal;
35050
- } else {
35051
- $(modal_id).empty();
35052
- }
35053
- await modalController.init(SESSION_ID, modal_id);
35060
+ // if (!APP_MODAL_OBJ[modal_id]) {
35061
+ // const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
35062
+ // APP_MODAL_OBJ[modal_id] = modal;
35063
+ // } else {
35064
+ // $(modal_id).empty();
35065
+ // }
35066
+ // await modalController.init(SESSION_ID, modal_id);
35054
35067
 
35055
- return $div;
35056
- };
35068
+ // return $div;
35069
+ // };
35057
35070
 
35058
- const close_modal = async function (modal_id) {
35059
- delete APP_MODAL_OBJ[modal_id];
35060
- const xu_modal_controller = document.querySelector('xu-modal-controller');
35061
- var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
35062
- if (params && params.$container) {
35063
- await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
35064
- func.datasource.clean_all(SESSION_ID, params.dsSession);
35065
- }
35066
- };
35071
+ // const close_modal = async function (modal_id) {
35072
+ // delete APP_MODAL_OBJ[modal_id];
35073
+ // const xu_modal_controller = document.querySelector('xu-modal-controller');
35074
+ // var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
35075
+ // if (params && params.$container) {
35076
+ // await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
35077
+ // func.datasource.clean_all(SESSION_ID, params.dsSession);
35078
+ // }
35079
+ // };
35067
35080
 
35068
- const close_all_modals = function () {
35069
- $.each(APP_MODAL_OBJ, function (key, val) {
35070
- if (val) {
35071
- // close_modal(key);
35072
- UI_FRAMEWORK_PLUGIN.modal.close(key);
35073
- }
35074
- });
35075
- };
35081
+ // const close_all_modals = function () {
35082
+ // $.each(APP_MODAL_OBJ, function (key, val) {
35083
+ // if (val) {
35084
+ // // close_modal(key);
35085
+ // UI_FRAMEWORK_PLUGIN.modal.close(key);
35086
+ // }
35087
+ // });
35088
+ // };
35076
35089
 
35077
- const open_popover = async function ($div) {
35078
- const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35090
+ // const open_popover = async function ($div) {
35091
+ // const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35079
35092
 
35080
- $(xu_popover_controller).data('xuControllerParams', {
35081
- menuTitle: paramsP.screenInfo.properties?.menuTitle,
35082
- screenId: paramsP.screenId,
35083
- $dialogDiv: $div.children(),
35084
- $container: $container,
35085
- });
35086
- const popover = new UI_FRAMEWORK_PLUGIN.popover(
35087
- SESSION_ID,
35088
- // ELEMENT_CLICK_EVENT,
35089
- // props
35090
- );
35091
- await popover.open(SESSION_ID);
35092
- CURRENT_APP_POPOVER = popover;
35093
+ // $(xu_popover_controller).data('xuControllerParams', {
35094
+ // menuTitle: paramsP.screenInfo.properties?.menuTitle,
35095
+ // screenId: paramsP.screenId,
35096
+ // $dialogDiv: $div.children(),
35097
+ // $container: $container,
35098
+ // });
35099
+ // const popover = new UI_FRAMEWORK_PLUGIN.popover(
35100
+ // SESSION_ID,
35101
+ // // ELEMENT_CLICK_EVENT,
35102
+ // // props
35103
+ // );
35104
+ // await popover.open(SESSION_ID);
35105
+ // CURRENT_APP_POPOVER = popover;
35106
+
35107
+ // return;
35108
+ // popoverController
35109
+ // .create({
35110
+ // component: 'xu-popover-content-' + SESSION_ID,
35111
+ // event: ELEMENT_CLICK_EVENT,
35112
+ // translucent: true,
35113
+ // })
35114
+ // .then((modal) => {
35115
+ // modal.present().then(() => {
35116
+ // CURRENT_APP_POPOVER = modal;
35093
35117
 
35094
- return;
35095
- popoverController
35096
- .create({
35097
- component: 'xu-popover-content-' + SESSION_ID,
35098
- event: ELEMENT_CLICK_EVENT,
35099
- translucent: true,
35100
- })
35101
- .then((modal) => {
35102
- modal.present().then(() => {
35103
- CURRENT_APP_POPOVER = modal;
35118
+ // if (callbackP) callbackP($div);
35119
+ // });
35120
+ // });
35121
+ // };
35122
+ // const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35123
+ // if (!is_mobile && nodeP.busy) return;
35124
+ // nodeP.busy = true;
35125
+ // const done = async function ($divP) {
35126
+ // setTimeout(function () {
35127
+ // nodeP.busy = false;
35128
+ // }, 1000);
35129
+
35130
+ // return $divP;
35131
+ // };
35132
+ // if (!nodeP || !nodeP.children) {
35133
+ // return await done($divP);
35134
+ // }
35104
35135
 
35105
- if (callbackP) callbackP($div);
35106
- });
35107
- });
35108
- };
35109
- const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35110
- if (!is_mobile && nodeP.busy) return;
35111
- nodeP.busy = true;
35112
- const done = async function ($divP) {
35113
- setTimeout(function () {
35114
- nodeP.busy = false;
35115
- }, 1000);
35136
+ // if (before_record_function) {
35137
+ // await before_record_function();
35138
+ // }
35139
+ // if (nodeP?.children?.length) {
35140
+ // let node_promises = [];
35141
+ // for (const [key, val] of Object.entries(nodeP.children)) {
35142
+ // node_promises.push(
35143
+ // new Promise(async (resolve, reject) => {
35144
+ // 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);
35145
+
35146
+ // resolve();
35147
+ // }),
35148
+ // );
35149
+ // }
35150
+ // await Promise.all(node_promises);
35151
+ // }
35152
+ // return await done($divP);
35153
+ // };
35116
35154
 
35117
- return $divP;
35118
- };
35119
- if (!nodeP || !nodeP.children) {
35120
- return await done($divP);
35121
- }
35155
+ // // const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35156
+ // // if (!is_mobile && nodeP.busy) return;
35157
+ // // nodeP.busy = true;
35158
+ // // const done = async function ($divP) {
35159
+ // // setTimeout(function () {
35160
+ // // nodeP.busy = false;
35161
+ // // }, 1000);
35122
35162
 
35123
- if (before_record_function) {
35124
- await before_record_function();
35125
- }
35126
- if (nodeP?.children?.length) {
35127
- let node_promises = [];
35128
- for (const [key, val] of Object.entries(nodeP.children)) {
35129
- node_promises.push(
35130
- new Promise(async (resolve, reject) => {
35131
- 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);
35163
+ // // return $divP;
35164
+ // // };
35165
+ // // if (!nodeP || !nodeP.children) {
35166
+ // // return await done($divP);
35167
+ // // }
35168
+
35169
+ // // if (before_record_function) {
35170
+ // // await before_record_function();
35171
+ // // }
35172
+ // // if (nodeP?.children?.length) {
35173
+ // // for await (const [key, val] of Object.entries(nodeP.children)) {
35174
+ // // 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);
35175
+ // // }
35176
+ // // }
35177
+ // // return await done($divP);
35178
+ // // };
35132
35179
 
35133
- resolve();
35134
- }),
35135
- );
35136
- }
35137
- await Promise.all(node_promises);
35138
- }
35139
- return await done($divP);
35140
- };
35180
+ // const _$ = function ($elm) {
35181
+ // try {
35182
+ // const id = $elm.attr('xu-ui-id');
35183
+ // if (!id || !glb.DEBUG_MODE) return $elm;
35184
+ // const $el = $(`[xu-ui-id="${id}"]`);
35141
35185
 
35142
- // const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35143
- // if (!is_mobile && nodeP.busy) return;
35144
- // nodeP.busy = true;
35145
- // const done = async function ($divP) {
35146
- // setTimeout(function () {
35147
- // nodeP.busy = false;
35148
- // }, 1000);
35149
-
35150
- // return $divP;
35151
- // };
35152
- // if (!nodeP || !nodeP.children) {
35153
- // return await done($divP);
35154
- // }
35186
+ // if ($el.length > 1) {
35187
+ // console.warn('Multiple elements for xu-ui-id: ' + id, $el);
35188
+ // }
35155
35189
 
35156
- // if (before_record_function) {
35157
- // await before_record_function();
35158
- // }
35159
- // if (nodeP?.children?.length) {
35160
- // for await (const [key, val] of Object.entries(nodeP.children)) {
35161
- // 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);
35162
- // }
35163
- // }
35164
- // return await done($divP);
35165
- // };
35190
+ // return $($el[0]);
35191
+ // } catch (e) {
35192
+ // console.error(e);
35193
+ // }
35194
+ // };
35166
35195
 
35167
- const _$ = function ($elm) {
35168
- try {
35169
- const id = $elm.attr('xu-ui-id');
35170
- if (!id || !glb.DEBUG_MODE) return $elm;
35171
- const $el = $(`[xu-ui-id="${id}"]`);
35196
+ // const hover_in = function ($div, e) {
35197
+ // if (is_skeleton || (e && (EXP_BUSY || UI_WORKER_OBJ.jobs.length))) return;
35198
+ // CLIENT_ACTIVITY_TS = Date.now();
35199
+ // if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
35200
+ // if (!_ds) return;
35201
+ // ///////// SET Attributes///////////
35202
+ // let attributes = {};
35203
+ // $.each($div[0].attributes, function (index, attr) {
35204
+ // attributes[attr.name] = attr.value;
35205
+ // });
35172
35206
 
35173
- if ($el.length > 1) {
35174
- console.warn('Multiple elements for xu-ui-id: ' + id, $el);
35175
- }
35207
+ // _session.DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
35208
+ // //////////////////////////////////
35209
+ // if (!$div.data()?.xuData) return;
35210
+ // const _iterate_info = $div.data().xuData.iterate_info;
35211
+ // if (_iterate_info) {
35212
+ // if (_iterate_info.is_key_dynamic_field) {
35213
+ // _ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
35214
+ // } else {
35215
+ // try {
35216
+ // const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35217
+ // _ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
35218
+ // } catch (err) {
35219
+ // console.error(err);
35220
+ // }
35221
+ // }
35176
35222
 
35177
- return $($el[0]);
35178
- } catch (e) {
35179
- console.error(e);
35180
- }
35181
- };
35223
+ // if (_iterate_info.is_val_dynamic_field) {
35224
+ // _ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
35225
+ // } else {
35226
+ // try {
35227
+ // const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35228
+ // _ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
35229
+ // } catch (err) {
35230
+ // console.error(err);
35231
+ // }
35232
+ // }
35233
+ // }
35182
35234
 
35183
- const hover_in = function ($div, e) {
35184
- if (is_skeleton || (e && (EXP_BUSY || UI_WORKER_OBJ.jobs.length))) return;
35185
- CLIENT_ACTIVITY_TS = Date.now();
35186
- if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
35187
- if (!_ds) return;
35188
- ///////// SET Attributes///////////
35189
- let attributes = {};
35190
- $.each($div[0].attributes, function (index, attr) {
35191
- attributes[attr.name] = attr.value;
35192
- });
35235
+ // if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
35236
+ // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
35237
+ // }
35193
35238
 
35194
- _session.DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
35195
- //////////////////////////////////
35196
- if (!$div.data()?.xuData) return;
35197
- const _iterate_info = $div.data().xuData.iterate_info;
35198
- if (_iterate_info) {
35199
- if (_iterate_info.is_key_dynamic_field) {
35200
- _ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
35201
- } else {
35202
- try {
35203
- const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35204
- _ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
35205
- } catch (err) {
35206
- console.error(err);
35207
- }
35208
- }
35239
+ // const set_value = function (field_id, value) {
35240
+ // var currentRecordId = _$($div).data().xuData.currentRecordId;
35209
35241
 
35210
- if (_iterate_info.is_val_dynamic_field) {
35211
- _ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
35212
- } else {
35213
- try {
35214
- const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35215
- _ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
35216
- } catch (err) {
35217
- console.error(err);
35218
- }
35219
- }
35220
- }
35242
+ // func.UI.worker.add_to_queue(
35243
+ // SESSION_ID,
35244
+ // 'gui event',
35245
+ // 'update_datasource',
35246
+ // {
35247
+ // currentRecordId,
35248
+ // field_id,
35249
+ // field_value: value,
35250
+ // },
35251
+ // null,
35252
+ // null,
35253
+ // paramsP.dsSessionP,
35254
+ // );
35255
+ // };
35221
35256
 
35222
- if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
35223
- func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
35224
- }
35257
+ // if ($div?.data()?.iterate_info) {
35258
+ // var data = $div.data().xuData.iterate_info;
35259
+ // if (data.iterator_key) {
35260
+ // set_value(data.iterator_key, data._key);
35261
+ // }
35262
+ // if (data.iterator_val) {
35263
+ // set_value(data.iterator_val, data._val);
35264
+ // }
35265
+ // }
35266
+ // };
35267
+ // const hover_out = function () {
35268
+ // if (is_skeleton) return;
35225
35269
 
35226
- const set_value = function (field_id, value) {
35227
- var currentRecordId = _$($div).data().xuData.currentRecordId;
35270
+ // CLIENT_ACTIVITY_TS = Date.now();
35271
+ // if (_$($container)?.data()?.xuData?.debug_info) {
35272
+ // _$($container).data().xuData.debug_info.hover_item = null;
35273
+ // }
35274
+ // if (_ds?.data_system) {
35275
+ // SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
35276
+ // }
35277
+ // };
35278
+ // const render_screen_type = async function ($div) {
35279
+ // const set_call_screen_properties_values = async function (ui_framework) {
35280
+ // params.properties = {};
35281
+ // const get_values = async function (property) {
35282
+ // var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
35283
+ // if (paramsP?.call_screen_propertiesP) {
35284
+ // if (paramsP.call_screen_propertiesP?.[property]) {
35285
+ // property_value = paramsP.call_screen_propertiesP[property];
35286
+ // }
35287
+ // if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
35288
+ // property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
35289
+ // }
35290
+ // }
35291
+ // return property_value;
35292
+ // };
35293
+ // params.properties['name'] = await get_values('menuTitle');
35294
+ // if (await ui_framework?.properties()) {
35295
+ // for await (const [key, val] of Object.entries(await ui_framework.properties())) {
35296
+ // params.properties[key] = await get_values(key);
35297
+ // }
35298
+ // }
35299
+ // };
35228
35300
 
35229
- func.UI.worker.add_to_queue(
35230
- SESSION_ID,
35231
- 'gui event',
35232
- 'update_datasource',
35233
- {
35234
- currentRecordId,
35235
- field_id,
35236
- field_value: value,
35237
- },
35238
- null,
35239
- null,
35240
- paramsP.dsSessionP,
35241
- );
35242
- };
35301
+ // var $div_content = $div.children();
35243
35302
 
35244
- if ($div?.data()?.iterate_info) {
35245
- var data = $div.data().xuData.iterate_info;
35246
- if (data.iterator_key) {
35247
- set_value(data.iterator_key, data._key);
35248
- }
35249
- if (data.iterator_val) {
35250
- set_value(data.iterator_val, data._val);
35251
- }
35252
- }
35253
- };
35254
- const hover_out = function () {
35255
- if (is_skeleton) return;
35303
+ // $.each($div_content, function (key, val) {
35304
+ // if (!$(val)?.data()?.xuData?.parent_container) {
35305
+ // return true;
35306
+ // }
35307
+ // $(val).data().xuData.parent_container = $div.data().xuData.parent_container;
35308
+ // });
35256
35309
 
35257
- CLIENT_ACTIVITY_TS = Date.now();
35258
- if (_$($container)?.data()?.xuData?.debug_info) {
35259
- _$($container).data().xuData.debug_info.hover_item = null;
35260
- }
35261
- if (_ds?.data_system) {
35262
- SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
35263
- }
35264
- };
35265
- const render_screen_type = async function ($div) {
35266
- const set_call_screen_properties_values = async function (ui_framework) {
35267
- params.properties = {};
35268
- const get_values = async function (property) {
35269
- var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
35270
- if (paramsP?.call_screen_propertiesP) {
35271
- if (paramsP.call_screen_propertiesP?.[property]) {
35272
- property_value = paramsP.call_screen_propertiesP[property];
35273
- }
35274
- if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
35275
- property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
35310
+ // let $ret = $div;
35311
+ // var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
35312
+ // var params;
35313
+ // switch (paramsP.screen_type) {
35314
+ // case 'modal':
35315
+ // const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35316
+ // var xu_modal_controller = document.querySelector('xu-modal-controller');
35317
+ // if (!xu_modal_controller) {
35318
+ // func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35319
+ // xu_modal_controller = document.querySelector('xu-modal-controller');
35320
+ // }
35321
+
35322
+ // var controller_params = $(xu_modal_controller).data('xuControllerParams');
35323
+
35324
+ // if (!controller_params) {
35325
+ // controller_params = {};
35326
+ // }
35327
+
35328
+ // params = {
35329
+ // screenId: paramsP.screenId,
35330
+ // $dialogDiv: $div.children(),
35331
+ // $container: $container,
35332
+ // dsSession: paramsP.dsSessionP,
35333
+ // modal_id,
35334
+ // screenInfo: paramsP.screenInfo,
35335
+ // close_callback: close_modal,
35336
+ // paramsP,
35337
+ // };
35338
+
35339
+ // controller_params[modal_id] = params;
35340
+
35341
+ // $(xu_modal_controller).data('xuControllerParams', controller_params);
35342
+ // const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35343
+ // await set_call_screen_properties_values(modalController);
35344
+ // if (!APP_MODAL_OBJ[modal_id]) {
35345
+ // const modal = await modalController.create(params);
35346
+
35347
+ // APP_MODAL_OBJ[modal_id] = modal;
35348
+ // } else {
35349
+ // $(modal_id).empty();
35350
+ // }
35351
+
35352
+ // await modalController.init(params);
35353
+
35354
+ // break;
35355
+
35356
+ // case 'popover':
35357
+ // // open_popover($div);
35358
+
35359
+ // const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35360
+ // params = {
35361
+ // menuTitle: paramsP.screenInfo.properties?.menuTitle,
35362
+ // screenId: paramsP.screenId,
35363
+ // $dialogDiv: $div.children(),
35364
+ // $container: $container,
35365
+ // };
35366
+
35367
+ // $(xu_popover_controller).data('xuControllerParams', params);
35368
+ // const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
35369
+ // await set_call_screen_properties_values(popover);
35370
+ // await popover.open(params);
35371
+ // CURRENT_APP_POPOVER = popover;
35372
+
35373
+ // func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
35374
+ // break;
35375
+
35376
+ // case 'page':
35377
+ // const nav = $nav[0];
35378
+
35379
+ // params = {
35380
+ // div: $div_content,
35381
+ // name: paramsP.screenInfo.properties?.menuTitle,
35382
+ // screenId: paramsP.screenId,
35383
+ // $container: $container,
35384
+ // dsSession: paramsP.dsSessionP,
35385
+ // SESSION_ID,
35386
+ // nav,
35387
+ // paramsP,
35388
+ // };
35389
+
35390
+ // var component_name = 'xu-page-component-' + paramsP.dsSessionP;
35391
+ // if (!$(nav).data().xuData.nav_params) {
35392
+ // $(nav).data().xuData.nav_params = {};
35393
+ // }
35394
+
35395
+ // //restore validate
35396
+ // if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
35397
+ // params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
35398
+ // }
35399
+
35400
+ // if (!$(nav)?.data()?.xuData) return;
35401
+ // $(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
35402
+ // if (!$(component_name).length) {
35403
+ // await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
35404
+ // const page = new UI_FRAMEWORK_PLUGIN.page();
35405
+ // await set_call_screen_properties_values(page);
35406
+ // await page.create(params);
35407
+ // await page.init(params);
35408
+ // nav.push(component_name, { params });
35409
+ // } else {
35410
+ // debugger;
35411
+ // $(component_name).empty();
35412
+
35413
+ // await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
35414
+ // }
35415
+ // $div.data().xuData.paramsP = $container.data().xuData.paramsP;
35416
+ // break;
35417
+
35418
+ // case 'panel':
35419
+ // $container.append($div_content);
35420
+ // $ret = $container;
35421
+ // break;
35422
+
35423
+ // default: // set data to nav to use in the component
35424
+ // if ($nav && $nav.length) {
35425
+ // // refresh made
35426
+ // } else {
35427
+ // $nav = $('<xu-nav>'); //.attr('xu-ui-id', SESSION_ID);
35428
+ // $container.append($nav);
35429
+ // func.UI.component.init_xu_nav($container, $nav);
35430
+ // }
35431
+
35432
+ // $nav.data().xuData.$div = $div_content;
35433
+
35434
+ // await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
35435
+ // $ret = $container;
35436
+ // break;
35437
+ // }
35438
+ // return $ret;
35439
+ // };
35440
+
35441
+ // if (!(await init())) return;
35442
+ // debug();
35443
+ // const fx = {
35444
+ // widget: async function () {
35445
+ // var _session = SESSION_OBJ[SESSION_ID];
35446
+
35447
+ // var exist_elm_obj = get_element_info();
35448
+ // var $div = exist_elm_obj.div;
35449
+ // if (!exist_elm_obj.div) {
35450
+ // $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);
35451
+
35452
+ // //////////////////////////
35453
+
35454
+ // let plugin_name = prop['xu-widget'],
35455
+ // method = prop['xu-method'],
35456
+ // dsP = paramsP.dsSessionP,
35457
+ // propsP = prop,
35458
+ // sourceP = 'widgets';
35459
+
35460
+ // // const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
35461
+ // // var obj = _.clone(docP);
35462
+ // // obj.date = await func.utils.get_dateTime(
35463
+ // // SESSION_ID,
35464
+ // // "SYS_DATE",
35465
+ // // docP.date
35466
+ // // );
35467
+ // // obj.time = await func.utils.get_dateTime(
35468
+ // // SESSION_ID,
35469
+ // // "SYS_TIME",
35470
+ // // docP.date
35471
+ // // );
35472
+
35473
+ // // var datasource_changes = {
35474
+ // // [0]: {
35475
+ // // ["data_system"]: {
35476
+ // // ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
35477
+ // // },
35478
+ // // },
35479
+ // // };
35480
+ // // await func.datasource.update(SESSION_ID, datasource_changes);
35481
+ // // };
35482
+ // const call_plugin_api = async function (plugin_nameP, dataP) {
35483
+ // return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
35484
+ // };
35485
+ // const report_error = function (descP, warn) {
35486
+ // func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35487
+ // module: 'widgets',
35488
+ // action: 'Init',
35489
+ // source: sourceP,
35490
+ // prop: descP,
35491
+ // details: descP,
35492
+ // result: null,
35493
+ // error: warn ? false : true,
35494
+ // fields: null,
35495
+ // type: 'widgets',
35496
+ // prog_id: _session.DS_GLB[dsP].prog_id,
35497
+ // });
35498
+ // };
35499
+ // const get_fields_data = async function (fields, props) {
35500
+ // const report_error = function (descP, warn) {
35501
+ // func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35502
+ // module: 'widgets',
35503
+ // action: 'Init',
35504
+ // source: sourceP,
35505
+ // prop: descP,
35506
+ // details: descP,
35507
+ // result: null,
35508
+ // error: warn ? false : true,
35509
+ // fields: null,
35510
+ // type: 'widgets',
35511
+ // prog_id: _session.DS_GLB[dsP].prog_id,
35512
+ // });
35513
+ // };
35514
+ // const get_property_value = async function (fieldIdP, val) {
35515
+ // if (!val) return;
35516
+ // var value = fieldIdP in props ? props[fieldIdP] : typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue;
35517
+ // if (val.render === 'eventId') {
35518
+ // value = props?.[fieldIdP]?.event;
35519
+ // }
35520
+
35521
+ // if (props[`xu-exp:${fieldIdP}`]) {
35522
+ // value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
35523
+ // }
35524
+
35525
+ // return func.common.get_cast_val(
35526
+ // SESSION_ID,
35527
+ // 'widgets',
35528
+ // fieldIdP,
35529
+ // val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
35530
+ // value,
35531
+ // null,
35532
+ // );
35533
+ // };
35534
+ // var data_obj = {};
35535
+ // var return_code = 1;
35536
+ // // $.each(fields, function (key, val) {
35537
+ // for await (const [key, val] of Object.entries(fields)) {
35538
+ // data_obj[key] = await get_property_value(key, val);
35539
+ // if (!data_obj[key] && val.mandatory) {
35540
+ // return_code = -1;
35541
+ // report_error(`${key} is a mandatory field.`);
35542
+ // break;
35543
+ // }
35544
+ // // console.log(val);
35545
+ // }
35546
+ // for await (const key of ['xu-bind']) {
35547
+ // data_obj[key] = await get_property_value(key, props[key]);
35548
+ // }
35549
+
35550
+ // return { code: return_code, data: data_obj };
35551
+ // };
35552
+
35553
+ // const load_css_style = function () {
35554
+ // const get_css_path = function (resource) {
35555
+ // if (_session.worker_type === 'Dev') {
35556
+ // return `../../plugins/${plugin_name}/${resource}`;
35557
+ // }
35558
+ // 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}`;
35559
+ // };
35560
+ // let path = get_css_path('style.css');
35561
+ // func.utils.load_css_on_demand(path);
35562
+ // };
35563
+
35564
+ // const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
35565
+ // const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
35566
+ // const methods = index.methods;
35567
+ // if (methods && !methods[method]) {
35568
+ // return report_error('method not found');
35569
+ // }
35570
+
35571
+ // const fields_ret = await get_fields_data(methods[method].fields, propsP);
35572
+ // if (fields_ret.code < 0) {
35573
+ // return report_error(fields_ret.data);
35574
+ // }
35575
+ // const fields = fields_ret.data;
35576
+
35577
+ // let exclude_attributes = [];
35578
+ // for await (const [key, val] of Object.entries(propsP)) {
35579
+ // if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
35580
+ // exclude_attributes.push(key);
35581
+ // }
35582
+ // }
35583
+
35584
+ // 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);
35585
+
35586
+ // $div.addClass('widget_wrapper'); // class get override in set_attributes_new
35587
+
35588
+ // if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
35589
+ // return report_error(`plugin ${plugin_name} not found`);
35590
+ // }
35591
+
35592
+ // if (APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest['style.css'].exist) {
35593
+ // load_css_style();
35594
+ // }
35595
+
35596
+ // const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
35597
+ // if (plugin_setup_ret.code < 0) {
35598
+ // return report_error(plugin_setup_ret);
35599
+ // }
35600
+
35601
+ // const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
35602
+ // func,
35603
+ // glb,
35604
+ // SESSION_OBJ,
35605
+ // SESSION_ID,
35606
+ // APP_OBJ,
35607
+ // dsSession: paramsP.dsSessionP,
35608
+ // job_id: jobNoP,
35609
+ // });
35610
+
35611
+ // const params = {
35612
+ // SESSION_ID,
35613
+ // method,
35614
+ // _session,
35615
+ // dsP,
35616
+ // sourceP,
35617
+ // propsP,
35618
+ // plugin_name,
35619
+ // $containerP: $div,
35620
+ // plugin_setup: plugin_setup_ret.data,
35621
+
35622
+ // report_error,
35623
+ // call_plugin_api,
35624
+ // // set_SYS_GLOBAL_OBJ_WIDGET_INFO,
35625
+ // api_utils,
35626
+ // };
35627
+
35628
+ // const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
35629
+
35630
+ // if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
35631
+ // const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
35632
+ // func.utils.load_css_on_demand(plugin_runtime_css_url);
35633
+ // }
35634
+
35635
+ // if (!fx[method]) {
35636
+ // throw `Method: ${method} does not exist`;
35637
+ // }
35638
+ // try {
35639
+ // await fx[method](fields, params);
35640
+ // } catch (err) {
35641
+ // func.utils.debug_report(SESSION_ID, `${plugin_name} widget`, err.message, 'E');
35642
+ // }
35643
+ // }
35644
+ // return $div;
35645
+ // },
35646
+ // [`xu-single-view`]: async function () {
35647
+ // var exist_elm_obj = get_element_info();
35648
+ // var $div = exist_elm_obj.div;
35649
+
35650
+ // if (!exist_elm_obj.div) {
35651
+ // var $wrapper = $('<div>');
35652
+ // $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, '');
35653
+
35654
+ // if (!$div) return;
35655
+
35656
+ // if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
35657
+ // close_all_modals();
35658
+ // }
35659
+
35660
+ // $div.hover(
35661
+ // function (e) {
35662
+ // hover_in();
35663
+ // // func.UI.screen.hover_in(SESSION_ID, null, $container, paramsP, is_skeleton);
35664
+ // },
35665
+ // function (e) {
35666
+ // // func.UI.screen.hover_out(SESSION_ID, $container, is_skeleton, paramsP);
35667
+ // hover_out();
35668
+ // },
35669
+ // );
35670
+ // }
35671
+
35672
+ // const ret = await iterate_child($div, nodeP, null, $div);
35673
+ // if (_.isEmpty($container.data().xuAttributes)) {
35674
+ // await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35675
+ // }
35676
+
35677
+ // $.each($div.data().xuData, function (key, val) {
35678
+ // $container.data().xuData[key] = _.cloneDeep(val);
35679
+ // });
35680
+ // $.each($div.data().xuAttributes, function (key, val) {
35681
+ // // $container.data().xuAttributes[key] = _.cloneDeep(val);
35682
+ // $container.data().xuAttributes[key] = klona.klona(val);
35683
+ // });
35684
+
35685
+ // return await render_screen_type($div);
35686
+ // },
35687
+ // [`xu-multi-view`]: async function () {
35688
+ // var $div = $container;
35689
+
35690
+ // if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
35691
+ // $div.data().xuData.node = nodeP;
35692
+ // }
35693
+
35694
+ // if (!$div.data().xuData.debug_info) {
35695
+ // $div.data().xuData.debug_info = {
35696
+ // id: nodeP.id,
35697
+ // parent_id: $container.data().xuData.ui_id,
35698
+ // };
35699
+ // }
35700
+
35701
+ // const done = async function (continuous_idx) {
35702
+ // // const do_callback = async function ($div) {
35703
+ // // // if ($root_container.data().xuData.progress_bar_circle) {
35704
+ // // // setTimeout(function () {
35705
+ // // // $.each(
35706
+ // // // $root_container.data().xuData.progress_bar_circle,
35707
+ // // // function (key, val) {
35708
+ // // // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
35709
+ // // // }
35710
+ // // // );
35711
+ // // // }, 2000);
35712
+ // // // }
35713
+
35714
+ // // if (paramsP.screenInfo.properties?.rtl) {
35715
+ // // $div_content.attr('dir', 'rtl');
35716
+ // // }
35717
+
35718
+ // // return $div;
35719
+ // // };
35720
+ // await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35721
+
35722
+ // return await render_screen_type($div);
35723
+ // };
35724
+
35725
+ // if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
35726
+ // close_all_modals();
35727
+ // }
35728
+
35729
+ // const empty_result = async function () {
35730
+ // // var content = prop.empty_result_content || '';
35731
+
35732
+ // // var res = await func.expression.get(
35733
+ // // SESSION_ID,
35734
+ // // content, // prop["xu-exp:empty_result_content"],
35735
+ // // paramsP.dsSessionP,
35736
+ // // 'empty_result_content_EXP',
35737
+ // // _ds.currentRecordId,
35738
+ // // );
35739
+ // // content = res.result;
35740
+
35741
+ // // let empty_result_node = {
35742
+ // // type: 'element',
35743
+ // // id: crypto.randomUUID(),
35744
+ // // content,
35745
+ // // // : content || (typeof content === "undefined" && "Empty results"),
35746
+ // // tagName: 'div',
35747
+ // // attributes: {},
35748
+ // // children: [],
35749
+ // // };
35750
+
35751
+ // // 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);
35752
+ // await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
35753
+ // return await done(null);
35754
+ // };
35755
+ // var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
35756
+
35757
+ // var continuous_idx = null;
35758
+
35759
+ // if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
35760
+ // return await empty_result();
35761
+ // }
35762
+
35763
+ // var i = 0;
35764
+ // for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
35765
+ // var node = JSON.parse(JSON.stringify(nodeP));
35766
+
35767
+ // _ds.currentRecordId = val._ROWID;
35768
+ // const ret = await iterate_child($div, node, { continuous_idx }, $root_container);
35769
+
35770
+ // if (_.isEmpty($container.data().xuAttributes)) {
35771
+ // await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35772
+ // }
35773
+ // }
35774
+
35775
+ // return await done(continuous_idx);
35776
+ // },
35777
+ // [`xu-panel`]: async function () {
35778
+ // const done = async function ($new_div) {
35779
+ // if (!$container.data()?.xuData?.paramsP) {
35780
+ // return $container;
35781
+ // }
35782
+ // var $div_items = $div.data().xuData.node.children;
35783
+
35784
+ // await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
35785
+
35786
+ // // TO FIX should be timeout
35787
+ // $container.data().xuData.node.children = $div_items;
35788
+
35789
+ // return $container;
35790
+ // };
35791
+
35792
+ // var $wrapper = $('<div>');
35793
+ // $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, '');
35794
+
35795
+ // 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);
35796
+ // if (ret.abort) {
35797
+ // // render N
35798
+ // return (ret.$new_div = $('<template>').append($div));
35799
+ // }
35800
+
35801
+ // let $ret_panel_div = ret.$new_div;
35802
+
35803
+ // if (!$ret_panel_div?.children()?.length) {
35804
+ // ////// render default children tree
35805
+ // if (nodeP.children.length) {
35806
+ // $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);
35807
+ // }
35808
+ // }
35809
+
35810
+ // let ret_done = await done($ret_panel_div);
35811
+
35812
+ // return ret_done;
35813
+ // },
35814
+ // };
35815
+
35816
+ // const draw_html_element_org = async function (element) {
35817
+ // const done = async function (ret = {}) {
35818
+ // return $div;
35819
+ // };
35820
+ // if (!element || element === 'script') return await done();
35821
+ // let str = '';
35822
+
35823
+ // 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);
35824
+
35825
+ // $div.hover(
35826
+ // function (e) {
35827
+ // hover_in($div, e);
35828
+ // },
35829
+ // function (e) {
35830
+ // hover_out();
35831
+ // },
35832
+ // );
35833
+ // if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35834
+ // $div.on('click contextmenu', function (e) {
35835
+ // hover_in($div, e);
35836
+ // });
35837
+ // }
35838
+
35839
+ // // 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);
35840
+ // 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);
35841
+ // 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'])) {
35842
+ // return await done(ret);
35843
+ // }
35844
+ // // check if iterator made to prevent children render
35845
+
35846
+ // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
35847
+ // // const xu_viewport = async function () {
35848
+ // // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
35849
+ // // const container_id = $container.attr('xu-ui-id');
35850
+ // // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
35851
+ // // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
35852
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
35853
+ // // } else {
35854
+ // // $div.remove();
35855
+ // // }
35856
+ // // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
35857
+
35858
+ // // // if (!$div.children().length) {
35859
+ // // // // render the first element to determine height
35860
+ // // // await iterate_child($div, nodeP, parent_infoP, $root_container);
35861
+ // // // // hover_in($div);
35862
+ // // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
35863
+ // // // } else {
35864
+ // // // }
35865
+ // // };
35866
+ // const xu_viewport = function () {
35867
+ // const observer_inViewport = new IntersectionObserver(
35868
+ // function (entries) {
35869
+ // entries.forEach((entry) => {
35870
+ // if (entry.isIntersecting) {
35871
+ // $(entry.target).trigger('inViewport');
35872
+
35873
+ // // Optional: stop observing once triggered
35874
+ // observer_inViewport.unobserve(entry.target);
35875
+ // }
35876
+ // });
35877
+ // },
35878
+ // {
35879
+ // threshold: 0.1, // Trigger when 10% of element is visible
35880
+ // },
35881
+ // );
35882
+
35883
+ // const observer_outViewport = new IntersectionObserver(
35884
+ // function (entries) {
35885
+ // entries.forEach((entry) => {
35886
+ // if (!entry.isIntersecting) {
35887
+ // // Element is OUT of viewport - trigger custom event
35888
+ // $(entry.target).trigger('outViewport');
35889
+
35890
+ // // Optional: stop observing once triggered
35891
+ // // observer_outViewport.unobserve(entry.target);
35892
+ // }
35893
+ // });
35894
+ // },
35895
+ // {
35896
+ // threshold: 0, // Trigger when element is completely out of view
35897
+ // },
35898
+ // );
35899
+
35900
+ // let ui_job_id;
35901
+ // $div.on('inViewport', function () {
35902
+ // if ($div.children().length) {
35903
+ // $div.removeClass('skeleton');
35904
+ // return;
35905
+ // }
35906
+
35907
+ // // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
35908
+ // // $div[0].style.removeProperty('height');
35909
+ // // $div.removeClass('skeleton');
35910
+ // // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
35911
+ // // } else {
35912
+ // hover_in($div);
35913
+ // 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);
35914
+ // // }
35915
+ // observer_outViewport.observe($div[0]);
35916
+ // });
35917
+
35918
+ // $div.on('outViewport', function () {
35919
+ // func.UI.worker.delete_job(SESSION_ID, ui_job_id);
35920
+
35921
+ // if ($div.children().length) {
35922
+ // // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
35923
+ // $div.empty();
35924
+ // const height = $div?.data()?.xuData?.viewport_height || 10;
35925
+ // if (typeof height !== 'undefined') {
35926
+ // $div.css('height', height);
35927
+ // }
35928
+ // }
35929
+ // // $div.addClass('skeleton');
35930
+ // observer_inViewport.observe($div[0]);
35931
+ // });
35932
+ // $div.addClass('skeleton');
35933
+ // observer_inViewport.observe($div[0]);
35934
+ // };
35935
+ // xu_viewport();
35936
+ // } else {
35937
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
35938
+ // }
35939
+
35940
+ // // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
35941
+ // return await done(ret);
35942
+ // };
35943
+
35944
+ // const draw_html_element = async function (element) {
35945
+ // const done = async function (ret = {}) {
35946
+ // const xu_ui_id = $div.attr('xu-ui-id');
35947
+ // $div.removeClass('display_none');
35948
+ // if (ret.has_xu_exp_render_attribute) {
35949
+ // // $div.css('display', 'unset');
35950
+
35951
+ // 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 || {}));
35952
+ // const _$div = $div.clone(true);
35953
+ // UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: _$div, paramsP, data: _$div.data() };
35954
+ // nodeP.xu_render_xu_ui_id = xu_ui_id;
35955
+ // nodeP.xu_render_cache_id = xu_render_cache_id;
35956
+
35957
+ // if (ret.xu_render_background_processing) {
35958
+ // temp_$div.remove();
35959
+ // // $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
35960
+ // return $div;
35961
+ // } else {
35962
+ // // $div.css('display', 'unset');
35963
+ // temp_$div.replaceWith($div);
35964
+ // return $div;
35965
+ // }
35966
+ // } else {
35967
+ // if (ret.has_xu_render_attribute) {
35968
+ // temp_$div.remove();
35969
+ // return $div;
35970
+ // }
35971
+ // // $div.css('display', 'unset');
35972
+ // temp_$div.replaceWith($div);
35973
+ // return $div;
35974
+ // }
35975
+ // };
35976
+ // if (!element || element === 'script') return await done();
35977
+ // let str = '';
35978
+
35979
+ // 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);
35980
+
35981
+ // let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
35982
+ // let $div = temp_$div.clone(true);
35983
+
35984
+ // // $div.css('display', 'none');
35985
+
35986
+ // $div.hover(
35987
+ // function (e) {
35988
+ // hover_in($div, e);
35989
+ // },
35990
+ // function (e) {
35991
+ // hover_out();
35992
+ // },
35993
+ // );
35994
+ // if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35995
+ // $div.on('click contextmenu', function (e) {
35996
+ // hover_in($div, e);
35997
+ // });
35998
+ // }
35999
+
36000
+ // 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);
36001
+ // 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'])) {
36002
+ // return await done(ret);
36003
+ // }
36004
+ // // check if iterator made to prevent children render
36005
+
36006
+ // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36007
+ // // const xu_viewport = async function () {
36008
+ // // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36009
+ // // const container_id = $container.attr('xu-ui-id');
36010
+ // // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36011
+ // // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36012
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36013
+ // // } else {
36014
+ // // $div.remove();
36015
+ // // }
36016
+ // // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36017
+
36018
+ // // // if (!$div.children().length) {
36019
+ // // // // render the first element to determine height
36020
+ // // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36021
+ // // // // hover_in($div);
36022
+ // // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
36023
+ // // // } else {
36024
+ // // // }
36025
+ // // };
36026
+ // const xu_viewport = function () {
36027
+ // const observer_inViewport = new IntersectionObserver(
36028
+ // function (entries) {
36029
+ // entries.forEach((entry) => {
36030
+ // if (entry.isIntersecting) {
36031
+ // $(entry.target).trigger('inViewport');
36032
+
36033
+ // // Optional: stop observing once triggered
36034
+ // observer_inViewport.unobserve(entry.target);
36035
+ // }
36036
+ // });
36037
+ // },
36038
+ // {
36039
+ // threshold: 0.1, // Trigger when 10% of element is visible
36040
+ // },
36041
+ // );
36042
+
36043
+ // const observer_outViewport = new IntersectionObserver(
36044
+ // function (entries) {
36045
+ // entries.forEach((entry) => {
36046
+ // if (!entry.isIntersecting) {
36047
+ // // Element is OUT of viewport - trigger custom event
36048
+ // $(entry.target).trigger('outViewport');
36049
+
36050
+ // // Optional: stop observing once triggered
36051
+ // // observer_outViewport.unobserve(entry.target);
36052
+ // }
36053
+ // });
36054
+ // },
36055
+ // {
36056
+ // threshold: 0, // Trigger when element is completely out of view
36057
+ // },
36058
+ // );
36059
+
36060
+ // let ui_job_id;
36061
+ // $div.on('inViewport', function () {
36062
+ // if ($div.children().length) {
36063
+ // $div.removeClass('skeleton');
36064
+ // return;
36065
+ // }
36066
+
36067
+ // // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
36068
+ // // $div[0].style.removeProperty('height');
36069
+ // // $div.removeClass('skeleton');
36070
+ // // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
36071
+ // // } else {
36072
+ // hover_in($div);
36073
+ // 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);
36074
+ // // }
36075
+ // observer_outViewport.observe($div[0]);
36076
+ // });
36077
+
36078
+ // $div.on('outViewport', function () {
36079
+ // func.UI.worker.delete_job(SESSION_ID, ui_job_id);
36080
+
36081
+ // if ($div.children().length) {
36082
+ // // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
36083
+ // $div.empty();
36084
+ // const height = $div?.data()?.xuData?.viewport_height || 10;
36085
+ // if (typeof height !== 'undefined') {
36086
+ // $div.css('height', height);
36087
+ // }
36088
+ // }
36089
+ // // $div.addClass('skeleton');
36090
+ // observer_inViewport.observe($div[0]);
36091
+ // });
36092
+ // $div.addClass('skeleton');
36093
+ // observer_inViewport.observe($div[0]);
36094
+ // };
36095
+ // xu_viewport();
36096
+ // } else {
36097
+ // // if (ret.xu_render_background_processing) {
36098
+ // // // let temp_$div = $div.clone(true);
36099
+ // // iterate_child($div, nodeP, parent_infoP, $root_container);
36100
+ // // } else {
36101
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36102
+ // // }
36103
+ // if (!ret.xu_render_background_processing) {
36104
+ // iterate_child($div, nodeP, parent_infoP, $root_container);
36105
+ // }
36106
+ // }
36107
+
36108
+ // // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
36109
+ // return await done(ret);
36110
+ // };
36111
+
36112
+ // if (nodeP.content && nodeP.attributes) {
36113
+ // nodeP.attributes['xu-content'] = nodeP.content;
36114
+ // }
36115
+
36116
+ // if (nodeP.tagName === 'xu-widget') {
36117
+ // if (is_skeleton) return;
36118
+ // return await fx['widget']();
36119
+ // }
36120
+ // if (fx[nodeP.tagName]) {
36121
+ // return await fx[nodeP.tagName]();
36122
+ // }
36123
+ // // const xu_viewport = async function () {
36124
+ // // const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36125
+ // // const container_id = $container.attr('xu-ui-id');
36126
+ // // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36127
+ // // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36128
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36129
+ // // }
36130
+ // // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36131
+ // // };
36132
+
36133
+ // // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36134
+ // // return await xu_viewport();
36135
+ // // } else {
36136
+ // if (!glb.new_xu_render) {
36137
+ // return await draw_html_element_org(nodeP.tagName);
36138
+ // }
36139
+ // return await draw_html_element(nodeP.tagName);
36140
+
36141
+ // // }
36142
+ // };
36143
+
36144
+ 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) {
36145
+ // Early cache session and datasource
36146
+ let _session, _ds;
36147
+ if (!is_skeleton) {
36148
+ _session = SESSION_OBJ[SESSION_ID];
36149
+ _ds = _session.DS_GLB[paramsP.dsSessionP];
36150
+ }
36151
+
36152
+ const prop = nodeP.attributes;
36153
+ const is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType);
36154
+ const nodeTag = nodeP.tagName;
36155
+
36156
+ // Optimized element finder with caching
36157
+ const get_element_info = function () {
36158
+ if (!_ds) return {};
36159
+
36160
+ const currentRecordId = _ds.currentRecordId || '';
36161
+ const $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
36162
+
36163
+ for (let i = 0; i < $div.length; i++) {
36164
+ const $el = $($div[i]);
36165
+ const xuData = $el.data().xuData;
36166
+ if (xuData?.recordid === currentRecordId && xuData?.key === keyP && $el.prop('tagName') !== 'XURENDER') {
36167
+ return { div: $div };
36168
+ }
36169
+ }
36170
+ return {};
36171
+ };
36172
+
36173
+ const init = async function () {
36174
+ return !!nodeP;
36175
+ };
36176
+
36177
+ const debug = function (is_errorP, error_descP) {
36178
+ func.utils.debug.log(SESSION_ID, `${paramsP.prog_id}_${nodeP.id_org}_ui_prop`, {
36179
+ module: 'gui',
36180
+ action: 'init',
36181
+ prop: nodeP.id,
36182
+ details: error_descP,
36183
+ result: null,
36184
+ error: is_errorP,
36185
+ source: _ds?.tree_obj?.menuName || '',
36186
+ fields: null,
36187
+ type: null,
36188
+ prog_id: paramsP.prog_id,
36189
+ dsSession: null,
36190
+ });
36191
+ };
36192
+
36193
+ const close_modal = async function (modal_id) {
36194
+ delete APP_MODAL_OBJ[modal_id];
36195
+ const xu_modal_controller = document.querySelector('xu-modal-controller');
36196
+ const params = $(xu_modal_controller).data().xuControllerParams?.[modal_id];
36197
+ if (params?.container) {
36198
+ await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
36199
+ func.datasource.clean_all(SESSION_ID, params.dsSession);
36200
+ }
36201
+ };
36202
+
36203
+ const close_all_modals = function () {
36204
+ Object.entries(APP_MODAL_OBJ).forEach(([key, val]) => {
36205
+ if (val) {
36206
+ UI_FRAMEWORK_PLUGIN.modal.close(key);
36207
+ }
36208
+ });
36209
+ };
36210
+
36211
+ const open_modal = async function ($div) {
36212
+ const modal_id = `app_modal-${paramsP.dsSessionP}`;
36213
+ let xu_modal_controller = document.querySelector('xu-modal-controller');
36214
+
36215
+ if (!xu_modal_controller) {
36216
+ func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
36217
+ xu_modal_controller = document.querySelector('xu-modal-controller');
36218
+ }
36219
+
36220
+ let controller_params = $(xu_modal_controller).data('xuControllerParams') || {};
36221
+
36222
+ controller_params[modal_id] = {
36223
+ menuTitle: paramsP.screenInfo.properties?.menuTitle,
36224
+ screenId: paramsP.screenId,
36225
+ $dialogDiv: $div.children(),
36226
+ $container: $container,
36227
+ dsSession: paramsP.dsSessionP,
36228
+ };
36229
+
36230
+ $(xu_modal_controller).data('xuControllerParams', controller_params);
36231
+ const modalController = new UI_FRAMEWORK_PLUGIN.modal();
36232
+
36233
+ if (!APP_MODAL_OBJ[modal_id]) {
36234
+ APP_MODAL_OBJ[modal_id] = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
36235
+ } else {
36236
+ $(modal_id).empty();
36237
+ }
36238
+
36239
+ await modalController.init(SESSION_ID, modal_id);
36240
+ return $div;
36241
+ };
36242
+
36243
+ const open_popover = async function ($div) {
36244
+ const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
36245
+
36246
+ $(xu_popover_controller).data('xuControllerParams', {
36247
+ menuTitle: paramsP.screenInfo.properties?.menuTitle,
36248
+ screenId: paramsP.screenId,
36249
+ $dialogDiv: $div.children(),
36250
+ $container: $container,
36251
+ });
36252
+
36253
+ const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
36254
+ await popover.open(SESSION_ID);
36255
+ CURRENT_APP_POPOVER = popover;
36256
+ };
36257
+
36258
+ // OPTIMIZED: Parallel child iteration with improved logic
36259
+ const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
36260
+ if (!is_mobile && nodeP.busy) return $divP;
36261
+
36262
+ nodeP.busy = true;
36263
+
36264
+ const done = function ($divP) {
36265
+ setTimeout(() => {
36266
+ nodeP.busy = false;
36267
+ }, 1000);
36268
+ return $divP;
36269
+ };
36270
+
36271
+ if (!nodeP?.children?.length) {
36272
+ return done($divP);
36273
+ }
36274
+
36275
+ if (before_record_function) {
36276
+ await before_record_function();
36277
+ }
36278
+
36279
+ // Parallel rendering for better performance
36280
+ await Promise.all(nodeP.children.map((child, key) => func.UI.screen.render_ui_tree(SESSION_ID, $divP, child, parent_infoP, paramsP, jobNoP, is_skeleton, key, null, nodeP, null, $root_container)));
36281
+
36282
+ return done($divP);
36283
+ };
36284
+
36285
+ const _$ = function ($elm) {
36286
+ try {
36287
+ const id = $elm.attr('xu-ui-id');
36288
+ if (!id || !glb.DEBUG_MODE) return $elm;
36289
+
36290
+ const $el = $(`[xu-ui-id="${id}"]`);
36291
+ if ($el.length > 1) {
36292
+ console.warn(`Multiple elements for xu-ui-id: ${id}`, $el);
36293
+ }
36294
+ return $($el[0]);
36295
+ } catch (e) {
36296
+ console.error(e);
36297
+ return $elm;
36298
+ }
36299
+ };
36300
+
36301
+ const hover_in = function ($div, e) {
36302
+ if (is_skeleton || (e && (EXP_BUSY || UI_WORKER_OBJ.jobs.length))) return;
36303
+
36304
+ CLIENT_ACTIVITY_TS = Date.now();
36305
+
36306
+ const containerXuData = _$($container)?.data()?.xuData;
36307
+ if (containerXuData?.debug_info) {
36308
+ containerXuData.debug_info.hover_item = $div.attr('xu-ui-id');
36309
+ }
36310
+
36311
+ if (!_ds) return;
36312
+
36313
+ // Set attributes
36314
+ const attributes = {};
36315
+ Array.from($div[0].attributes).forEach((attr) => {
36316
+ attributes[attr.name] = attr.value;
36317
+ });
36318
+ _session.DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
36319
+
36320
+ const divXuData = $div.data()?.xuData;
36321
+ if (!divXuData) return;
36322
+
36323
+ const _iterate_info = divXuData.iterate_info;
36324
+ if (_iterate_info) {
36325
+ const set_field_value = (field_id, value, is_dynamic) => {
36326
+ if (is_dynamic) {
36327
+ _ds.dynamic_fields[field_id].value = value;
36328
+ } else {
36329
+ try {
36330
+ const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
36331
+ _ds.data_feed.rows[row_idx][field_id] = value;
36332
+ } catch (err) {
36333
+ console.error(err);
36334
+ }
36335
+ }
36336
+ };
36337
+
36338
+ set_field_value(_iterate_info.iterator_key, _iterate_info._key, _iterate_info.is_key_dynamic_field);
36339
+ set_field_value(_iterate_info.iterator_val, _iterate_info._val, _iterate_info.is_val_dynamic_field);
36340
+ }
36341
+
36342
+ if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
36343
+ func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
36344
+ }
36345
+
36346
+ const iterate_data = $div?.data()?.xuData?.iterate_info;
36347
+ if (iterate_data) {
36348
+ const set_value = (field_id, value) => {
36349
+ func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId, field_id, field_value: value }, null, null, paramsP.dsSessionP);
36350
+ };
36351
+
36352
+ if (iterate_data.iterator_key) set_value(iterate_data.iterator_key, iterate_data._key);
36353
+ if (iterate_data.iterator_val) set_value(iterate_data.iterator_val, iterate_data._val);
36354
+ }
36355
+ };
36356
+
36357
+ const hover_out = function () {
36358
+ if (is_skeleton) return;
36359
+
36360
+ CLIENT_ACTIVITY_TS = Date.now();
36361
+
36362
+ const containerXuData = _$($container)?.data()?.xuData;
36363
+ if (containerXuData?.debug_info) {
36364
+ containerXuData.debug_info.hover_item = null;
36365
+ }
36366
+
36367
+ if (_ds?.data_system) {
36368
+ SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
36369
+ }
36370
+ };
36371
+
36372
+ const render_screen_type = async function ($div) {
36373
+ const set_call_screen_properties_values = async function (ui_framework) {
36374
+ params.properties = {};
36375
+
36376
+ const get_values = async function (property) {
36377
+ let property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
36378
+
36379
+ if (paramsP?.call_screen_propertiesP) {
36380
+ if (paramsP.call_screen_propertiesP[property]) {
36381
+ property_value = paramsP.call_screen_propertiesP[property];
36382
+ }
36383
+ const expKey = `xu-exp:${property}`;
36384
+ if (paramsP.call_screen_propertiesP[expKey]) {
36385
+ property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[expKey], paramsP.dsSessionP, property)).result;
35276
36386
  }
35277
36387
  }
35278
36388
  return property_value;
35279
36389
  };
36390
+
35280
36391
  params.properties['name'] = await get_values('menuTitle');
35281
- if (await ui_framework?.properties()) {
35282
- for await (const [key, val] of Object.entries(await ui_framework.properties())) {
36392
+ const uiProps = await ui_framework?.properties?.();
36393
+ if (uiProps) {
36394
+ for (const [key, val] of Object.entries(uiProps)) {
35283
36395
  params.properties[key] = await get_values(key);
35284
36396
  }
35285
36397
  }
35286
36398
  };
35287
36399
 
35288
- var $div_content = $div.children();
36400
+ const $div_content = $div.children();
35289
36401
 
35290
- $.each($div_content, function (key, val) {
35291
- if (!$(val)?.data()?.xuData?.parent_container) {
35292
- return true;
36402
+ // Update parent container for children
36403
+ $div_content.each((key, val) => {
36404
+ const xuData = $(val)?.data()?.xuData;
36405
+ if (xuData && !xuData.parent_container) {
36406
+ xuData.parent_container = $div.data().xuData.parent_container;
35293
36407
  }
35294
- $(val).data().xuData.parent_container = $div.data().xuData.parent_container;
35295
36408
  });
35296
36409
 
35297
36410
  let $ret = $div;
35298
- var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
35299
- var params;
36411
+ const $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
36412
+ let params;
36413
+
35300
36414
  switch (paramsP.screen_type) {
35301
36415
  case 'modal':
35302
- const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35303
- var xu_modal_controller = document.querySelector('xu-modal-controller');
36416
+ const modal_id = `app_modal-${paramsP.dsSessionP}`;
36417
+ let xu_modal_controller = document.querySelector('xu-modal-controller');
36418
+
35304
36419
  if (!xu_modal_controller) {
35305
36420
  func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35306
36421
  xu_modal_controller = document.querySelector('xu-modal-controller');
35307
36422
  }
35308
36423
 
35309
- var controller_params = $(xu_modal_controller).data('xuControllerParams');
35310
-
35311
- if (!controller_params) {
35312
- controller_params = {};
35313
- }
36424
+ let controller_params = $(xu_modal_controller).data('xuControllerParams') || {};
35314
36425
 
35315
36426
  params = {
35316
36427
  screenId: paramsP.screenId,
@@ -35324,25 +36435,20 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35324
36435
  };
35325
36436
 
35326
36437
  controller_params[modal_id] = params;
35327
-
35328
36438
  $(xu_modal_controller).data('xuControllerParams', controller_params);
35329
- const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
36439
+
36440
+ const modalController = new UI_FRAMEWORK_PLUGIN.modal();
35330
36441
  await set_call_screen_properties_values(modalController);
35331
- if (!APP_MODAL_OBJ[modal_id]) {
35332
- const modal = await modalController.create(params);
35333
36442
 
35334
- APP_MODAL_OBJ[modal_id] = modal;
36443
+ if (!APP_MODAL_OBJ[modal_id]) {
36444
+ APP_MODAL_OBJ[modal_id] = await modalController.create(params);
35335
36445
  } else {
35336
36446
  $(modal_id).empty();
35337
36447
  }
35338
-
35339
36448
  await modalController.init(params);
35340
-
35341
36449
  break;
35342
36450
 
35343
36451
  case 'popover':
35344
- // open_popover($div);
35345
-
35346
36452
  const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35347
36453
  params = {
35348
36454
  menuTitle: paramsP.screenInfo.properties?.menuTitle,
@@ -35356,13 +36462,11 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35356
36462
  await set_call_screen_properties_values(popover);
35357
36463
  await popover.open(params);
35358
36464
  CURRENT_APP_POPOVER = popover;
35359
-
35360
- func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
36465
+ func.UI.utils.screen_blocker(false, `${paramsP.prog_id}_${paramsP.sourceScreenP}`);
35361
36466
  break;
35362
36467
 
35363
36468
  case 'page':
35364
36469
  const nav = $nav[0];
35365
-
35366
36470
  params = {
35367
36471
  div: $div_content,
35368
36472
  name: paramsP.screenInfo.properties?.menuTitle,
@@ -35374,18 +36478,21 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35374
36478
  paramsP,
35375
36479
  };
35376
36480
 
35377
- var component_name = 'xu-page-component-' + paramsP.dsSessionP;
35378
- if (!$(nav).data().xuData.nav_params) {
35379
- $(nav).data().xuData.nav_params = {};
36481
+ const component_name = `xu-page-component-${paramsP.dsSessionP}`;
36482
+ const navXuData = $(nav).data().xuData;
36483
+
36484
+ if (!navXuData.nav_params) {
36485
+ navXuData.nav_params = {};
35380
36486
  }
35381
36487
 
35382
- //restore validate
35383
- if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
35384
- params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
36488
+ // Restore validate
36489
+ if (navXuData.params?.[paramsP.dsSessionP]) {
36490
+ params.$container.data().xuData.validate_screen_ready = navXuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
35385
36491
  }
35386
36492
 
35387
- if (!$(nav)?.data()?.xuData) return;
35388
- $(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
36493
+ if (!navXuData) return;
36494
+ navXuData.nav_params[paramsP.dsSessionP] = params;
36495
+
35389
36496
  if (!$(component_name).length) {
35390
36497
  await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
35391
36498
  const page = new UI_FRAMEWORK_PLUGIN.page();
@@ -35394,9 +36501,7 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35394
36501
  await page.init(params);
35395
36502
  nav.push(component_name, { params });
35396
36503
  } else {
35397
- debugger;
35398
36504
  $(component_name).empty();
35399
-
35400
36505
  await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
35401
36506
  }
35402
36507
  $div.data().xuData.paramsP = $container.data().xuData.paramsP;
@@ -35407,18 +36512,15 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35407
36512
  $ret = $container;
35408
36513
  break;
35409
36514
 
35410
- default: // set data to nav to use in the component
35411
- if ($nav && $nav.length) {
35412
- // refresh made
35413
- } else {
35414
- $nav = $('<xu-nav>'); //.attr('xu-ui-id', SESSION_ID);
36515
+ default:
36516
+ if (!$nav?.length) {
36517
+ $nav = $('<xu-nav>');
35415
36518
  $container.append($nav);
35416
36519
  func.UI.component.init_xu_nav($container, $nav);
35417
36520
  }
35418
36521
 
35419
36522
  $nav.data().xuData.$div = $div_content;
35420
-
35421
- await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
36523
+ await $nav[0].setRoot(`xu-root-component-${SESSION_ID}`);
35422
36524
  $ret = $container;
35423
36525
  break;
35424
36526
  }
@@ -35427,130 +36529,92 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35427
36529
 
35428
36530
  if (!(await init())) return;
35429
36531
  debug();
36532
+
35430
36533
  const fx = {
35431
36534
  widget: async function () {
35432
- var _session = SESSION_OBJ[SESSION_ID];
36535
+ const exist_elm_obj = get_element_info();
36536
+ let $div = exist_elm_obj.div;
35433
36537
 
35434
- var exist_elm_obj = get_element_info();
35435
- var $div = exist_elm_obj.div;
35436
36538
  if (!exist_elm_obj.div) {
35437
36539
  $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);
35438
36540
 
35439
- //////////////////////////
35440
-
35441
- let plugin_name = prop['xu-widget'],
35442
- method = prop['xu-method'],
35443
- dsP = paramsP.dsSessionP,
35444
- propsP = prop,
35445
- sourceP = 'widgets';
35446
-
35447
- // const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
35448
- // var obj = _.clone(docP);
35449
- // obj.date = await func.utils.get_dateTime(
35450
- // SESSION_ID,
35451
- // "SYS_DATE",
35452
- // docP.date
35453
- // );
35454
- // obj.time = await func.utils.get_dateTime(
35455
- // SESSION_ID,
35456
- // "SYS_TIME",
35457
- // docP.date
35458
- // );
35459
-
35460
- // var datasource_changes = {
35461
- // [0]: {
35462
- // ["data_system"]: {
35463
- // ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
35464
- // },
35465
- // },
35466
- // };
35467
- // await func.datasource.update(SESSION_ID, datasource_changes);
35468
- // };
35469
- const call_plugin_api = async function (plugin_nameP, dataP) {
36541
+ const plugin_name = prop['xu-widget'];
36542
+ const method = prop['xu-method'];
36543
+ const dsP = paramsP.dsSessionP;
36544
+ const propsP = prop;
36545
+ const sourceP = 'widgets';
36546
+
36547
+ const call_plugin_api = async (plugin_nameP, dataP) => {
35470
36548
  return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
35471
36549
  };
35472
- const report_error = function (descP, warn) {
35473
- func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
36550
+
36551
+ const report_error = (descP, warn) => {
36552
+ func.utils.debug.log(SESSION_ID, `${_session.DS_GLB[dsP].prog_id}_${_session.DS_GLB[dsP].callingMenuId}`, {
35474
36553
  module: 'widgets',
35475
36554
  action: 'Init',
35476
36555
  source: sourceP,
35477
36556
  prop: descP,
35478
36557
  details: descP,
35479
36558
  result: null,
35480
- error: warn ? false : true,
36559
+ error: !warn,
35481
36560
  fields: null,
35482
36561
  type: 'widgets',
35483
36562
  prog_id: _session.DS_GLB[dsP].prog_id,
35484
36563
  });
35485
36564
  };
35486
- const get_fields_data = async function (fields, props) {
35487
- const report_error = function (descP, warn) {
35488
- func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35489
- module: 'widgets',
35490
- action: 'Init',
35491
- source: sourceP,
35492
- prop: descP,
35493
- details: descP,
35494
- result: null,
35495
- error: warn ? false : true,
35496
- fields: null,
35497
- type: 'widgets',
35498
- prog_id: _session.DS_GLB[dsP].prog_id,
35499
- });
35500
- };
35501
- const get_property_value = async function (fieldIdP, val) {
36565
+
36566
+ const get_fields_data = async (fields, props) => {
36567
+ const get_property_value = async (fieldIdP, val) => {
35502
36568
  if (!val) return;
35503
- var value = fieldIdP in props ? props[fieldIdP] : typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue;
36569
+
36570
+ let value = fieldIdP in props ? props[fieldIdP] : typeof val.defaultValue === 'function' ? val.defaultValue() : val.defaultValue;
36571
+
35504
36572
  if (val.render === 'eventId') {
35505
36573
  value = props?.[fieldIdP]?.event;
35506
36574
  }
35507
36575
 
35508
- if (props[`xu-exp:${fieldIdP}`]) {
35509
- value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
36576
+ const expKey = `xu-exp:${fieldIdP}`;
36577
+ if (props[expKey]) {
36578
+ value = (await func.expression.get(SESSION_ID, props[expKey], dsP, 'widget property')).result;
35510
36579
  }
35511
36580
 
35512
- return func.common.get_cast_val(
35513
- SESSION_ID,
35514
- 'widgets',
35515
- fieldIdP,
35516
- val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
35517
- value,
35518
- null,
35519
- );
36581
+ return func.common.get_cast_val(SESSION_ID, 'widgets', fieldIdP, val.type, value, null);
35520
36582
  };
35521
- var data_obj = {};
35522
- var return_code = 1;
35523
- // $.each(fields, function (key, val) {
35524
- for await (const [key, val] of Object.entries(fields)) {
36583
+
36584
+ const data_obj = {};
36585
+ let return_code = 1;
36586
+
36587
+ for (const [key, val] of Object.entries(fields)) {
35525
36588
  data_obj[key] = await get_property_value(key, val);
35526
36589
  if (!data_obj[key] && val.mandatory) {
35527
36590
  return_code = -1;
35528
36591
  report_error(`${key} is a mandatory field.`);
35529
36592
  break;
35530
36593
  }
35531
- // console.log(val);
35532
- }
35533
- for await (const key of ['xu-bind']) {
35534
- data_obj[key] = await get_property_value(key, props[key]);
35535
36594
  }
35536
36595
 
36596
+ data_obj['xu-bind'] = await get_property_value('xu-bind', props['xu-bind']);
36597
+
35537
36598
  return { code: return_code, data: data_obj };
35538
36599
  };
35539
36600
 
35540
- const load_css_style = function () {
35541
- const get_css_path = function (resource) {
36601
+ const load_css_style = () => {
36602
+ const get_css_path = (resource) => {
35542
36603
  if (_session.worker_type === 'Dev') {
35543
36604
  return `../../plugins/${plugin_name}/${resource}`;
35544
36605
  }
35545
- 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}`;
36606
+ const manifest = APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest[resource];
36607
+ const dist = manifest.dist ? 'dist/' : '';
36608
+ return `https://${_session.domain}/plugins/${plugin_name}/${dist}${resource}?gtp_token=${_session.gtp_token}&app_id=${_session.app_id}`;
35546
36609
  };
35547
- let path = get_css_path('style.css');
35548
- func.utils.load_css_on_demand(path);
36610
+ func.utils.load_css_on_demand(get_css_path('style.css'));
35549
36611
  };
35550
36612
 
35551
36613
  const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
35552
- const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
36614
+ const indexDist = _plugin.manifest['index.mjs'].dist ? 'dist/' : '';
36615
+ const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${indexDist}index.mjs`);
35553
36616
  const methods = index.methods;
36617
+
35554
36618
  if (methods && !methods[method]) {
35555
36619
  return report_error('method not found');
35556
36620
  }
@@ -35559,18 +36623,13 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35559
36623
  if (fields_ret.code < 0) {
35560
36624
  return report_error(fields_ret.data);
35561
36625
  }
35562
- const fields = fields_ret.data;
35563
36626
 
35564
- let exclude_attributes = [];
35565
- for await (const [key, val] of Object.entries(propsP)) {
35566
- if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
35567
- exclude_attributes.push(key);
35568
- }
35569
- }
36627
+ const fields = fields_ret.data;
36628
+ const exclude_attributes = Object.keys(propsP).filter((key) => fields[key] !== undefined || fields[`xu-exp:${key}`] !== undefined);
35570
36629
 
35571
- 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);
36630
+ const 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);
35572
36631
 
35573
- $div.addClass('widget_wrapper'); // class get override in set_attributes_new
36632
+ $div.addClass('widget_wrapper');
35574
36633
 
35575
36634
  if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
35576
36635
  return report_error(`plugin ${plugin_name} not found`);
@@ -35605,23 +36664,23 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35605
36664
  plugin_name,
35606
36665
  $containerP: $div,
35607
36666
  plugin_setup: plugin_setup_ret.data,
35608
-
35609
36667
  report_error,
35610
36668
  call_plugin_api,
35611
- // set_SYS_GLOBAL_OBJ_WIDGET_INFO,
35612
36669
  api_utils,
35613
36670
  };
35614
36671
 
35615
- const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
36672
+ const runtimeDist = _plugin.manifest['runtime.mjs'].dist ? 'dist/' : '';
36673
+ const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${runtimeDist}runtime.mjs`);
35616
36674
 
35617
36675
  if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
35618
- const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
35619
- func.utils.load_css_on_demand(plugin_runtime_css_url);
36676
+ const css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
36677
+ func.utils.load_css_on_demand(css_url);
35620
36678
  }
35621
36679
 
35622
36680
  if (!fx[method]) {
35623
36681
  throw `Method: ${method} does not exist`;
35624
36682
  }
36683
+
35625
36684
  try {
35626
36685
  await fx[method](fields, params);
35627
36686
  } catch (err) {
@@ -35630,12 +36689,13 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35630
36689
  }
35631
36690
  return $div;
35632
36691
  },
35633
- [`xu-single-view`]: async function () {
35634
- var exist_elm_obj = get_element_info();
35635
- var $div = exist_elm_obj.div;
36692
+
36693
+ 'xu-single-view': async function () {
36694
+ const exist_elm_obj = get_element_info();
36695
+ let $div = exist_elm_obj.div;
35636
36696
 
35637
36697
  if (!exist_elm_obj.div) {
35638
- var $wrapper = $('<div>');
36698
+ const $wrapper = $('<div>');
35639
36699
  $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, '');
35640
36700
 
35641
36701
  if (!$div) return;
@@ -35645,67 +36705,41 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35645
36705
  }
35646
36706
 
35647
36707
  $div.hover(
35648
- function (e) {
35649
- hover_in();
35650
- // func.UI.screen.hover_in(SESSION_ID, null, $container, paramsP, is_skeleton);
35651
- },
35652
- function (e) {
35653
- // func.UI.screen.hover_out(SESSION_ID, $container, is_skeleton, paramsP);
35654
- hover_out();
35655
- },
36708
+ (e) => hover_in(),
36709
+ (e) => hover_out(),
35656
36710
  );
35657
36711
  }
35658
36712
 
35659
- const ret = await iterate_child($div, nodeP, null, $div);
36713
+ await iterate_child($div, nodeP, null, $div);
36714
+
35660
36715
  if (_.isEmpty($container.data().xuAttributes)) {
35661
36716
  await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35662
36717
  }
35663
36718
 
35664
- $.each($div.data().xuData, function (key, val) {
35665
- $container.data().xuData[key] = _.cloneDeep(val);
35666
- });
35667
- $.each($div.data().xuAttributes, function (key, val) {
35668
- // $container.data().xuAttributes[key] = _.cloneDeep(val);
35669
- $container.data().xuAttributes[key] = klona.klona(val);
35670
- });
36719
+ // Copy xuData and xuAttributes
36720
+ Object.assign($container.data().xuData, _.cloneDeep($div.data().xuData));
36721
+ Object.assign($container.data().xuAttributes, klona.klona($div.data().xuAttributes));
35671
36722
 
35672
36723
  return await render_screen_type($div);
35673
36724
  },
35674
- [`xu-multi-view`]: async function () {
35675
- var $div = $container;
35676
36725
 
35677
- if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
35678
- $div.data().xuData.node = nodeP;
36726
+ 'xu-multi-view': async function () {
36727
+ let $div = $container;
36728
+
36729
+ const divXuData = $div.data().xuData;
36730
+ if (!divXuData.node || !divXuData.node.children) {
36731
+ divXuData.node = nodeP;
35679
36732
  }
35680
36733
 
35681
- if (!$div.data().xuData.debug_info) {
35682
- $div.data().xuData.debug_info = {
36734
+ if (!divXuData.debug_info) {
36735
+ divXuData.debug_info = {
35683
36736
  id: nodeP.id,
35684
36737
  parent_id: $container.data().xuData.ui_id,
35685
36738
  };
35686
36739
  }
35687
36740
 
35688
36741
  const done = async function (continuous_idx) {
35689
- // const do_callback = async function ($div) {
35690
- // // if ($root_container.data().xuData.progress_bar_circle) {
35691
- // // setTimeout(function () {
35692
- // // $.each(
35693
- // // $root_container.data().xuData.progress_bar_circle,
35694
- // // function (key, val) {
35695
- // // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
35696
- // // }
35697
- // // );
35698
- // // }, 2000);
35699
- // // }
35700
-
35701
- // if (paramsP.screenInfo.properties?.rtl) {
35702
- // $div_content.attr('dir', 'rtl');
35703
- // }
35704
-
35705
- // return $div;
35706
- // };
35707
36742
  await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35708
-
35709
36743
  return await render_screen_type($div);
35710
36744
  };
35711
36745
 
@@ -35714,351 +36748,150 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
35714
36748
  }
35715
36749
 
35716
36750
  const empty_result = async function () {
35717
- // var content = prop.empty_result_content || '';
35718
-
35719
- // var res = await func.expression.get(
35720
- // SESSION_ID,
35721
- // content, // prop["xu-exp:empty_result_content"],
35722
- // paramsP.dsSessionP,
35723
- // 'empty_result_content_EXP',
35724
- // _ds.currentRecordId,
35725
- // );
35726
- // content = res.result;
35727
-
35728
- // let empty_result_node = {
35729
- // type: 'element',
35730
- // id: crypto.randomUUID(),
35731
- // content,
35732
- // // : content || (typeof content === "undefined" && "Empty results"),
35733
- // tagName: 'div',
35734
- // attributes: {},
35735
- // children: [],
35736
- // };
35737
-
35738
- // 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);
35739
36751
  await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
35740
36752
  return await done(null);
35741
36753
  };
35742
- var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
35743
-
35744
- var continuous_idx = null;
35745
36754
 
35746
36755
  if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
35747
36756
  return await empty_result();
35748
36757
  }
35749
36758
 
35750
- var i = 0;
35751
- for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
35752
- var node = JSON.parse(JSON.stringify(nodeP));
35753
-
36759
+ for (const [key, val] of Object.entries(_ds.data_feed.rows)) {
36760
+ const node = JSON.parse(JSON.stringify(nodeP));
35754
36761
  _ds.currentRecordId = val._ROWID;
35755
- const ret = await iterate_child($div, node, { continuous_idx }, $root_container);
36762
+ await iterate_child($div, node, { continuous_idx: null }, $root_container);
35756
36763
 
35757
36764
  if (_.isEmpty($container.data().xuAttributes)) {
35758
36765
  await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35759
36766
  }
35760
36767
  }
35761
36768
 
35762
- return await done(continuous_idx);
36769
+ return await done(null);
35763
36770
  },
35764
- [`xu-panel`]: async function () {
36771
+
36772
+ 'xu-panel': async function () {
35765
36773
  const done = async function ($new_div) {
35766
36774
  if (!$container.data()?.xuData?.paramsP) {
35767
36775
  return $container;
35768
36776
  }
35769
- var $div_items = $div.data().xuData.node.children;
35770
36777
 
36778
+ const $div_items = $div.data().xuData.node.children;
35771
36779
  await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
35772
-
35773
- // TO FIX should be timeout
35774
36780
  $container.data().xuData.node.children = $div_items;
35775
-
35776
36781
  return $container;
35777
36782
  };
35778
36783
 
35779
- var $wrapper = $('<div>');
35780
- $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, '');
36784
+ const $wrapper = $('<div>');
36785
+ const $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, '');
36786
+
36787
+ const 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);
35781
36788
 
35782
- 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);
35783
36789
  if (ret.abort) {
35784
- // render N
35785
36790
  return (ret.$new_div = $('<template>').append($div));
35786
36791
  }
35787
36792
 
35788
36793
  let $ret_panel_div = ret.$new_div;
35789
36794
 
35790
- if (!$ret_panel_div?.children()?.length) {
35791
- ////// render default children tree
35792
- if (nodeP.children.length) {
35793
- $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);
35794
- }
36795
+ if (!$ret_panel_div?.children()?.length && nodeP.children.length) {
36796
+ $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);
35795
36797
  }
35796
36798
 
35797
- let ret_done = await done($ret_panel_div);
35798
-
35799
- return ret_done;
36799
+ return await done($ret_panel_div);
35800
36800
  },
35801
36801
  };
35802
36802
 
35803
- const draw_html_element_org = async function (element) {
35804
- const done = async function (ret = {}) {
35805
- return $div;
35806
- };
35807
- if (!element || element === 'script') return await done();
35808
- let str = '';
35809
-
35810
- 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);
35811
-
35812
- $div.hover(
35813
- function (e) {
35814
- hover_in($div, e);
35815
- },
35816
- function (e) {
35817
- hover_out();
35818
- },
35819
- );
35820
- if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35821
- $div.on('click contextmenu', function (e) {
35822
- hover_in($div, e);
35823
- });
35824
- }
35825
-
35826
- // 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);
35827
- 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);
35828
- 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'])) {
35829
- return await done(ret);
35830
- }
35831
- // check if iterator made to prevent children render
35832
-
35833
- if (nodeP?.attributes?.['xu-viewport'] == 'true') {
35834
- // const xu_viewport = async function () {
35835
- // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
35836
- // const container_id = $container.attr('xu-ui-id');
35837
- // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
35838
- // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
35839
- // await iterate_child($div, nodeP, parent_infoP, $root_container);
35840
- // } else {
35841
- // $div.remove();
35842
- // }
35843
- // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
35844
-
35845
- // // if (!$div.children().length) {
35846
- // // // render the first element to determine height
35847
- // // await iterate_child($div, nodeP, parent_infoP, $root_container);
35848
- // // // hover_in($div);
35849
- // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
35850
- // // } else {
35851
- // // }
35852
- // };
35853
- const xu_viewport = function () {
35854
- const observer_inViewport = new IntersectionObserver(
35855
- function (entries) {
35856
- entries.forEach((entry) => {
35857
- if (entry.isIntersecting) {
35858
- $(entry.target).trigger('inViewport');
35859
-
35860
- // Optional: stop observing once triggered
35861
- observer_inViewport.unobserve(entry.target);
35862
- }
35863
- });
35864
- },
35865
- {
35866
- threshold: 0.1, // Trigger when 10% of element is visible
35867
- },
35868
- );
35869
-
35870
- const observer_outViewport = new IntersectionObserver(
35871
- function (entries) {
35872
- entries.forEach((entry) => {
35873
- if (!entry.isIntersecting) {
35874
- // Element is OUT of viewport - trigger custom event
35875
- $(entry.target).trigger('outViewport');
35876
-
35877
- // Optional: stop observing once triggered
35878
- // observer_outViewport.unobserve(entry.target);
35879
- }
35880
- });
35881
- },
35882
- {
35883
- threshold: 0, // Trigger when element is completely out of view
35884
- },
35885
- );
35886
-
35887
- let ui_job_id;
35888
- $div.on('inViewport', function () {
35889
- if ($div.children().length) {
35890
- $div.removeClass('skeleton');
35891
- return;
35892
- }
35893
-
35894
- // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
35895
- // $div[0].style.removeProperty('height');
35896
- // $div.removeClass('skeleton');
35897
- // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
35898
- // } else {
35899
- hover_in($div);
35900
- 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);
35901
- // }
35902
- observer_outViewport.observe($div[0]);
35903
- });
35904
-
35905
- $div.on('outViewport', function () {
35906
- func.UI.worker.delete_job(SESSION_ID, ui_job_id);
35907
-
35908
- if ($div.children().length) {
35909
- // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
35910
- $div.empty();
35911
- const height = $div?.data()?.xuData?.viewport_height || 10;
35912
- if (typeof height !== 'undefined') {
35913
- $div.css('height', height);
35914
- }
35915
- }
35916
- // $div.addClass('skeleton');
35917
- observer_inViewport.observe($div[0]);
35918
- });
35919
- $div.addClass('skeleton');
35920
- observer_inViewport.observe($div[0]);
35921
- };
35922
- xu_viewport();
35923
- } else {
35924
- await iterate_child($div, nodeP, parent_infoP, $root_container);
35925
- }
35926
-
35927
- // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
35928
- return await done(ret);
35929
- };
35930
-
35931
36803
  const draw_html_element = async function (element) {
35932
36804
  const done = async function (ret = {}) {
35933
36805
  const xu_ui_id = $div.attr('xu-ui-id');
35934
36806
  $div.removeClass('display_none');
35935
- if (ret.has_xu_exp_render_attribute) {
35936
- // $div.css('display', 'unset');
35937
36807
 
36808
+ if (ret.has_xu_exp_render_attribute) {
35938
36809
  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 || {}));
36810
+
35939
36811
  const _$div = $div.clone(true);
35940
- UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: _$div, paramsP, data: _$div.data() };
36812
+ UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = {
36813
+ $div: _$div,
36814
+ paramsP,
36815
+ data: _$div.data(),
36816
+ };
36817
+
35941
36818
  nodeP.xu_render_xu_ui_id = xu_ui_id;
35942
36819
  nodeP.xu_render_cache_id = xu_render_cache_id;
35943
36820
 
35944
36821
  if (ret.xu_render_background_processing) {
35945
- temp_$div.remove();
35946
- // $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
35947
- return $div;
35948
- } else {
35949
- // $div.css('display', 'unset');
35950
- temp_$div.replaceWith($div);
35951
- return $div;
35952
- }
35953
- } else {
35954
- if (ret.has_xu_render_attribute) {
35955
36822
  temp_$div.remove();
35956
36823
  return $div;
35957
36824
  }
35958
- // $div.css('display', 'unset');
35959
36825
  temp_$div.replaceWith($div);
35960
36826
  return $div;
35961
36827
  }
36828
+
36829
+ if (ret.has_xu_render_attribute) {
36830
+ temp_$div.remove();
36831
+ return $div;
36832
+ }
36833
+
36834
+ temp_$div.replaceWith($div);
36835
+ return $div;
35962
36836
  };
35963
- if (!element || element === 'script') return await done();
35964
- let str = '';
35965
36837
 
35966
- 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);
36838
+ if (!element || element === 'script') return await done();
35967
36839
 
35968
- let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
35969
- let $div = temp_$div.clone(true);
36840
+ const 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, '', true);
35970
36841
 
35971
- // $div.css('display', 'none');
36842
+ const temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
36843
+ const $div = temp_$div.clone(true);
35972
36844
 
35973
36845
  $div.hover(
35974
- function (e) {
35975
- hover_in($div, e);
35976
- },
35977
- function (e) {
35978
- hover_out();
35979
- },
36846
+ (e) => hover_in($div, e),
36847
+ (e) => hover_out(),
35980
36848
  );
36849
+
35981
36850
  if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35982
- $div.on('click contextmenu', function (e) {
35983
- hover_in($div, e);
35984
- });
36851
+ $div.on('click contextmenu', (e) => hover_in($div, e));
35985
36852
  }
35986
36853
 
35987
- 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);
35988
- 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'])) {
36854
+ const 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);
36855
+
36856
+ if (ret.abort || nodeTag === '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'])) {
35989
36857
  return await done(ret);
35990
36858
  }
35991
- // check if iterator made to prevent children render
35992
-
35993
- if (nodeP?.attributes?.['xu-viewport'] == 'true') {
35994
- // const xu_viewport = async function () {
35995
- // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
35996
- // const container_id = $container.attr('xu-ui-id');
35997
- // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
35998
- // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
35999
- // await iterate_child($div, nodeP, parent_infoP, $root_container);
36000
- // } else {
36001
- // $div.remove();
36002
- // }
36003
- // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36004
-
36005
- // // if (!$div.children().length) {
36006
- // // // render the first element to determine height
36007
- // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36008
- // // // hover_in($div);
36009
- // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
36010
- // // } else {
36011
- // // }
36012
- // };
36859
+
36860
+ if (nodeP?.attributes?.['xu-viewport'] === 'true') {
36013
36861
  const xu_viewport = function () {
36014
36862
  const observer_inViewport = new IntersectionObserver(
36015
- function (entries) {
36863
+ (entries) => {
36016
36864
  entries.forEach((entry) => {
36017
36865
  if (entry.isIntersecting) {
36018
36866
  $(entry.target).trigger('inViewport');
36019
-
36020
- // Optional: stop observing once triggered
36021
36867
  observer_inViewport.unobserve(entry.target);
36022
36868
  }
36023
36869
  });
36024
36870
  },
36025
- {
36026
- threshold: 0.1, // Trigger when 10% of element is visible
36027
- },
36871
+ { threshold: 0.1 },
36028
36872
  );
36029
36873
 
36030
36874
  const observer_outViewport = new IntersectionObserver(
36031
- function (entries) {
36875
+ (entries) => {
36032
36876
  entries.forEach((entry) => {
36033
36877
  if (!entry.isIntersecting) {
36034
- // Element is OUT of viewport - trigger custom event
36035
36878
  $(entry.target).trigger('outViewport');
36036
-
36037
- // Optional: stop observing once triggered
36038
- // observer_outViewport.unobserve(entry.target);
36039
36879
  }
36040
36880
  });
36041
36881
  },
36042
- {
36043
- threshold: 0, // Trigger when element is completely out of view
36044
- },
36882
+ { threshold: 0 },
36045
36883
  );
36046
36884
 
36047
36885
  let ui_job_id;
36886
+
36048
36887
  $div.on('inViewport', function () {
36049
36888
  if ($div.children().length) {
36050
36889
  $div.removeClass('skeleton');
36051
36890
  return;
36052
36891
  }
36053
36892
 
36054
- // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
36055
- // $div[0].style.removeProperty('height');
36056
- // $div.removeClass('skeleton');
36057
- // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
36058
- // } else {
36059
36893
  hover_in($div);
36060
36894
  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);
36061
- // }
36062
36895
  observer_outViewport.observe($div[0]);
36063
36896
  });
36064
36897
 
@@ -36066,66 +36899,49 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
36066
36899
  func.UI.worker.delete_job(SESSION_ID, ui_job_id);
36067
36900
 
36068
36901
  if ($div.children().length) {
36069
- // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
36070
36902
  $div.empty();
36071
36903
  const height = $div?.data()?.xuData?.viewport_height || 10;
36072
- if (typeof height !== 'undefined') {
36904
+ if (height !== undefined) {
36073
36905
  $div.css('height', height);
36074
36906
  }
36075
36907
  }
36076
- // $div.addClass('skeleton');
36077
36908
  observer_inViewport.observe($div[0]);
36078
36909
  });
36910
+
36079
36911
  $div.addClass('skeleton');
36080
36912
  observer_inViewport.observe($div[0]);
36081
36913
  };
36082
36914
  xu_viewport();
36083
36915
  } else {
36084
- // if (ret.xu_render_background_processing) {
36085
- // // let temp_$div = $div.clone(true);
36086
- // iterate_child($div, nodeP, parent_infoP, $root_container);
36087
- // } else {
36088
- // await iterate_child($div, nodeP, parent_infoP, $root_container);
36089
- // }
36090
36916
  if (!ret.xu_render_background_processing) {
36091
36917
  iterate_child($div, nodeP, parent_infoP, $root_container);
36092
36918
  }
36093
36919
  }
36094
36920
 
36095
- // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
36096
36921
  return await done(ret);
36097
36922
  };
36098
36923
 
36924
+ // Handle content attribute
36099
36925
  if (nodeP.content && nodeP.attributes) {
36100
36926
  nodeP.attributes['xu-content'] = nodeP.content;
36101
36927
  }
36102
36928
 
36103
- if (nodeP.tagName === 'xu-widget') {
36929
+ // Handle xu-widget
36930
+ if (nodeTag === 'xu-widget') {
36104
36931
  if (is_skeleton) return;
36105
36932
  return await fx['widget']();
36106
36933
  }
36107
- if (fx[nodeP.tagName]) {
36108
- return await fx[nodeP.tagName]();
36934
+
36935
+ // Handle custom tags
36936
+ if (fx[nodeTag]) {
36937
+ return await fx[nodeTag]();
36109
36938
  }
36110
- // const xu_viewport = async function () {
36111
- // const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36112
- // const container_id = $container.attr('xu-ui-id');
36113
- // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36114
- // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36115
- // await iterate_child($div, nodeP, parent_infoP, $root_container);
36116
- // }
36117
- // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36118
- // };
36119
36939
 
36120
- // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36121
- // return await xu_viewport();
36122
- // } else {
36940
+ // Render HTML element
36123
36941
  if (!glb.new_xu_render) {
36124
- return await draw_html_element_org(nodeP.tagName);
36942
+ return await draw_html_element_org(nodeTag);
36125
36943
  }
36126
- return await draw_html_element(nodeP.tagName);
36127
-
36128
- // }
36944
+ return await draw_html_element(nodeTag);
36129
36945
  };
36130
36946
 
36131
36947
  func.UI.screen.refresh_document_changes_for_realtime_update = async function (SESSION_ID, doc_change) {