directual-web-components-v2 3.11.326 → 3.11.327

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14741,6 +14741,7 @@ function FpsCards2(_ref2) {
14741
14741
  const [loading, setLoading] = React.useState(false);
14742
14742
  const [initialLoading, setInitialLoading] = React.useState(debug ? false : true);
14743
14743
  const isFirstRender = React.useRef(true);
14744
+ const isRestoringFromUrl = React.useRef(false);
14744
14745
  const cardsContainerRef = React.useRef(null);
14745
14746
  const updatePageInUrl = newPage => {
14746
14747
  const urlParams = new URLSearchParams(window.location.search);
@@ -14755,6 +14756,11 @@ function FpsCards2(_ref2) {
14755
14756
  console.log(sort);
14756
14757
  setDQL(dql);
14757
14758
  setSort(sort);
14759
+ if (isRestoringFromUrl.current) {
14760
+ console.log('Restoring filters from URL, skipping refresh');
14761
+ isRestoringFromUrl.current = false;
14762
+ return;
14763
+ }
14758
14764
  if (page == 0) {
14759
14765
  refresh(dql, sort);
14760
14766
  } else {
@@ -15189,31 +15195,79 @@ function FpsCards2(_ref2) {
15189
15195
  console.log("Cards2 Debug mode: using data from props, skipping API calls");
15190
15196
  return;
15191
15197
  }
15192
- const hasFiltersInUrl = () => {
15193
- if (!comp_ID || typeof window === 'undefined') return false;
15198
+ const getFiltersFromUrl = () => {
15199
+ if (!comp_ID || typeof window === 'undefined') return {
15200
+ dql: '',
15201
+ sort: {}
15202
+ };
15194
15203
  const urlParams = new URLSearchParams(window.location.search);
15195
- return urlParams.has("filters_" + comp_ID) || urlParams.has("sort_" + comp_ID);
15204
+ const filtersParam = urlParams.get("filters_" + comp_ID);
15205
+ const sortParam = urlParams.get("sort_" + comp_ID);
15206
+ let urlDql = '';
15207
+ let urlSort = {};
15208
+ if (filtersParam) {
15209
+ try {
15210
+ const filters = JSON.parse(decodeURIComponent(filtersParam));
15211
+ const dqlParts = Object.keys(filters).filter(key => {
15212
+ return filters[key].value || filters[key].valueFrom || filters[key].valueTo;
15213
+ }).map(key => {
15214
+ const f = filters[key];
15215
+ if (f.type === 'string' || f.type === 'boolean') {
15216
+ return "('" + key + "' like '" + f.value + "')";
15217
+ }
15218
+ if (f.type === 'multiOptions' && f.value) {
15219
+ return '(' + Object.keys(f.value).map(v => "('" + key + "' like '" + v + "')").join(' OR ') + ')';
15220
+ }
15221
+ if (f.type === 'date' || f.type === 'number') {
15222
+ const parts = [];
15223
+ if (f.valueFrom) parts.push("('" + key + "' >= '" + f.valueFrom + "')");
15224
+ if (f.valueTo) parts.push("('" + key + "' <= '" + f.valueTo + "')");
15225
+ return parts.join(' AND ');
15226
+ }
15227
+ return '';
15228
+ }).filter(Boolean);
15229
+ urlDql = dqlParts.join(' AND ');
15230
+ } catch (e) {
15231
+ console.error('Failed to parse filters from URL:', e);
15232
+ }
15233
+ }
15234
+ if (sortParam && sortParam.includes(':')) {
15235
+ const [field, direction] = sortParam.split(':');
15236
+ urlSort = {
15237
+ field,
15238
+ direction
15239
+ };
15240
+ }
15241
+ return {
15242
+ dql: urlDql,
15243
+ sort: urlSort
15244
+ };
15196
15245
  };
15197
15246
  const urlPage = getPageFromUrl() || 0;
15198
- if (hasFiltersInUrl()) {
15199
- console.log("Filters found in URL, skipping initial load - TableTitle will handle it");
15200
- setInitialLoading(false);
15201
- return;
15247
+ const {
15248
+ dql: urlDql,
15249
+ sort: urlSort
15250
+ } = getFiltersFromUrl();
15251
+ if (urlDql || urlSort.field) {
15252
+ isRestoringFromUrl.current = true;
15253
+ setDQL(urlDql);
15254
+ setSort(urlSort);
15202
15255
  }
15203
15256
  if (data && data.sl) {
15204
- console.log("Loading initial page from URL: " + urlPage);
15257
+ console.log("Loading initial data from URL: page=" + urlPage + ", dql=" + urlDql);
15205
15258
  setPageLoading(true);
15259
+ const sortString = urlSort && urlSort.field ? urlSort.field + ":" + (urlSort.direction || 'asc') : '';
15206
15260
  callEndpointGET(data.sl, {
15207
15261
  pageSize: data.pageSize || 10,
15208
15262
  page: urlPage,
15209
- dql: '',
15210
- sort: ''
15211
- }, (result, data) => {
15212
- const dataInfo = _$1__default.get(data, "result.data", {});
15213
- if (dataInfo && dataInfo.content) {
15214
- delete dataInfo.content;
15263
+ dql: urlDql,
15264
+ sort: sortString
15265
+ }, (result, responseData) => {
15266
+ const newDataInfo = _$1__default.get(responseData, "result.data", {});
15267
+ if (newDataInfo && newDataInfo.content) {
15268
+ delete newDataInfo.content;
15215
15269
  }
15216
- setDataInfo(dataInfo);
15270
+ setDataInfo(newDataInfo);
15217
15271
  setObjects(result);
15218
15272
  setPageLoading(false);
15219
15273
  setInitialLoading(false);
@@ -23129,6 +23183,7 @@ function FpsTable(_ref) {
23129
23183
  const [pageLoading, setPageLoading] = React.useState(false);
23130
23184
  const [dataInfo, setDataInfo] = React.useState({});
23131
23185
  const isFirstRender = React.useRef(true);
23186
+ const isRestoringFromUrl = React.useRef(false);
23132
23187
  function callEndpointGET(endpoint, params, finish) {
23133
23188
  console.log('===> calling endpoint GET /' + endpoint);
23134
23189
  const httpParams = _$1__default.get(currentData, "params.httpParams") || _$1__default.get(currentData, "httpParams") || {};
@@ -23170,6 +23225,11 @@ function FpsTable(_ref) {
23170
23225
  setSort(sortParam);
23171
23226
  setCurrentDQL(dqlParam);
23172
23227
  setCurrentSort(sortParam);
23228
+ if (isRestoringFromUrl.current) {
23229
+ console.log('Restoring filters from URL, skipping refresh');
23230
+ isRestoringFromUrl.current = false;
23231
+ return;
23232
+ }
23173
23233
  if (page == 0) {
23174
23234
  refresh(dqlParam, sortParam);
23175
23235
  } else {
@@ -23443,24 +23503,75 @@ function FpsTable(_ref) {
23443
23503
  refresh(dql, sort);
23444
23504
  }, [page]);
23445
23505
  React.useEffect(() => {
23446
- const hasFiltersInUrl = () => {
23447
- if (!comp_ID || typeof window === 'undefined') return false;
23506
+ const getFiltersFromUrl = () => {
23507
+ if (!comp_ID || typeof window === 'undefined') return {
23508
+ dql: '',
23509
+ sort: {}
23510
+ };
23448
23511
  const urlParams = new URLSearchParams(window.location.search);
23449
- return urlParams.has("filters_" + comp_ID) || urlParams.has("sort_" + comp_ID);
23512
+ const filtersParam = urlParams.get("filters_" + comp_ID);
23513
+ const sortParam = urlParams.get("sort_" + comp_ID);
23514
+ let urlDql = '';
23515
+ let urlSort = {};
23516
+ if (filtersParam) {
23517
+ try {
23518
+ const filters = JSON.parse(decodeURIComponent(filtersParam));
23519
+ const dqlParts = Object.keys(filters).filter(key => {
23520
+ return filters[key].value || filters[key].valueFrom || filters[key].valueTo;
23521
+ }).map(key => {
23522
+ const f = filters[key];
23523
+ if (f.type === 'string' || f.type === 'boolean') {
23524
+ return "('" + key + "' like '" + f.value + "')";
23525
+ }
23526
+ if (f.type === 'multiOptions' && f.value) {
23527
+ return '(' + Object.keys(f.value).map(v => "('" + key + "' like '" + v + "')").join(' OR ') + ')';
23528
+ }
23529
+ if (f.type === 'date' || f.type === 'number') {
23530
+ const parts = [];
23531
+ if (f.valueFrom) parts.push("('" + key + "' >= '" + f.valueFrom + "')");
23532
+ if (f.valueTo) parts.push("('" + key + "' <= '" + f.valueTo + "')");
23533
+ return parts.join(' AND ');
23534
+ }
23535
+ return '';
23536
+ }).filter(Boolean);
23537
+ urlDql = dqlParts.join(' AND ');
23538
+ } catch (e) {
23539
+ console.error('Failed to parse filters from URL:', e);
23540
+ }
23541
+ }
23542
+ if (sortParam && sortParam.includes(':')) {
23543
+ const [field, direction] = sortParam.split(':');
23544
+ urlSort = {
23545
+ field,
23546
+ direction
23547
+ };
23548
+ }
23549
+ return {
23550
+ dql: urlDql,
23551
+ sort: urlSort
23552
+ };
23450
23553
  };
23451
- if (hasFiltersInUrl()) {
23452
- console.log("Filters found in URL, skipping initial load - TableTitle will handle it");
23453
- return;
23454
- }
23455
23554
  const urlPage = getPageFromUrl() || 0;
23555
+ const {
23556
+ dql: urlDql,
23557
+ sort: urlSort
23558
+ } = getFiltersFromUrl();
23559
+ if (urlDql || urlSort.field) {
23560
+ isRestoringFromUrl.current = true;
23561
+ setDQL(urlDql);
23562
+ setSort(urlSort);
23563
+ setCurrentDQL(urlDql);
23564
+ setCurrentSort(urlSort);
23565
+ }
23456
23566
  if (currentData && currentData.sl) {
23457
- console.log("Loading initial page from URL: " + urlPage);
23567
+ console.log("Loading initial data from URL: page=" + urlPage + ", dql=" + urlDql);
23458
23568
  setPageLoading(true);
23569
+ const sortString = urlSort && urlSort.field ? urlSort.field + ":" + (urlSort.direction || 'asc') : '';
23459
23570
  callEndpointGET(currentData.sl, {
23460
23571
  pageSize: currentData.pageSize || 10,
23461
23572
  page: urlPage,
23462
- dql: '',
23463
- sort: ''
23573
+ dql: urlDql,
23574
+ sort: sortString
23464
23575
  }, (result, responseData) => {
23465
23576
  const newDataInfo = _$1__default.get(responseData, "result.data", {});
23466
23577
  if (newDataInfo && newDataInfo.content) delete newDataInfo.content;