@7365admin1/layer-common 4.97.1-staging.656 → 4.97.1-staging.658
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/components/InventoryItemDetail.vue +6 -8
- package/components/InventoryMain.vue +23 -12
- package/components/InventoryReportsTab.vue +9 -1
- package/components/InventorySettingsTab.vue +68 -13
- package/components/InventorySitePicker.vue +38 -0
- package/composables/useInventory.ts +3 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +2 -0
- package/utils/inventory-store-label.ts +18 -0
- package/utils/work-order-link.ts +24 -0
|
@@ -105,6 +105,7 @@ import { inventoryItemMeta } from "../utils/inventory-store-label";
|
|
|
105
105
|
import { inventoryControls } from "../utils/inventory-presets";
|
|
106
106
|
import { receiptRefText } from "../utils/inventory-receiving";
|
|
107
107
|
import { availableText, inventoryStepsLive, lowStockAlertText, qtyUnit, unitWord, writeOffLabel } from "../utils/inventory-ack";
|
|
108
|
+
import { workOrderLinkTarget } from "../utils/work-order-link";
|
|
108
109
|
|
|
109
110
|
const show = defineModel<boolean>({ default: false });
|
|
110
111
|
const props = defineProps({
|
|
@@ -134,17 +135,14 @@ const stepsLive = computed(() => inventoryStepsLive(props.store));
|
|
|
134
135
|
const formatDate = (d: string) => standardFormatDate(d);
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
|
-
* The work order a "Used" row came from
|
|
138
|
-
* (same organisation and site as the page). None
|
|
139
|
-
* exists or the app has no
|
|
138
|
+
* The work order a "Used" row came from: its feedback's details when it is tied
|
|
139
|
+
* to one, else Work Order Details (same organisation and site as the page). None
|
|
140
|
+
* when the work order no longer exists or the app has no such page: the number
|
|
141
|
+
* then shows as text.
|
|
140
142
|
*/
|
|
141
143
|
const route = useRoute();
|
|
142
144
|
const router = useRouter();
|
|
143
|
-
|
|
144
|
-
if (!t.workOrder || t.workOrderExists === false) return null;
|
|
145
|
-
if (!router.hasRoute("org-site-work-orders-id") || !route.params.org || !route.params.site) return null;
|
|
146
|
-
return { name: "org-site-work-orders-id", params: { org: route.params.org, site: route.params.site, id: t.workOrder } };
|
|
147
|
-
}
|
|
145
|
+
const workOrderRoute = (t: TInventoryTransaction) => workOrderLinkTarget(t, route, router);
|
|
148
146
|
|
|
149
147
|
function describe(t: TInventoryTransaction) {
|
|
150
148
|
const parts: string[] = [];
|
|
@@ -104,17 +104,10 @@
|
|
|
104
104
|
<v-text-field v-model="setup.name" :rules="[requiredRule]" density="comfortable" placeholder="e.g. Main Store" class="mb-2" />
|
|
105
105
|
<template v-if="supplySites.length > 1">
|
|
106
106
|
<InputLabel title="Properties this store supplies" required class="mb-1" />
|
|
107
|
-
<
|
|
107
|
+
<InventorySitePicker
|
|
108
108
|
v-model="setup.sites"
|
|
109
|
-
:items="
|
|
110
|
-
|
|
111
|
-
item-value="_id"
|
|
112
|
-
multiple
|
|
113
|
-
chips
|
|
114
|
-
density="comfortable"
|
|
115
|
-
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
116
|
-
hint="Choose more than one only if one store supplies them all (e.g. a company's central store). If a property keeps its own separate stock, leave it out and set up its own store there."
|
|
117
|
-
persistent-hint
|
|
109
|
+
:items="setupSiteItems"
|
|
110
|
+
hint="Most properties keep their own store. Choose more than one only if they share one store room."
|
|
118
111
|
class="mb-4"
|
|
119
112
|
/>
|
|
120
113
|
</template>
|
|
@@ -183,7 +176,7 @@
|
|
|
183
176
|
<InventorySuppliersTab :store="store" />
|
|
184
177
|
</v-window-item>
|
|
185
178
|
<v-window-item v-if="ctl.tabs.settings" value="settings">
|
|
186
|
-
<InventorySettingsTab :store="store" :org-sites="supplySites" @saved="loadStores" />
|
|
179
|
+
<InventorySettingsTab :store="store" :org-sites="supplySites" @saved="loadStores" @deleted="afterStoreDeleted" />
|
|
187
180
|
</v-window-item>
|
|
188
181
|
</v-window>
|
|
189
182
|
</template>
|
|
@@ -224,7 +217,7 @@ const linked = { storeId: String(linkQuery.storeId ?? ""), tab: String(linkQuery
|
|
|
224
217
|
// `?requestId=` (approved / confirm-received alerts): the Requests tab opens on that request.
|
|
225
218
|
const focusRequest = String(linkQuery.requestId ?? "");
|
|
226
219
|
|
|
227
|
-
const { getHandovers, getStores, getStore, createStore: apiCreateStore, getRequests, getReport } = useInventory();
|
|
220
|
+
const { getHandovers, getStores, getStore, createStore: apiCreateStore, getSiteOwners, getRequests, getReport } = useInventory();
|
|
228
221
|
const { getSites } = useSite();
|
|
229
222
|
const { requiredRule } = useUtils();
|
|
230
223
|
|
|
@@ -306,6 +299,13 @@ const tabs = computed(() => {
|
|
|
306
299
|
];
|
|
307
300
|
});
|
|
308
301
|
|
|
302
|
+
/** After a store is deleted: reload, and with none left show the set-up form for its freed properties. */
|
|
303
|
+
async function afterStoreDeleted() {
|
|
304
|
+
await Promise.all([loadStores(), loadSiteOwners()]);
|
|
305
|
+
Object.assign(setup, { name: "Main Store", sites: [props.siteId] });
|
|
306
|
+
showSetup.value = !store.value;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
309
|
async function loadStores() {
|
|
310
310
|
loading.value = true;
|
|
311
311
|
loadError.value = "";
|
|
@@ -396,6 +396,15 @@ const supplySites = computed(() => inventorySupplySites(orgSites.value, mySites.
|
|
|
396
396
|
const setupSiteOptions = computed(() =>
|
|
397
397
|
inventorySiteOptions(supplySites.value, { sites: setup.sites, siteNames: [...mySites.value, { _id: props.siteId, name: currentSiteName.value }] }),
|
|
398
398
|
);
|
|
399
|
+
const siteOwners = ref<{ site: string; store: string; name: string }[]>([]);
|
|
400
|
+
const setupSiteItems = computed(() => inventorySitePickerItems(setupSiteOptions.value, siteOwners.value));
|
|
401
|
+
async function loadSiteOwners() {
|
|
402
|
+
try {
|
|
403
|
+
siteOwners.value = await getSiteOwners(props.orgId);
|
|
404
|
+
} catch {
|
|
405
|
+
siteOwners.value = []; // the picker then shows no hints; saving still names the clash
|
|
406
|
+
}
|
|
407
|
+
}
|
|
399
408
|
const currentSiteName = computed(() => mySites.value.find((s) => s._id === props.siteId)?.name || storeSites.value.find((s) => s._id === props.siteId)?.name || "this property");
|
|
400
409
|
async function loadMySites() {
|
|
401
410
|
try {
|
|
@@ -446,6 +455,7 @@ async function createStore() {
|
|
|
446
455
|
try {
|
|
447
456
|
const created = await apiCreateStore({ org: props.orgId, sites: setup.sites, name: setup.name });
|
|
448
457
|
notify("Store created. Add your items next.");
|
|
458
|
+
loadSiteOwners();
|
|
449
459
|
showSetup.value = false;
|
|
450
460
|
storeId.value = (created as any)?._id ?? "";
|
|
451
461
|
await loadStores();
|
|
@@ -471,5 +481,6 @@ onMounted(() => {
|
|
|
471
481
|
loadStores();
|
|
472
482
|
loadOrgSites();
|
|
473
483
|
loadMySites();
|
|
484
|
+
loadSiteOwners();
|
|
474
485
|
});
|
|
475
486
|
</script>
|
|
@@ -205,7 +205,11 @@
|
|
|
205
205
|
<template #item.receivingType="{ item }">{{ item.kind === "Opening stock" ? "Opening stock" : receivingLabel(item.receivingType) }}</template>
|
|
206
206
|
<template #item.reference="{ item }">
|
|
207
207
|
<a v-if="report === 'purchases' && item.reference" href="#" class="text-primary" title="See ordered vs received for this PO" @click.prevent="openPo(item.reference)">{{ item.reference }}</a>
|
|
208
|
-
|
|
208
|
+
<!-- a work order's materials (2026-11): the number links to the work order, or to its feedback when tied -->
|
|
209
|
+
<NuxtLink v-else-if="workOrderLinkTarget(item, route, router)" :to="workOrderLinkTarget(item, route, router)!" class="text-primary">
|
|
210
|
+
{{ item.workOrderNumber || item.reference }}
|
|
211
|
+
</NuxtLink>
|
|
212
|
+
<span v-else>{{ item.workOrderNumber || item.reference || "—" }}</span>
|
|
209
213
|
</template>
|
|
210
214
|
<template #item.doNumber="{ item }">
|
|
211
215
|
<span v-if="item.doNumber">{{ item.doNumber }}<span v-if="item.doDate" class="d-block text-caption text-medium-emphasis">{{ standardFormatDate(item.doDate) }}</span></span>
|
|
@@ -265,6 +269,7 @@ import { inventoryControls } from "../utils/inventory-presets";
|
|
|
265
269
|
import { USED_BY_FILTERS } from "../utils/inventory-used-by";
|
|
266
270
|
import { USAGE_FLAG_WORDS, USAGE_STATUS_CHOICES, usagePathText, usageQuery, usageTotals } from "../utils/inventory-usage";
|
|
267
271
|
import { receivingLabel } from "../utils/inventory-receiving";
|
|
272
|
+
import { workOrderLinkTarget } from "../utils/work-order-link";
|
|
268
273
|
import { inventoryStepsLive, qtyUnit, reconciliationCheckText, reconciliationPersonText, writeOffReasonText } from "../utils/inventory-ack";
|
|
269
274
|
|
|
270
275
|
const props = defineProps({
|
|
@@ -275,6 +280,9 @@ const ctl = computed(() => inventoryControls(props.store.access));
|
|
|
275
280
|
|
|
276
281
|
const api = useInventory();
|
|
277
282
|
const { standardFormatDate, standardFormatDateTime } = useUtils();
|
|
283
|
+
// Work order numbers link to the work order, or its feedback (workOrderLinkTarget).
|
|
284
|
+
const route = useRoute();
|
|
285
|
+
const router = useRouter();
|
|
278
286
|
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
279
287
|
|
|
280
288
|
const worker = useWorkerTerm({ providers: true });
|
|
@@ -6,17 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
<template v-if="orgSites.length > 1 || sites.length > 1">
|
|
8
8
|
<InputLabel title="Properties this store supplies" required class="mb-1" />
|
|
9
|
-
<
|
|
9
|
+
<InventorySitePicker
|
|
10
10
|
v-model="sites"
|
|
11
11
|
:items="siteItems"
|
|
12
|
-
|
|
13
|
-
item-value="_id"
|
|
14
|
-
multiple
|
|
15
|
-
chips
|
|
16
|
-
density="comfortable"
|
|
17
|
-
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
18
|
-
hint="Choose more than one only if this store supplies them all (e.g. a company's central store). A property that keeps its own separate stock needs its own store instead."
|
|
19
|
-
persistent-hint
|
|
12
|
+
hint="Keep one property per store unless they share one store room."
|
|
20
13
|
class="mb-4"
|
|
21
14
|
/>
|
|
22
15
|
</template>
|
|
@@ -59,23 +52,48 @@
|
|
|
59
52
|
<div class="d-flex mt-6">
|
|
60
53
|
<v-btn class="text-none screen-btn-primary" variant="flat" :loading="saving" @click="save">Save settings</v-btn>
|
|
61
54
|
</div>
|
|
55
|
+
|
|
56
|
+
<template v-if="store.access?.canManage">
|
|
57
|
+
<v-divider class="my-6" />
|
|
58
|
+
<div class="text-subtitle-1 mb-1">Delete store</div>
|
|
59
|
+
<p class="text-body-2 text-medium-emphasis mb-2">Stop using this store. Its items and history are kept for reports.</p>
|
|
60
|
+
<v-btn class="text-none" color="error" variant="outlined" @click="openDelete">Delete store</v-btn>
|
|
61
|
+
</template>
|
|
62
62
|
</v-form>
|
|
63
|
+
|
|
64
|
+
<v-dialog v-model="showDelete" max-width="520">
|
|
65
|
+
<AppCard class="pa-6">
|
|
66
|
+
<div class="text-h6 mb-2">Delete {{ store.name }}?</div>
|
|
67
|
+
<p class="text-body-2 mb-2">
|
|
68
|
+
It will no longer be used at: {{ siteNamesText }}. Its {{ itemCount }} items and their history are kept for reports.
|
|
69
|
+
People can no longer request from it. You can then set up a new store for these sites.
|
|
70
|
+
</p>
|
|
71
|
+
<InputLabel :title="`Type "${store.name}" to confirm`" class="mb-1" />
|
|
72
|
+
<v-text-field v-model="confirmName" density="comfortable" autocomplete="off" />
|
|
73
|
+
<div class="d-flex ga-2 mt-2">
|
|
74
|
+
<v-btn class="text-none screen-btn-ghost" variant="outlined" @click="showDelete = false">Cancel</v-btn>
|
|
75
|
+
<v-btn class="text-none" color="error" variant="flat" :disabled="confirmName.trim() !== store.name" :loading="deleting" @click="removeStore">
|
|
76
|
+
Delete store
|
|
77
|
+
</v-btn>
|
|
78
|
+
</div>
|
|
79
|
+
</AppCard>
|
|
80
|
+
</v-dialog>
|
|
63
81
|
</AppCard>
|
|
64
82
|
</template>
|
|
65
83
|
|
|
66
84
|
<script setup lang="ts">
|
|
67
85
|
import useInventory from "../composables/useInventory";
|
|
68
86
|
import useUtils from "../composables/useUtils";
|
|
69
|
-
import { inventorySiteOptions } from "../utils/inventory-store-label";
|
|
87
|
+
import { inventorySiteOptions, inventorySitePickerItems, type TSiteOwner } from "../utils/inventory-store-label";
|
|
70
88
|
import { inventoryStepsLive, reminderDaysText } from "../utils/inventory-ack";
|
|
71
89
|
|
|
72
90
|
const props = defineProps({
|
|
73
91
|
store: { type: Object as PropType<TInventoryStore>, required: true },
|
|
74
92
|
orgSites: { type: Array as PropType<{ _id: string; name: string }[]>, default: () => [] },
|
|
75
93
|
});
|
|
76
|
-
const emit = defineEmits(["saved"]);
|
|
94
|
+
const emit = defineEmits(["saved", "deleted"]);
|
|
77
95
|
|
|
78
|
-
const { updateStore } = useInventory();
|
|
96
|
+
const { updateStore, getSiteOwners, getItems, deleteStore } = useInventory();
|
|
79
97
|
const { requiredRule } = useUtils();
|
|
80
98
|
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
81
99
|
|
|
@@ -90,7 +108,44 @@ const reminderDays = ref<number>(1);
|
|
|
90
108
|
const workOrderMaterials = ref(false);
|
|
91
109
|
const stepsLive = computed(() => inventoryStepsLive(props.store));
|
|
92
110
|
|
|
93
|
-
const
|
|
111
|
+
const owners = ref<TSiteOwner[]>([]);
|
|
112
|
+
const siteItems = computed(() => inventorySitePickerItems(inventorySiteOptions(props.orgSites, props.store), owners.value, props.store._id));
|
|
113
|
+
async function loadOwners() {
|
|
114
|
+
try {
|
|
115
|
+
owners.value = await getSiteOwners(props.store.org);
|
|
116
|
+
} catch {
|
|
117
|
+
owners.value = []; // no hints; saving still names the clashing property
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
onMounted(loadOwners);
|
|
121
|
+
|
|
122
|
+
const showDelete = ref(false);
|
|
123
|
+
const deleting = ref(false);
|
|
124
|
+
const confirmName = ref("");
|
|
125
|
+
const itemCount = ref(0);
|
|
126
|
+
const siteNamesText = computed(() => siteItems.value.filter((i) => props.store.sites.includes(i._id)).map((i) => i.name).join(", ") || "its properties");
|
|
127
|
+
async function openDelete() {
|
|
128
|
+
confirmName.value = "";
|
|
129
|
+
showDelete.value = true;
|
|
130
|
+
try {
|
|
131
|
+
itemCount.value = (await getItems(props.store._id, { limit: 1 }))?.total ?? 0;
|
|
132
|
+
} catch {
|
|
133
|
+
itemCount.value = 0;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function removeStore() {
|
|
137
|
+
deleting.value = true;
|
|
138
|
+
try {
|
|
139
|
+
await deleteStore(props.store._id);
|
|
140
|
+
showDelete.value = false;
|
|
141
|
+
notify("Store deleted.");
|
|
142
|
+
emit("deleted");
|
|
143
|
+
} catch (error: any) {
|
|
144
|
+
notify(error?.data?.message || "Could not delete the store.", "error");
|
|
145
|
+
} finally {
|
|
146
|
+
deleting.value = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
94
149
|
|
|
95
150
|
function reset() {
|
|
96
151
|
name.value = props.store.name;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-select
|
|
3
|
+
v-model="model"
|
|
4
|
+
:items="items"
|
|
5
|
+
item-title="name"
|
|
6
|
+
item-value="_id"
|
|
7
|
+
multiple
|
|
8
|
+
chips
|
|
9
|
+
density="comfortable"
|
|
10
|
+
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
11
|
+
:hint="hint"
|
|
12
|
+
persistent-hint
|
|
13
|
+
>
|
|
14
|
+
<template #prepend-item>
|
|
15
|
+
<div class="d-flex ga-2 px-4 py-2">
|
|
16
|
+
<v-btn size="small" variant="text" class="text-none" @click.stop="selectAll">Select all</v-btn>
|
|
17
|
+
<v-btn size="small" variant="text" class="text-none" @click.stop="model = []">Clear</v-btn>
|
|
18
|
+
</div>
|
|
19
|
+
<v-divider />
|
|
20
|
+
</template>
|
|
21
|
+
</v-select>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
type TItem = { _id: string; name: string; props?: { disabled?: boolean } };
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
modelValue: { type: Array as PropType<string[]>, default: () => [] },
|
|
28
|
+
items: { type: Array as PropType<TItem[]>, default: () => [] },
|
|
29
|
+
hint: { type: String, default: "" },
|
|
30
|
+
});
|
|
31
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
32
|
+
const model = computed({ get: () => props.modelValue, set: (v: string[]) => emit("update:modelValue", v) });
|
|
33
|
+
|
|
34
|
+
// Every property that is free to pick; ones another store supplies are skipped.
|
|
35
|
+
function selectAll() {
|
|
36
|
+
model.value = props.items.filter((i) => !i.props?.disabled).map((i) => i._id);
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
@@ -29,6 +29,9 @@ export default function useInventory() {
|
|
|
29
29
|
|
|
30
30
|
getStores: async (site: string) =>
|
|
31
31
|
((await api<TInventoryStore[]>("/stores", { query: { site } })) ?? []).map((s) => ({ ...s, access: inventoryCaps(s.access) })),
|
|
32
|
+
/** Which store of the organisation supplies each property (for the picker). */
|
|
33
|
+
getSiteOwners: async (org: string) => (await api<{ site: string; store: string; name: string }[]>("/stores/site-owners", { query: { org } })) ?? [],
|
|
34
|
+
deleteStore: (id: string) => api<{ deleted: boolean }>(`/stores/${id}`, { method: "DELETE" }),
|
|
32
35
|
createStore: (body: { org: string; sites: string[]; name: string }) =>
|
|
33
36
|
api<TInventoryStore>("/stores", { method: "POST", body }),
|
|
34
37
|
updateStore: (id: string, body: Partial<Pick<TInventoryStore, "name" | "sites" | "showInResidentApp" | "showCostInResidentApp" | "lowStockReminderDays" | "workOrderMaterials">>) =>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.658",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/types/inventory.d.ts
CHANGED
|
@@ -143,6 +143,8 @@ declare type TInventoryTransaction = {
|
|
|
143
143
|
workOrder?: string;
|
|
144
144
|
workOrderNumber?: string;
|
|
145
145
|
workOrderExists?: boolean;
|
|
146
|
+
/** The feedback the work order is tied to (2026-11): its link goes there. */
|
|
147
|
+
workOrderFeedback?: string | null;
|
|
146
148
|
supplier?: string;
|
|
147
149
|
/** Receiving (2026-10): missing on older rows = PO. */
|
|
148
150
|
receivingType?: "PO" | "DO" | "CASH";
|
|
@@ -104,3 +104,21 @@ export function inventoryTwoStoresText(stores: TStoreLike[]) {
|
|
|
104
104
|
if (!ours || !theirs) return "";
|
|
105
105
|
return "Two stores supply this property. Our store is your company's own stock. Main store is the property manager's stock: you can only request from it.";
|
|
106
106
|
}
|
|
107
|
+
|
|
108
|
+
export type TSiteOwner = { site: string; store: string; name: string };
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The picker rows: a property already supplied by ANOTHER store of the organisation is disabled with
|
|
112
|
+
* the reason as its subtitle; the current store's own properties stay selectable.
|
|
113
|
+
*/
|
|
114
|
+
export function inventorySitePickerItems(
|
|
115
|
+
options: { _id: string; name: string }[],
|
|
116
|
+
owners: TSiteOwner[],
|
|
117
|
+
currentStore?: string,
|
|
118
|
+
) {
|
|
119
|
+
const taken = new Map(owners.filter((o) => o.store !== currentStore).map((o) => [o.site, o.name]));
|
|
120
|
+
return options.map((o) => {
|
|
121
|
+
const by = taken.get(o._id);
|
|
122
|
+
return by ? { ...o, props: { disabled: true, subtitle: `Already supplied by ${by}` } } : { ...o };
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where a work order number in Inventory (History, reports) links to (2026-11): the
|
|
5
|
+
* feedback's details when the work order is tied to a feedback (its work is done there), else
|
|
6
|
+
* the work order's details - in this app, at the page's organisation and site. Null (shown as
|
|
7
|
+
* text) when there is no work order, it no longer exists, or the app has no such page.
|
|
8
|
+
*/
|
|
9
|
+
export function workOrderLinkTarget(
|
|
10
|
+
row: { workOrder?: unknown; workOrderExists?: boolean; workOrderFeedback?: string | null },
|
|
11
|
+
route: RouteLocationNormalizedLoaded,
|
|
12
|
+
router: Router,
|
|
13
|
+
) {
|
|
14
|
+
if (!row.workOrder || row.workOrderExists === false) return null;
|
|
15
|
+
const { org, site } = route.params;
|
|
16
|
+
if (!org || !site) return null;
|
|
17
|
+
if (row.workOrderFeedback && router.hasRoute("org-site-feedbacks-id")) {
|
|
18
|
+
return { name: "org-site-feedbacks-id", params: { org, site, id: String(row.workOrderFeedback) } };
|
|
19
|
+
}
|
|
20
|
+
if (router.hasRoute("org-site-work-orders-id")) {
|
|
21
|
+
return { name: "org-site-work-orders-id", params: { org, site, id: String(row.workOrder) } };
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|