@ynput/ayon-frontend-shared 0.3.55 → 0.3.56

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.
Files changed (131) hide show
  1. package/dist/_virtual/index.cjs22.js +1 -1
  2. package/dist/_virtual/index.cjs23.js +1 -1
  3. package/dist/_virtual/index.cjs24.js +1 -1
  4. package/dist/_virtual/index.cjs5.js +1 -1
  5. package/dist/_virtual/index.cjs6.js +1 -1
  6. package/dist/_virtual/index.cjs8.js +1 -1
  7. package/dist/_virtual/index.es15.js +2 -2
  8. package/dist/_virtual/index.es22.js +3 -3
  9. package/dist/_virtual/index.es23.js +5 -5
  10. package/dist/_virtual/index.es24.js +5 -5
  11. package/dist/_virtual/index.es5.js +4 -4
  12. package/dist/_virtual/index.es6.js +5 -2
  13. package/dist/_virtual/index.es6.js.map +1 -1
  14. package/dist/_virtual/index.es8.js +2 -5
  15. package/dist/_virtual/index.es8.js.map +1 -1
  16. package/dist/_virtual/index.es9.js +2 -2
  17. package/dist/api.cjs.js +1 -1
  18. package/dist/api.es.js +193 -192
  19. package/dist/node_modules/match-sorter/dist/match-sorter.esm.cjs.js +1 -1
  20. package/dist/node_modules/match-sorter/dist/match-sorter.esm.es.js +1 -1
  21. package/dist/node_modules/rehype/node_modules/unified/lib/index.cjs.js +1 -1
  22. package/dist/node_modules/rehype/node_modules/unified/lib/index.es.js +2 -2
  23. package/dist/node_modules/rehype/node_modules/vfile/lib/index.cjs.js +1 -1
  24. package/dist/node_modules/rehype/node_modules/vfile/lib/index.es.js +1 -1
  25. package/dist/node_modules/rehype-parse/lib/index.cjs.js +1 -1
  26. package/dist/node_modules/rehype-parse/lib/index.es.js +1 -1
  27. package/dist/node_modules/remove-accents/index.cjs.js +1 -1
  28. package/dist/node_modules/remove-accents/index.cjs.js.map +1 -1
  29. package/dist/node_modules/remove-accents/index.es.js +1 -1
  30. package/dist/shared/node_modules/@module-federation/error-codes/dist/index.cjs.js +1 -1
  31. package/dist/shared/node_modules/@module-federation/error-codes/dist/index.es.js +1 -1
  32. package/dist/shared/node_modules/@module-federation/runtime-core/dist/index.cjs.js +1 -1
  33. package/dist/shared/node_modules/@module-federation/runtime-core/dist/index.es.js +1 -1
  34. package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/semver/utils.cjs.js +1 -1
  35. package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/semver/utils.es.js +1 -1
  36. package/dist/shared/node_modules/@module-federation/sdk/dist/utils.cjs.js +1 -1
  37. package/dist/shared/node_modules/@module-federation/sdk/dist/utils.es.js +1 -1
  38. package/dist/shared/node_modules/prop-types/index.cjs.js +1 -1
  39. package/dist/shared/node_modules/prop-types/index.cjs.js.map +1 -1
  40. package/dist/shared/node_modules/prop-types/index.es.js +1 -1
  41. package/dist/shared/node_modules/react-is/index.cjs.js +1 -1
  42. package/dist/shared/node_modules/react-is/index.es.js +1 -1
  43. package/dist/shared/node_modules/react-transition-group/esm/CSSTransition.cjs.js +1 -1
  44. package/dist/shared/node_modules/react-transition-group/esm/CSSTransition.es.js +1 -1
  45. package/dist/shared/node_modules/react-transition-group/esm/Transition.cjs.js +1 -1
  46. package/dist/shared/node_modules/react-transition-group/esm/Transition.es.js +1 -1
  47. package/dist/shared/node_modules/react-transition-group/esm/utils/PropTypes.cjs.js +1 -1
  48. package/dist/shared/node_modules/react-transition-group/esm/utils/PropTypes.es.js +1 -1
  49. package/dist/shared/src/api/generated/graphql.cjs.js +4 -0
  50. package/dist/shared/src/api/generated/graphql.cjs.js.map +1 -1
  51. package/dist/shared/src/api/generated/graphql.es.js +4 -0
  52. package/dist/shared/src/api/generated/graphql.es.js.map +1 -1
  53. package/dist/shared/src/api/generated/graphqlLinks.cjs.js.map +1 -1
  54. package/dist/shared/src/api/generated/graphqlLinks.es.js.map +1 -1
  55. package/dist/shared/src/api/queries/entities/transformDetailsPanelData.cjs.js +1 -1
  56. package/dist/shared/src/api/queries/entities/transformDetailsPanelData.cjs.js.map +1 -1
  57. package/dist/shared/src/api/queries/entities/transformDetailsPanelData.es.js +17 -16
  58. package/dist/shared/src/api/queries/entities/transformDetailsPanelData.es.js.map +1 -1
  59. package/dist/shared/src/api/queries/entityLists/getLists.cjs.js +1 -1
  60. package/dist/shared/src/api/queries/entityLists/getLists.cjs.js.map +1 -1
  61. package/dist/shared/src/api/queries/entityLists/getLists.es.js +47 -47
  62. package/dist/shared/src/api/queries/entityLists/getLists.es.js.map +1 -1
  63. package/dist/shared/src/api/queries/folders/getFolders.cjs.js +1 -1
  64. package/dist/shared/src/api/queries/folders/getFolders.cjs.js.map +1 -1
  65. package/dist/shared/src/api/queries/folders/getFolders.es.js +20 -22
  66. package/dist/shared/src/api/queries/folders/getFolders.es.js.map +1 -1
  67. package/dist/shared/src/api/queries/overview/getOverview.cjs.js +1 -1
  68. package/dist/shared/src/api/queries/overview/getOverview.cjs.js.map +1 -1
  69. package/dist/shared/src/api/queries/overview/getOverview.es.js +92 -89
  70. package/dist/shared/src/api/queries/overview/getOverview.es.js.map +1 -1
  71. package/dist/shared/src/api/queries/project/getProject.cjs.js +1 -1
  72. package/dist/shared/src/api/queries/project/getProject.cjs.js.map +1 -1
  73. package/dist/shared/src/api/queries/project/getProject.es.js +1 -1
  74. package/dist/shared/src/api/queries/project/getProject.es.js.map +1 -1
  75. package/dist/shared/src/api/queries/users/getUsers.cjs.js +1 -1
  76. package/dist/shared/src/api/queries/users/getUsers.cjs.js.map +1 -1
  77. package/dist/shared/src/api/queries/users/getUsers.es.js +1 -1
  78. package/dist/shared/src/api/queries/users/getUsers.es.js.map +1 -1
  79. package/dist/shared/src/api/queries/versions/getVersionsProducts.cjs.js +1 -1
  80. package/dist/shared/src/api/queries/versions/getVersionsProducts.cjs.js.map +1 -1
  81. package/dist/shared/src/api/queries/versions/getVersionsProducts.es.js +23 -23
  82. package/dist/shared/src/api/queries/versions/getVersionsProducts.es.js.map +1 -1
  83. package/dist/shared/src/api/queries/versions/getVersionsProductsUtils.cjs.js +1 -1
  84. package/dist/shared/src/api/queries/versions/getVersionsProductsUtils.cjs.js.map +1 -1
  85. package/dist/shared/src/api/queries/versions/getVersionsProductsUtils.es.js +13 -13
  86. package/dist/shared/src/api/queries/versions/getVersionsProductsUtils.es.js.map +1 -1
  87. package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.cjs.js +3 -3
  88. package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.cjs.js.map +1 -1
  89. package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.es.js +51 -50
  90. package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.es.js.map +1 -1
  91. package/dist/shared/src/containers/ListTable/ListTableWidgets.cjs.js +1 -1
  92. package/dist/shared/src/containers/ListTable/ListTableWidgets.cjs.js.map +1 -1
  93. package/dist/shared/src/containers/ListTable/ListTableWidgets.es.js +62 -58
  94. package/dist/shared/src/containers/ListTable/ListTableWidgets.es.js.map +1 -1
  95. package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js +1 -1
  96. package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js.map +1 -1
  97. package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js +21 -20
  98. package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js.map +1 -1
  99. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.cjs.js +1 -1
  100. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.cjs.js.map +1 -1
  101. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.es.js +25 -24
  102. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.es.js.map +1 -1
  103. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.cjs.js +1 -1
  104. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.cjs.js.map +1 -1
  105. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.es.js +20 -19
  106. package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.es.js.map +1 -1
  107. package/dist/shared/src/containers/ProjectTreeTable/hooks/useUpdateTableData.cjs.js +1 -1
  108. package/dist/shared/src/containers/ProjectTreeTable/hooks/useUpdateTableData.cjs.js.map +1 -1
  109. package/dist/shared/src/containers/ProjectTreeTable/hooks/useUpdateTableData.es.js +152 -133
  110. package/dist/shared/src/containers/ProjectTreeTable/hooks/useUpdateTableData.es.js.map +1 -1
  111. package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.cjs.js +2 -2
  112. package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.cjs.js.map +1 -1
  113. package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.es.js +75 -73
  114. package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.es.js.map +1 -1
  115. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidget.cjs.js +1 -1
  116. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidget.cjs.js.map +1 -1
  117. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidget.es.js +21 -19
  118. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidget.es.js.map +1 -1
  119. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidgetInput.cjs.js +2 -2
  120. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidgetInput.cjs.js.map +1 -1
  121. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidgetInput.es.js +58 -43
  122. package/dist/shared/src/containers/ProjectTreeTable/widgets/DateWidgetInput.es.js.map +1 -1
  123. package/dist/types/api/generated/graphql.d.ts +5 -0
  124. package/dist/types/api/generated/graphqlLinks.d.ts +1 -0
  125. package/dist/types/api/queries/entities/transformDetailsPanelData.d.ts +1 -0
  126. package/dist/types/api/queries/overview/getOverview.d.ts +2 -1
  127. package/dist/types/containers/ProjectTreeTable/types/table.d.ts +3 -1
  128. package/dist/types/containers/ProjectTreeTable/widgets/CellWidget.d.ts +1 -0
  129. package/dist/types/containers/ProjectTreeTable/widgets/DateWidget.d.ts +1 -0
  130. package/dist/types/containers/ProjectTreeTable/widgets/DateWidgetInput.d.ts +1 -0
  131. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { toast as x } from "react-toastify";
2
- import { useProjectTableQueriesContext as B } from "../context/ProjectTableQueriesContext.es.js";
3
- import { useCallback as k } from "react";
4
- import { useProjectTableContext as L } from "../context/ProjectTableContext.es.js";
2
+ import { useProjectTableQueriesContext as N } from "../context/ProjectTableQueriesContext.es.js";
3
+ import { useCallback as j } from "react";
4
+ import { useProjectTableContext as B } from "../context/ProjectTableContext.es.js";
5
5
  import "../../../context/RemoteModulesContext.es.js";
6
6
  import "../../../../../_virtual/jsx-runtime.es.js";
7
7
  import "../../../../../_virtual/runtime.es.js";
@@ -123,7 +123,7 @@ import "../../../context/AddonContext.es.js";
123
123
  import "../../../context/MenuContext.es.js";
124
124
  import "../../../context/WebsocketContext.es.js";
125
125
  import "../../../context/GlobalContext.es.js";
126
- import { useProjectContext as Q } from "../../../context/ProjectContext.es.js";
126
+ import { useProjectContext as L } from "../../../context/ProjectContext.es.js";
127
127
  import "../../../context/ProjectFoldersContextInstance.es.js";
128
128
  import "../../../context/EntityUpdatesContextInstance.es.js";
129
129
  import "../../ContextMenu/ContextMenuContext.es.js";
@@ -300,117 +300,117 @@ import "../../Views/ViewsMenuContainer/ViewsMenuContainer.es.js";
300
300
  import "../../ListTable/ListTableRow.es.js";
301
301
  import "../../ListTable/ListTable.styled.es.js";
302
302
  import "../../../context/DeleteEntitiesContext.es.js";
