cloud-ide-core 2.0.121 → 2.0.123

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.
@@ -13195,15 +13195,23 @@ class CideCoreUserCreateComponent {
13195
13195
  this.loadRolesForEntity(index, entityIdString);
13196
13196
  }
13197
13197
  });
13198
- // Load role permissions for each mapping that has a role selected
13198
+ // Load role permissions and menu rights for each mapping that has a role selected
13199
13199
  data.core_entity_mapping.forEach((mapping, index) => {
13200
- if (mapping.syenm_role_id_syusrol) {
13200
+ if (mapping.syenm_role_id_syusrol && mapping.syenm_entity_id_syen) {
13201
13201
  const roleId = typeof mapping.syenm_role_id_syusrol === 'object'
13202
13202
  ? mapping.syenm_role_id_syusrol._id
13203
13203
  : mapping.syenm_role_id_syusrol;
13204
- if (roleId) {
13205
- console.log(`🎭 Loading role permissions for mapping ${index} with role ${roleId}`);
13204
+ const entityId = typeof mapping.syenm_entity_id_syen === 'object' && mapping.syenm_entity_id_syen !== null
13205
+ ? mapping.syenm_entity_id_syen._id
13206
+ : mapping.syenm_entity_id_syen;
13207
+ if (roleId && entityId) {
13208
+ console.log(`🎭 Loading role permissions for mapping ${index} with role ${roleId} and entity ${entityId}`);
13206
13209
  this.loadRolePermissions(roleId, index);
13210
+ // Load menu rights after a short delay to ensure form is patched
13211
+ setTimeout(() => {
13212
+ console.log(`🚀 Loading menu rights for mapping ${index} after data load`);
13213
+ this.loadMenuRights(index);
13214
+ }, 200);
13207
13215
  }
13208
13216
  }
13209
13217
  });
@@ -13857,22 +13865,61 @@ class CideCoreUserCreateComponent {
13857
13865
  console.log(`🎭 Role changed for mapping ${mappingIndex}:`, role);
13858
13866
  if (!role) {
13859
13867
  this.clearRolePermissions();
13868
+ this.clearRoleForMapping(mappingIndex);
13860
13869
  return;
13861
13870
  }
13871
+ const roleId = role?._id || '';
13862
13872
  this.selectedEntityIndex.set(mappingIndex);
13863
- this.selectedRoleId.set(role?._id || '');
13873
+ this.selectedRoleId.set(roleId);
13874
+ // Update the signal with the selected role
13875
+ this.entityMappings.update(mappings => {
13876
+ const updated = [...mappings];
13877
+ if (updated[mappingIndex]) {
13878
+ updated[mappingIndex] = {
13879
+ ...updated[mappingIndex],
13880
+ syenm_role_id_syusrol: {
13881
+ _id: roleId,
13882
+ syusrol_name: role.syusrol_role_name || ''
13883
+ }
13884
+ };
13885
+ }
13886
+ return updated;
13887
+ });
13864
13888
  // Load role details and permissions
13865
- this.loadRolePermissions(role?._id || '', mappingIndex);
13889
+ this.loadRolePermissions(roleId, mappingIndex);
13890
+ // Get entity ID from form control or signal
13891
+ const mappingFormGroup = this.entityMappingsFormArray.at(mappingIndex);
13892
+ let entityId = undefined;
13893
+ if (mappingFormGroup) {
13894
+ const entityIdValue = mappingFormGroup.get('syenm_entity_id_syen')?.value;
13895
+ if (entityIdValue) {
13896
+ entityId = typeof entityIdValue === 'string'
13897
+ ? entityIdValue
13898
+ : (entityIdValue._id || undefined);
13899
+ }
13900
+ }
13901
+ // Fallback to signal
13902
+ if (!entityId) {
13903
+ const mapping = this.entityMappings()[mappingIndex];
13904
+ if (mapping?.syenm_entity_id_syen) {
13905
+ const entityValue = mapping.syenm_entity_id_syen;
13906
+ entityId = typeof entityValue === 'string'
13907
+ ? entityValue
13908
+ : (entityValue._id || undefined);
13909
+ }
13910
+ }
13866
13911
  // Automatically load menu rights when both entity and role are selected
13867
- const mapping = this.entityMappings()[mappingIndex];
13868
- if (mapping?.syenm_entity_id_syen && mapping?.syenm_role_id_syusrol) {
13869
- console.log(`🚀 Auto-loading menu rights for mapping ${mappingIndex}`);
13912
+ if (entityId && roleId) {
13913
+ console.log(`🚀 Auto-loading menu rights for mapping ${mappingIndex} with entity ${entityId} and role ${roleId}`);
13870
13914
  this.loadMenuRights(mappingIndex);
13871
13915
  // Force refresh the grid to show updated permission states
13872
13916
  setTimeout(() => {
13873
13917
  this.cdr.detectChanges();
13874
13918
  }, 100);
13875
13919
  }
13920
+ else {
13921
+ console.warn(`⚠️ Cannot load menu rights: entity=${entityId}, role=${roleId}`);
13922
+ }
13876
13923
  }
13877
13924
  /**
13878
13925
  * Load role permissions from API
@@ -14601,12 +14648,52 @@ class CideCoreUserCreateComponent {
14601
14648
  return menuRights[mappingIndex.toString()] || [];
14602
14649
  }
14603
14650
  loadMenuRights(mappingIndex) {
14604
- const mapping = this.entityMappings()[mappingIndex];
14605
- if (!mapping.syenm_entity_id_syen || !mapping.syenm_role_id_syusrol) {
14606
- console.warn('Entity and Role must be selected before loading menu rights');
14651
+ // Get entity ID from form control or signal
14652
+ const mappingFormGroup = this.entityMappingsFormArray.at(mappingIndex);
14653
+ let entityId = undefined;
14654
+ let roleId = undefined;
14655
+ // Try to get from form control first
14656
+ if (mappingFormGroup) {
14657
+ const entityIdValue = mappingFormGroup.get('syenm_entity_id_syen')?.value;
14658
+ if (entityIdValue) {
14659
+ entityId = typeof entityIdValue === 'string'
14660
+ ? entityIdValue
14661
+ : (entityIdValue._id || undefined);
14662
+ }
14663
+ const roleIdValue = mappingFormGroup.get('syenm_role_id_syusrol')?.value;
14664
+ if (roleIdValue) {
14665
+ roleId = typeof roleIdValue === 'string'
14666
+ ? roleIdValue
14667
+ : (roleIdValue._id || undefined);
14668
+ }
14669
+ }
14670
+ // Fallback to signal
14671
+ if (!entityId || !roleId) {
14672
+ const mapping = this.entityMappings()[mappingIndex];
14673
+ if (mapping?.syenm_entity_id_syen && !entityId) {
14674
+ const entityValue = mapping.syenm_entity_id_syen;
14675
+ entityId = typeof entityValue === 'string'
14676
+ ? entityValue
14677
+ : (entityValue._id || undefined);
14678
+ }
14679
+ if (mapping?.syenm_role_id_syusrol && !roleId) {
14680
+ const roleValue = mapping.syenm_role_id_syusrol;
14681
+ roleId = typeof roleValue === 'string'
14682
+ ? roleValue
14683
+ : (roleValue._id || undefined);
14684
+ }
14685
+ }
14686
+ if (!entityId || !roleId) {
14687
+ console.warn('Entity and Role must be selected before loading menu rights', {
14688
+ mappingIndex,
14689
+ entityId,
14690
+ roleId,
14691
+ formControl: mappingFormGroup?.value,
14692
+ signal: this.entityMappings()[mappingIndex]
14693
+ });
14607
14694
  return;
14608
14695
  }
14609
- console.log('🚀 Loading menu rights for mapping:', mappingIndex);
14696
+ console.log('🚀 Loading menu rights for mapping:', mappingIndex, 'Entity:', entityId, 'Role:', roleId);
14610
14697
  this.loading.set(true);
14611
14698
  // Use actual API call to get menu list
14612
14699
  const requestBody = {