@anzusystems/common-admin 2.0.0-rc.14 → 2.0.0-rc.15

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 (27) hide show
  1. package/dist/common-admin.js +38 -35
  2. package/dist/domains/anzuUser/api/anzuUserApi.d.ts +1 -1
  3. package/dist/domains/anzuUser/api/anzuUserApi.js +2 -2
  4. package/dist/domains/anzuUser/api/anzuUserApi.js.map +1 -1
  5. package/dist/domains/anzuUser/components/AUserManageButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/domains/anzuUser/components/AUserMissingAccount.js +6 -0
  7. package/dist/domains/anzuUser/components/AUserMissingAccount.js.map +1 -0
  8. package/dist/domains/anzuUser/components/AUserMissingAccount.vue.d.ts +20 -0
  9. package/dist/domains/anzuUser/components/AUserMissingAccount.vue_vue_type_script_setup_true_lang.js +38 -0
  10. package/dist/domains/anzuUser/components/AUserMissingAccount.vue_vue_type_script_setup_true_lang.js.map +1 -0
  11. package/dist/domains/anzuUser/components/AUserOtherSystemsTable.vue.d.ts +56 -11
  12. package/dist/domains/anzuUser/components/AUserOtherSystemsTable.vue_vue_type_script_setup_true_lang.js +36 -27
  13. package/dist/domains/anzuUser/components/AUserOtherSystemsTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  14. package/dist/domains/anzuUser/components/AUserSystemPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/domains/anzuUser/components/AUserTabsShell.vue.d.ts +15 -33
  16. package/dist/domains/anzuUser/components/AUserTabsShell.vue_vue_type_script_setup_true_lang.js +54 -155
  17. package/dist/domains/anzuUser/components/AUserTabsShell.vue_vue_type_script_setup_true_lang.js.map +1 -1
  18. package/dist/domains/anzuUser/composables/anzuUserActions.d.ts +2 -0
  19. package/dist/domains/anzuUser/composables/anzuUserActions.js +74 -71
  20. package/dist/domains/anzuUser/composables/anzuUserActions.js.map +1 -1
  21. package/dist/domains/anzuUser/composables/userCreateFromSource.d.ts +70 -0
  22. package/dist/domains/anzuUser/composables/userCreateFromSource.js +62 -0
  23. package/dist/domains/anzuUser/composables/userCreateFromSource.js.map +1 -0
  24. package/dist/domains/anzuUser/utils/userTabs.d.ts +7 -1
  25. package/dist/domains/anzuUser/utils/userTabs.js.map +1 -1
  26. package/dist/lib.d.ts +5 -2
  27. package/package.json +2 -2
@@ -1,60 +1,42 @@
1
+ import { RouteLocationRaw } from 'vue-router';
1
2
  import { AnyUserSystemDescriptor } from '../composables/userSystemDescriptor';
2
- import { IntegerId } from '../../../shared/types/common';
3
3
  import { UserSystemRefreshHook } from '../composables/userSystemProbe';
4
+ import { UserSystemTab } from '../utils/userTabs';
4
5
  type __VLS_Props = {
5
- userId: IntegerId;
6
- /** Which tab carries the owning form, i.e. gets the slot. */
7
- owner: string;
8
6
  /**
9
- * The tabs in draw order. This component appends "other systems".
10
- * A prop, not derived from descriptors, because it depends on the route. admin-inhouse
11
- * owns four systems but has two tabs, since the system is part of the path.
7
+ * One per system this admin manages and the operator may open, in draw order.
8
+ * Each links to that system's user page in the page's mode (detail or edit); the admin decides which are shown.
12
9
  */
13
- ownedTabs: string[];
14
- /** Every system this admin can reach. The "other systems" tab lists the ones not in a tab. */
10
+ tabs: UserSystemTab[];
11
+ /** The "other systems" page. Without it the tab is not drawn. */
12
+ otherSystemsTo?: RouteLocationRaw | undefined;
13
+ /** The tab of the page shown: a system of `tabs` or `OTHER_SYSTEMS_TAB`. */
14
+ active: string;
15
+ /** For the tab labels. */
15
16
  descriptors: AnyUserSystemDescriptor[];
16
17
  /**
17
18
  * After a 401, refresh once and retry.
18
19
  * Each app refreshes differently (inhouse `refreshSession`, cms and contentHub a
19
20
  * `refresh-token` call), so the library cannot do it. Without it an expired token shows as "no
20
- * account in this system", which decision 16 forbids. Every panel in this shell receives it.
21
+ * account in this system", which decision 16 forbids. Every panel in the slot receives it.
21
22
  */
22
23
  refreshHook?: UserSystemRefreshHook | undefined;
23
- readonly?: boolean;
24
24
  /**
25
- * Whether the owning form has unsaved edits.
26
- * It drives the dot on the owning tab. The Save button stays visible
27
- * everywhere, because a hidden button would read as read-only.
28
- * It also drives the leave guard. Switching tabs is not navigation,
29
- * so nothing else asks before a panel button leaves the page.
25
+ * Whether the page's form has unsaved edits.
26
+ * It drives the dot on the active tab and the leave guard, which asks before a tab leaves the page.
30
27
  */
31
28
  unsavedChanges?: boolean;
32
- tabQueryKey?: string;
33
29
  };
34
- type __VLS_ModelProps = {
35
- 'activeTab'?: string;
36
- };
37
- type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
38
30
  declare const __VLS_template: () => {
39
31
  __VLS_Slots: {
40
32
  default?: (props: {}) => any;
41
33
  };
42
34
  };
43
35
  type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
