From 18ca4616b5296c1ee9b06b1d586147e1b24f68cb Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Tue, 27 Dec 2016 14:13:14 -0500 Subject: [PATCH] Added missing capabilities to User Roles screen Fixes #897 --- app/admin/roles/controller.js | 29 +++++++++++++++++++++++++++-- app/locales/en/translations.js | 6 +++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/admin/roles/controller.js b/app/admin/roles/controller.js index 5f5464a08b..9090003368 100644 --- a/app/admin/roles/controller.js +++ b/app/admin/roles/controller.js @@ -30,6 +30,7 @@ export default AbstractEditController.extend(UserRoles, UserSession, { name: 'billing', capabilities: [ 'billing', + 'addBillingDiagnosis', 'addCharge', 'addPricing', 'addPricingProfile', @@ -48,12 +49,15 @@ export default AbstractEditController.extend(UserRoles, UserSession, { capabilities: [ 'patients', 'addDiagnosis', + 'addNote', 'addPhoto', 'addPatient', 'addProcedure', + 'addSocialwork', 'addVisit', 'addVitals', 'admitPatient', + 'deleteNote', 'deletePhoto', 'deletePatient', 'deleteAppointment', @@ -103,6 +107,26 @@ export default AbstractEditController.extend(UserRoles, UserSession, { ] }], + missingCapablities: Ember.computed('availableCapabilities', 'defaultCapabilities', function() { + let availableCapabilities = this.get('availableCapabilities'); + let capabilityBySection = Object.keys(availableCapabilities); + let defaultCapabilities = Object.keys(this.get('defaultCapabilities')); + let missing = []; + defaultCapabilities.forEach((capability) => { + let capabilityUsed = false; + capabilityBySection.forEach((sectionName) => { + let section = availableCapabilities[sectionName]; + if (section.capabilities.includes(capability.camelize())) { + capabilityUsed = true; + } + }); + if (!capabilityUsed) { + missing.push(`${capability} - ${capability.camelize()}`); + } + }); + return missing; + }), + capabilitySections: Ember.computed.map('availableCapabilities', function(section) { let mappedCapabilities = []; section.capabilities.forEach((key) => { @@ -139,9 +163,10 @@ export default AbstractEditController.extend(UserRoles, UserSession, { Object.keys(defaultCapabilities).forEach((capability) => { let capabilityRoles = defaultCapabilities[capability]; if (capabilityRoles.includes(role)) { - this.set(capability, true); + console.log(`Role has capability: ${capability}`); + this.set(capability.camelize(), true); } else { - this.set(capability, false); + this.set(capability.camelize(), false); } }); } diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index a253646ee4..7c40e4ec3d 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -273,7 +273,11 @@ export default { adjustInventoryLocation: 'Adjust Inventory Location', deleteInventoryItem: 'Delete Inventory Item', fulfillInventory: 'Fulfill Inventory', - defineUserRoles: 'Define User Roles' + defineUserRoles: 'Define User Roles', + addBillingDiagnosis: 'Add Billing Diagnosis', + addNote: 'Add Note', + addSocialwork: 'Add Social Work', + deleteNote: 'Delete Note' }, messages: { roleSaved: 'The {{roleName}} role has been saved.'