@7365admin1/layer-common 4.97.1-staging.655 → 4.97.1-staging.656

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.
@@ -45,7 +45,11 @@
45
45
  <v-text-field v-if="mode !== 'issue'" :model-value="holderName" density="comfortable" readonly />
46
46
  </template>
47
47
 
48
- <div class="text-subtitle-2 mb-2">Items</div>
48
+ <div class="text-subtitle-2 mb-2">
49
+ Items
50
+ <!-- Same count as the mobile request sheet: what this request holds so far. -->
51
+ <span v-if="mode === 'request' && chosenCount > 0" class="text-primary">· {{ chosenCount === 1 ? "1 item in this request" : `${chosenCount} items in this request` }}</span>
52
+ </div>
49
53
  <div v-for="(line, i) in rows" :key="i" class="d-flex flex-wrap ga-2 align-start mb-1">
50
54
  <!-- An item not in the stock list (client 2026-11): a delivery adds it, a request asks for it. -->
51
55
  <template v-if="line.newItem">
@@ -320,6 +324,7 @@ function addNew(line: TRow) {
320
324
  line.item = "";
321
325
  }
322
326
  const rows = ref<TRow[]>([blank()]);
327
+ const chosenCount = computed(() => rows.value.filter((r) => r.item || r.newItem?.name?.trim()).length);
323
328
  const supplier = ref("");
324
329
  const reference = ref("");
325
330
  const remarks = ref("");
@@ -2,6 +2,9 @@
2
2
  <div class="inventory">
3
3
  <PageHeader :title="store ? store.name : 'Inventory'" :subtitle="subtitle">
4
4
  <template #actions>
5
+ <v-btn variant="text" size="small" class="text-none" prepend-icon="mdi-help-circle-outline" @click="showHowItWorks = true">
6
+ {{ HOW.title }}
7
+ </v-btn>
5
8
  <!-- Many stores (staff of several organisations at one property): a list, not a row of buttons. -->
6
9
  <v-select
7
10
  v-if="stores.length > 3"
@@ -50,6 +53,25 @@
50
53
  </div>
51
54
  </v-alert>
52
55
 
56
+ <!-- Owner 2026-11-05: the three set-ups, in plain words, one tap away on every inventory screen. -->
57
+ <v-dialog v-model="showHowItWorks" max-width="640">
58
+ <v-card>
59
+ <v-card-title class="text-h6">{{ HOW.title }}</v-card-title>
60
+ <v-card-text>
61
+ <p class="text-body-2 mb-4">{{ HOW.intro }}</p>
62
+ <div v-for="s in HOW.setups" :key="s.title" class="mb-3">
63
+ <div class="font-weight-medium">{{ s.title }}</div>
64
+ <div class="text-body-2">{{ s.text }}</div>
65
+ </div>
66
+ <p class="text-caption mt-2">{{ HOW.where }}</p>
67
+ </v-card-text>
68
+ <v-card-actions>
69
+ <v-spacer />
70
+ <v-btn class="text-none" variant="text" @click="showHowItWorks = false">Close</v-btn>
71
+ </v-card-actions>
72
+ </v-card>
73
+ </v-dialog>
74
+
53
75
  <v-progress-linear v-if="loading" indeterminate color="primary" class="mb-4" />
54
76
 
55
77
  <AppCard v-else-if="loadError" class="pa-6">
@@ -59,7 +81,8 @@
59
81
  </AppCard>
60
82
 
61
83
  <!-- No store yet: one clear next step, or one clear explanation. -->
62
- <AppCard v-else-if="!store" class="pa-6">
84
+ <!-- Also open when a provider sets up its own store beside the main store (scenario 3). -->
85
+ <AppCard v-else-if="!store || showSetup" class="pa-6">
63
86
  <template v-if="!showSetup">
64
87
  <div class="text-h6 mb-2">Inventory is not set up for this property yet</div>
65
88
  <p class="text-body-2 mb-4">
@@ -67,6 +90,8 @@
67
90
  </p>
68
91
  <p class="text-body-2 mb-4">
69
92
  One store can supply several properties (for example a company's central store): choose them all when you set it up, or later under Settings.
93
+ If each property keeps its own separate stock, set up a store at each property instead.
94
+ <a href="#" class="text-primary" @click.prevent="showHowItWorks = true">How inventory works</a>
70
95
  </p>
71
96
  <v-btn class="text-none screen-btn-primary" variant="flat" @click="showSetup = true">Set up inventory</v-btn>
72
97
  <p class="text-caption mt-3">
@@ -88,7 +113,7 @@
88
113
  chips
89
114
  density="comfortable"
90
115
  :rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
91
- hint="Choose more than one if one store supplies them all, e.g. a company's central store for all its sites."
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."
92
117
  persistent-hint
93
118
  class="mb-4"
94
119
  />
@@ -105,6 +130,10 @@
105
130
  <v-alert v-if="requestOnly" type="info" variant="tonal" density="compact" class="mb-4" icon="mdi-cart-arrow-down">
106
131
  <div class="font-weight-medium">Request items from the main store</div>
107
132
  <div class="text-body-2">Pick the items you need and press Request Stock. You are told when the store keeper approves it.</div>
133
+ <div v-if="canSetUpOwnStore" class="d-flex align-center flex-wrap ga-2 mt-2">
134
+ <span class="text-body-2">Your company can also keep its own store here for stock it buys itself.</span>
135
+ <v-btn size="small" variant="outlined" class="text-none" @click="openOwnStoreSetup">Set up our own store</v-btn>
136
+ </div>
108
137
  </v-alert>
109
138
  <v-alert
110
139
  v-else-if="store.access.canApprove && pendingCount > 0 && tab !== 'requests'"
@@ -124,6 +153,9 @@
124
153
  <v-btn size="small" variant="flat" color="warning" class="text-none" @click="tab = 'mine'">Open My Stock</v-btn>
125
154
  </div>
126
155
  </v-alert>
156
+ <v-alert v-if="twoStoresText" type="info" variant="tonal" density="compact" class="mb-4" icon="mdi-store-outline">
157
+ {{ twoStoresText }}
158
+ </v-alert>
127
159
  <v-tabs v-model="tab" color="primary" class="mb-4" show-arrows>
128
160
  <v-tab v-for="t in tabs" :key="t.value" :value="t.value" class="text-none">
129
161
  {{ t.label }}
@@ -166,7 +198,16 @@ import useWorkerTerm from "../composables/useWorkerTerm";
166
198
  import useSite from "../composables/useSite";
167
199
  import useCustomerSite from "../composables/useCustomerSite";
168
200
  import useUtils from "../composables/useUtils";
169
- import { inventoryManagedBy, inventorySiteOptions, inventoryStoreLabel, inventorySuppliesText, inventorySupplySites } from "../utils/inventory-store-label";
201
+ import {
202
+ INVENTORY_HOW_IT_WORKS as HOW,
203
+ inventoryManagedBy,
204
+ inventorySiteOptions,
205
+ inventoryStoreLabel,
206
+ inventorySuppliesText,
207
+ inventorySupplySites,
208
+ inventoryTwoStoresText,
209
+ } from "../utils/inventory-store-label";
210
+ import useInventoryPermission from "../composables/useInventoryPermission";
170
211
  import { inventoryControls } from "../utils/inventory-presets";
171
212
  import { inventoryStepsLive } from "../utils/inventory-ack";
172
213
  import useLocalAuth from "../composables/useLocalAuth";
@@ -198,6 +239,16 @@ const pendingCount = ref(0);
198
239
  const orgSites = ref<{ _id: string; name: string }[]>([]);
199
240
 
200
241
  const showSetup = ref(false);
242
+ const showHowItWorks = ref(false);
243
+ const { canManageInventory } = useInventoryPermission();
244
+ const twoStoresText = computed(() => inventoryTwoStoresText(stores.value));
245
+ // Scenario 3: a provider at a property with a main store may add its own store; offered only when it has none here.
246
+ const canSetUpOwnStore = computed(() => canManageInventory.value && !stores.value.some((s) => s.owner === true));
247
+ function openOwnStoreSetup() {
248
+ // Never "Main Store": that is the property manager's store in every label.
249
+ Object.assign(setup, { name: "Our Store", sites: [props.siteId] });
250
+ showSetup.value = true;
251
+ }
201
252
  const setupForm = ref();
202
253
  const setup = reactive({ name: "Main Store", sites: [props.siteId] as string[] });
203
254
 
@@ -15,7 +15,7 @@
15
15
  chips
16
16
  density="comfortable"
17
17
  :rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
18
- hint="Choose more than one if this store supplies them all, e.g. a company's central store for all its sites."
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
19
  persistent-hint
20
20
  class="mb-4"
21
21
  />
@@ -31,5 +31,12 @@ export default function useInventoryPermission() {
31
31
  );
32
32
  });