303
- const j = (O, a, u) => {
304
- switch (O) {
303
+ const O = (P, s, u) => {
304
+ switch (P) {
305
305
  case "unique-violation":
306
- return `${a} with the name "${u}" already exists`;
306
+ return `${s} with the name "${u}" already exists`;
307
307
  case "not-null-violation":
308
- return `${a} "${u}" is missing required fields`;
308
+ return `${s} "${u}" is missing required fields`;
309
309
  case "foreign-key-violation":
310
- return `${a} "${u}" references invalid data`;
310
+ return `${s} "${u}" references invalid data`;
311
311
  case "integrity-constraint-violation":
312
- return `${a} "${u}" violates data integrity rules`;
312
+ return `${s} "${u}" violates data integrity rules`;
313
313
  default:
314
- return `Failed to update ${a}: ${u}`;
314
+ return `Failed to update ${s}: ${u}`;
315
315
  }
316
- }, gp = (O) => {
317
- const { pushHistory: a, removeHistoryEntries: u } = O || {}, { projectName: F } = Q(), {
318
- getEntityById: g,
319
- getInheritedDependents: $,
316
+ }, wp = (P) => {
317
+ const { pushHistory: s, removeHistoryEntries: u } = P || {}, { projectName: C } = L(), {
318
+ getEntityById: b,
319
+ getInheritedDependents: F,
320
320
  findInheritedValueFromAncestors: U,
321
321
  findNonInheritedValues: V
322
- } = L(), { updateEntities: C } = B(), M = k(
323
- async (b = [], v = !0) => {
324
- if (!b.length || !F)
322
+ } = B(), { updateEntities: $ } = N(), M = j(
323
+ async (h = [], D = !0) => {
324
+ if (!h.length || !C)
325
325
  return;
326
- let h = b.filter((t) => !t.isLink);
327
- const T = h.filter((t) => !(t.field === "folderType" && t.type === "folder" && g(t.id)?.hasVersions)), E = h.length - T.length;
326
+ let g = h.filter((t) => !t.isLink);
327
+ const w = g.filter((t) => !(t.field === "folderType" && t.type === "folder" && b(t.id)?.hasVersions)), E = g.length - w.length;
328
328
  if (E > 0 && x.error(
329
329
  `Cannot change folder type for ${E} folder${E > 1 ? "s" : ""} with published versions`
330
- ), h = T, !h.length)
330
+ ), g = w, !g.length)
331
331
  return;
332
- if (a && v) {
333
- const t = h.map(
334
- ({ rowId: d, id: r, type: p, field: e, isAttrib: f, meta: I }) => {
335
- const s = g(r);
336
- if (!s)
332
+ if (s && D) {
333
+ const t = g.map(
334
+ ({ rowId: n, id: r, type: p, field: m, isAttrib: d, meta: I }) => {
335
+ const y = b(r);
336
+ if (!y)
337
337
  throw "Entity not found: " + r;
338
- const n = s?.entityId || s.id, w = f ? s.attrib?.[e] ?? null : s[e] ?? null, D = s?.ownAttrib || [], y = f && !D.includes(e);
338
+ const a = y?.entityId || y.id, A = d ? y.attrib?.[m] ?? null : y[m] ?? null, v = y?.ownAttrib || [], f = d && !v.includes(m);
339
339
  return {
340
- rowId: d,
341
- id: n,
340
+ rowId: n,
341
+ id: a,
342
342
  type: p,
343
- field: e,
344
- value: w,
345
- isAttrib: f,
346
- wasInherited: y,
343
+ field: m,
344
+ value: A,
345
+ isAttrib: d,
346
+ wasInherited: f,
347
347
  // Track inheritance status for undo
348
- ownAttrib: D,
349
- folderId: s?.folderId || s?.parentId,
348
+ ownAttrib: v,
349
+ folderId: y?.folderId || y?.parentId,
350
350
  meta: I
351
351
  };
352
352
  }
353
- ), c = h.flatMap(
354
- ({ rowId: d, id: r, type: p, field: e, value: f, isAttrib: I, meta: s }) => {
355
- const n = g(r), w = n?.entityId || n?.id || r;
356
- return n ? {
357
- rowId: d,
358
- id: w,
353
+ ), c = g.flatMap(
354
+ ({ rowId: n, id: r, type: p, field: m, value: d, isAttrib: I, meta: y }) => {
355
+ const a = b(r), A = a?.entityId || a?.id || r;
356
+ return a ? {
357
+ rowId: n,
358
+ id: A,
359
359
  type: p,
360
- field: e,
361
- value: f,
360
+ field: m,
361
+ value: d,
362
362
  isAttrib: I,
363
- ownAttrib: n?.ownAttrib || [],
364
- folderId: "folderId" in n ? n.folderId : n?.parentId,
365
- meta: s
363
+ ownAttrib: a?.ownAttrib || [],
364
+ folderId: "folderId" in a ? a.folderId : a?.parentId,
365
+ meta: y
366
366
  } : [];
367
367
  }
368
368
  );
369
- a(t, c);
369
+ s(t, c);
370
370
  }
371
- const A = [
371
+ const T = [
372
372
  "task",
373
373
  "folder",
374
374
  "product",
375
375
  "version"
376
376
  ];
377
377
  let i = [];
378
- for (const t of h) {
379
- let { id: c, type: d, field: r, value: p, isAttrib: e, meta: f } = t;
380
- const I = g(c), s = I?.entityId || I?.id || c;
381
- let n = d;
382
- if (!A.includes(n))
378
+ for (const t of g) {
379
+ let { id: c, type: n, field: r, value: p, isAttrib: m, meta: d } = t;
380
+ const I = b(c), y = I?.entityId || I?.id || c;
381
+ let a = n;
382
+ if (!T.includes(a))
383
383
  continue;
384
- const w = e ? { attrib: { [r]: p } } : { [r]: p };
385
- if (e) {
386
- const y = [...I?.ownAttrib || []];
387
- y.includes(r) || y.push(r), w.ownAttrib = y;
384
+ const A = m ? { attrib: { [r]: p } } : { [r]: p };
385
+ if (m) {
386
+ const f = [...I?.ownAttrib || []];
387
+ f.includes(r) || f.push(r), A.ownAttrib = f;
388
388
  }
389
- const D = i.findIndex(
390
- (y) => y.entityId === s && y.entityType === n
389
+ const v = i.findIndex(
390
+ (f) => f.entityId === y && f.entityType === a
391
391
  );
392
- if (D !== -1) {
393
- const y = i[D];
394
- let P = { ...y.data, ...w };
395
- y.data?.attrib && w.attrib && (P = { ...P, attrib: { ...y.data.attrib, ...w.attrib } }), i[D] = {
396
- ...y,
397
- data: P
392
+ if (v !== -1) {
393
+ const f = i[v];
394
+ let k = { ...f.data, ...A };
395
+ f.data?.attrib && A.attrib && (k = { ...k, attrib: { ...f.data.attrib, ...A.attrib } }), i[v] = {
396
+ ...f,
397
+ data: k
398
398
  };
399
399
  } else
400
400
  i.push({
401
- entityType: n,
402
- entityId: s,
401
+ entityType: a,
402
+ entityId: y,
403
403
  rowId: t.rowId,
404
404
  type: "update",
405
- data: w,
406
- meta: f
405
+ data: A,
406
+ meta: d
407
407
  });
408
408
  }
409
409
  const l = i.filter((t) => !!t.entityId && t.type === "update" && t.data && "attrib" in t.data).map((t) => ({
410
410
  entityId: t.entityId,
411
411
  entityType: t.entityType,
412
412
  attrib: t.data && "attrib" in t.data ? t.data?.attrib : {}
413
- })), m = $(l).map((t) => ({
413
+ })), e = F(l).map((t) => ({
414
414
  entityId: t.entityId,
415
415
  entityType: t.entityType,
416
416
  data: {
@@ -418,55 +418,65 @@ const j = (O, a, u) => {
418
418
  }
419
419
  }));
420
420
  try {
421
- i.length && await C({
421
+ i.length && await $({
422
422
  operations: i,
423
- patchOperations: m
423
+ patchOperations: e
424
424
  });
425
425
  } catch (t) {
426
- console.error("Error updating entities:", t), i.length === 1 ? t.errorCodes.forEach((c) => {
427
- const d = i[0], r = g(d.entityId), p = r?.label || r?.name || d.entityId || "", e = j(c, d.entityType, p);
428
- x.error(e);
429
- }) : x.error("Failed to update entities"), a && v && u && u(1);
426
+ console.error("Error updating entities:", t);
427
+ const c = Array.isArray(t?.errorCodes) ? t.errorCodes : [];
428
+ if (i.length === 1 && c.length > 0)
429
+ c.forEach((n) => {
430
+ const r = i[0], p = b(r.entityId), m = p?.label || p?.name || r.entityId || "", d = O(n, r.entityType, m);
431
+ x.error(d);
432
+ });
433
+ else {
434
+ const n = i[0], r = n && b(n.entityId), p = r?.label || r?.name || n?.entityId || "";
435
+ x.error(
436
+ i.length === 1 ? O(void 0, n.entityType, p) : "Failed to update entities"
437
+ );
438
+ }
439
+ s && D && u && u(1);
430
440
  }
431
441
  },
432
442
  [
433
- F,
434
443
  C,
435
- //
436
- g,
437
444
  $,
438
- a,
445
+ //
446
+ b,
447
+ F,
448
+ s,
439
449
  u
440
450
  ]
441
- ), q = k(
442
- async (b, v = !0) => {
443
- if (!b.length || !F)
451
+ ), q = j(
452
+ async (h, D = !0) => {
453
+ if (!h.length || !C)
444
454
  return;
445
- if (v && a) {
455
+ if (D && s) {
446
456
  const i = [];
447
- for (const o of b) {
448
- const m = g(o.entityId);
457
+ for (const o of h) {
458
+ const e = b(o.entityId);
449
459
  for (const t of o.attribs)
450
- m?.attrib && t in m.attrib && i.push({
460
+ e?.attrib && t in e.attrib && i.push({
451
461
  rowId: o.rowId,
452
- id: m?.entityId || m?.id || o.entityId,
462
+ id: e?.entityId || e?.id || o.entityId,
453
463
  type: o.entityType,
454
464
  field: t,
455
- value: m.attrib[t],
465
+ value: e.attrib[t],
456
466
  isAttrib: !0,
457
467
  wasInherited: !1,
458
468
  // Mark as not inherited
459
- ownAttrib: m?.ownAttrib || [],
460
- folderId: m?.folderId,
461
- meta: m.meta
469
+ ownAttrib: e?.ownAttrib || [],
470
+ folderId: e?.folderId,
471
+ meta: e.meta
462
472
  });
463
473
  }
464
- const l = b.flatMap(
465
- (o) => o.attribs.map((m) => ({
474
+ const l = h.flatMap(
475
+ (o) => o.attribs.map((e) => ({
466
476
  rowId: o.rowId,
467
477
  id: o.entityId,
468
478
  type: o.entityType,
469
- field: m,
479
+ field: e,
470
480
  value: null,
471
481
  isAttrib: !0,
472
482
  wasInherited: !0,
@@ -476,18 +486,18 @@ const j = (O, a, u) => {
476
486
  meta: o.meta
477
487
  }))
478
488
  );
479
- i.length > 0 && a(i, l);
489
+ i.length > 0 && s(i, l);
480
490
  }
481
- const h = ["task", "folder"], T = [], E = [];
482
- for (const i of b) {
491
+ const g = ["task", "folder"], w = [], E = [];
492
+ for (const i of h) {
483
493
  let l = i.entityType;
484
- if (!h.includes(l))
494
+ if (!g.includes(l))
485
495
  continue;
486
496
  l = l;
487
497
  const o = {};
488
498
  i.attribs.forEach((p) => {
489
499
  o[p] = null;
490
- }), T.push({
500
+ }), w.push({
491
501
  entityType: l,
492
502
  entityId: i.entityId,
493
503
  rowId: i.rowId,
@@ -498,12 +508,12 @@ const j = (O, a, u) => {
498
508
  meta: i.meta
499
509
  });
500
510
  const t = (() => {
501
- const p = i.folderId, e = [];
502
- let f = p, I = b.find((n) => n.entityId === f);
511
+ const p = i.folderId, m = [];
512
+ let d = p, I = h.find((a) => a.entityId === d);
503
513
  for (; I; )
504
- e.push(I), f = I.folderId, I = b.find((n) => n.entityId === f);
505
- return e.length > 0 ? e[e.length - 1] : null;
506
- })(), c = t?.attribs || [], d = i.attribs.filter(
514
+ m.push(I), d = I.folderId, I = h.find((a) => a.entityId === d);
515
+ return m.length > 0 ? m[m.length - 1] : null;
516
+ })(), c = t?.attribs || [], n = i.attribs.filter(
507
517
  (p) => c.includes(p)
508
518
  ), r = i.attribs.filter(
509
519
  (p) => !c.includes(p)
@@ -511,27 +521,27 @@ const j = (O, a, u) => {
511
521
  r.length > 0 && E.push({
512
522
  ...i,
513
523
  attribs: r
514
- }), t && d.length > 0 && E.push({
524
+ }), t && n.length > 0 && E.push({
515
525
  ...i,
516
- attribs: d,
526
+ attribs: n,
517
527
  folderId: t.folderId
518
528
  });
519
529
  }
520
- const A = [];
530
+ const T = [];
521
531
  for (const i of E) {
522
532
  const l = i.entityType, o = [...i.ownAttrib || []].filter(
523
533
  (r) => !i.attribs.includes(r)
524
- ), m = V(i.folderId, i.attribs), t = {
534
+ ), e = V(i.folderId, i.attribs), t = {
525
535
  entityId: i.entityId,
526
536
  entityType: l,
527
537
  data: {
528
- attrib: m,
538
+ attrib: e,
529
539
  ownAttrib: o
530
540
  }
531
541
  };
532
- A.push(t);
533
- const d = $([
534
- { entityId: i.entityId, entityType: l, attrib: m }
542
+ T.push(t);
543
+ const n = F([
544
+ { entityId: i.entityId, entityType: l, attrib: e }
535
545
  ]).map((r) => ({
536
546
  entityId: r.entityId,
537
547
  entityType: r.entityType,
@@ -539,24 +549,24 @@ const j = (O, a, u) => {
539
549
  attrib: r.attrib
540
550
  }
541
551
  }));
542
- for (const r of d) {
543
- const p = A.findIndex(
544
- (e) => e.entityId === r.entityId
552
+ for (const r of n) {
553
+ const p = T.findIndex(
554
+ (m) => m.entityId === r.entityId
545
555
  );
546
556
  if (p !== -1) {
547
- const e = A[p];
548
- let f = {
557
+ const m = T[p];
558
+ let d = {
549
559
  // @ts-ignore
550
- ...e.data?.attrib || {},
560
+ ...m.data?.attrib || {},
551
561
  // @ts-ignore
552
562
  ...r.data?.attrib || {}
553
563
  };
554
- A[p] = {
555
- ...e,
556
- data: { attrib: f }
564
+ T[p] = {
565
+ ...m,
566
+ data: { attrib: d }
557
567
  };
558
568
  } else
559
- A.push({
569
+ T.push({
560
570
  entityId: r.entityId,
561
571
  entityType: r.entityType,
562
572
  data: r.data
@@ -564,29 +574,38 @@ const j = (O, a, u) => {
564
574
  }
565
575
  }
566
576
  try {
567
- await C({
568
- operations: T,
569
- patchOperations: A
577
+ await $({
578
+ operations: w,
579
+ patchOperations: T
570
580
  });
571
581
  } catch (i) {
572
- T.length === 1 ? i.errorCodes.forEach((l) => {
573
- const o = T[0], m = g(o.entityId), t = m?.label || m?.name || o.entityId || "", c = j(l, o.entityType, t);
574
- x.error(c);
575
- }) : x.error("Failed to update entities"), v && a && u && u(1);
582
+ const l = Array.isArray(i?.errorCodes) ? i.errorCodes : [];
583
+ if (w.length === 1 && l.length > 0)
584
+ l.forEach((o) => {
585
+ const e = w[0], t = b(e.entityId), c = t?.label || t?.name || e.entityId || "", n = O(o, e.entityType, c);
586
+ x.error(n);
587
+ });
588
+ else {
589
+ const o = w[0], e = o && b(o.entityId), t = e?.label || e?.name || o?.entityId || "";
590
+ x.error(
591
+ w.length === 1 ? O(void 0, o.entityType, t) : "Failed to update entities"
592
+ );
593
+ }
594
+ D && s && u && u(1);
576
595
  }
577
596
  },
578
597
  [
579
- F,
580
598
  C,
581
599
  $,
600
+ F,
582
601
  U,
583
- a,
602
+ s,
584
603
  u
585
604
  ]
586
605
  );
587
606
  return { updateEntities: M, inheritFromParent: q };
588
607
  };
589
608
  export {
590
- gp as default
609
+ wp as default
591
610
  };
592
611
  //# sourceMappingURL=useUpdateTableData.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUpdateTableData.es.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/useUpdateTableData.ts"],"sourcesContent":["import { CellId } from '../utils/cellUtils'\nimport { CellValue } from '../widgets/CellWidget'\nimport { toast } from 'react-toastify'\nimport { useProjectTableQueriesContext } from '../context/ProjectTableQueriesContext'\nimport { useCallback } from 'react'\nimport { InheritedDependent } from './useFolderRelationships'\nimport { useProjectTableContext } from '../context/ProjectTableContext'\nimport { OperationModel } from '../types/operations'\nimport { PatchOperation } from '../types'\nimport { HistoryEntityUpdate, UseHistoryReturn } from './useHistory'\nimport { useProjectContext } from '@shared/context'\n\nconst getErrorMessage = (\n errorCode: string | undefined,\n entityType: string,\n entityName: string,\n): string => {\n switch (errorCode) {\n case 'unique-violation':\n return `${entityType} with the name \"${entityName}\" already exists`\n case 'not-null-violation':\n return `${entityType} \"${entityName}\" is missing required fields`\n case 'foreign-key-violation':\n return `${entityType} \"${entityName}\" references invalid data`\n case 'integrity-constraint-violation':\n return `${entityType} \"${entityName}\" violates data integrity rules`\n default:\n return `Failed to update ${entityType}: ${entityName}`\n }\n}\n\nexport type EntityUpdate = {\n rowId: string\n id: string\n type: string\n field: string\n value: CellValue | CellValue[] | null\n isAttrib?: boolean\n isLink?: boolean // link updates use different endpoint\n meta?: Record<string, any>\n}\nexport type UpdateTableEntities = (entities: EntityUpdate[], pushHistory?: boolean) => Promise<void>\n\nexport type InheritFromParentEntity = {\n rowId: string\n entityId: string\n entityType: string\n attribs: string[]\n ownAttrib: string[]\n folderId?: string // the parent folder ID\n meta?: Record<string, any>\n}\nexport type InheritFromParent = (\n entities: InheritFromParentEntity[],\n pushHistory?: boolean,\n) => Promise<void>\n\nexport type UpdateTableEntity = (\n cellId: CellId,\n value: string,\n { includeSelection }: { includeSelection: boolean },\n) => Promise<void>\n\nexport type OperationWithRowId = OperationModel & { rowId: string; meta?: Record<string, any> }\n\ninterface UseUpdateTableDataProps {\n pushHistory?: UseHistoryReturn['pushHistory']\n removeHistoryEntries?: UseHistoryReturn['removeHistoryEntries']\n}\n\nconst useUpdateTableData = (props?: UseUpdateTableDataProps) => {\n const { pushHistory, removeHistoryEntries } = props || {}\n const { projectName } = useProjectContext()\n const {\n getEntityById,\n getInheritedDependents,\n findInheritedValueFromAncestors,\n findNonInheritedValues,\n } = useProjectTableContext()\n const { updateEntities } = useProjectTableQueriesContext()\n\n const handleUpdateEntities = useCallback<UpdateTableEntities>(\n async (entities = [], pushToHistory = true) => {\n if (!entities.length || !projectName) {\n return\n }\n\n // Filter out link updates - they should be handled by useUpdateTableLinks\n let entityUpdates = entities.filter((e) => !e.isLink)\n\n // Filter out folder type updates for folders with versions\n const filteredUpdates = entityUpdates.filter((entity) => {\n if (entity.field === 'folderType' && entity.type === 'folder') {\n const entityData = getEntityById(entity.id)\n if (entityData?.hasVersions) {\n return false\n }\n }\n return true\n })\n\n // Show warning if any updates were filtered out\n const filteredCount = entityUpdates.length - filteredUpdates.length\n if (filteredCount > 0) {\n toast.error(\n `Cannot change folder type for ${filteredCount} folder${\n filteredCount > 1 ? 's' : ''\n } with published versions`,\n )\n }\n\n entityUpdates = filteredUpdates\n\n // If no entity updates to process, return early\n if (!entityUpdates.length) {\n return\n }\n\n // Record history of previous values before applying update\n if (pushHistory && pushToHistory) {\n const inverseEntities: HistoryEntityUpdate[] = entityUpdates.map(\n ({ rowId, id, type, field, isAttrib, meta }) => {\n const entityData = getEntityById(id) as Record<string, any>\n if (!entityData) {\n throw 'Entity not found: ' + id\n }\n const entityId = entityData?.entityId || entityData.id\n const oldValue = isAttrib\n ? (entityData.attrib as Record<string, any>)?.[field] ?? null\n : entityData[field] ?? null\n\n // Check if the field was inherited (not in ownAttrib)\n const ownAttrib = entityData?.ownAttrib || []\n const wasInherited = isAttrib && !ownAttrib.includes(field)\n\n return {\n rowId: rowId,\n id: entityId,\n type,\n field,\n value: oldValue,\n isAttrib,\n wasInherited, // Track inheritance status for undo\n ownAttrib: ownAttrib,\n folderId: entityData?.folderId || entityData?.parentId,\n meta,\n }\n },\n )\n const historyEntities: HistoryEntityUpdate[] = entityUpdates.flatMap(\n ({ rowId, id, type, field, value, isAttrib, meta }) => {\n const entityData = getEntityById(id)\n const entityId = entityData?.entityId || entityData?.id || id\n\n if (!entityData) return []\n\n return {\n rowId: rowId,\n id: entityId,\n type,\n field,\n value,\n isAttrib,\n ownAttrib: entityData?.ownAttrib || [],\n folderId: 'folderId' in entityData ? entityData.folderId : entityData?.parentId,\n meta,\n }\n },\n )\n pushHistory(inverseEntities, historyEntities)\n }\n\n const supportedEntityTypes: OperationModel['entityType'][] = [\n 'task',\n 'folder',\n 'product',\n 'version',\n ]\n // Group operations by entity type for bulk processing\n let operations: OperationWithRowId[] = []\n for (const entity of entityUpdates) {\n let { id, type, field, value, isAttrib, meta } = entity\n const entityData = getEntityById(id)\n const entityId = entityData?.entityId || entityData?.id || id\n // Skip unsupported entity types\n let entityType = type as OperationModel['entityType']\n if (!supportedEntityTypes.includes(entityType)) {\n continue\n }\n\n // create data object for change, taking into account if it's an attribute change\n const data: Record<string, any> = isAttrib\n ? { attrib: { [field]: value } }\n : { [field]: value }\n\n // if the entity is an attribute get the entity data\n // then update ownAttrib to include the new value\n if (isAttrib) {\n const ownAttrib = [...(entityData?.ownAttrib || [])]\n // add the new value to the ownAttrib if it doesn't already exist\n if (!ownAttrib.includes(field)) {\n ownAttrib.push(field)\n }\n // update the data object with the new ownAttrib\n data.ownAttrib = ownAttrib\n }\n\n const existingOperationIndex = operations.findIndex(\n (op) => op.entityId === entityId && op.entityType === entityType,\n )\n\n if (existingOperationIndex !== -1) {\n // Merge data with existing operation\n const existingOperation = operations[existingOperationIndex]\n let newData = { ...existingOperation.data, ...data }\n\n // @ts-ignore\n if (existingOperation.data?.attrib && data.attrib) {\n // @ts-ignore\n newData = { ...newData, attrib: { ...existingOperation.data.attrib, ...data.attrib } }\n }\n\n operations[existingOperationIndex] = {\n ...existingOperation,\n data: newData,\n }\n } else {\n // Add new operation\n operations.push({\n entityType: entityType,\n entityId: entityId,\n rowId: entity.rowId,\n type: 'update',\n data: data,\n meta: meta,\n })\n }\n }\n\n const folderAttribEntities: InheritedDependent[] = operations\n .filter((op) => !!op.entityId && op.type === 'update' && op.data && 'attrib' in op.data)\n .map((op) => ({\n entityId: op.entityId as string,\n entityType: op.entityType as 'folder' | 'task',\n attrib:\n op.data && 'attrib' in op.data ? (op.data?.attrib as InheritedDependent['attrib']) : {},\n }))\n\n const inheritedDependents = getInheritedDependents(folderAttribEntities)\n\n // convert to operations\n const inheritedDependentsOperations: PatchOperation[] = inheritedDependents.map((op) => ({\n entityId: op.entityId,\n entityType: op.entityType,\n data: {\n attrib: op.attrib,\n },\n }))\n\n // now make api call to update all entities and links\n try {\n if (operations.length) {\n await updateEntities({\n operations,\n patchOperations: inheritedDependentsOperations,\n })\n }\n } catch (error: any) {\n console.error('Error updating entities:', error)\n if (operations.length === 1) {\n error.errorCodes.forEach((errorCode: string) => {\n const op = operations[0]\n const entity = getEntityById(op.entityId as string)\n const entityName = entity?.label || entity?.name || op.entityId || ''\n const message = getErrorMessage(errorCode, op.entityType, entityName)\n toast.error(message)\n })\n } else {\n toast.error('Failed to update entities')\n }\n // Remove the failed update from history stack\n if (pushHistory && pushToHistory && removeHistoryEntries) {\n removeHistoryEntries(1)\n }\n }\n },\n [\n projectName,\n updateEntities, //\n getEntityById,\n getInheritedDependents,\n pushHistory,\n removeHistoryEntries,\n ],\n )\n\n // set the attrib fields to be inherited from the parent\n // (remove the field from the ownAttrib array)\n // invalidate the cache for the folder/task so that it can be re-fetched with inherited values\n const inheritFromParent = useCallback<InheritFromParent>(\n async (entities, pushToHistory = true) => {\n if (!entities.length || !projectName) {\n return\n }\n\n // Record history for the inheritance operation\n if (pushToHistory && pushHistory) {\n // Create undo entities (restore explicit values)\n const undoEntities: HistoryEntityUpdate[] = []\n\n // For each entity and attribute being inherited, record current values\n for (const entity of entities) {\n const entityData = getEntityById(entity.entityId) as Record<string, any>\n\n // For each attribute that will be inherited, record its current value\n for (const attrib of entity.attribs) {\n if (entityData?.attrib && attrib in entityData.attrib) {\n undoEntities.push({\n rowId: entity.rowId,\n id: entityData?.entityId || entityData?.id || entity.entityId,\n type: entity.entityType,\n field: attrib,\n value: (entityData.attrib as Record<string, any>)[attrib],\n isAttrib: true,\n wasInherited: false, // Mark as not inherited\n ownAttrib: entityData?.ownAttrib || [],\n folderId: entityData?.folderId,\n meta: entityData.meta,\n })\n }\n }\n }\n\n // Create redo entities (to re-inherit)\n const redoEntities: HistoryEntityUpdate[] = entities.flatMap((entity) =>\n entity.attribs.map((attrib) => ({\n rowId: entity.rowId,\n id: entity.entityId,\n type: entity.entityType,\n field: attrib,\n value: null,\n isAttrib: true,\n wasInherited: true, // Mark as inherited\n ownAttrib: entity.ownAttrib,\n folderId: entity.folderId,\n meta: entity.meta,\n })),\n )\n\n // Push to history if we have changes to record\n if (undoEntities.length > 0) {\n pushHistory(undoEntities, redoEntities)\n }\n }\n\n const supportedEntityTypes: OperationModel['entityType'][] = ['task', 'folder']\n // Group operations by entity type for bulk processing\n const operations: OperationWithRowId[] = [] // operations sent to the server\n const entitiesToPatch: InheritFromParentEntity[] = []\n for (const entity of entities) {\n // Skip unsupported entity types\n let entityType = entity.entityType as OperationModel['entityType']\n if (!supportedEntityTypes.includes(entityType)) {\n continue\n }\n entityType = entityType as 'task' | 'folder'\n\n // Create data object with null values for each attrib to inherit\n const attribData: Record<string, null> = {}\n entity.attribs.forEach((attrib) => {\n attribData[attrib] = null\n })\n\n // Add new operation this is what's sent to the server and is actually updated in the DB\n operations.push({\n entityType: entityType,\n entityId: entity.entityId,\n rowId: entity.rowId,\n type: 'update',\n data: {\n attrib: attribData,\n },\n meta: entity.meta,\n })\n\n // check if this entity has a folderId that is in entities\n // if so we check their intersection attrib names\n const findTopFolder = () => {\n // For each entity, we need to find the top-most folder in the hierarchy\n const folderId = entity.folderId\n\n // Find all ancestor folders that are in our entities list\n const ancestorChain: InheritFromParentEntity[] = []\n let currentFolderId = folderId\n let currentFolder = entities.find((e) => e.entityId === currentFolderId)\n\n // Climb up the folder hierarchy to build the chain of ancestors\n while (currentFolder) {\n ancestorChain.push(currentFolder)\n currentFolderId = currentFolder.folderId\n currentFolder = entities.find((e) => e.entityId === currentFolderId)\n }\n\n // The top folder is the last one in our ancestor chain (if any)\n const topFolder =\n ancestorChain.length > 0 ? ancestorChain[ancestorChain.length - 1] : null\n\n return topFolder\n }\n\n const topFolder = findTopFolder()\n const folderAttribs = topFolder?.attribs || []\n const entityAttribsIntersection = entity.attribs.filter((attrib) =>\n folderAttribs.includes(attrib),\n )\n const entityAttribsRemoved = entity.attribs.filter(\n (attrib) => !folderAttribs.includes(attrib),\n )\n\n // only add to patch operations if there are attribs left\n if (entityAttribsRemoved.length > 0)\n entitiesToPatch.push({\n ...entity,\n attribs: entityAttribsRemoved,\n })\n\n if (topFolder && entityAttribsIntersection.length > 0) {\n entitiesToPatch.push({\n ...entity,\n attribs: entityAttribsIntersection,\n folderId: topFolder.folderId,\n })\n }\n }\n\n const patchOperations: PatchOperation[] = [] // operations only for patching the cache\n for (const entity of entitiesToPatch) {\n const entityType = entity.entityType as 'task' | 'folder'\n // we also need to update ownAttrib to remove the inherited attribs\n const ownAttrib = [...(entity.ownAttrib || [])].filter(\n (attrib) => !entity.attribs.includes(attrib),\n )\n\n // now we must calculate all the entities that need to be updated in the cache\n // first we need to find the the ancestor folder to inherit from\n const ancestorAttrib = findNonInheritedValues(entity.folderId, entity.attribs)\n\n const entityPatch = {\n entityId: entity.entityId,\n entityType: entityType,\n data: {\n attrib: ancestorAttrib,\n ownAttrib: ownAttrib,\n },\n }\n\n // create new patch operation for the entity\n patchOperations.push(entityPatch)\n\n // now find any dependent that also need updating\n const inheritedDependents = getInheritedDependents([\n { entityId: entity.entityId, entityType: entityType, attrib: ancestorAttrib },\n ])\n\n // convert to operations\n const inheritedDependentsOperations: PatchOperation[] = inheritedDependents.map((op) => ({\n entityId: op.entityId,\n entityType: op.entityType,\n data: {\n attrib: op.attrib,\n },\n }))\n\n // try to add to patch operations\n // if it already exists then merge the attribs\n for (const inheritedDependent of inheritedDependentsOperations) {\n const existingOperationIndex = patchOperations.findIndex(\n (op) => op.entityId === inheritedDependent.entityId,\n )\n\n if (existingOperationIndex !== -1) {\n // Merge attribs with existing operation\n const existingOperation = patchOperations[existingOperationIndex]\n let newAttrib = {\n // @ts-ignore\n ...(existingOperation.data?.attrib || {}),\n // @ts-ignore\n ...(inheritedDependent.data?.attrib || {}),\n }\n\n patchOperations[existingOperationIndex] = {\n ...existingOperation,\n data: { attrib: newAttrib },\n }\n } else {\n // Add new operation\n patchOperations.push({\n entityId: inheritedDependent.entityId,\n entityType: inheritedDependent.entityType,\n data: inheritedDependent.data,\n })\n }\n }\n }\n\n // now make api call to update all entities\n try {\n await updateEntities({\n operations,\n patchOperations,\n })\n } catch (error: any) {\n // Extract error code from operation result - check multiple paths\n if (operations.length === 1) {\n error.errorCodes.forEach((errorCode: string) => {\n const op = operations[0]\n const entity = getEntityById(op.entityId as string)\n const entityName = entity?.label || entity?.name || op.entityId || ''\n const message = getErrorMessage(errorCode, op.entityType, entityName)\n toast.error(message)\n })\n } else {\n toast.error('Failed to update entities')\n }\n\n // Remove the failed update from history stack\n if (pushToHistory && pushHistory && removeHistoryEntries) {\n removeHistoryEntries(1)\n }\n }\n },\n [\n projectName,\n updateEntities,\n getInheritedDependents,\n findInheritedValueFromAncestors,\n pushHistory,\n removeHistoryEntries,\n ],\n )\n\n return { updateEntities: handleUpdateEntities, inheritFromParent }\n}\n\nexport default useUpdateTableData\n"],"names":["getErrorMessage","errorCode","entityType","entityName","useUpdateTableData","props","pushHistory","removeHistoryEntries","projectName","useProjectContext","getEntityById","getInheritedDependents","findInheritedValueFromAncestors","findNonInheritedValues","useProjectTableContext","updateEntities","useProjectTableQueriesContext","handleUpdateEntities","useCallback","entities","pushToHistory","entityUpdates","e","filteredUpdates","entity","filteredCount","toast","inverseEntities","rowId","id","type","field","isAttrib","meta","entityData","entityId","oldValue","ownAttrib","wasInherited","historyEntities","value","supportedEntityTypes","operations","data","existingOperationIndex","op","existingOperation","newData","folderAttribEntities","inheritedDependentsOperations","error","message","inheritFromParent","undoEntities","attrib","redoEntities","entitiesToPatch","attribData","topFolder","folderId","ancestorChain","currentFolderId","currentFolder","folderAttribs","entityAttribsIntersection","entityAttribsRemoved","patchOperations","ancestorAttrib","entityPatch","inheritedDependent","newAttrib"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAA,UAE9B;AAEE,YAAAJ,EAAgB,KAAK;AAAA,cACnB,UAAUG,EAAmB;AAAA,cAC7B,YAAYA,EAAmB;AAAA,cAC/B,MAAMA,EAAmB;AAAA,YAAA,CAC1B;AAAA,QAEL;AAAA,MACF;AAGA,UAAI;AACF,cAAMtD,EAAe;AAAA,UACnB,YAAA2B;AAAA,UACA,iBAAAwB;AAAA,QAAA,CACD;AAAA,MACH,SAAShB,GAAY;AAEnB,QAAIR,EAAW,WAAW,IACxBQ,EAAM,WAAW,QAAQ,CAACjD,MAAsB;AAC9C,gBAAM4C,IAAKH,EAAW,CAAC,GACjBlB,IAASd,EAAcmC,EAAG,QAAkB,GAC5C1C,IAAaqB,GAAQ,SAASA,GAAQ,QAAQqB,EAAG,YAAY,IAC7DM,IAAUnD,EAAgBC,GAAW4C,EAAG,YAAY1C,CAAU;AACpE,UAAAuB,EAAM,MAAMyB,CAAO;AAAA,QACrB,CAAC,IAEDzB,EAAM,MAAM,2BAA2B,GAIrCN,KAAiBd,KAAeC,KAClCA,EAAqB,CAAC;AAAA,MAE1B;AAAA,IACF;AAAA,IACA;AAAA,MACEC;AAAA,MACAO;AAAA,MACAJ;AAAA,MACAC;AAAA,MACAN;AAAA,MACAC;AAAA,IAAA;AAAA,EACF;AAGF,SAAO,EAAE,gBAAgBU,GAAsB,mBAAAmC,EAAA;AACjD;"}
1
+ {"version":3,"file":"useUpdateTableData.es.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/useUpdateTableData.ts"],"sourcesContent":["import { CellId } from '../utils/cellUtils'\nimport { CellValue } from '../widgets/CellWidget'\nimport { toast } from 'react-toastify'\nimport { useProjectTableQueriesContext } from '../context/ProjectTableQueriesContext'\nimport { useCallback } from 'react'\nimport { InheritedDependent } from './useFolderRelationships'\nimport { useProjectTableContext } from '../context/ProjectTableContext'\nimport { OperationModel } from '../types/operations'\nimport { PatchOperation } from '../types'\nimport { HistoryEntityUpdate, UseHistoryReturn } from './useHistory'\nimport { useProjectContext } from '@shared/context'\n\nconst getErrorMessage = (\n errorCode: string | undefined,\n entityType: string,\n entityName: string,\n): string => {\n switch (errorCode) {\n case 'unique-violation':\n return `${entityType} with the name \"${entityName}\" already exists`\n case 'not-null-violation':\n return `${entityType} \"${entityName}\" is missing required fields`\n case 'foreign-key-violation':\n return `${entityType} \"${entityName}\" references invalid data`\n case 'integrity-constraint-violation':\n return `${entityType} \"${entityName}\" violates data integrity rules`\n default:\n return `Failed to update ${entityType}: ${entityName}`\n }\n}\n\nexport type EntityUpdate = {\n rowId: string\n id: string\n type: string\n field: string\n value: CellValue | CellValue[] | null\n isAttrib?: boolean\n isLink?: boolean // link updates use different endpoint\n meta?: Record<string, any>\n}\nexport type UpdateTableEntities = (entities: EntityUpdate[], pushHistory?: boolean) => Promise<void>\n\nexport type InheritFromParentEntity = {\n rowId: string\n entityId: string\n entityType: string\n attribs: string[]\n ownAttrib: string[]\n folderId?: string // the parent folder ID\n meta?: Record<string, any>\n}\nexport type InheritFromParent = (\n entities: InheritFromParentEntity[],\n pushHistory?: boolean,\n) => Promise<void>\n\nexport type UpdateTableEntity = (\n cellId: CellId,\n value: string,\n { includeSelection }: { includeSelection: boolean },\n) => Promise<void>\n\nexport type OperationWithRowId = OperationModel & { rowId: string; meta?: Record<string, any> }\n\ninterface UseUpdateTableDataProps {\n pushHistory?: UseHistoryReturn['pushHistory']\n removeHistoryEntries?: UseHistoryReturn['removeHistoryEntries']\n}\n\nconst useUpdateTableData = (props?: UseUpdateTableDataProps) => {\n const { pushHistory, removeHistoryEntries } = props || {}\n const { projectName } = useProjectContext()\n const {\n getEntityById,\n getInheritedDependents,\n findInheritedValueFromAncestors,\n findNonInheritedValues,\n } = useProjectTableContext()\n const { updateEntities } = useProjectTableQueriesContext()\n\n const handleUpdateEntities = useCallback<UpdateTableEntities>(\n async (entities = [], pushToHistory = true) => {\n if (!entities.length || !projectName) {\n return\n }\n\n // Filter out link updates - they should be handled by useUpdateTableLinks\n let entityUpdates = entities.filter((e) => !e.isLink)\n\n // Filter out folder type updates for folders with versions\n const filteredUpdates = entityUpdates.filter((entity) => {\n if (entity.field === 'folderType' && entity.type === 'folder') {\n const entityData = getEntityById(entity.id)\n if (entityData?.hasVersions) {\n return false\n }\n }\n return true\n })\n\n // Show warning if any updates were filtered out\n const filteredCount = entityUpdates.length - filteredUpdates.length\n if (filteredCount > 0) {\n toast.error(\n `Cannot change folder type for ${filteredCount} folder${\n filteredCount > 1 ? 's' : ''\n } with published versions`,\n )\n }\n\n entityUpdates = filteredUpdates\n\n // If no entity updates to process, return early\n if (!entityUpdates.length) {\n return\n }\n\n // Record history of previous values before applying update\n if (pushHistory && pushToHistory) {\n const inverseEntities: HistoryEntityUpdate[] = entityUpdates.map(\n ({ rowId, id, type, field, isAttrib, meta }) => {\n const entityData = getEntityById(id) as Record<string, any>\n if (!entityData) {\n throw 'Entity not found: ' + id\n }\n const entityId = entityData?.entityId || entityData.id\n const oldValue = isAttrib\n ? (entityData.attrib as Record<string, any>)?.[field] ?? null\n : entityData[field] ?? null\n\n // Check if the field was inherited (not in ownAttrib)\n const ownAttrib = entityData?.ownAttrib || []\n const wasInherited = isAttrib && !ownAttrib.includes(field)\n\n return {\n rowId: rowId,\n id: entityId,\n type,\n field,\n value: oldValue,\n isAttrib,\n wasInherited, // Track inheritance status for undo\n ownAttrib: ownAttrib,\n folderId: entityData?.folderId || entityData?.parentId,\n meta,\n }\n },\n )\n const historyEntities: HistoryEntityUpdate[] = entityUpdates.flatMap(\n ({ rowId, id, type, field, value, isAttrib, meta }) => {\n const entityData = getEntityById(id)\n const entityId = entityData?.entityId || entityData?.id || id\n\n if (!entityData) return []\n\n return {\n rowId: rowId,\n id: entityId,\n type,\n field,\n value,\n isAttrib,\n ownAttrib: entityData?.ownAttrib || [],\n folderId: 'folderId' in entityData ? entityData.folderId : entityData?.parentId,\n meta,\n }\n },\n )\n pushHistory(inverseEntities, historyEntities)\n }\n\n const supportedEntityTypes: OperationModel['entityType'][] = [\n 'task',\n 'folder',\n 'product',\n 'version',\n ]\n // Group operations by entity type for bulk processing\n let operations: OperationWithRowId[] = []\n for (const entity of entityUpdates) {\n let { id, type, field, value, isAttrib, meta } = entity\n const entityData = getEntityById(id)\n const entityId = entityData?.entityId || entityData?.id || id\n // Skip unsupported entity types\n let entityType = type as OperationModel['entityType']\n if (!supportedEntityTypes.includes(entityType)) {\n continue\n }\n\n // create data object for change, taking into account if it's an attribute change\n const data: Record<string, any> = isAttrib\n ? { attrib: { [field]: value } }\n : { [field]: value }\n\n // if the entity is an attribute get the entity data\n // then update ownAttrib to include the new value\n if (isAttrib) {\n const ownAttrib = [...(entityData?.ownAttrib || [])]\n // add the new value to the ownAttrib if it doesn't already exist\n if (!ownAttrib.includes(field)) {\n ownAttrib.push(field)\n }\n // update the data object with the new ownAttrib\n data.ownAttrib = ownAttrib\n }\n\n const existingOperationIndex = operations.findIndex(\n (op) => op.entityId === entityId && op.entityType === entityType,\n )\n\n if (existingOperationIndex !== -1) {\n // Merge data with existing operation\n const existingOperation = operations[existingOperationIndex]\n let newData = { ...existingOperation.data, ...data }\n\n // @ts-ignore\n if (existingOperation.data?.attrib && data.attrib) {\n // @ts-ignore\n newData = { ...newData, attrib: { ...existingOperation.data.attrib, ...data.attrib } }\n }\n\n operations[existingOperationIndex] = {\n ...existingOperation,\n data: newData,\n }\n } else {\n // Add new operation\n operations.push({\n entityType: entityType,\n entityId: entityId,\n rowId: entity.rowId,\n type: 'update',\n data: data,\n meta: meta,\n })\n }\n }\n\n const folderAttribEntities: InheritedDependent[] = operations\n .filter((op) => !!op.entityId && op.type === 'update' && op.data && 'attrib' in op.data)\n .map((op) => ({\n entityId: op.entityId as string,\n entityType: op.entityType as 'folder' | 'task',\n attrib:\n op.data && 'attrib' in op.data ? (op.data?.attrib as InheritedDependent['attrib']) : {},\n }))\n\n const inheritedDependents = getInheritedDependents(folderAttribEntities)\n\n // convert to operations\n const inheritedDependentsOperations: PatchOperation[] = inheritedDependents.map((op) => ({\n entityId: op.entityId,\n entityType: op.entityType,\n data: {\n attrib: op.attrib,\n },\n }))\n\n // now make api call to update all entities and links\n try {\n if (operations.length) {\n await updateEntities({\n operations,\n patchOperations: inheritedDependentsOperations,\n })\n }\n } catch (error: any) {\n console.error('Error updating entities:', error)\n const errorCodes = Array.isArray(error?.errorCodes) ? error.errorCodes : []\n if (operations.length === 1 && errorCodes.length > 0) {\n errorCodes.forEach((errorCode: string) => {\n const op = operations[0]\n const entity = getEntityById(op.entityId as string)\n const entityName = entity?.label || entity?.name || op.entityId || ''\n const message = getErrorMessage(errorCode, op.entityType, entityName)\n toast.error(message)\n })\n } else {\n const op = operations[0]\n const entity = op && getEntityById(op.entityId as string)\n const entityName = entity?.label || entity?.name || op?.entityId || ''\n toast.error(\n operations.length === 1\n ? getErrorMessage(undefined, op.entityType, entityName)\n : 'Failed to update entities',\n )\n }\n // Remove the failed update from history stack\n if (pushHistory && pushToHistory && removeHistoryEntries) {\n removeHistoryEntries(1)\n }\n }\n },\n [\n projectName,\n updateEntities, //\n getEntityById,\n getInheritedDependents,\n pushHistory,\n removeHistoryEntries,\n ],\n )\n\n // set the attrib fields to be inherited from the parent\n // (remove the field from the ownAttrib array)\n // invalidate the cache for the folder/task so that it can be re-fetched with inherited values\n const inheritFromParent = useCallback<InheritFromParent>(\n async (entities, pushToHistory = true) => {\n if (!entities.length || !projectName) {\n return\n }\n\n // Record history for the inheritance operation\n if (pushToHistory && pushHistory) {\n // Create undo entities (restore explicit values)\n const undoEntities: HistoryEntityUpdate[] = []\n\n // For each entity and attribute being inherited, record current values\n for (const entity of entities) {\n const entityData = getEntityById(entity.entityId) as Record<string, any>\n\n // For each attribute that will be inherited, record its current value\n for (const attrib of entity.attribs) {\n if (entityData?.attrib && attrib in entityData.attrib) {\n undoEntities.push({\n rowId: entity.rowId,\n id: entityData?.entityId || entityData?.id || entity.entityId,\n type: entity.entityType,\n field: attrib,\n value: (entityData.attrib as Record<string, any>)[attrib],\n isAttrib: true,\n wasInherited: false, // Mark as not inherited\n ownAttrib: entityData?.ownAttrib || [],\n folderId: entityData?.folderId,\n meta: entityData.meta,\n })\n }\n }\n }\n\n // Create redo entities (to re-inherit)\n const redoEntities: HistoryEntityUpdate[] = entities.flatMap((entity) =>\n entity.attribs.map((attrib) => ({\n rowId: entity.rowId,\n id: entity.entityId,\n type: entity.entityType,\n field: attrib,\n value: null,\n isAttrib: true,\n wasInherited: true, // Mark as inherited\n ownAttrib: entity.ownAttrib,\n folderId: entity.folderId,\n meta: entity.meta,\n })),\n )\n\n // Push to history if we have changes to record\n if (undoEntities.length > 0) {\n pushHistory(undoEntities, redoEntities)\n }\n }\n\n const supportedEntityTypes: OperationModel['entityType'][] = ['task', 'folder']\n // Group operations by entity type for bulk processing\n const operations: OperationWithRowId[] = [] // operations sent to the server\n const entitiesToPatch: InheritFromParentEntity[] = []\n for (const entity of entities) {\n // Skip unsupported entity types\n let entityType = entity.entityType as OperationModel['entityType']\n if (!supportedEntityTypes.includes(entityType)) {\n continue\n }\n entityType = entityType as 'task' | 'folder'\n\n // Create data object with null values for each attrib to inherit\n const attribData: Record<string, null> = {}\n entity.attribs.forEach((attrib) => {\n attribData[attrib] = null\n })\n\n // Add new operation this is what's sent to the server and is actually updated in the DB\n operations.push({\n entityType: entityType,\n entityId: entity.entityId,\n rowId: entity.rowId,\n type: 'update',\n data: {\n attrib: attribData,\n },\n meta: entity.meta,\n })\n\n // check if this entity has a folderId that is in entities\n // if so we check their intersection attrib names\n const findTopFolder = () => {\n // For each entity, we need to find the top-most folder in the hierarchy\n const folderId = entity.folderId\n\n // Find all ancestor folders that are in our entities list\n const ancestorChain: InheritFromParentEntity[] = []\n let currentFolderId = folderId\n let currentFolder = entities.find((e) => e.entityId === currentFolderId)\n\n // Climb up the folder hierarchy to build the chain of ancestors\n while (currentFolder) {\n ancestorChain.push(currentFolder)\n currentFolderId = currentFolder.folderId\n currentFolder = entities.find((e) => e.entityId === currentFolderId)\n }\n\n // The top folder is the last one in our ancestor chain (if any)\n const topFolder =\n ancestorChain.length > 0 ? ancestorChain[ancestorChain.length - 1] : null\n\n return topFolder\n }\n\n const topFolder = findTopFolder()\n const folderAttribs = topFolder?.attribs || []\n const entityAttribsIntersection = entity.attribs.filter((attrib) =>\n folderAttribs.includes(attrib),\n )\n const entityAttribsRemoved = entity.attribs.filter(\n (attrib) => !folderAttribs.includes(attrib),\n )\n\n // only add to patch operations if there are attribs left\n if (entityAttribsRemoved.length > 0)\n entitiesToPatch.push({\n ...entity,\n attribs: entityAttribsRemoved,\n })\n\n if (topFolder && entityAttribsIntersection.length > 0) {\n entitiesToPatch.push({\n ...entity,\n attribs: entityAttribsIntersection,\n folderId: topFolder.folderId,\n })\n }\n }\n\n const patchOperations: PatchOperation[] = [] // operations only for patching the cache\n for (const entity of entitiesToPatch) {\n const entityType = entity.entityType as 'task' | 'folder'\n // we also need to update ownAttrib to remove the inherited attribs\n const ownAttrib = [...(entity.ownAttrib || [])].filter(\n (attrib) => !entity.attribs.includes(attrib),\n )\n\n // now we must calculate all the entities that need to be updated in the cache\n // first we need to find the the ancestor folder to inherit from\n const ancestorAttrib = findNonInheritedValues(entity.folderId, entity.attribs)\n\n const entityPatch = {\n entityId: entity.entityId,\n entityType: entityType,\n data: {\n attrib: ancestorAttrib,\n ownAttrib: ownAttrib,\n },\n }\n\n // create new patch operation for the entity\n patchOperations.push(entityPatch)\n\n // now find any dependent that also need updating\n const inheritedDependents = getInheritedDependents([\n { entityId: entity.entityId, entityType: entityType, attrib: ancestorAttrib },\n ])\n\n // convert to operations\n const inheritedDependentsOperations: PatchOperation[] = inheritedDependents.map((op) => ({\n entityId: op.entityId,\n entityType: op.entityType,\n data: {\n attrib: op.attrib,\n },\n }))\n\n // try to add to patch operations\n // if it already exists then merge the attribs\n for (const inheritedDependent of inheritedDependentsOperations) {\n const existingOperationIndex = patchOperations.findIndex(\n (op) => op.entityId === inheritedDependent.entityId,\n )\n\n if (existingOperationIndex !== -1) {\n // Merge attribs with existing operation\n const existingOperation = patchOperations[existingOperationIndex]\n let newAttrib = {\n // @ts-ignore\n ...(existingOperation.data?.attrib || {}),\n // @ts-ignore\n ...(inheritedDependent.data?.attrib || {}),\n }\n\n patchOperations[existingOperationIndex] = {\n ...existingOperation,\n data: { attrib: newAttrib },\n }\n } else {\n // Add new operation\n patchOperations.push({\n entityId: inheritedDependent.entityId,\n entityType: inheritedDependent.entityType,\n data: inheritedDependent.data,\n })\n }\n }\n }\n\n // now make api call to update all entities\n try {\n await updateEntities({\n operations,\n patchOperations,\n })\n } catch (error: any) {\n // Extract error code from operation result - check multiple paths\n const errorCodes = Array.isArray(error?.errorCodes) ? error.errorCodes : []\n if (operations.length === 1 && errorCodes.length > 0) {\n errorCodes.forEach((errorCode: string) => {\n const op = operations[0]\n const entity = getEntityById(op.entityId as string)\n const entityName = entity?.label || entity?.name || op.entityId || ''\n const message = getErrorMessage(errorCode, op.entityType, entityName)\n toast.error(message)\n })\n } else {\n const op = operations[0]\n const entity = op && getEntityById(op.entityId as string)\n const entityName = entity?.label || entity?.name || op?.entityId || ''\n toast.error(\n operations.length === 1\n ? getErrorMessage(undefined, op.entityType, entityName)\n : 'Failed to update entities',\n )\n }\n\n // Remove the failed update from history stack\n if (pushToHistory && pushHistory && removeHistoryEntries) {\n removeHistoryEntries(1)\n }\n }\n },\n [\n projectName,\n updateEntities,\n getInheritedDependents,\n findInheritedValueFromAncestors,\n pushHistory,\n removeHistoryEntries,\n ],\n )\n\n return { updateEntities: handleUpdateEntities, inheritFromParent }\n}\n\nexport default useUpdateTableData\n"],"names":["getErrorMessage","errorCode","entityType","entityName","useUpdateTableData","props","pushHistory","removeHistoryEntries","projectName","useProjectContext","getEntityById","getInheritedDependents","findInheritedValueFromAncestors","findNonInheritedValues","useProjectTableContext","updateEntities","useProjectTableQueriesContext","handleUpdateEntities","useCallback","entities","pushToHistory","entityUpdates","e","filteredUpdates","entity","filteredCount","toast","inverseEntities","rowId","id","type","field","isAttrib","meta","entityData","entityId","oldValue","ownAttrib","wasInherited","historyEntities","value","supportedEntityTypes","operations","data","existingOperationIndex","op","existingOperation","newData","folderAttribEntities","inheritedDependentsOperations","error","errorCodes","message","inheritFromParent","undoEntities","attrib","redoEntities","entitiesToPatch","attribData","topFolder","folderId","ancestorChain","currentFolderId","currentFolder","folderAttribs","entityAttribsIntersection","entityAttribsRemoved","patchOperations","ancestorAttrib","entityPatch","inheritedDependent","newAttrib"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAMA,IAAkB,CACtBC,GACAC,GACAC,MACW;AACX,UAAQF,GAAA;AAAA,IACN,KAAK;AACH,aAAO,GAAGC,CAAU,mBAAmBC,CAAU;AAAA,IACnD,KAAK;AACH,aAAO,GAAGD,CAAU,KAAKC,CAAU;AAAA,IACrC,KAAK;AACH,aAAO,GAAGD,CAAU,KAAKC,CAAU;AAAA,IACrC,KAAK;AACH,aAAO,GAAGD,CAAU,KAAKC,CAAU;AAAA,IACrC;AACE,aAAO,oBAAoBD,CAAU,KAAKC,CAAU;AAAA,EAAA;AAE1D,GAyCMC,KAAqB,CAACC,MAAoC;AAC9D,QAAM,EAAE,aAAAC,GAAa,sBAAAC,EAAA,IAAyBF,KAAS,CAAA,GACjD,EAAE,aAAAG,EAAA,IAAgBC,EAAA,GAClB;AAAA,IACJ,eAAAC;AAAA,IACA,wBAAAC;AAAA,IACA,iCAAAC;AAAA,IACA,wBAAAC;AAAA,EAAA,IACEC,EAAA,GACE,EAAE,gB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