law-common 14.0.8-beta.2 → 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.
@@ -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.2",
3
+ "version": "14.0.8-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [