@7365admin1/layer-common 4.168.3 → 4.169.0
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/CHANGELOG.md +52 -4
- package/components/InventoryItemDetail.vue +37 -3
- package/components/InventoryMain.vue +23 -12
- package/components/InventoryReportsTab.vue +9 -1
- package/components/InventorySettingsTab.vue +81 -14
- package/components/InventorySitePicker.vue +38 -0
- package/components/WorkOrder/MaterialsDialog.vue +756 -0
- package/components/WorkOrder/MaterialsGroups.vue +128 -0
- package/composables/useCommonPermission.ts +15 -1
- package/composables/useInventory.ts +13 -1
- package/composables/useSecurityPermission.ts +6 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +11 -0
- package/types/work-order-material.d.ts +15 -0
- package/utils/inventory-store-label.ts +18 -0
- package/utils/work-order-link.ts +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.169.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b9802fd: Inventory: the "Properties this store supplies" picker shows which store already supplies a property (disabled, with the reason), has Select all / Clear, and store managers can delete a store from Settings
|
|
8
|
+
|
|
9
|
+
Uses the new `GET /api/inventory/stores/site-owners` and `DELETE /api/inventory/stores/:id`. Deleting asks for the store name; items and history are kept.
|
|
10
|
+
|
|
11
|
+
## 4.168.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 806ba6f: Inventory History: link a work order's materials to the work order
|
|
16
|
+
|
|
17
|
+
A "Used" row from a work order's submit now shows the work order number after
|
|
18
|
+
"Used" (e.g. "Used · #ME0209"), linking to that app's Work Order Details, and
|
|
19
|
+
the store's balance, since those materials come straight off the shelf. A
|
|
20
|
+
deleted work order shows its saved number as plain text. Other rows are
|
|
21
|
+
unchanged.
|
|
22
|
+
|
|
23
|
+
- 6b270ce: Inventory: work order numbers link everywhere, to the feedback when tied
|
|
24
|
+
|
|
25
|
+
The Usage report's "Work order / ref" column now links each work order's
|
|
26
|
+
materials to it, like Inventory History. A work order tied to a feedback
|
|
27
|
+
links straight to that Feedback Details (`workOrderFeedback`); others to
|
|
28
|
+
Work Order Details. One helper, `utils/work-order-link.ts`, for both.
|
|
29
|
+
|
|
30
|
+
- dc1e7b4: Work order materials: shared picker and materials list
|
|
31
|
+
|
|
32
|
+
`WorkOrderMaterialsDialog` picks parts from the site's inventory for a work
|
|
33
|
+
order (search opens a multiple-select list, quantity up to the stock, totals;
|
|
34
|
+
out-of-stock items cannot be picked; quantities are lowered when the stock has
|
|
35
|
+
changed). `WorkOrderMaterialsGroups` lists materials per work order with a
|
|
36
|
+
total each and a Grand Total. New global type `TWorkOrderMaterial`. For the
|
|
37
|
+
service apps' Work Order and Feedback Details; the picks go with the submit,
|
|
38
|
+
which takes them from stock (API-core).
|
|
39
|
+
|
|
40
|
+
New work order permission "add-work-order-materials" (Add Work Order
|
|
41
|
+
Materials) for the service apps' role editors - the shared trade list and
|
|
42
|
+
Security's - and so the org app's Roles & Permissions. Property Management's
|
|
43
|
+
list does not offer it.
|
|
44
|
+
|
|
45
|
+
Store Settings gets "Use for work order materials" (off until a store's manager
|
|
46
|
+
turns it on). The picker lists items only from stores with it on that the
|
|
47
|
+
person may use, through the new `useInventory().getWorkOrderItems` (API-core
|
|
48
|
+
`GET /inventory/work-order-items`, no Inventory right needed); with none, it
|
|
49
|
+
says how to set one up.
|
|
50
|
+
|
|
3
51
|
## 4.168.3
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
|
@@ -3813,11 +3861,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
3813
3861
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
3814
3862
|
own rule from two endpoints the console already calls, unprojected:
|
|
3815
3863
|
|
|
3816
|
-
|
|
3817
|
-
|
|
3864
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
3865
|
+
GET /api/roles/id/:role that membership's role document
|
|
3818
3866
|
|
|
3819
|
-
|
|
3820
|
-
|
|
3867
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
3868
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
3821
3869
|
|
|
3822
3870
|
`role.default` is the marker because it is the only property of a platform
|
|
3823
3871
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -65,11 +65,22 @@
|
|
|
65
65
|
<tbody>
|
|
66
66
|
<tr v-for="t in history" :key="t._id">
|
|
67
67
|
<td class="text-no-wrap">{{ formatDate(t.date) }}</td>
|
|
68
|
-
<td>
|
|
68
|
+
<td>
|
|
69
|
+
{{ typeLabels[t.type] }}
|
|
70
|
+
<template v-if="t.workOrder">
|
|
71
|
+
·
|
|
72
|
+
<NuxtLink v-if="workOrderRoute(t)" :to="workOrderRoute(t)!" class="history-wo-link" @click="show = false">
|
|
73
|
+
{{ t.workOrderNumber || t.reference }}
|
|
74
|
+
</NuxtLink>
|
|
75
|
+
<span v-else>{{ t.workOrderNumber || t.reference }}</span>
|
|
76
|
+
</template>
|
|
77
|
+
</td>
|
|
69
78
|
<td class="text-right" :class="t.storeChange > 0 ? 'text-success' : t.storeChange < 0 ? 'text-error' : ''">
|
|
70
79
|
{{ t.storeChange > 0 ? "+" : "" }}{{ t.storeChange || (t.type === "use" ? "" : 0) }}
|
|
71
80
|
</td>
|
|
72
|
-
|
|
81
|
+
<!-- Usage from a person's stock leaves the store as it was (no balance); a work order's
|
|
82
|
+
materials come off the shelf, so the store's balance shows. -->
|
|
83
|
+
<td class="text-right">{{ t.type === "use" && !t.storeChange ? "" : t.storeBalance }}</td>
|
|
73
84
|
<td class="text-caption">{{ describe(t) }}</td>
|
|
74
85
|
<td class="text-caption">{{ (t as any).createdByLabel || t.createdByName }}</td>
|
|
75
86
|
</tr>
|
|
@@ -94,6 +105,7 @@ import { inventoryItemMeta } from "../utils/inventory-store-label";
|
|
|
94
105
|
import { inventoryControls } from "../utils/inventory-presets";
|
|
95
106
|
import { receiptRefText } from "../utils/inventory-receiving";
|
|
96
107
|
import { availableText, inventoryStepsLive, lowStockAlertText, qtyUnit, unitWord, writeOffLabel } from "../utils/inventory-ack";
|
|
108
|
+
import { workOrderLinkTarget } from "../utils/work-order-link";
|
|
97
109
|
|
|
98
110
|
const show = defineModel<boolean>({ default: false });
|
|
99
111
|
const props = defineProps({
|
|
@@ -122,6 +134,16 @@ const stepsLive = computed(() => inventoryStepsLive(props.store));
|
|
|
122
134
|
|
|
123
135
|
const formatDate = (d: string) => standardFormatDate(d);
|
|
124
136
|
|
|
137
|
+
/**
|
|
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.
|
|
142
|
+
*/
|
|
143
|
+
const route = useRoute();
|
|
144
|
+
const router = useRouter();
|
|
145
|
+
const workOrderRoute = (t: TInventoryTransaction) => workOrderLinkTarget(t, route, router);
|
|
146
|
+
|
|
125
147
|
function describe(t: TInventoryTransaction) {
|
|
126
148
|
const parts: string[] = [];
|
|
127
149
|
if (t.type === "receive") parts.push(t.supplier || "", receiptRefText(t));
|
|
@@ -134,7 +156,8 @@ function describe(t: TInventoryTransaction) {
|
|
|
134
156
|
parts.push(
|
|
135
157
|
`${who} used ${t.qty}`,
|
|
136
158
|
t.location?.type === "tenant_unit" ? `${t.location.unitName} ${t.location.tenantName || ""}` : t.location?.area || "",
|
|
137
|
-
|
|
159
|
+
// A work order's number is shown (as a link) after "Used" instead.
|
|
160
|
+
t.workOrder ? "" : t.reference || "",
|
|
138
161
|
);
|
|
139
162
|
if (t.type === "adjust") parts.push(t.remarks || "");
|
|
140
163
|
if (t.type === "write_off") parts.push(`${t.qty} ${writeOffLabel(t.writeOffReason).toLowerCase()}`, (t.holderChange ?? 0) < 0 ? `by ${who}` : "from the shelf", t.remarks || "");
|
|
@@ -182,3 +205,14 @@ watch(show, (open) => {
|
|
|
182
205
|
load(1);
|
|
183
206
|
});
|
|
184
207
|
</script>
|
|
208
|
+
|
|
209
|
+
<style scoped>
|
|
210
|
+
.history-wo-link {
|
|
211
|
+
color: var(--accent);
|
|
212
|
+
font-weight: 600;
|
|
213
|
+
text-decoration: none;
|
|
214
|
+
}
|
|
215
|
+
.history-wo-link:hover {
|
|
216
|
+
text-decoration: underline;
|
|
217
|
+
}
|
|
218
|
+
</style>
|
|
@@ -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>
|
|
@@ -41,6 +34,13 @@
|
|
|
41
34
|
/>
|
|
42
35
|
</template>
|
|
43
36
|
|
|
37
|
+
<v-divider class="my-4" />
|
|
38
|
+
<div class="text-subtitle-1 mb-1">Work orders</div>
|
|
39
|
+
<v-switch v-model="workOrderMaterials" color="primary" hide-details label="Use for work order materials" />
|
|
40
|
+
<p class="text-body-2 text-medium-emphasis mt-1 mb-2">
|
|
41
|
+
Technicians at the properties this store supplies can pick parts from it on a work order. They're taken from stock when the work order is submitted.
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
44
|
<v-divider class="my-4" />
|
|
45
45
|
<div class="text-subtitle-1 mb-1">Service365 app</div>
|
|
46
46
|
<p class="text-body-2 text-medium-emphasis mb-2">
|
|
@@ -52,23 +52,48 @@
|
|
|
52
52
|
<div class="d-flex mt-6">
|
|
53
53
|
<v-btn class="text-none screen-btn-primary" variant="flat" :loading="saving" @click="save">Save settings</v-btn>
|
|
54
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>
|
|
55
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>
|
|
56
81
|
</AppCard>
|
|
57
82
|
</template>
|
|
58
83
|
|
|
59
84
|
<script setup lang="ts">
|
|
60
85
|
import useInventory from "../composables/useInventory";
|
|
61
86
|
import useUtils from "../composables/useUtils";
|
|
62
|
-
import { inventorySiteOptions } from "../utils/inventory-store-label";
|
|
87
|
+
import { inventorySiteOptions, inventorySitePickerItems, type TSiteOwner } from "../utils/inventory-store-label";
|
|
63
88
|
import { inventoryStepsLive, reminderDaysText } from "../utils/inventory-ack";
|
|
64
89
|
|
|
65
90
|
const props = defineProps({
|
|
66
91
|
store: { type: Object as PropType<TInventoryStore>, required: true },
|
|
67
92
|
orgSites: { type: Array as PropType<{ _id: string; name: string }[]>, default: () => [] },
|
|
68
93
|
});
|
|
69
|
-
const emit = defineEmits(["saved"]);
|
|
94
|
+
const emit = defineEmits(["saved", "deleted"]);
|
|
70
95
|
|
|
71
|
-
const { updateStore } = useInventory();
|
|
96
|
+
const { updateStore, getSiteOwners, getItems, deleteStore } = useInventory();
|
|
72
97
|
const { requiredRule } = useUtils();
|
|
73
98
|
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
74
99
|
|
|
@@ -79,9 +104,48 @@ const sites = ref<string[]>([]);
|
|
|
79
104
|
const showInResidentApp = ref(false);
|
|
80
105
|
const showCostInResidentApp = ref(false);
|
|
81
106
|
const reminderDays = ref<number>(1);
|
|
107
|
+
/** "Use for work order materials" (2026-11); missing = off. */
|
|
108
|
+
const workOrderMaterials = ref(false);
|
|
82
109
|
const stepsLive = computed(() => inventoryStepsLive(props.store));
|
|
83
110
|
|
|
84
|
-
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
|
+
}
|
|
85
149
|
|
|
86
150
|
function reset() {
|
|
87
151
|
name.value = props.store.name;
|
|
@@ -89,6 +153,7 @@ function reset() {
|
|
|
89
153
|
showInResidentApp.value = props.store.showInResidentApp;
|
|
90
154
|
showCostInResidentApp.value = props.store.showCostInResidentApp;
|
|
91
155
|
reminderDays.value = props.store.lowStockReminderDays ?? 1;
|
|
156
|
+
workOrderMaterials.value = !!props.store.workOrderMaterials;
|
|
92
157
|
}
|
|
93
158
|
|
|
94
159
|
async function save() {
|
|
@@ -103,6 +168,8 @@ async function save() {
|
|
|
103
168
|
showCostInResidentApp: showInResidentApp.value && showCostInResidentApp.value,
|
|
104
169
|
// Only to an API that has reminders (an older one refuses the unknown field).
|
|
105
170
|
...(stepsLive.value ? { lowStockReminderDays: Number(reminderDays.value) } : {}),
|
|
171
|
+
// Only when changed: an API without the setting refuses the unknown field.
|
|
172
|
+
...(workOrderMaterials.value !== !!props.store.workOrderMaterials ? { workOrderMaterials: workOrderMaterials.value } : {}),
|
|
106
173
|
});
|
|
107
174
|
notify("Settings saved.");
|
|
108
175
|
emit("saved");
|
|
@@ -113,5 +180,5 @@ async function save() {
|
|
|
113
180
|
}
|
|
114
181
|
}
|
|
115
182
|
|
|
116
|
-
watch(() => [props.store, props.store.lowStockReminderDays], reset, { immediate: true });
|
|
183
|
+
watch(() => [props.store, props.store.lowStockReminderDays, props.store.workOrderMaterials], reset, { immediate: true });
|
|
117
184
|
</script>
|
|
@@ -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>
|