@shisyamo4131/air-guard-v2-schemas 1.3.1-dev.12 → 1.3.1-dev.14

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "1.3.1-dev.12",
3
+ "version": "1.3.1-dev.14",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -170,12 +170,20 @@
170
170
  * - @param {Object|string} key - The combined key string or object
171
171
  * - @returns {Array<string>} - Array containing [siteId, shiftType, date]
172
172
  * - @throws {Error} - If the key is invalid.
173
+ * @method toggleLock - Toggle the lock status of an OperationResult document
174
+ * - @param {string} docId - Document ID
175
+ * - @param {boolean} value - Lock status value
176
+ * - @returns {Promise<void>}
173
177
  *
174
- * @override create - Override create method to indicate not implemented
178
+ * @override
179
+ * @method create - Override create method to indicate not implemented
175
180
  * - Creation of OperationBilling instances is not implemented, as billing records are typically
176
181
  * generated through the OperationResult class.
182
+ * @method update - Override update method to allow editing even when isLocked is true
183
+ * @method delete - Override delete method to allow deletion even when isLocked is true
177
184
  *****************************************************************************/
178
185
  import OperationResult from "./OperationResult.js";
186
+ import Operation from "./Operation.js";
179
187
 
180
188
  export default class OperationBilling extends OperationResult {
181
189
  static className = "稼働請求";
@@ -189,4 +197,43 @@ export default class OperationBilling extends OperationResult {
189
197
  async create() {
190
198
  return Promise.reject(new Error("[OperationBilling.js] Not implemented."));
191
199
  }
200
+
201
+ /**
202
+ * Override update method to allow editing even when isLocked is true
203
+ * @param {*} options
204
+ * @returns {Promise<void>}
205
+ */
206
+ async update(options = {}) {
207
+ // isLockedのチェックをスキップして、親クラス(Operation)のupdateを直接呼び出す
208
+ return await Operation.prototype.update.call(this, options);
209
+ }
210
+
211
+ /**
212
+ * Override delete method to allow deletion even when isLocked is true
213
+ * @param {*} options
214
+ * @returns {Promise<void>}
215
+ */
216
+ async delete(options = {}) {
217
+ // isLockedのチェックをスキップして、親クラス(Operation)のdeleteを直接呼び出す
218
+ return await Operation.prototype.delete.call(this, options);
219
+ }
220
+
221
+ /**
222
+ * Toggle the lock status of an OperationResult document
223
+ * @param {string} docId - Document ID
224
+ * @param {boolean} value - Lock status value
225
+ */
226
+ static async toggleLock(docId, value) {
227
+ if (!docId || typeof docId !== "string") {
228
+ throw new Error("Invalid docId provided to toggleLock method");
229
+ }
230
+ if (typeof value !== "boolean") {
231
+ throw new Error("Invalid value provided to toggleLock method");
232
+ }
233
+ const firestore = this.getAdapter().firestore;
234
+ const colPath = this.getCollectionPath();
235
+ const colRef = collection(firestore, colPath);
236
+ const docRef = doc(colRef, docId);
237
+ await updateDoc(docRef, { isLocked: value });
238
+ }
192
239
  }
@@ -205,7 +205,7 @@ const classProps = {
205
205
  label: "資格残業(調整)",
206
206
  default: 0,
207
207
  }),
208
- billingDateAt: defField("dateAt", { label: "請求日付" }),
208
+ billingDateAt: defField("dateAt", { label: "請求締日" }),
209
209
  employees: defField("array", { customClass: OperationResultDetail }),
210
210
  outsourcers: defField("array", {
211
211
  customClass: OperationResultDetail,
@@ -216,7 +216,7 @@ const classProps = {
216
216
  }),
217
217
  agreement: defField("object", { label: "取極め", customClass: Agreement }),
218
218
  allowEmptyAgreement: defField("check", {
219
- label: "取極めなしを無視",
219
+ label: "取極めなしを許容",
220
220
  default: false,
221
221
  }),
222
222
  };
@@ -245,7 +245,6 @@ export default class OperationResult extends Operation {
245
245
  super.afterInitialize();
246
246
 
247
247
  /** Computed properties */
248
- let _agreement = this.agreement;
249
248
  Object.defineProperties(this, {
250
249
  statistics: {
251
250
  configurable: true,
@@ -430,18 +429,6 @@ export default class OperationResult extends Operation {
430
429
  },
431
430
  set(v) {},
432
431
  },
433
-
434
- agreement: {
435
- configurable: true,
436
- enumerable: true,
437
- get() {
438
- return _agreement;
439
- },
440
- set(v) {
441
- _agreement = v;
442
- this.refreshBillingDateAt();
443
- },
444
- },
445
432
  hasAgreement: {
446
433
  configurable: true,
447
434
  enumerable: true,
@@ -465,6 +452,25 @@ export default class OperationResult extends Operation {
465
452
  set(v) {},
466
453
  },
467
454
  });
455
+
456
+ /** Triggers */
457
+ let _agreement = this.agreement;
458
+ Object.defineProperties(this, {
459
+ agreement: {
460
+ configurable: true,
461
+ enumerable: true,
462
+ get() {
463
+ return _agreement;
464
+ },
465
+ set(v) {
466
+ const oldKey = _agreement ? _agreement.key : null;
467
+ const newKey = v ? v.key : null;
468
+ if (oldKey === newKey) return;
469
+ _agreement = v;
470
+ this.refreshBillingDateAt();
471
+ },
472
+ },
473
+ });
468
474
  }
469
475
 
470
476
  /**