@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.10 → 2.4.2-dev.12
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/Company.js +102 -13
- package/src/SiteOperationSchedule.js +28 -12
- package/src/parts/fieldDefinitions.js +6 -1
package/package.json
CHANGED
package/src/Company.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/*****************************************************************************
|
|
2
2
|
* Company Model
|
|
3
|
-
* @version 1.0.0
|
|
4
3
|
* @author shisyamo4131
|
|
5
|
-
|
|
6
|
-
* @update 2025-12-29 - Add `isCompleteRequiredFields` computed property.
|
|
7
|
-
* @update 2025-12-02 - Add maintenance information properties.
|
|
8
|
-
* @update 2025-12-01 - Add Stripe integration fields (stripeCustomerId, subscription).
|
|
9
|
-
* @update 2025-11-27 - Add bank information fields for billing.
|
|
10
|
-
* @update 2025-11-23 - Set `usePrefix` to false.
|
|
11
|
-
*/
|
|
4
|
+
*****************************************************************************/
|
|
12
5
|
import FireModel from "@shisyamo4131/air-firebase-v2";
|
|
13
6
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
14
7
|
import { defAccessor } from "./parts/accessorDefinitions.js";
|
|
@@ -56,11 +49,19 @@ const classProps = {
|
|
|
56
49
|
}),
|
|
57
50
|
|
|
58
51
|
/**
|
|
59
|
-
*
|
|
52
|
+
* Property to manage the display order of site-shift type pairs for arrangement management.
|
|
60
53
|
* Format: { siteId, shiftType }
|
|
54
|
+
* NOTE: `key` is a unique identifier combined from siteId and shiftType.
|
|
61
55
|
*/
|
|
62
56
|
siteOrder: defField("array", { customClass: SiteOrder, hidden: true }),
|
|
63
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Property to manage the display order of site-shift type pairs for site-operation-schedule.
|
|
60
|
+
* Format: { siteId, shiftType, key }
|
|
61
|
+
* NOTE: `key` is a unique identifier combined from siteId and shiftType.
|
|
62
|
+
*/
|
|
63
|
+
scheduleOrder: defField("array", { customClass: SiteOrder, hidden: true }),
|
|
64
|
+
|
|
64
65
|
/** Geolocation */
|
|
65
66
|
location: defField("location", { hidden: true }),
|
|
66
67
|
|
|
@@ -203,7 +204,7 @@ export default class Company extends GeocodableMixin(FireModel) {
|
|
|
203
204
|
const newOrder = new SiteOrder({ siteId, shiftType });
|
|
204
205
|
if (this.some((order) => order.key === newOrder.key)) {
|
|
205
206
|
throw new Error(
|
|
206
|
-
`SiteOrder with key ${newOrder.key} already exists
|
|
207
|
+
`SiteOrder with key ${newOrder.key} already exists.`,
|
|
207
208
|
);
|
|
208
209
|
}
|
|
209
210
|
index === -1 ? this.push(newOrder) : this.splice(index, 0, newOrder);
|
|
@@ -253,13 +254,101 @@ export default class Company extends GeocodableMixin(FireModel) {
|
|
|
253
254
|
key = `${arg.siteId}-${arg.shiftType}`;
|
|
254
255
|
} else {
|
|
255
256
|
throw new Error(
|
|
256
|
-
"Invalid argument for remove. Must be a string key or an object with siteId and shiftType."
|
|
257
|
+
"Invalid argument for remove. Must be a string key or an object with siteId and shiftType.",
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const index = this.findIndex((order) => order.key === key);
|
|
262
|
+
if (index === -1) {
|
|
263
|
+
throw new Error(`ScheduleOrder with key ${key} does not exist.`);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
this.splice(index, 1);
|
|
267
|
+
},
|
|
268
|
+
writable: false,
|
|
269
|
+
enumerable: false,
|
|
270
|
+
configurable: true,
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
/*************************************************************************
|
|
275
|
+
* CUSTOM METHODS FOR scheduleOrder ARRAY
|
|
276
|
+
* Note: These methods modify the scheduleOrder array directly.
|
|
277
|
+
* The Company instance itself is not updated by these methods.
|
|
278
|
+
* Use the provided public methods to interact with scheduleOrder.
|
|
279
|
+
*************************************************************************/
|
|
280
|
+
Object.defineProperties(this.scheduleOrder, {
|
|
281
|
+
/**
|
|
282
|
+
* Inserts a new ScheduleOrder into the `scheduleOrder` array.
|
|
283
|
+
* @param {Object} params - The parameters for the ScheduleOrder.
|
|
284
|
+
* @param {string} params.siteId - The ID of the site.
|
|
285
|
+
* @param {string} params.shiftType - The shift type associated with the site.
|
|
286
|
+
* @param {number} [index=-1] - The position to insert the new ScheduleOrder. Defaults to the end.
|
|
287
|
+
* @returns {ScheduleOrder} The newly created ScheduleOrder instance.
|
|
288
|
+
* @throws {Error} If a ScheduleOrder with the same key already exists.
|
|
289
|
+
*/
|
|
290
|
+
add: {
|
|
291
|
+
value: function ({ siteId, shiftType }, index = -1) {
|
|
292
|
+
const newOrder = new ScheduleOrder({ siteId, shiftType });
|
|
293
|
+
if (this.some((order) => order.key === newOrder.key)) {
|
|
294
|
+
throw new Error(
|
|
295
|
+
`ScheduleOrder with key ${newOrder.key} already exists.`,
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
index === -1 ? this.push(newOrder) : this.splice(index, 0, newOrder);
|
|
299
|
+
return newOrder;
|
|
300
|
+
},
|
|
301
|
+
writable: false,
|
|
302
|
+
enumerable: false,
|
|
303
|
+
configurable: true,
|
|
304
|
+
},
|
|
305
|
+
/**
|
|
306
|
+
* Changes the order of a ScheduleOrder in the scheduleOrder array.
|
|
307
|
+
* Note: Company instance does not be updated by this method.
|
|
308
|
+
* @param {number} oldIndex - The current index of the ScheduleOrder.
|
|
309
|
+
* @param {number} newIndex - The new index to move the ScheduleOrder to.
|
|
310
|
+
* @returns {void}
|
|
311
|
+
* @throws {Error} If oldIndex or newIndex are out of bounds.
|
|
312
|
+
*/
|
|
313
|
+
change: {
|
|
314
|
+
value: function (oldIndex, newIndex) {
|
|
315
|
+
const length = this.length;
|
|
316
|
+
if (oldIndex < 0 || oldIndex >= length) {
|
|
317
|
+
throw new Error("Invalid oldIndex for site order change.");
|
|
318
|
+
}
|
|
319
|
+
if (newIndex < 0 || newIndex >= length) {
|
|
320
|
+
throw new Error("Invalid newIndex for site order change.");
|
|
321
|
+
}
|
|
322
|
+
const [movedOrder] = this.splice(oldIndex, 1);
|
|
323
|
+
this.splice(newIndex, 0, movedOrder);
|
|
324
|
+
},
|
|
325
|
+
writable: false,
|
|
326
|
+
enumerable: false,
|
|
327
|
+
configurable: true,
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Removes a ScheduleOrder from the scheduleOrder array.
|
|
331
|
+
* Note: Company instance does not be updated by this method.
|
|
332
|
+
* @param {string|Object} arg - The key or {siteId, shiftType} of the ScheduleOrder to remove.
|
|
333
|
+
* @returns {void}
|
|
334
|
+
* @throws {Error} If the ScheduleOrder does not exist or if the argument is invalid.
|
|
335
|
+
*/
|
|
336
|
+
remove: {
|
|
337
|
+
value: function (arg) {
|
|
338
|
+
let key = "";
|
|
339
|
+
if (typeof arg === "string") {
|
|
340
|
+
key = arg;
|
|
341
|
+
} else if (typeof arg === "object" && arg.siteId && arg.shiftType) {
|
|
342
|
+
key = `${arg.siteId}-${arg.shiftType}`;
|
|
343
|
+
} else {
|
|
344
|
+
throw new Error(
|
|
345
|
+
"Invalid argument for remove. Must be a string key or an object with siteId and shiftType.",
|
|
257
346
|
);
|
|
258
347
|
}
|
|
259
348
|
|
|
260
349
|
const index = this.findIndex((order) => order.key === key);
|
|
261
350
|
if (index === -1) {
|
|
262
|
-
throw new Error(`
|
|
351
|
+
throw new Error(`ScheduleOrder with key ${key} does not exist.`);
|
|
263
352
|
}
|
|
264
353
|
|
|
265
354
|
this.splice(index, 1);
|
|
@@ -37,9 +37,13 @@
|
|
|
37
37
|
* @getter {boolean} isEditable - Indicates whether the instance is editable (read-only)
|
|
38
38
|
* - Returns `false` if `operationResultId` is set, `true` otherwise
|
|
39
39
|
*
|
|
40
|
+
* @deprecated
|
|
40
41
|
* @getter {boolean} isNotificatedAllWorkers - Indicates whether all workers have been notified (read-only)
|
|
41
42
|
* - Returns `true` if all workers in the `workers` array have `hasNotification` set to `true`
|
|
42
43
|
*
|
|
44
|
+
* @getter {boolean} isNotifiedAllWorkers - Indicates whether all workers have been notified (read-only)
|
|
45
|
+
* - Returns `true` if all workers in the `workers` array have `hasNotification` set to `true`
|
|
46
|
+
*
|
|
43
47
|
* @inherited - The following properties are inherited from Operation:
|
|
44
48
|
* @property {string} siteId - Site document ID (trigger property)
|
|
45
49
|
* - Automatically synchronizes to all `employees` and `outsourcers` when changed.
|
|
@@ -339,7 +343,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
339
343
|
set(v) {
|
|
340
344
|
if (typeof v !== "number" || isNaN(v) || v < 0) {
|
|
341
345
|
throw new Error(
|
|
342
|
-
`breakMinutes must be a non-negative number. breakMinutes: ${v}
|
|
346
|
+
`breakMinutes must be a non-negative number. breakMinutes: ${v}`,
|
|
343
347
|
);
|
|
344
348
|
}
|
|
345
349
|
if (_breakMinutes === v) return;
|
|
@@ -354,7 +358,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
354
358
|
set(v) {
|
|
355
359
|
if (typeof v !== "boolean") {
|
|
356
360
|
throw new Error(
|
|
357
|
-
`isStartNextDay must be a boolean. isStartNextDay: ${v}
|
|
361
|
+
`isStartNextDay must be a boolean. isStartNextDay: ${v}`,
|
|
358
362
|
);
|
|
359
363
|
}
|
|
360
364
|
if (_isStartNextDay === v) return;
|
|
@@ -376,10 +380,22 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
376
380
|
}
|
|
377
381
|
|
|
378
382
|
/**
|
|
383
|
+
* @deprecated
|
|
379
384
|
* Returns whether all workers have been notified.
|
|
380
385
|
* @returns {boolean} - Whether all workers have been notified.
|
|
381
386
|
*/
|
|
382
387
|
get isNotificatedAllWorkers() {
|
|
388
|
+
console.warn(
|
|
389
|
+
"`isNotificatedAllWorkers` is deprecated. Use `isNotifiedAllWorkers` instead.",
|
|
390
|
+
);
|
|
391
|
+
return this.workers.every((worker) => worker.hasNotification);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Returns whether all workers have been notified.
|
|
396
|
+
* @returns {boolean} - Whether all workers have been notified.
|
|
397
|
+
*/
|
|
398
|
+
get isNotifiedAddWorkers() {
|
|
383
399
|
return this.workers.every((worker) => worker.hasNotification);
|
|
384
400
|
}
|
|
385
401
|
|
|
@@ -397,7 +413,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
397
413
|
async beforeUpdate(args = {}) {
|
|
398
414
|
if (this._beforeData.operationResultId) {
|
|
399
415
|
throw new Error(
|
|
400
|
-
`Could not update this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}
|
|
416
|
+
`Could not update this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}`,
|
|
401
417
|
);
|
|
402
418
|
}
|
|
403
419
|
await super.beforeUpdate(args);
|
|
@@ -414,7 +430,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
414
430
|
async beforeDelete(args = {}) {
|
|
415
431
|
if (this._beforeData.operationResultId) {
|
|
416
432
|
throw new Error(
|
|
417
|
-
`Could not delete this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}
|
|
433
|
+
`Could not delete this document. The OperationResult based on this document already exists. OperationResultId: ${this._beforeData.operationResultId}`,
|
|
418
434
|
);
|
|
419
435
|
}
|
|
420
436
|
await super.beforeDelete(args);
|
|
@@ -588,7 +604,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
588
604
|
}
|
|
589
605
|
if (dates.some((d) => !(d instanceof Date) && typeof d !== "string")) {
|
|
590
606
|
throw new TypeError(
|
|
591
|
-
"日付の指定が無効です。Dateオブジェクトか文字列で指定してください。"
|
|
607
|
+
"日付の指定が無効です。Dateオブジェクトか文字列で指定してください。",
|
|
592
608
|
);
|
|
593
609
|
}
|
|
594
610
|
if (dates.length > 20) {
|
|
@@ -632,7 +648,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
632
648
|
// トランザクションで一括作成
|
|
633
649
|
await this.constructor.runTransaction(async (transaction) => {
|
|
634
650
|
await Promise.all(
|
|
635
|
-
newSchedules.map((schedule) => schedule.create({ transaction }))
|
|
651
|
+
newSchedules.map((schedule) => schedule.create({ transaction })),
|
|
636
652
|
);
|
|
637
653
|
});
|
|
638
654
|
|
|
@@ -694,7 +710,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
694
710
|
className: "SiteOperationSchedule",
|
|
695
711
|
arguments: {},
|
|
696
712
|
state: this.toObject(),
|
|
697
|
-
}
|
|
713
|
+
},
|
|
698
714
|
);
|
|
699
715
|
}
|
|
700
716
|
}
|
|
@@ -716,7 +732,7 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
716
732
|
// ドキュメントIDがない(現場稼働予定ドキュメントとして未作成)場合はエラー
|
|
717
733
|
if (!this.docId) {
|
|
718
734
|
throw new Error(
|
|
719
|
-
"不正な処理です。作成前の現場稼働予定から稼働実績を作成することはできません。"
|
|
735
|
+
"不正な処理です。作成前の現場稼働予定から稼働実績を作成することはできません。",
|
|
720
736
|
);
|
|
721
737
|
}
|
|
722
738
|
|
|
@@ -726,12 +742,12 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
726
742
|
const siteIsExist = await siteInstance.fetch({ docId: this.siteId });
|
|
727
743
|
if (!siteIsExist) {
|
|
728
744
|
throw new Error(
|
|
729
|
-
`不正な処理です。現場ID: ${this.siteId}
|
|
745
|
+
`不正な処理です。現場ID: ${this.siteId} の現場データが存在しません。`,
|
|
730
746
|
);
|
|
731
747
|
}
|
|
732
748
|
if (siteInstance.isTemporary) {
|
|
733
749
|
throw new Error(
|
|
734
|
-
`不正な処理です。現場ID: ${this.siteId}
|
|
750
|
+
`不正な処理です。現場ID: ${this.siteId} の現場データは仮登録状態です。`,
|
|
735
751
|
);
|
|
736
752
|
}
|
|
737
753
|
|
|
@@ -813,8 +829,8 @@ export default class SiteOperationSchedule extends Operation {
|
|
|
813
829
|
const color = !this.isEditable
|
|
814
830
|
? "grey"
|
|
815
831
|
: this.shiftType === "DAY"
|
|
816
|
-
|
|
817
|
-
|
|
832
|
+
? "orange"
|
|
833
|
+
: "indigo";
|
|
818
834
|
return {
|
|
819
835
|
name,
|
|
820
836
|
start: this.dateAt,
|
|
@@ -320,6 +320,7 @@ export const fieldDefinitions = {
|
|
|
320
320
|
name: generalDefinitions.oneLine.component.name,
|
|
321
321
|
attrs: {
|
|
322
322
|
inputType: "email",
|
|
323
|
+
inputmode: "email",
|
|
323
324
|
},
|
|
324
325
|
},
|
|
325
326
|
},
|
|
@@ -347,6 +348,7 @@ export const fieldDefinitions = {
|
|
|
347
348
|
attrs: {
|
|
348
349
|
counter: true,
|
|
349
350
|
inputType: "tel",
|
|
351
|
+
inputmode: "tel",
|
|
350
352
|
},
|
|
351
353
|
},
|
|
352
354
|
},
|
|
@@ -359,6 +361,7 @@ export const fieldDefinitions = {
|
|
|
359
361
|
attrs: {
|
|
360
362
|
counter: true,
|
|
361
363
|
inputType: "tel",
|
|
364
|
+
inputmode: "tel",
|
|
362
365
|
},
|
|
363
366
|
},
|
|
364
367
|
},
|
|
@@ -421,6 +424,7 @@ export const fieldDefinitions = {
|
|
|
421
424
|
attrs: {
|
|
422
425
|
counter: true,
|
|
423
426
|
inputType: "tel",
|
|
427
|
+
inputmode: "tel",
|
|
424
428
|
},
|
|
425
429
|
},
|
|
426
430
|
},
|
|
@@ -482,6 +486,7 @@ export const fieldDefinitions = {
|
|
|
482
486
|
attrs: {
|
|
483
487
|
counter: true,
|
|
484
488
|
inputType: "tel",
|
|
489
|
+
inputmode: "tel",
|
|
485
490
|
},
|
|
486
491
|
},
|
|
487
492
|
},
|
|
@@ -704,7 +709,7 @@ export const defField = (key, options = {}) => {
|
|
|
704
709
|
|
|
705
710
|
if (!baseConfigSource) {
|
|
706
711
|
console.warn(
|
|
707
|
-
`[parts/fieldDefinitions.js defField] Definition for key "${key}" not found. Using fieldDefinitions.default as base
|
|
712
|
+
`[parts/fieldDefinitions.js defField] Definition for key "${key}" not found. Using fieldDefinitions.default as base.`,
|
|
708
713
|
);
|
|
709
714
|
baseConfigSource = effectiveDefaultDefinition;
|
|
710
715
|
isFallback = true;
|