33
33
 
34
- return { canSeeInventory };
34
+ /** May set up a store for this organisation (the API checks again; this only decides whether to offer the button). */
35
+ const canManageInventory = computed(() => {
36
+ const role = userAppRole.value;
37
+ if (!role || permissionsDenied(["inventory"], userAppModulesDenied?.value)) return false;
38
+ return role.permissions.includes("*") || hasPermission(role, permissions, "inventory", "manage-inventory");
39
+ });
40
+
41
+ return { canSeeInventory, canManageInventory };
35
42
  }
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.655",
5
+ "version": "4.97.1-staging.656",
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.",
@@ -68,3 +68,39 @@ export function inventoryItemMeta(item: TItemLike) {
68
68
  .filter(Boolean)
69
69
  .join(" · ");
70
70
  }
71
+
72
+ /**
73
+ * "How inventory works" (owner 2026-11-05): the three ways clients run stock, in the words the screens use.
74
+ * The mobile apps carry the same sentences; change both together.
75
+ */
76
+ export const INVENTORY_HOW_IT_WORKS = {
77
+ title: "How inventory works",
78
+ intro:
79
+ "A store is the stock one company keeps. The company that owns a store runs it: adds items, receives deliveries, approves requests and issues stock. Everyone else can only request from it.",
80
+ setups: [
81
+ {
82
+ title: "1. One company store for many sites",
83
+ text: "For example a security agency: one store supplies every site the company serves. When you set it up, tick all those sites. Staff at each site request from it; issues, usage and reports are recorded per site.",
84
+ },
85
+ {
86
+ title: "2. One store per property",
87
+ text: "For example Winsland House 1 and Winsland House 2: each property keeps its own stock, so each gets its own store. Set up the store at each property and tick only that property. Use Switch property to move between them; stock never mixes.",
88
+ },
89
+ {
90
+ title: "3. Main store and service providers",
91
+ text: "The property manager's Main store supplies the service providers at the property: their staff request, the store keeper issues to the person. A provider can also keep its own store (Our store) for stock it buys itself. Stock does not move between stores.",
92
+ },
93
+ ],
94
+ where: "Stores are set up on the web (Inventory, by a person allowed to manage inventory). The mobile apps request, receive and record usage.",
95
+ };
96
+
97
+ /**
98
+ * Two stores at one property for the same person: say which is which, so a request goes to the right one.
99
+ * Empty unless the person sees both their own company's store and another company's main store.
100
+ */
101
+ export function inventoryTwoStoresText(stores: TStoreLike[]) {
102
+ const ours = stores.some((s) => s.owner === true);
103
+ const theirs = stores.some((s) => s.owner === false && s.main);
104
+ if (!ours || !theirs) return "";
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
+ }