In my array of objects, there is a property named "modulePermissions"
inside an array of objects called "tabList"
. I have another object called "moduleName"
, which has the same value as the "modulePermissions"
name, and a boolean value has been assigned to it. Now, we need to check for the value of "modulePermissions" in the "tabList"
; if it matches with the moduleName
property name, then the boolean value of the moduleName property should be assigned to the "enableTabs" property in the "tabList".
Ts:
moduleName = {
Details: true,
"Basic Info": true,
"Captive Info": true,
"Users": true,
"Settings": true,
"Restrictions": true,
"Agents Group View": true,
"W9": true,
"EO": true,
"License": true,
"ACH": true,
"Contacts": true,
"Uploads": true,
"Notes": true,
"Tasks": true,
"History": true,
"Commissions": true
}
tabList = [
{ name: 'Details', class: 'active', active: false, href: 'basic', tabEvent: '_detailsTab', id: 1, enableTabs: false,modulePermissions:'Details' },
{ name: 'W-9', class: '', active: false, href: 'w9', tabEvent: '_w9Tab', id: 2, enableTabs: false,modulePermissions:'W9' },
{ name: 'E&O', class: '', active: false, href: 'eo', tabEvent: '_eoTab', id: 3, enableTabs: false,modulePermissions:'EO'},
{ name: 'License', class: '', active: false, href: 'license', tabEvent: '_licenseTab', id: 4, enableTabs: false,modulePermissions:'License' },
{ name: 'ACH', class: '', active: false, href: 'ach', tabEvent: '_achTab', id: 5, enableTabs: false,modulePermissions:'ACH' },
{ name: 'Contacts', class: '', active: false, href: 'contacts', tabEvent: '_contactsTab', id: 6, enableTabs: false,modulePermissions:'Contacts' },
{ name: 'Uploads', class: '', active: false, href: 'uploads', tabEvent: '_uploadTab', id: 7, enableTabs: false,modulePermissions:'Uploads' },
{ name: 'Notes', class: '', active: false, href: 'notes', tabEvent: '_notesTab', id: 8, enableTabs: false,modulePermissions:'Notes' },
{ name: 'Tasks', class: '', active: false, href: 'tasks', tabEvent: '_taskTab', id: 9, enableTabs: false,modulePermissions:'Tasks' },
{ name: 'History', class: 'link-disabled', active: false, href: 'history', tabEvent: '_historyTab', id: 10, enableTabs: false,modulePermissions: 'History'},
{ name: 'Commissions', class: '', active: false, href: 'commission', tabEvent: '_commissionTab', id: 11, enableTabs: false,modulePermissions:'Commissions' }
]
I attempted to achieve this by using the following code:
getValue(){
for (let i = 0; i < 16; i++) {
this.tabList[i]['modulePermissions'] == userPermissions.moduleName.this.tabList[i]['modulePermissions'];
this.tabList[i]['enableTabs'] = userPermissions.moduleName.this.tabList[i]['modulePermissions']
}
}