law-common 14.0.8-beta.1 → 14.0.8-beta.3

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.
@@ -11,11 +11,11 @@ const to_do_list_status_enum_1 = require("../enums/to_do_list_status_enum");
11
11
  *
12
12
  * @Post() TO_DO_LIST_CREATE_ORG, _CREATE_PROJECT, _CREATE_SELF
13
13
  * @Patch(":id") TO_DO_LIST_UPDATE_ORG, _UPDATE_PROJECT, _UPDATE_SELF
14
- * @Delete(":id") TO_DO_LIST_DELETE_ORG, _DELETE_PROJECT
14
+ * @Delete(":id") TO_DO_LIST_DELETE_ORG, _DELETE_PROJECT, _DELETE_SELF
15
15
  *
16
- * DELETE carries only two: TO_DO_LIST_DELETE_SELF has never been seeded, so a user whose only
17
- * to-do-list authority is over their own rows cannot delete. That matches today's behaviour and is
18
- * preserved rather than fixed here.
16
+ * DELETE now carries all three. TO_DO_LIST_DELETE_SELF is seeded in higher environments (not in the
17
+ * original 1752573777447-ToDoListEntityPermissions migration) and scopes deletes to the acting
18
+ * user's own rows via the V2 getDeletePermissionFilterFunction.
19
19
  *
20
20
  * DEACTIVATE / ACTIVATE / RESTORE are unscoped - LW-826 seeded them flat - so those keep single-name
21
21
  * arrays. Mixing the two shapes in one config is deliberate: each action names the rows that exist.
@@ -28,7 +28,7 @@ const to_do_list_status_enum_1 = require("../enums/to_do_list_status_enum");
28
28
  */
29
29
  const TO_DO_LIST_CREATE_PERMISSION = ["TO_DO_LIST_CREATE_ORG", "TO_DO_LIST_CREATE_PROJECT", "TO_DO_LIST_CREATE_SELF"];
30
30
  const TO_DO_LIST_UPDATE_PERMISSION = ["TO_DO_LIST_UPDATE_ORG", "TO_DO_LIST_UPDATE_PROJECT", "TO_DO_LIST_UPDATE_SELF"];
31
- const TO_DO_LIST_DELETE_PERMISSION = ["TO_DO_LIST_DELETE_ORG", "TO_DO_LIST_DELETE_PROJECT"];
31
+ const TO_DO_LIST_DELETE_PERMISSION = ["TO_DO_LIST_DELETE_ORG", "TO_DO_LIST_DELETE_PROJECT", "TO_DO_LIST_DELETE_SELF"];
32
32
  const TO_DO_LIST_DEACTIVATE_PERMISSION = ["TO_DO_LIST_DEACTIVATE"];
33
33
  const TO_DO_LIST_ACTIVATE_PERMISSION = ["TO_DO_LIST_ACTIVATE"];
34
34
  const TO_DO_LIST_RESTORE_PERMISSION = ["TO_DO_LIST_RESTORE"];
@@ -87,8 +87,8 @@ export declare class ToDoListEntityModel extends BaseEntityModel<EntityEnum.TO_D
87
87
  label: string;
88
88
  }>;
89
89
  customLabels?: Partial<Record<ToDoListActionEnum, string>>;
90
- }): IRowActions<EntityEnum.TO_DO_LIST>[];
91
- getUpdateActionVisibility(currentUser: UserEntityModel): {
90
+ }, currentUserProjectIds?: number[]): IRowActions<EntityEnum.TO_DO_LIST>[];
91
+ getUpdateActionVisibility(currentUser: UserEntityModel, currentUserProjectIds?: number[]): {
92
92
  [key: string]: () => boolean;
93
93
  };
94
94
  }
@@ -425,20 +425,34 @@ class ToDoListEntityModel extends base_entity_model_1.BaseEntityModel {
425
425
  const nextStatus = matchingPermissionConfig.next(toDoListFlowConfigContextData);
426
426
  return nextStatus;
427
427
  }
428
- getAvailableActions(currentUser, config) {
428
+ getAvailableActions(currentUser, config, currentUserProjectIds) {
429
429
  var _a;
430
430
  const params = {
431
431
  flowConfig: to_do_list_flow_config_1.toDoListFlowConfig,
432
432
  currentStatus: this.status,
433
433
  userPermissions: (_a = currentUser.permissions) !== null && _a !== void 0 ? _a : [],
434
- visibilityData: this.getUpdateActionVisibility.bind(this, currentUser),
434
+ visibilityData: this.getUpdateActionVisibility.bind(this, currentUser, currentUserProjectIds),
435
435
  combinedActions: config === null || config === void 0 ? void 0 : config.combinedActions,
436
436
  customLabels: config === null || config === void 0 ? void 0 : config.customLabels,
437
437
  };
438
438
  return utils_1.EntityActionFlowResolverV2.getAvailableActionsData(params);
439
439
  }
440
- getUpdateActionVisibility(currentUser) {
441
- return {};
440
+ getUpdateActionVisibility(currentUser, currentUserProjectIds) {
441
+ var _a, _b;
442
+ // LW-799: legacy parity - PROJECT-scoped UPDATE/DELETE resolves the acting user's project
443
+ // memberships (mirrors timesheet.entity.model.ts:107-126); the caller passes the ids
444
+ // fetched via the USER -> PROJECT_USER_MAPPING relations, falling back to the auth user's
445
+ // own projecUserMappings when not supplied.
446
+ const projectIds = (_b = currentUserProjectIds !== null && currentUserProjectIds !== void 0 ? currentUserProjectIds : (_a = currentUser.projecUserMappings) === null || _a === void 0 ? void 0 : _a.map((mapping) => mapping.projectId)) !== null && _b !== void 0 ? _b : [];
447
+ const isProjectOwnerOrSelf = (projectId) => projectIds.includes(projectId) || currentUser.id === this.userId;
448
+ return {
449
+ TO_DO_LIST_UPDATE_SELF: () => currentUser.id === this.userId,
450
+ TO_DO_LIST_UPDATE_PROJECT: () => isProjectOwnerOrSelf(this.projectId),
451
+ TO_DO_LIST_DELETE_SELF: () => currentUser.id === this.userId,
452
+ TO_DO_LIST_DELETE_PROJECT: () => isProjectOwnerOrSelf(this.projectId),
453
+ TO_DO_LIST_UPDATE_ORG: () => true,
454
+ TO_DO_LIST_DELETE_ORG: () => true,
455
+ };
442
456
  }
443
457
  }
444
458
  exports.ToDoListEntityModel = ToDoListEntityModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "14.0.8-beta.1",
3
+ "version": "14.0.8-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [