@wisemen/wise-crm-web 2.0.0-alpha.44 → 2.0.0-alpha.46

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/README.md CHANGED
@@ -174,3 +174,73 @@ Type the arrays with `WiseCrmBusinessHeaderBadge`, `WiseCrmIndividualHeaderBadge
174
174
  - A skeleton is shown while `getData` is pending.
175
175
  - When `getData` throws, the badge is hidden and the error is logged; it is not retried.
176
176
  - Badges are not refetched when the entity is edited in the CRM, since the host app's data usually only follows through an event. To refresh them, for example on a websocket event, invalidate the `wiseCrmHeaderBadge` query key.
177
+
178
+ ## Extending the overview tables
179
+
180
+ ### Host entity overview
181
+
182
+ `WiseCrmBusinessTable` and `WiseCrmIndividualTable` can show the host app's rows and columns instead of the CRM's, for example to show, filter or sort on data the host app owns. The package keeps the search field, infinite scroll, error state and the link to the detail view. Register it through `overview` on the `business` / `individual` options of `useWiseCrmConfig().init()`:
183
+
184
+ ```ts
185
+ import type {
186
+ WiseCrmBusinessOverviewOptions,
187
+ WiseCrmBusinessUuid,
188
+ } from '@wisemen/wise-crm-web'
189
+
190
+ interface CustomerRow {
191
+ uuid: WiseCrmBusinessUuid
192
+ name: string
193
+ blocking: CustomerBlocking
194
+ }
195
+
196
+ useWiseCrmConfig().init({
197
+ // ...
198
+ options: {
199
+ business: {
200
+ overview: {
201
+ getData: ({ pagination, search }) => CustomerService.getIndex({ pagination, search }),
202
+ columns: [
203
+ {
204
+ key: 'name',
205
+ headerLabel: computed<string>(() => t('crm.business.table.name')),
206
+ size: {
207
+ max: '20rem',
208
+ min: '12rem',
209
+ },
210
+ component: CustomerNameCell,
211
+ },
212
+ {
213
+ key: 'blocking',
214
+ headerLabel: computed<string>(() => t('crm.business.table.blocking')),
215
+ component: CustomerBlockingCell,
216
+ },
217
+ ],
218
+ } satisfies WiseCrmBusinessOverviewOptions<CustomerRow>,
219
+ },
220
+ individual: {
221
+ overview: {...},
222
+ },
223
+ },
224
+ })
225
+ ```
226
+
227
+ | Field | Description |
228
+ | --------- | ----------- |
229
+ | `getData` | Receives `{ pagination: { limit, offset }, search }` and resolves to `{ data, meta: { limit, offset, total } }`. `search` is trimmed, or `null` when empty. Called instead of the CRM index. |
230
+ | `columns` | Replace the built-in columns. Each has a `key` (unique per table), a `headerLabel` (`ComputedRef<string>`), an optional `size` (`{ min, max }`) and a `component`. |
231
+
232
+ The package only reads `uuid` from a row: the CRM business or individual uuid, used as the row key and for the link to the detail view. Everything else is up to the host app's columns.
233
+
234
+ The column component receives the whole row and renders only the cell content; the package wraps it in the table cell:
235
+
236
+ ```vue
237
+ <script setup lang="ts">
238
+ const props = defineProps<{
239
+ row: CustomerRow
240
+ }>()
241
+ </script>
242
+ ```
243
+
244
+ - When `getData` throws, the table shows its error state.
245
+ - The table is not refetched when an entity is edited in the CRM, since the host app's data usually only follows through an event. To refresh it, invalidate the `wiseCrmHostEntityOverview` query key (optionally with `{ entity: 'business' }`).
246
+ - Without `overview`, the tables show the CRM index and columns as before.
@@ -1,11 +1,11 @@
1
1
  import { defineComponent as x, computed as f, openBlock as a, createBlock as m, unref as e, createElementBlock as k, renderSlot as se, withCtx as _, createVNode as u, mergeProps as pe, createTextVNode as _e, toDisplayString as O, createElementVNode as S, resolveDynamicComponent as V, ref as L, Fragment as T, createCommentVNode as D, normalizeClass as fe, renderList as K } from "vue";
2
2
  import { useRouteParams as ve } from "@vueuse/router";
3
3
  import { useI18n as N } from "vue-i18n";
4
- import { B as $, u as q, _ as ye, a as ge, b as he, c as Ce, d as Ue, e as xe, f as we, l as Be, A as Pe, g as Se, h as ke, i as De, j as ne, S as W, k as Ne, m as $e, J as X, o as J, n as te, p as Ie, q as Ae, W as Fe, r as Ee, s as Me, V as Qe, Q as Ve, t as Te, v as ie, I as ae, w as qe, x as ze, y as Oe, z as Le, C as Ke, D as je, E as Re, F as Ge, G as He } from "./index-D4L5GVbr.js";
5
- import { N as oe, _ as Je, u as We, a as Xe, b as Ye, c as Ze, d as ue, e as Q, C as re, f as F, g as es, h as ss, i as ns, j as ts, k as is } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-CTukbqp5.js";
4
+ import { B as I, u as q, _ as ye, a as ge, b as he, c as Ce, d as Ue, e as xe, f as we, l as Be, A as Pe, g as Se, h as ke, i as De, j as ne, S as W, k as Ne, m as $e, J as X, o as J, n as te, p as Ie, q as Ae, W as Fe, r as Ee, s as Me, V as Qe, Q as Ve, t as Te, v as ie, I as ae, w as qe, x as ze, y as Oe, z as Le, C as Ke, D as je, E as Re, F as Ge, G as He } from "./index-DoUWBza_.js";
5
+ import { N as oe, _ as Je, u as We, a as Xe, b as Ye, c as Ze, d as ue, e as Q, C as re, f as F, g as es, h as ss, i as ns, j as ts, k as is } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-CMzz9bVK.js";
6
6
  import { z as H } from "zod";
7
7
  import { bs as E } from "./uuid.util-DUuuAgdg.js";
8
- import { _ as as, c as os, a as us, b as Y, d as rs, e as ls, f as cs, u as ds, g as ms, h as bs, i as ps } from "./CrmDetailSidebarMapCard.vue_vue_type_script_setup_true_lang-CeS10J7W.js";
8
+ import { _ as as, c as os, a as us, b as Y, d as rs, e as ls, f as cs, u as ds, g as ms, h as bs, i as ps } from "./CrmDetailSidebarMapCard.vue_vue_type_script_setup_true_lang-CteTxdvx.js";
9
9
  import { useKeysetInfiniteQuery as le, useMutation as z, useQuery as _s } from "@wisemen/vue-core-api-utils";
10
10
  import { useOverlay as ce, UIButton as R, createAutocompleteOptions as fs, UIAutocomplete as vs, toFormField as ys, UIDialog as gs, UIFormDialog as de, UIDialogHeader as me, UIForm as Z, UIDialogFooter as hs, UIDialogFooterSubmit as Cs, UIIconButton as ee, UIPopover as Us, UIConfirmDialog as xs } from "@wisemen/vue-core-design-system";
11
11
  import { Motion as ws } from "motion-v";
@@ -13,7 +13,7 @@ import { useQueryClient as Bs, useMutation as Ps } from "@tanstack/vue-query";
13
13
  import { useForm as j } from "formango";
14
14
  function Ss(n) {
15
15
  return le("businessActivityIndex", {
16
- queryFn: (s) => $.getActivity(n.value, s.key)
16
+ queryFn: (s) => I.getActivity(n.value, s.key)
17
17
  });
18
18
  }
19
19
  const ks = /* @__PURE__ */ x({
@@ -106,7 +106,7 @@ function Is() {
106
106
  const {
107
107
  businessUuid: o,
108
108
  contactPersonUuid: l
109
- } = i, r = await $.setPrimaryContactPersonForBusiness(o, l);
109
+ } = i, r = await I.setPrimaryContactPersonForBusiness(o, l);
110
110
  if (r.isErr())
111
111
  throw r.error;
112
112
  },
@@ -181,7 +181,7 @@ function As() {
181
181
  queryFn: async ({
182
182
  body: n,
183
183
  params: s
184
- }) => await $.unlinkContactPerson(s.businessUuid, n.contactPersonUuid),
184
+ }) => await I.unlinkContactPerson(s.businessUuid, n.contactPersonUuid),
185
185
  queryKeysToInvalidate: {
186
186
  businessIndex: {},
187
187
  wiseCrmBusinessDetail: {
@@ -194,7 +194,7 @@ function Fs() {
194
194
  return z({
195
195
  queryFn: async ({
196
196
  params: n
197
- }) => await $.addChildBusiness(n.parentUuid, n.childUuid),
197
+ }) => await I.addChildBusiness(n.parentUuid, n.childUuid),
198
198
  queryKeysToInvalidate: {
199
199
  businessIndex: {},
200
200
  wiseCrmBusinessDetail: {
@@ -356,11 +356,11 @@ const Vs = /* @__PURE__ */ ye(Es, [["render", Qs]]), Ts = /* @__PURE__ */ x({
356
356
  onUpdateCbeSearchItem: g
357
357
  } = Se({
358
358
  onClose: y,
359
- onCreate: async (I) => {
359
+ onCreate: async (A) => {
360
360
  try {
361
361
  await p.execute({
362
362
  params: {
363
- childUuid: I,
363
+ childUuid: A,
364
364
  parentUuid: t.businessUuid
365
365
  }
366
366
  });
@@ -369,11 +369,11 @@ const Vs = /* @__PURE__ */ ye(Es, [["render", Qs]]), Ts = /* @__PURE__ */ x({
369
369
  }
370
370
  }
371
371
  });
372
- async function P(I) {
372
+ async function P(A) {
373
373
  try {
374
374
  await p.execute({
375
375
  params: {
376
- childUuid: I,
376
+ childUuid: A,
377
377
  parentUuid: t.businessUuid
378
378
  }
379
379
  }), i("close");
@@ -387,7 +387,7 @@ const Vs = /* @__PURE__ */ ye(Es, [["render", Qs]]), Ts = /* @__PURE__ */ x({
387
387
  function G() {
388
388
  c(), r.value = !0;
389
389
  }
390
- return (I, U) => (a(), m(e(gs), { onClose: y }, {
390
+ return (A, U) => (a(), m(e(gs), { onClose: y }, {
391
391
  default: _(() => [
392
392
  r.value ? (a(), m(ke, {
393
393
  key: 0,
@@ -410,7 +410,7 @@ const Vs = /* @__PURE__ */ ye(Es, [["render", Qs]]), Ts = /* @__PURE__ */ x({
410
410
  }, null, 8, ["title", "description", "icon"]),
411
411
  u(qs, {
412
412
  modelValue: b.value,
413
- "onUpdate:modelValue": U[0] || (U[0] = (A) => b.value = A),
413
+ "onUpdate:modelValue": U[0] || (U[0] = ($) => b.value = $),
414
414
  "parent-business-uuid": t.businessUuid,
415
415
  "on-submit": P,
416
416
  onCreateNew: G
@@ -428,7 +428,7 @@ function Hs() {
428
428
  queryFn: async ({
429
429
  body: n,
430
430
  params: s
431
- }) => await $.linkContactPerson(
431
+ }) => await I.linkContactPerson(
432
432
  s.businessUuid,
433
433
  n.contactPersonUuid,
434
434
  n.position,
@@ -587,7 +587,7 @@ function Ws() {
587
587
  queryFn: async ({
588
588
  body: n,
589
589
  params: s
590
- }) => await $.updateContactPerson(s.businessUuid, s.contactPersonUuid, n),
590
+ }) => await I.updateContactPerson(s.businessUuid, s.contactPersonUuid, n),
591
591
  queryKeysToInvalidate: {
592
592
  businessIndex: {},
593
593
  contactPersonDetail: {
@@ -610,7 +610,7 @@ function Xs(n, s) {
610
610
  throw new Error("Business UUID is null");
611
611
  if (s.value === null)
612
612
  throw new Error("Contact Person UUID is null");
613
- return $.getContactPerson(n.value, s.value);
613
+ return I.getContactPerson(n.value, s.value);
614
614
  }
615
615
  });
616
616
  }
@@ -871,7 +871,7 @@ const Ys = /* @__PURE__ */ x({
871
871
  f(() => ({
872
872
  businessUuid: s.business.uuid
873
873
  }))
874
- ), b = ce(), p = b.create(xs), y = Is(), v = As(), h = b.create(Js), d = b.create(Zs), C = b.create(Gs), w = f(() => s.business.contactPersons.length > 0), c = f(() => s.business.contactPersons.toSorted((U, A) => Number(A.isPrimary) - Number(U.isPrimary)));
874
+ ), b = ce(), p = b.create(xs), y = Is(), v = As(), h = b.create(Js), d = b.create(Zs), C = b.create(Gs), w = f(() => s.business.contactPersons.length > 0), c = f(() => s.business.contactPersons.toSorted((U, $) => Number($.isPrimary) - Number(U.isPrimary)));
875
875
  function g() {
876
876
  h.open({
877
877
  businessUuid: s.business.uuid
@@ -890,20 +890,15 @@ const Ys = /* @__PURE__ */ x({
890
890
  confirmLabel: t.t("shared.delete"),
891
891
  description: t.t("wise_crm.info_dialog.sidebar.overview.delete_contact_person_description"),
892
892
  onConfirm: async () => {
893
- try {
894
- await v.execute({
895
- body: {
896
- contactPersonUuid: U
897
- },
898
- params: {
899
- businessUuid: s.business.uuid
900
- }
901
- });
902
- } catch (A) {
903
- i.show(A);
904
- } finally {
905
- p.close();
906
- }
893
+ const $ = await v.execute({
894
+ body: {
895
+ contactPersonUuid: U
896
+ },
897
+ params: {
898
+ businessUuid: s.business.uuid
899
+ }
900
+ });
901
+ p.close(), $.isErr() && i.show($.error);
907
902
  }
908
903
  });
909
904
  }
@@ -915,12 +910,12 @@ const Ys = /* @__PURE__ */ x({
915
910
  }
916
911
  });
917
912
  }
918
- function I() {
913
+ function A() {
919
914
  C.open({
920
915
  businessUuid: s.business.uuid
921
916
  });
922
917
  }
923
- return (U, A) => (a(), m(ue, {
918
+ return (U, $) => (a(), m(ue, {
924
919
  "default-values": ["business", "invoice", "contact-persons", ...l.value.map((B) => `custom-${B.key}`)]
925
920
  }, {
926
921
  default: _(() => [
@@ -932,7 +927,7 @@ const Ys = /* @__PURE__ */ x({
932
927
  default: _(() => [
933
928
  u(mn, {
934
929
  business: n.business,
935
- onAddChild: I
930
+ onAddChild: A
936
931
  }, null, 8, ["business"])
937
932
  ]),
938
933
  _: 1