cloud-ide-core 2.0.119 → 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.
|
@@ -13171,12 +13171,17 @@ class CideCoreUserCreateComponent {
|
|
|
13171
13171
|
// Update entity mappings FormArray
|
|
13172
13172
|
const entityMappingFormArray = this.entityMappingsFormArray;
|
|
13173
13173
|
entityMappingFormArray.clear();
|
|
13174
|
-
data.core_entity_mapping.forEach((mapping) => {
|
|
13174
|
+
data.core_entity_mapping.forEach((mapping, index) => {
|
|
13175
13175
|
const mappingGroup = this.createEntityMappingFormGroup();
|
|
13176
13176
|
let core_entity_mapping = {};
|
|
13177
|
+
// Extract entity ID as string (handle both object and string formats)
|
|
13178
|
+
const entityIdValue = mapping?.syenm_entity_id_syen;
|
|
13179
|
+
const entityIdString = typeof entityIdValue === 'string'
|
|
13180
|
+
? entityIdValue
|
|
13181
|
+
: (entityIdValue?._id || '');
|
|
13177
13182
|
core_entity_mapping = {
|
|
13178
13183
|
...mapping,
|
|
13179
|
-
syenm_entity_id_syen:
|
|
13184
|
+
syenm_entity_id_syen: entityIdString,
|
|
13180
13185
|
syenm_designation_id_sydsg: mapping?.syenm_designation_id_sydsg?._id,
|
|
13181
13186
|
syenm_role_id_syusrol: mapping?.syenm_role_id_syusrol?._id,
|
|
13182
13187
|
syenm_department_id_sydept: mapping?.syenm_department_id_sydept?._id
|
|
@@ -13184,16 +13189,29 @@ class CideCoreUserCreateComponent {
|
|
|
13184
13189
|
mappingGroup.patchValue(core_entity_mapping);
|
|
13185
13190
|
mappingGroup.get('syenm_entity_id_syen')?.disable();
|
|
13186
13191
|
entityMappingFormArray.push(mappingGroup);
|
|
13192
|
+
// Load roles for this entity after form is patched
|
|
13193
|
+
if (entityIdString) {
|
|
13194
|
+
console.log(`🎭 Loading roles for entity ${entityIdString} in mapping ${index} after form patch`);
|
|
13195
|
+
this.loadRolesForEntity(index, entityIdString);
|
|
13196
|
+
}
|
|
13187
13197
|
});
|
|
13188
|
-
// 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
|
|
13189
13199
|
data.core_entity_mapping.forEach((mapping, index) => {
|
|
13190
|
-
if (mapping.syenm_role_id_syusrol) {
|
|
13200
|
+
if (mapping.syenm_role_id_syusrol && mapping.syenm_entity_id_syen) {
|
|
13191
13201
|
const roleId = typeof mapping.syenm_role_id_syusrol === 'object'
|
|
13192
13202
|
? mapping.syenm_role_id_syusrol._id
|
|
13193
13203
|
: mapping.syenm_role_id_syusrol;
|
|
13194
|
-
|
|
13195
|
-
|
|
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}`);
|
|
13196
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);
|
|
13197
13215
|
}
|
|
13198
13216
|
}
|
|
13199
13217
|
});
|
|
@@ -13479,19 +13497,42 @@ class CideCoreUserCreateComponent {
|
|
|
13479
13497
|
});
|
|
13480
13498
|
}
|
|
13481
13499
|
getRoleOptionsForEntity(mappingIndex) {
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13500
|
+
// First try to get entity ID from form control (most reliable)
|
|
13501
|
+
const mappingFormGroup = this.entityMappingsFormArray.at(mappingIndex);
|
|
13502
|
+
let entityId = undefined;
|
|
13503
|
+
if (mappingFormGroup) {
|
|
13504
|
+
const entityIdValue = mappingFormGroup.get('syenm_entity_id_syen')?.value;
|
|
13505
|
+
if (entityIdValue) {
|
|
13506
|
+
// Handle both string and object formats
|
|
13507
|
+
entityId = typeof entityIdValue === 'string'
|
|
13508
|
+
? entityIdValue
|
|
13509
|
+
: (entityIdValue._id || undefined);
|
|
13510
|
+
}
|
|
13511
|
+
}
|
|
13512
|
+
// Fallback: try to get from entity mappings signal
|
|
13513
|
+
if (!entityId) {
|
|
13514
|
+
const mapping = this.entityMappings()[mappingIndex];
|
|
13515
|
+
if (mapping?.syenm_entity_id_syen) {
|
|
13516
|
+
const entityValue = mapping.syenm_entity_id_syen;
|
|
13517
|
+
// Handle both string and object formats
|
|
13518
|
+
entityId = typeof entityValue === 'string'
|
|
13519
|
+
? entityValue
|
|
13520
|
+
: (entityValue._id || undefined);
|
|
13521
|
+
}
|
|
13522
|
+
}
|
|
13523
|
+
if (!entityId) {
|
|
13524
|
+
console.log(`🎭 getRoleOptionsForEntity: No entity ID found for mapping ${mappingIndex}`);
|
|
13485
13525
|
return [];
|
|
13486
13526
|
}
|
|
13487
|
-
|
|
13488
|
-
console.log(`🎭 roles:`, this.roleOptions());
|
|
13527
|
+
console.log(`🎭 getRoleOptionsForEntity for entity ${entityId}:`, this.roleOptions());
|
|
13489
13528
|
const roles = this.roleOptions()[entityId];
|
|
13490
|
-
|
|
13491
|
-
|
|
13529
|
+
// If roles are not loaded yet, trigger loading
|
|
13530
|
+
if (!roles && entityId) {
|
|
13531
|
+
console.log(`🎭 Roles not cached for entity ${entityId}, loading...`);
|
|
13532
|
+
this.loadRolesForEntity(mappingIndex, entityId);
|
|
13533
|
+
return []; // Return empty while loading
|
|
13492
13534
|
}
|
|
13493
|
-
|
|
13494
|
-
return [];
|
|
13535
|
+
return roles || [];
|
|
13495
13536
|
}
|
|
13496
13537
|
/**
|
|
13497
13538
|
* Get filtered entity options with disabled state for already selected entities in other mappings
|
|
@@ -13824,22 +13865,61 @@ class CideCoreUserCreateComponent {
|
|
|
13824
13865
|
console.log(`🎭 Role changed for mapping ${mappingIndex}:`, role);
|
|
13825
13866
|
if (!role) {
|
|
13826
13867
|
this.clearRolePermissions();
|
|
13868
|
+
this.clearRoleForMapping(mappingIndex);
|
|
13827
13869
|
return;
|
|
13828
13870
|
}
|
|
13871
|
+
const roleId = role?._id || '';
|
|
13829
13872
|
this.selectedEntityIndex.set(mappingIndex);
|
|
13830
|
-
this.selectedRoleId.set(
|
|
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
|
+
});
|
|
13831
13888
|
// Load role details and permissions
|
|
13832
|
-
this.loadRolePermissions(
|
|
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
|
+
}
|
|
13833
13911
|
// Automatically load menu rights when both entity and role are selected
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
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}`);
|
|
13837
13914
|
this.loadMenuRights(mappingIndex);
|
|
13838
13915
|
// Force refresh the grid to show updated permission states
|
|
13839
13916
|
setTimeout(() => {
|
|
13840
13917
|
this.cdr.detectChanges();
|
|
13841
13918
|
}, 100);
|
|
13842
13919
|
}
|
|
13920
|
+
else {
|
|
13921
|
+
console.warn(`⚠️ Cannot load menu rights: entity=${entityId}, role=${roleId}`);
|
|
13922
|
+
}
|
|
13843
13923
|
}
|
|
13844
13924
|
/**
|
|
13845
13925
|
* Load role permissions from API
|
|
@@ -14568,12 +14648,52 @@ class CideCoreUserCreateComponent {
|
|
|
14568
14648
|
return menuRights[mappingIndex.toString()] || [];
|
|
14569
14649
|
}
|
|
14570
14650
|
loadMenuRights(mappingIndex) {
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
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
|
+
});
|
|
14574
14694
|
return;
|
|
14575
14695
|
}
|
|
14576
|
-
console.log('🚀 Loading menu rights for mapping:', mappingIndex);
|
|
14696
|
+
console.log('🚀 Loading menu rights for mapping:', mappingIndex, 'Entity:', entityId, 'Role:', roleId);
|
|
14577
14697
|
this.loading.set(true);
|
|
14578
14698
|
// Use actual API call to get menu list
|
|
14579
14699
|
const requestBody = {
|