44
- declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
45
- refresh: () => void;
46
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
47
- "update:activeTab": (value: string) => any;
48
- } & {
49
- created: (descriptor: AnyUserSystemDescriptor) => any;
50
- }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
51
- onCreated?: ((descriptor: AnyUserSystemDescriptor) => any) | undefined;
52
- "onUpdate:activeTab"?: ((value: string) => any) | undefined;
53
- }>, {
36
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
54
37
  unsavedChanges: boolean;
55
- readonly: boolean;
56
38
  refreshHook: UserSystemRefreshHook;
57
- tabQueryKey: string;
39
+ otherSystemsTo: string | import('vue-router').RouteLocationAsRelativeGeneric | import('vue-router').RouteLocationAsPathGeneric;
58
40
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
59
41
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
60
42
  declare const _default: typeof __VLS_export;
@@ -1,179 +1,78 @@
1
- import { useAlerts as e } from "../../system/composables/alerts.js";
2
- import { useAnzuUserFactory as t } from "../factory/AnzuUserFactory.js";
3
- import { cloneDeep as n, isNull as r, isUndefined as i } from "../../../shared/utils/common.js";
4
- import { BulkOutcome as a } from "../store/userCrossSystemStore.js";
5
- import { useUserCrossSystemWrites as o } from "../composables/userCrossSystemWrites.js";
6
- import s from "../../unsavedGuard/components/AUnsavedConfirmDialog.js";
7
- import { useUnsavedChangesGuard as c } from "../../unsavedGuard/composables/useUnsavedChangesGuard.js";
8
- import ee from "./AUserOtherSystemsTable.js";
9
- import te from "./AUserSystemPanel.js";
10
- import { descriptorMayWrite as l } from "../composables/userSystemDescriptor.js";
11
- import { UserSystemRefreshHookKey as ne } from "../composables/userSystemProbe.js";
12
- import { OTHER_SYSTEMS_TAB as u } from "../utils/userTabs.js";
13
- import { Fragment as d, computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createTextVNode as re, createVNode as g, defineComponent as _, isRef as v, mergeModels as y, onMounted as ie, openBlock as b, provide as ae, ref as x, renderList as S, renderSlot as oe, toDisplayString as se, unref as C, useModel as w, watch as T, withCtx as E } from "vue";
14
- import { useI18n as ce } from "vue-i18n";
15
- import { VIcon as le } from "vuetify/components/VIcon";
16
- import { useRoute as D, useRouter as O } from "vue-router";
17
- import { VTab as k, VTabs as ue } from "vuetify/components/VTabs";
18
- import { VWindow as de, VWindowItem as A } from "vuetify/components/VWindow";
1
+ import e from "../../unsavedGuard/components/AUnsavedConfirmDialog.js";
2
+ import { useUnsavedChangesGuard as t } from "../../unsavedGuard/composables/useUnsavedChangesGuard.js";
3
+ import { UserSystemRefreshHookKey as n } from "../composables/userSystemProbe.js";
4
+ import { OTHER_SYSTEMS_TAB as r } from "../utils/userTabs.js";
5
+ import { isUndefined as i } from "../../../shared/utils/common.js";
6
+ import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, isRef as m, openBlock as h, provide as g, renderList as _, renderSlot as v, toDisplayString as y, unref as b, withCtx as x } from "vue";
7
+ import { useI18n as S } from "vue-i18n";
8
+ import { VIcon as C } from "vuetify/components/VIcon";
9
+ import { VTab as w, VTabs as T } from "vuetify/components/VTabs";
19
10
  // src/domains/anzuUser/components/AUserTabsShell.vue?vue&type=script&setup=true&lang.ts
