@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.18 → 1.3.1-dev.19
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/package.json +1 -1
- package/src/Site.js +27 -11
package/package.json
CHANGED
package/src/Site.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file src/Site.js
|
|
3
3
|
* @author shisyamo4131
|
|
4
|
-
* @version 1.
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @update 2025-11-20 version 0.2.0-bata
|
|
6
|
+
* - Prevent changing customer reference on update.
|
|
7
|
+
* - Move `customer` property to the top of classProps for better visibility.
|
|
5
8
|
*/
|
|
6
9
|
import { default as FireModel } from "@shisyamo4131/air-firebase-v2";
|
|
7
10
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
@@ -12,6 +15,16 @@ import Agreement from "./Agreement.js";
|
|
|
12
15
|
import { VALUES } from "./constants/site-status.js";
|
|
13
16
|
|
|
14
17
|
const classProps = {
|
|
18
|
+
customer: defField("customer", {
|
|
19
|
+
required: true,
|
|
20
|
+
customClass: CustomerMinimal,
|
|
21
|
+
component: {
|
|
22
|
+
attrs: {
|
|
23
|
+
api: () => fetchDocsApi(CustomerMinimal),
|
|
24
|
+
noFilter: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
15
28
|
code: defField("code", { label: "現場コード" }),
|
|
16
29
|
name: defField("name", {
|
|
17
30
|
label: "現場名",
|
|
@@ -29,16 +42,6 @@ const classProps = {
|
|
|
29
42
|
address: defField("address", { required: true }),
|
|
30
43
|
building: defField("building"),
|
|
31
44
|
location: defField("location"),
|
|
32
|
-
customer: defField("customer", {
|
|
33
|
-
required: true,
|
|
34
|
-
customClass: CustomerMinimal,
|
|
35
|
-
component: {
|
|
36
|
-
attrs: {
|
|
37
|
-
api: () => fetchDocsApi(CustomerMinimal),
|
|
38
|
-
noFilter: true,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
45
|
remarks: defField("multipleLine", { label: "備考" }),
|
|
43
46
|
agreements: defField("array", { label: "取極め", customClass: Agreement }),
|
|
44
47
|
status: defField("siteStatus", { required: true }),
|
|
@@ -115,6 +118,19 @@ export default class Site extends FireModel {
|
|
|
115
118
|
static STATUS_ACTIVE = VALUES.ACTIVE.value;
|
|
116
119
|
static STATUS_TERMINATED = VALUES.TERMINATED.value;
|
|
117
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Override beforeUpdate to prevent changing customer reference.
|
|
123
|
+
* @returns {Promise<void>}
|
|
124
|
+
*/
|
|
125
|
+
async beforeUpdate() {
|
|
126
|
+
await super.beforeUpdate();
|
|
127
|
+
if (this.customer.docId !== this._beforeData.customer.docId) {
|
|
128
|
+
return Promise.reject(
|
|
129
|
+
new Error("Not allowed to change customer reference.")
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
118
134
|
afterInitialize(item = {}) {
|
|
119
135
|
super.afterInitialize(item);
|
|
120
136
|
|