Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Added missing capabilities to User Roles screen
Browse files Browse the repository at this point in the history
Fixes #897
  • Loading branch information
jkleinsc committed Dec 27, 2016
1 parent 4db8c13 commit 18ca461
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
29 changes: 27 additions & 2 deletions app/admin/roles/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default AbstractEditController.extend(UserRoles, UserSession, {
name: 'billing',
capabilities: [
'billing',
'addBillingDiagnosis',
'addCharge',
'addPricing',
'addPricingProfile',
Expand All @@ -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',
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
}
});
}
Expand Down
6 changes: 5 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down

0 comments on commit 18ca461

Please sign in to comment.