20
- var j = /*@__PURE__*/ _({
11
+ var E = { class: "mt-4" }, D = /*@__PURE__*/ p({
21
12
  __name: "AUserTabsShell",
22
- props: /*@__PURE__*/ y({
23
- userId: {},
24
- owner: {},
25
- ownedTabs: {},
13
+ props: {
14
+ tabs: {},
15
+ otherSystemsTo: { default: void 0 },
16
+ active: {},
26
17
  descriptors: {},
27
18
  refreshHook: {
28
19
  type: Function,
29
20
  default: void 0
30
21
  },
31
- readonly: {
32
- type: Boolean,
33
- default: !1
34
- },
35
22
  unsavedChanges: {
36
23
  type: Boolean,
37
24
  default: !1
38
- },
39
- tabQueryKey: { default: "tab" }
40
- }, {
41
- activeTab: {
42
- required: !1,
43
- default: ""
44
- },
45
- activeTabModifiers: {}
46
- }),
47
- emits: /*@__PURE__*/ y(["created"], ["update:activeTab"]),
48
- setup(_, { expose: y, emit: j }) {
49
- let M = _, N = j, P = w(_, "activeTab"), { t: F } = ce(), I = D(), L = O(), R = f(() => new Map(M.descriptors.map((e) => [e.system, e]))), z = f(() => [...M.ownedTabs, u]), B = f(() => M.descriptors.filter((e) => !M.ownedTabs.includes(e.system))), V = (e) => R.value.get(e)?.label ?? e, H = (e) => typeof e == "string" && z.value.includes(e);
50
- ie(() => {
51
- let e = I.query[M.tabQueryKey];
52
- P.value = H(e) ? e : M.owner;
53
- }), T(P, (e) => {
54
- H(e) && L.replace({ query: {
55
- ...I.query,
56
- [M.tabQueryKey]: e
57
- } });
58
- });
59
- let fe = f(() => M.unsavedChanges), { hasUnsavedChanges: pe, dirtyLabels: me, promptOpen: U, resolvePrompt: he } = c({ sources: [fe] }), W = x(null), G = x([]), K = o(), { createAnzuUser: ge } = t(), { showError: q, showRecordWas: _e } = e();
60
- i(M.refreshHook) || ae(ne, M.refreshHook);
61
- let J = f(() => R.value.get(M.owner)), Y = x(null), X = x(null), Z = async () => {
62
- let e = J.value;
63
- i(e) || (Y.value = await K.readSourceUser(e, M.userId));
64
- }, Q = f(() => Y.value?.enabled === !0), $ = async (e, t) => {
65
- let o = J.value;
66
- if (!i(o)) {
67
- X.value = e.system;
68
- try {
69
- let i = await K.readSourceUser(o, M.userId);
70
- if (r(i)) {
71
- q(F("common.userSystem.create.sourceUnreadable", { system: V(o.system) }));
72
- return;
73
- }
74
- if (i.enabled !== Q.value) {
75
- Y.value = i, q(F("common.userSystem.create.sourceChanged"));
76
- return;
77
- }
78
- if (!l(e, "create")) return;
79
- let s = ge(e.system);
80
- s.id = i.id, s.email = t.email, s.person = n(t.person), s.avatar = n(t.avatar), s.enabled = i.enabled;
81
- let c = await K.createInSystem(e, s);
82
- if (c.outcome !== a.Done) {
83
- q(V(e.system) + ": " + F("common.userSystem.bulk.outcome." + c.outcome));
84
- return;
85
- }
86
- _e("created"), N("created", e), W.value?.refreshSystem(e.system), G.value.forEach((e) => e?.refresh());
87
- } finally {
88
- X.value = null;
89
- }
90
- }
91
- };
92
- return T(P, (e) => {
93
- H(e) && e !== M.owner && r(Y.value) && Z();
94
- }, { immediate: !0 }), y({ refresh: () => {
95
- Z(), W.value?.refresh(), G.value.forEach((e) => e?.refresh());
96
- } }), (e, t) => (b(), h("div", null, [
97
- g(ue, {
98
- modelValue: P.value,
99
- "onUpdate:modelValue": t[0] ||= (e) => P.value = e,
25
+ }
26
+ },
27
+ setup(p) {
28
+ let D = p, { t: O } = S(), k = o(() => new Map(D.descriptors.map((e) => [e.system, e]))), A = (e) => k.value.get(e)?.label ?? e, j = o(() => D.unsavedChanges), { hasUnsavedChanges: M, dirtyLabels: N, promptOpen: P, resolvePrompt: F } = t({ sources: [j] });
29
+ return i(D.refreshHook) || g(n, D.refreshHook), (t, n) => (h(), l("div", null, [
30
+ f(T, {
31
+ "model-value": p.active,
100
32
  "data-cy": "user-tabs"
101
33
  }, {
102
- default: E(() => [(b(!0), h(d, null, S(z.value, (e) => (b(), p(k, {
103
- key: e,
104
- value: e,
105
- "data-cy": `user-tab-${e}`
34
+ default: x(() => [(h(!0), l(a, null, _(p.tabs, (e) => (h(), s(w, {
35
+ key: e.system,
36
+ value: e.system,
37
+ to: e.to,
38
+ exact: "",
39
+ "data-cy": `user-tab-${e.system}`
106
40
  }, {
107
- default: E(() => [re(se(e === C("__otherSystems") ? C(F)("common.userSystem.tab.otherSystems") : V(e)) + " ", 1), e === _.owner && C(pe) ? (b(), p(le, {
41
+ default: x(() => [d(y(A(e.system)) + " ", 1), e.system === p.active && b(M) ? (h(), s(C, {
108
42
  key: 0,
109
43
  class: "ml-1",
110
44
  size: "x-small",
111
45
  color: "warning",
112
46
  icon: "mdi-circle",
113
47
  "data-cy": "user-tab-unsaved"
114
- })) : m("", !0)]),
48
+ })) : c("", !0)]),
115
49
  _: 2
116
- }, 1032, ["value", "data-cy"]))), 128))]),
117
- _: 1
118
- }, 8, ["modelValue"]),
119
- g(de, {
120
- modelValue: P.value,
121
- "onUpdate:modelValue": t[1] ||= (e) => P.value = e,
122
- class: "mt-4"
123
- }, {
124
- default: E(() => [(b(!0), h(d, null, S(_.ownedTabs, (t) => (b(), p(A, {
125
- key: t,
126
- value: t
50
+ }, 1032, [
51
+ "value",
52
+ "to",
53
+ "data-cy"
54
+ ]))), 128)), b(i)(p.otherSystemsTo) ? c("", !0) : (h(), s(w, {
55
+ key: 0,
56
+ value: b(r),
57
+ to: p.otherSystemsTo,
58
+ exact: "",
59
+ "data-cy": `user-tab-${b(r)}`
127
60
  }, {
128
- default: E(() => [t === _.owner ? oe(e.$slots, "default", {}, void 0, void 0, 0) : C(i)(R.value.get(t)) ? m("", !0) : (b(), p(te, {
129
- key: 1,
130
- ref_for: !0,
131
- ref_key: "ownedPanels",
132
- ref: G,
133
- descriptor: R.value.get(t),
134
- "user-id": _.userId,
135
- readonly: _.readonly,
136
- "create-enabled": Q.value,
137
- source: Y.value,
138
- creating: X.value === t,
139
- onCreate: $
140
- }, null, 8, [
141
- "descriptor",
142
- "user-id",
143
- "readonly",
144
- "create-enabled",
145
- "source",
146
- "creating"
147
- ]))]),
148
- _: 2
149
- }, 1032, ["value"]))), 128)), g(A, { value: C(u) }, {
150
- default: E(() => [g(ee, {
151
- ref_key: "otherSystems",
152
- ref: W,
153
- descriptors: B.value,
154
- "user-id": _.userId,
155
- readonly: _.readonly,
156
- "create-enabled": Q.value,
157
- source: Y.value,
158
- "creating-system": X.value,
159
- onCreate: $
160
- }, null, 8, [
161
- "descriptors",
162
- "user-id",
163
- "readonly",
164
- "create-enabled",
165
- "source",
166
- "creating-system"
167
- ])]),
61
+ default: x(() => [d(y(b(O)("common.userSystem.tab.otherSystems")), 1)]),
168
62
  _: 1
169
- }, 8, ["value"])]),
170
- _: 3
171
- }, 8, ["modelValue"]),
172
- g(s, {
173
- modelValue: C(U),
174
- "onUpdate:modelValue": t[2] ||= (e) => v(U) ? U.value = e : null,
175
- "dirty-labels": C(me),
176
- onResolve: C(he)
63
+ }, 8, [
64
+ "value",
65
+ "to",
66
+ "data-cy"
67
+ ]))]),
68
+ _: 1
69
+ }, 8, ["model-value"]),
70
+ u("div", E, [v(t.$slots, "default")]),
71
+ f(e, {
72
+ modelValue: b(P),
73
+ "onUpdate:modelValue": n[0] ||= (e) => m(P) ? P.value = e : null,
74
+ "dirty-labels": b(N),
75
+ onResolve: b(F)
177
76
  }, null, 8, [
178
77
  "modelValue",
179
78
  "dirty-labels",
@@ -182,6 +81,6 @@ var j = /*@__PURE__*/ _({
182
81
  ]));
183
82
  }
184
83
  });
185
- export { j as default };
84
+ export { D as default };
186
85
 
187
86
  //# sourceMappingURL=AUserTabsShell.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AUserTabsShell.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_createVNode","_component_VTabs","_withCtx","_Fragment","_renderList","_createBlock","_component_VTab","_createTextVNode","_toDisplayString","_unref","_component_VIcon","_component_VWindow","_component_VWindowItem","_renderSlot","AUserSystemPanel","AUserOtherSystemsTable","AUnsavedConfirmDialog","_isRef","AUnsavedConfirmDialog_default","AUserOtherSystemsTable_default","AUserSystemPanel_default","AUserTabsShell_vue_vue_type_script_setup_true_lang_default","\"activeTab\"","\"activeTabModifiers\"","__expose","__emit","props","__props","emit","activeTab","useModel","useI18n","route","useRoute","router","useRouter","bySystem","computed","item","tabs","OTHER_SYSTEMS_TAB","otherDescriptors","labelFor","system","isValidTab","value","onMounted","fromUrl","watch","unsavedSource","useUnsavedChangesGuard","otherSystems","ref","ownedPanels","writes","useUserCrossSystemWrites","useAnzuUserFactory","useAlerts","isUndefined","provide","UserSystemRefreshHookKey","ownerDescriptor","sourceUser","creatingSystem","loadSource","descriptor","createEnabled","onCreate","owner","source","isNull","t","showError","descriptorMayWrite","body","createAnzuUser","metadata","cloneDeep","result","BulkOutcome","showRecordWas","panel","openBlock","createElementBlock","createVNode","VTabs","_cache","$event","withCtx","Fragment","renderList","createBlock","VTab","tab","createTextVNode","toDisplayString","unref","hasUnsavedChanges","VIcon","createCommentVNode","VWindow","VWindowItem","renderSlot","_ctx","promptOpen","isRef","dirtyLabels","resolvePrompt"],"sources":["../../../../src/domains/anzuUser/components/AUserTabsShell.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, onMounted, provide, ref, watch } from 'vue'\nimport { useI18n } from 'vue-i18n'\nimport { useRoute, useRouter } from 'vue-router'\nimport { useAlerts } from '@/domains/system/composables/alerts'\nimport { useAnzuUserFactory } from '@/domains/anzuUser/factory/AnzuUserFactory'\nimport { cloneDeep, isNull, isUndefined } from '@/shared/utils/common'\nimport { BulkOutcome } from '@/domains/anzuUser/store/userCrossSystemStore'\nimport { useUserCrossSystemWrites } from '@/domains/anzuUser/composables/userCrossSystemWrites'\nimport AUnsavedConfirmDialog from '@/domains/unsavedGuard/components/AUnsavedConfirmDialog.vue'\nimport { useUnsavedChangesGuard } from '@/domains/unsavedGuard/composables/useUnsavedChangesGuard'\nimport AUserOtherSystemsTable from '@/domains/anzuUser/components/AUserOtherSystemsTable.vue'\nimport AUserSystemPanel from '@/domains/anzuUser/components/AUserSystemPanel.vue'\nimport { type AnyUserSystemDescriptor, descriptorMayWrite } from '@/domains/anzuUser/composables/userSystemDescriptor'\nimport type { AnzuUser, BaseUser } from '@/shared/types/AnzuUser'\nimport type { IntegerId } from '@/shared/types/common'\nimport { UserSystemRefreshHookKey, type UserSystemRefreshHook } from '@/domains/anzuUser/composables/userSystemProbe'\nimport { OTHER_SYSTEMS_TAB } from '@/domains/anzuUser/utils/userTabs'\n\nconst props = withDefaults(\n defineProps<{\n userId: IntegerId\n /** Which tab carries the owning form, i.e. gets the slot. */\n owner: string\n /**\n * The tabs in draw order. This component appends \"other systems\".\n * A prop, not derived from descriptors, because it depends on the route. admin-inhouse\n * owns four systems but has two tabs, since the system is part of the path.\n */\n ownedTabs: string[]\n /** Every system this admin can reach. The \"other systems\" tab lists the ones not in a tab. */\n descriptors: AnyUserSystemDescriptor[]\n /**\n * After a 401, refresh once and retry.\n * Each app refreshes differently (inhouse `refreshSession`, cms and contentHub a\n * `refresh-token` call), so the library cannot do it. Without it an expired token shows as \"no\n * account in this system\", which decision 16 forbids. Every panel in this shell receives it.\n */\n refreshHook?: UserSystemRefreshHook | undefined\n readonly?: boolean\n /**\n * Whether the owning form has unsaved edits.\n * It drives the dot on the owning tab. The Save button stays visible\n * everywhere, because a hidden button would read as read-only.\n * It also drives the leave guard. Switching tabs is not navigation,\n * so nothing else asks before a panel button leaves the page.\n */\n unsavedChanges?: boolean\n tabQueryKey?: string\n }>(),\n {\n refreshHook: undefined,\n readonly: false,\n unsavedChanges: false,\n tabQueryKey: 'tab',\n }\n)\n\nconst emit = defineEmits<{\n /** After an account was created in another system, so a page can react if it wants to. */\n (e: 'created', descriptor: AnyUserSystemDescriptor): void\n}>()\n\nconst activeTab = defineModel<string>('activeTab', { required: false, default: '' })\n\nconst { t } = useI18n()\nconst route = useRoute()\nconst router = useRouter()\n\nconst bySystem = computed(() => new Map(props.descriptors.map((item) => [item.system, item])))\n\nconst tabs = computed(() => [...props.ownedTabs, OTHER_SYSTEMS_TAB])\n\nconst otherDescriptors = computed(() => props.descriptors.filter((item) => !props.ownedTabs.includes(item.system)))\n\nconst labelFor = (system: string) => bySystem.value.get(system)?.label ?? system\n\nconst isValidTab = (value: unknown): value is string => typeof value === 'string' && tabs.value.includes(value)\n\nonMounted(() => {\n const fromUrl = route.query[props.tabQueryKey]\n // An unknown tab, for example a system removed from the configuration\n // since the link was sent, is ignored silently and the owning tab opens.\n activeTab.value = isValidTab(fromUrl) ? fromUrl : props.owner\n})\n\nwatch(activeTab, (value) => {\n if (!isValidTab(value)) return\n // `replace`, not `push`: with `push` the back button would walk through the tabs instead of\n // leaving the page.\n void router.replace({ query: { ...route.query, [props.tabQueryKey]: value } })\n})\n\n/**\n * Registered here, not in the page, because an internal \"manage in X\" link inside a\n * panel leaves from here and `onBeforeRouteLeave` must be bound inside the route.\n * An external link opens a new tab and needs no guard.\n */\nconst unsavedSource = computed(() => props.unsavedChanges)\nconst { hasUnsavedChanges, dirtyLabels, promptOpen, resolvePrompt } = useUnsavedChangesGuard({\n sources: [unsavedSource],\n})\n\nconst otherSystems = ref<InstanceType<typeof AUserOtherSystemsTable> | null>(null)\nconst ownedPanels = ref<InstanceType<typeof AUserSystemPanel>[]>([])\n\n/**\n * Creating this person's account in another system.\n * Handled here because the panel offering it lives here and the\n * operation belongs to the library. The page would only pass it through.\n */\nconst writes = useUserCrossSystemWrites()\nconst { createAnzuUser } = useAnzuUserFactory()\nconst { showError, showRecordWas } = useAlerts()\n\n// Provide only when present. Providing `undefined` explicitly would signal a hook to code that only checks for the key.\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nif (!isUndefined(props.refreshHook)) provide(UserSystemRefreshHookKey, props.refreshHook)\n\nconst ownerDescriptor = computed(() => bySystem.value.get(props.owner))\n/**\n * The owning system's record as the server holds it, not as the form does.\n * Read together with the panels, so the owning tab costs nothing, and read again before each POST. An unsaved\n * switch in the form must not be copied, because in blog and forum it would mean a working public account.\n */\nconst sourceUser = ref<AnzuUser | null>(null)\nconst creatingSystem = ref<string | null>(null)\n\nconst loadSource = async () => {\n const descriptor = ownerDescriptor.value\n if (isUndefined(descriptor)) return\n sourceUser.value = await writes.readSourceUser(descriptor, props.userId)\n}\n\n/** Copying a person into another system copies whether they are switched on. Roles stay empty. */\nconst createEnabled = computed(() => sourceUser.value?.enabled === true)\n\nconst onCreate = async (descriptor: AnyUserSystemDescriptor, metadata: BaseUser) => {\n const owner = ownerDescriptor.value\n if (isUndefined(owner)) return\n creatingSystem.value = descriptor.system\n try {\n const source = await writes.readSourceUser(owner, props.userId)\n if (isNull(source)) {\n showError(t('common.userSystem.create.sourceUnreadable', { system: labelFor(owner.system) }))\n return\n }\n // The dialog already promised \"created ready to use\" or \"created switched off\" from the earlier read. If the\n // server now disagrees, the promise was wrong, and in blog and forum that means a working public account.\n // Usually the first read failed, leaving `sourceUser` null and the dialog saying \"disabled\"\n // for an enabled account. Nothing is written until the corrected row is confirmed again.\n if (source.enabled !== createEnabled.value) {\n sourceUser.value = source\n showError(t('common.userSystem.create.sourceChanged'))\n return\n }\n // The create right may have been lost while the source was read. Nothing is offered then, so nothing is reported.\n if (!descriptorMayWrite(descriptor, 'create')) return\n // Built by the library factory, never by hand. A body of base fields\n // alone makes the backend add `ROLE_USER`, a role nobody granted.\n // Metadata comes from the dialog, validated against the target's profile. The source may leave fields empty\n // (blog never fills `person`) that the target requires. The id and `enabled` come from the fresh read.\n const body = createAnzuUser(descriptor.system)\n body.id = source.id\n body.email = metadata.email\n body.person = cloneDeep(metadata.person)\n body.avatar = cloneDeep(metadata.avatar)\n body.enabled = source.enabled\n const result = await writes.createInSystem(descriptor, body)\n if (result.outcome !== BulkOutcome.Done) {\n // Without this message the failure looked like success: the\n // re-probed row still said \"absent\" with no explanation.\n showError(labelFor(descriptor.system) + ': ' + t('common.userSystem.bulk.outcome.' + result.outcome))\n return\n }\n showRecordWas('created')\n emit('created', descriptor)\n otherSystems.value?.refreshSystem(descriptor.system)\n ownedPanels.value.forEach((panel) => panel?.refresh())\n } finally {\n creatingSystem.value = null\n }\n}\n\n/**\n * Called by the page after the owning form saved.\n * `VWindowItem` hides panels with `v-show`, so a mounted panel never re-fetches by itself. Without\n * this it shows pre-save data, and create-in-another-system would copy that stale snapshot.\n * Not a refetch on every tab activation: that would cost eight calls per tab switch.\n */\nconst refresh = () => {\n void loadSource()\n otherSystems.value?.refresh()\n ownedPanels.value.forEach((panel) => panel?.refresh())\n}\n\n// Read on the first activation of a non-owning tab, so the owning tab makes no foreign call.\nwatch(\n activeTab,\n (value) => {\n // `isValidTab` first: before mount settles, the model is an empty string.\n // Treating it as a non-owning tab would fetch on the owning tab too.\n if (!isValidTab(value) || value === props.owner) return\n if (isNull(sourceUser.value)) void loadSource()\n },\n { immediate: true }\n)\n\ndefineExpose({ refresh })\n</script>\n\n<template>\n <div>\n <!--\n No tab navigates. Tabs only switch content, and leaving the page is done by the Manage\n anchor inside a panel. `VTab` renders `role=\"tab\"` and cannot carry navigation semantically.\n -->\n <VTabs\n v-model=\"activeTab\"\n data-cy=\"user-tabs\"\n >\n <VTab\n v-for=\"tab in tabs\"\n :key=\"tab\"\n :value=\"tab\"\n :data-cy=\"`user-tab-${tab}`\"\n >\n {{ tab === OTHER_SYSTEMS_TAB ? t('common.userSystem.tab.otherSystems') : labelFor(tab) }}\n <!-- The owning tab says it holds unsaved work; the Save button itself is always visible. -->\n <VIcon\n v-if=\"tab === owner && hasUnsavedChanges\"\n class=\"ml-1\"\n size=\"x-small\"\n color=\"warning\"\n icon=\"mdi-circle\"\n data-cy=\"user-tab-unsaved\"\n />\n </VTab>\n </VTabs>\n <VWindow\n v-model=\"activeTab\"\n class=\"mt-4\"\n >\n <VWindowItem\n v-for=\"tab in ownedTabs\"\n :key=\"tab\"\n :value=\"tab\"\n >\n <!-- The owning system of the current route: the full form. -->\n <slot v-if=\"tab === owner\" />\n <!--\n Another system this admin owns whose route is not open: a probe\n with a summary and a Manage button, like any other system.\n -->\n <AUserSystemPanel\n v-else-if=\"!isUndefined(bySystem.get(tab))\"\n ref=\"ownedPanels\"\n :descriptor=\"bySystem.get(tab)!\"\n :user-id=\"userId\"\n :readonly=\"readonly\"\n :create-enabled=\"createEnabled\"\n :source=\"sourceUser\"\n :creating=\"creatingSystem === tab\"\n @create=\"onCreate\"\n />\n </VWindowItem>\n <VWindowItem :value=\"OTHER_SYSTEMS_TAB\">\n <!-- `VWindowItem` renders content on first activation, so opening a user makes no foreign calls. -->\n <AUserOtherSystemsTable\n ref=\"otherSystems\"\n :descriptors=\"otherDescriptors\"\n :user-id=\"userId\"\n :readonly=\"readonly\"\n :create-enabled=\"createEnabled\"\n :source=\"sourceUser\"\n :creating-system=\"creatingSystem\"\n @create=\"onCreate\"\n />\n </VWindowItem>\n </VWindow>\n <AUnsavedConfirmDialog\n v-model=\"promptOpen\"\n :dirty-labels=\"dirtyLabels\"\n @resolve=\"resolvePrompt\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBA,IAAM6B,IAAQC,GAuCRC,IAAOH,GAKPI,IAAYhC,EAAmB8B,GAAC,WAA6C,GAE7E,EAAE,SAAMI,GAAQ,GAChBC,IAAQC,EAAS,GACjBC,IAASC,EAAU,GAEnBC,IAAWC,QAAe,IAAI,IAAIX,EAAM,YAAY,KAAK,MAAS,CAACY,EAAK,QAAQA,CAAI,CAAC,CAAC,CAAC,GAEvFC,IAAOF,QAAe,CAAC,GAAGX,EAAM,WAAWc,CAAiB,CAAC,GAE7DC,IAAmBJ,QAAeX,EAAM,YAAY,QAAQ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;MAC5B,WAASlE,EAAA;MACT,UAAUA,EAAA;MACV,kBAAgBuC,EAAA;MAChB,QAAQJ,EAAA;MACR,UAAUC,EAAA,UAAmB8B;MACrB;;;;;;;;;;I,8BAGb7F,EAYcY,GAAA,EAZA,OAAOH,EAAA+B,CAAA,EAAiB,GAAA;KAEpC,SAAAtC,QASE,CATFF,EASEe,IAAA;MARI,SAAA;MAAJ,KAAIoC;MACH,aAAaV,EAAA;MACb,WAASd,EAAA;MACT,UAAUA,EAAA;MACV,kBAAgBuC,EAAA;MAChB,QAAQJ,EAAA;MACR,mBAAiBC,EAAA;MACT;;;;;;;;;;;;;GAIf/D,EAIEgB,GAAA;IAHS,YAAAP,EAAA+F,CAAA;IAAA,uBAAA,AAAAlB,EAAA,QAAA,MAAArE,EAAAuF,CAAA,IAAA,EAAU,QAAAjB,IAAA;IAClB,gBAAc9E,EAAAiG,EAAA;IACd,WAASjG,EAAAkG,EAAA"}
1
+ {"version":3,"file":"AUserTabsShell.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createVNode","_component_VTabs","_withCtx","_Fragment","_renderList","_createBlock","_component_VTab","_createTextVNode","_toDisplayString","_unref","_component_VIcon","_createElementVNode","_renderSlot","AUnsavedConfirmDialog","_isRef","AUnsavedConfirmDialog_default","_hoisted_1","AUserTabsShell_vue_vue_type_script_setup_true_lang_default","props","__props","useI18n","bySystem","computed","item","labelFor","system","unsavedSource","useUnsavedChangesGuard","isUndefined","provide","UserSystemRefreshHookKey","openBlock","createElementBlock","createVNode","VTabs","withCtx","Fragment","renderList","createBlock","VTab","tab","createTextVNode","toDisplayString","unref","hasUnsavedChanges","VIcon","createCommentVNode","OTHER_SYSTEMS_TAB","t","createElementVNode","renderSlot","_ctx","promptOpen","_cache","isRef","$event","dirtyLabels","resolvePrompt"],"sources":["../../../../src/domains/anzuUser/components/AUserTabsShell.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, provide } from 'vue'\nimport { useI18n } from 'vue-i18n'\nimport type { RouteLocationRaw } from 'vue-router'\nimport AUnsavedConfirmDialog from '@/domains/unsavedGuard/components/AUnsavedConfirmDialog.vue'\nimport { useUnsavedChangesGuard } from '@/domains/unsavedGuard/composables/useUnsavedChangesGuard'\nimport type { AnyUserSystemDescriptor } from '@/domains/anzuUser/composables/userSystemDescriptor'\nimport { UserSystemRefreshHookKey, type UserSystemRefreshHook } from '@/domains/anzuUser/composables/userSystemProbe'\nimport { OTHER_SYSTEMS_TAB, type UserSystemTab } from '@/domains/anzuUser/utils/userTabs'\nimport { isUndefined } from '@/shared/utils/common'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * One per system this admin manages and the operator may open, in draw order.\n * Each links to that system's user page in the page's mode (detail or edit); the admin decides which are shown.\n */\n tabs: UserSystemTab[]\n /** The \"other systems\" page. Without it the tab is not drawn. */\n otherSystemsTo?: RouteLocationRaw | undefined\n /** The tab of the page shown: a system of `tabs` or `OTHER_SYSTEMS_TAB`. */\n active: string\n /** For the tab labels. */\n descriptors: AnyUserSystemDescriptor[]\n /**\n * After a 401, refresh once and retry.\n * Each app refreshes differently (inhouse `refreshSession`, cms and contentHub a\n * `refresh-token` call), so the library cannot do it. Without it an expired token shows as \"no\n * account in this system\", which decision 16 forbids. Every panel in the slot receives it.\n */\n refreshHook?: UserSystemRefreshHook | undefined\n /**\n * Whether the page's form has unsaved edits.\n * It drives the dot on the active tab and the leave guard, which asks before a tab leaves the page.\n */\n unsavedChanges?: boolean\n }>(),\n {\n otherSystemsTo: undefined,\n refreshHook: undefined,\n unsavedChanges: false,\n }\n)\n\nconst { t } = useI18n()\n\nconst bySystem = computed(() => new Map(props.descriptors.map((item) => [item.system, item])))\n\nconst labelFor = (system: string) => bySystem.value.get(system)?.label ?? system\n\n/** Registered here, not in the page: every user page has the shell, and a tab is a link out of it. */\nconst unsavedSource = computed(() => props.unsavedChanges)\nconst { hasUnsavedChanges, dirtyLabels, promptOpen, resolvePrompt } = useUnsavedChangesGuard({\n sources: [unsavedSource],\n})\n\n// Provide only when present. Providing `undefined` explicitly would signal a hook to code that only checks for the key.\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nif (!isUndefined(props.refreshHook)) provide(UserSystemRefreshHookKey, props.refreshHook)\n</script>\n\n<template>\n <div>\n <!-- `exact` on each tab: an active link selects its tab, and without it a link is also active on nested routes. -->\n <VTabs\n :model-value=\"active\"\n data-cy=\"user-tabs\"\n >\n <VTab\n v-for=\"tab in tabs\"\n :key=\"tab.system\"\n :value=\"tab.system\"\n :to=\"tab.to\"\n exact\n :data-cy=\"`user-tab-${tab.system}`\"\n >\n {{ labelFor(tab.system) }}\n <VIcon\n v-if=\"tab.system === active && hasUnsavedChanges\"\n class=\"ml-1\"\n size=\"x-small\"\n color=\"warning\"\n icon=\"mdi-circle\"\n data-cy=\"user-tab-unsaved\"\n />\n </VTab>\n <VTab\n v-if=\"!isUndefined(otherSystemsTo)\"\n :value=\"OTHER_SYSTEMS_TAB\"\n :to=\"otherSystemsTo\"\n exact\n :data-cy=\"`user-tab-${OTHER_SYSTEMS_TAB}`\"\n >\n {{ t('common.userSystem.tab.otherSystems') }}\n </VTab>\n </VTabs>\n <div class=\"mt-4\">\n <slot />\n </div>\n <AUnsavedConfirmDialog\n v-model=\"promptOpen\"\n :dirty-labels=\"dirtyLabels\"\n @resolve=\"resolvePrompt\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAWA,IAAMoB,IAAQC,GAiCR,EAAE,SAAMC,EAAQ,GAEhBC,IAAWC,QAAe,IAAI,IAAIJ,EAAM,YAAY,KAAK,MAAS,CAACK,EAAK,QAAQA,CAAI,CAAC,CAAC,CAAC,GAEvFC,KAAY,MAAmBH,EAAS,MAAM,IAAII,CAAM,CAAC,EAAE,SAASA,GAGpEC,IAAgBJ,QAAeJ,EAAM,cAAc,GACnD,EAAE,sBAAmB,gBAAa,eAAY,qBAAkBS,EAAuB,EAC3F,SAAS,CAACD,CAAa,EACzB,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134
  };
135
135
  }>;
136
136
  loadingAnzuUser: Ref<boolean, boolean>;
137
+ anzuUserNotFound: Ref<boolean, boolean>;
137
138
  fetchAnzuUser: (id: IntegerId, options?: {
138
139
  signal?: AbortSignal;
140
+ keepOnNotFound?: boolean;
139
141
  }) => Promise<boolean | undefined>;
140
142
  createAnzuUser: () => Promise<AnzuUser | null>;
141
143
  updateAnzuUser: () => Promise<boolean>;
@@ -1,103 +1,106 @@
1
1
  import { useAlerts as e } from "../../system/composables/alerts.js";
2
2
  import { handleRecordLoadError as t } from "../../system/composables/recordPage.js";
3
- import { ANZU_USER_ENDPOINT as n, ANZU_USER_ENTITY as r, useAnzuUserApi as i } from "../api/anzuUserApi.js";
4
- import { useAnzuUserOneStore as a } from "../store/anzuUserStore.js";
5
- import { AnzuFatalError as o } from "../../../shared/error/AnzuFatalError.js";
6
- import { isNull as s, isUndefined as c } from "../../../shared/utils/common.js";
7
- import { syncUserAndTimeTracking as l } from "../../../shared/utils/userAndTimeTracking.js";
8
- import { computed as u, nextTick as d, ref as f } from "vue";
9
- import p from "@vuelidate/core";
10
- import { storeToRefs as m } from "pinia";
3
+ import { USER_PROBE_ENTITY as n, apiErrorStatus as r } from "../../api/utils/apiErrors.js";
4
+ import "../../../shared/statusCodes.js";
5
+ import { ANZU_USER_ENDPOINT as i, ANZU_USER_ENTITY as a, useAnzuUserApi as o } from "../api/anzuUserApi.js";
6
+ import { useAnzuUserOneStore as s } from "../store/anzuUserStore.js";
7
+ import { AnzuFatalError as c } from "../../../shared/error/AnzuFatalError.js";
8
+ import { isNull as l, isUndefined as u } from "../../../shared/utils/common.js";
9
+ import { syncUserAndTimeTracking as d } from "../../../shared/utils/userAndTimeTracking.js";
10
+ import { computed as f, nextTick as p, ref as m } from "vue";
11
+ import h from "@vuelidate/core";
12
+ import { storeToRefs as g } from "pinia";
11
13
  // src/domains/anzuUser/composables/anzuUserActions.ts
12
- var h = 0, g = (g) => {
13
- let { client: _, system: v, entity: y = r, endPoint: b = n } = g, { showErrorsDefault: x, showRecordWas: S, showValidationError: C } = e(), { useFetchAnzuUserList: w, useFetchAnzuUser: T, useCreateAnzuUser: E, useUpdateAnzuUser: D } = i({
14
- client: _,
15
- system: v,
16
- entity: y,
17
- validationSystem: g.validationSystem,
18
- validationEntity: g.validationEntity,
19
- endPoint: b
20
- }), { execute: O, abort: k } = w(), A = f([]), j = f(!1), M = f([]), N = 0, P = async (e, t, n) => {
21
- let r = ++N;
22
- j.value = !0;
14
+ var _ = 0, v = (v) => {
15
+ let { client: y, system: b, entity: x = a, endPoint: S = i } = v, { showErrorsDefault: C, showRecordWas: w, showValidationError: T } = e(), { useFetchAnzuUserList: E, useFetchAnzuUser: D, useCreateAnzuUser: O, useUpdateAnzuUser: k } = o({
16
+ client: y,
17
+ system: b,
18
+ entity: x,
19
+ validationSystem: v.validationSystem,
20
+ validationEntity: v.validationEntity,
21
+ endPoint: S
22
+ }), { execute: A, abort: j } = E(), M = m([]), N = m(!1), P = m([]), F = 0, I = async (e, t, n) => {
23
+ let r = ++F;
24
+ N.value = !0;
23
25
  try {
24
- let i = await O(e, t, n);
25
- if (r !== N) return;
26
- A.value = i;
26
+ let i = await A(e, t, n);
27
+ if (r !== F) return;
28
+ M.value = i;
27
29
  } catch (e) {
28
- if (r !== N) return;
29
- A.value = [], x(e);
30
+ if (r !== F) return;
31
+ M.value = [], C(e);
30
32
  } finally {
31
- r === N && (j.value = !1);
33
+ r === F && (N.value = !1);
32
34
  }
33
- }, F = () => {
34
- N++, k();
35
- }, I = a(), { anzuUser: L, loadingAnzuUser: R } = m(I), z = f(""), B = () => {
36
- z.value = JSON.stringify(I.anzuUser);
37
- }, V = u(() => z.value !== "" && z.value !== JSON.stringify(L.value)), H = async (e, n = {}) => {
38
- let r = ++h, i = () => h === r;
39
- I.setLoadingAnzuUser(!0);
35
+ }, L = () => {
36
+ F++, j();
37
+ }, R = s(), { anzuUser: z, loadingAnzuUser: B } = g(R), V = m(""), H = () => {
38
+ V.value = JSON.stringify(R.anzuUser);
39
+ }, U = f(() => V.value !== "" && V.value !== JSON.stringify(z.value)), W = m(!1), G = async (e, i = {}) => {
40
+ let a = ++_, o = () => _ === a;
41
+ R.setLoadingAnzuUser(!0);
40
42
  try {
41
- let { execute: t } = T(), r = await t({
43
+ let { execute: t } = D(i.keepOnNotFound ? n : void 0), r = await t({
42
44
  urlParams: { id: e },
43
- signal: n.signal
45
+ signal: i.signal
44
46
  });
45
- return i() ? (I.setAnzuUser(r), await d(), B(), !0) : void 0;
47
+ return o() ? (W.value = !1, R.setAnzuUser(r), await p(), H(), !0) : void 0;
46
48
  } catch (e) {
47
- return i() ? (I.reset(v), z.value = "", !t(e) && void 0) : void 0;
49
+ return (!o() || (R.reset(b), V.value = "", W.value = i.keepOnNotFound === !0 && r(e) === 404, W.value) || !t(e)) && void 0;
48
50
  } finally {
49
- i() && I.setLoadingAnzuUser(!1);
51
+ o() && R.setLoadingAnzuUser(!1);
50
52
  }
51
- }, U = g.validationScope ? p({}, {}, { $scope: g.validationScope }) : p(), W = f(!1), G = async () => {
53
+ }, K = v.validationScope ? h({}, {}, { $scope: v.validationScope }) : h(), q = m(!1), J = async () => {
52
54
  try {
53
- if (W.value = !0, U.value.$touch(), U.value.$invalid) return C(), null;
54
- let { execute: e } = E(), t = await e({ body: I.anzuUser });
55
- return S("created"), B(), t;
55
+ if (q.value = !0, K.value.$touch(), K.value.$invalid) return T(), null;
56
+ let { execute: e } = O(), t = await e({ body: R.anzuUser });
57
+ return w("created"), H(), t;
56
58
  } catch (e) {
57
- return x(e), null;
59
+ return C(e), null;
58
60
  } finally {
59
- W.value = !1;
61
+ q.value = !1;
60
62
  }
61
- }, K = f(!1);
63
+ }, Y = m(!1);
62
64
  return {
63
- isDirty: V,
64
- markPristine: B,
65
- anzuUserList: A,
66
- loadingAnzuUserList: j,
67
- datatableHiddenColumns: M,
68
- fetchAnzuUserList: P,
69
- cancelAnzuUserList: F,
70
- anzuUser: L,
71
- loadingAnzuUser: R,
72
- fetchAnzuUser: H,
73
- createAnzuUser: G,
65
+ isDirty: U,
66
+ markPristine: H,
67
+ anzuUserList: M,
68
+ loadingAnzuUserList: N,
69
+ datatableHiddenColumns: P,
70
+ fetchAnzuUserList: I,
71
+ cancelAnzuUserList: L,
72
+ anzuUser: z,
73
+ loadingAnzuUser: B,
74
+ anzuUserNotFound: W,
75
+ fetchAnzuUser: G,
76
+ createAnzuUser: J,
74
77
  updateAnzuUser: async () => {
75
78
  try {
76
- if (K.value = !0, U.value.$touch(), U.value.$invalid) return C(), !1;
77
- let e = I.anzuUser.id;
78
- if (s(e) || c(e)) throw new o(void 0, "[useAnzuUserActions] update called on a record with no id.");
79
- let { execute: t } = D(), n = h, r = I.anzuUser, i = await t({
79
+ if (Y.value = !0, K.value.$touch(), K.value.$invalid) return T(), !1;
80
+ let e = R.anzuUser.id;
81
+ if (l(e) || u(e)) throw new c(void 0, "[useAnzuUserActions] update called on a record with no id.");
82
+ let { execute: t } = k(), n = _, r = R.anzuUser, i = await t({
80
83
  urlParams: { id: e },
81
- body: I.anzuUser
84
+ body: R.anzuUser
82
85
  });
83
- if (S("updated"), n !== h || I.anzuUser !== r) return !0;
84
- l(I.anzuUser, i);
85
- let a = I.anzuUser, u = i;
86
- for (let e of g.updateResponseFields ?? []) c(u[e]) || (a[e] = u[e]);
87
- return B(), !0;
86
+ if (w("updated"), n !== _ || R.anzuUser !== r) return !0;
87
+ d(R.anzuUser, i);
88
+ let a = R.anzuUser, o = i;
89
+ for (let e of v.updateResponseFields ?? []) u(o[e]) || (a[e] = o[e]);
90
+ return H(), !0;
88
91
  } catch (e) {
89
- return x(e), !1;
92
+ return C(e), !1;
90
93
  } finally {
91
- K.value = !1;
94
+ Y.value = !1;
92
95
  }
93
96
  },
94
- loadingCreateAnzuUser: W,
95
- loadingUpdateAnzuUser: K,
97
+ loadingCreateAnzuUser: q,
98
+ loadingUpdateAnzuUser: Y,
96
99
  resetAnzuUserStore: (...e) => {
97
- h++, I.reset(...e);
100
+ _++, R.reset(...e);
98
101
  }
99
102
  };
100
103
  };
101
- export { g as useAnzuUserActions };
104
+ export { v as useAnzuUserActions };
102
105
 
103
106
  //# sourceMappingURL=anzuUserActions.js.map