Loading module/Oscar/src/Oscar/Controller/AdministrationController.php +5 −0 Original line number Diff line number Diff line Loading @@ -1047,6 +1047,11 @@ class AdministrationController extends AbstractOscarController implements UsePro $roleData = json_decode($request->getPost('role'), true); $roleRepository->updateRole($roleData); break; case 'delrole': $this->getLoggerService()->error("Delette role..."); $roleId = json_decode($request->getPost('roleid'), true); $roleRepository->deleteRole($roleId); break; default: throw new OscarException("Action inconnue"); } Loading module/Oscar/src/Oscar/Entity/RoleRepository.php +11 −0 Original line number Diff line number Diff line Loading @@ -468,4 +468,15 @@ class RoleRepository extends EntityRepository $this->getEntityManager()->flush(); } public function deleteRole(int $roleId): void { $role = $this->find($roleId); if( $role->getRoleId() === "Administrateur" || $role->getRoleId() === "Utilisateur") { throw new OscarException(_("les rôles Administrateurs et Utilisateur ne peuvent pas être supprimés")); } $this->getEntityManager()->remove($role); $this->getEntityManager()->flush(); } } ui/src/utils/AxiosOscar.js +11 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,17 @@ export default { return response; }, patch: (url, params = {}, options = {}) => { pendingOn(options); let response = axios.patch(url, params); response.catch((error) => { GlobalModel.commit('addError', AxiosMessage.manageErrorResponse(error).message); }).finally(() => { pendingOff(options); }); return response; }, put: (url, params = {}, options = {}) => { pendingOn(options); let response = axios.put(url, params); Loading ui/src/views/AdminGestionPrivileges.vue +40 −3 Original line number Diff line number Diff line Loading @@ -56,6 +56,11 @@ :visible="confirmCopy" @modal-valid="handlerConfirmCopy" @modal-cancel="confirmCopy = null" /> <modal :title="deletedRoleMsg" message="Êtes-vous sûr ?" :visible="deletedRole" @modal-valid="handlerRoleDeleteConfirm" @modal-cancel="deletedRole = null" /> <h1><i class="icon-calculator"></i>Privileges</h1> <nav> <button class="btn btn-default" @click="showRoles = !showRoles"> Loading Loading @@ -171,8 +176,13 @@ </section> </div> <div class="col-md-3" v-if="showRoles"> <h2>Rôles</h2> {{ selectedSpot }} <h2> Rôles <button class="btn btn-primary" @click="handlerRoleNew"> Nouveau rôle </button> </h2> <article v-for="role in roles" :key="role.id" class="card role" :class="{ 'principal':role.principal, Loading @@ -189,7 +199,7 @@ <a href="#" @click="handlerEditRole(role)"> <i class="icon-pencil"></i> </a> <a href="#" @click="handlerDeleteRole"> <a href="#" @click="handlerRoleDelete(role)"> <i class="icon-trash"></i> </a> </nav> Loading Loading @@ -386,6 +396,33 @@ export default { } }, handlerRoleDelete(role){ this.deletedRole = role; }, handlerRoleDeleteConfirm(){ let data = new FormData(); data.append('roleid', this.deletedRole.id); data.append('action', "delrole"); AxiosOscar.post(this.url, data).then( ok => { this.deletedRole = null; this.fetch(); }, ko => { console.log(ko); }) }, handlerRoleNew(){ this.editedRole = { id: null, roleId: "", ldapFilter: "", description: "", principal: false, spot: 0 } }, //////////////////////////////////////////////////////////////// // // OPERATIONS REST Loading Loading
module/Oscar/src/Oscar/Controller/AdministrationController.php +5 −0 Original line number Diff line number Diff line Loading @@ -1047,6 +1047,11 @@ class AdministrationController extends AbstractOscarController implements UsePro $roleData = json_decode($request->getPost('role'), true); $roleRepository->updateRole($roleData); break; case 'delrole': $this->getLoggerService()->error("Delette role..."); $roleId = json_decode($request->getPost('roleid'), true); $roleRepository->deleteRole($roleId); break; default: throw new OscarException("Action inconnue"); } Loading
module/Oscar/src/Oscar/Entity/RoleRepository.php +11 −0 Original line number Diff line number Diff line Loading @@ -468,4 +468,15 @@ class RoleRepository extends EntityRepository $this->getEntityManager()->flush(); } public function deleteRole(int $roleId): void { $role = $this->find($roleId); if( $role->getRoleId() === "Administrateur" || $role->getRoleId() === "Utilisateur") { throw new OscarException(_("les rôles Administrateurs et Utilisateur ne peuvent pas être supprimés")); } $this->getEntityManager()->remove($role); $this->getEntityManager()->flush(); } }
ui/src/utils/AxiosOscar.js +11 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,17 @@ export default { return response; }, patch: (url, params = {}, options = {}) => { pendingOn(options); let response = axios.patch(url, params); response.catch((error) => { GlobalModel.commit('addError', AxiosMessage.manageErrorResponse(error).message); }).finally(() => { pendingOff(options); }); return response; }, put: (url, params = {}, options = {}) => { pendingOn(options); let response = axios.put(url, params); Loading
ui/src/views/AdminGestionPrivileges.vue +40 −3 Original line number Diff line number Diff line Loading @@ -56,6 +56,11 @@ :visible="confirmCopy" @modal-valid="handlerConfirmCopy" @modal-cancel="confirmCopy = null" /> <modal :title="deletedRoleMsg" message="Êtes-vous sûr ?" :visible="deletedRole" @modal-valid="handlerRoleDeleteConfirm" @modal-cancel="deletedRole = null" /> <h1><i class="icon-calculator"></i>Privileges</h1> <nav> <button class="btn btn-default" @click="showRoles = !showRoles"> Loading Loading @@ -171,8 +176,13 @@ </section> </div> <div class="col-md-3" v-if="showRoles"> <h2>Rôles</h2> {{ selectedSpot }} <h2> Rôles <button class="btn btn-primary" @click="handlerRoleNew"> Nouveau rôle </button> </h2> <article v-for="role in roles" :key="role.id" class="card role" :class="{ 'principal':role.principal, Loading @@ -189,7 +199,7 @@ <a href="#" @click="handlerEditRole(role)"> <i class="icon-pencil"></i> </a> <a href="#" @click="handlerDeleteRole"> <a href="#" @click="handlerRoleDelete(role)"> <i class="icon-trash"></i> </a> </nav> Loading Loading @@ -386,6 +396,33 @@ export default { } }, handlerRoleDelete(role){ this.deletedRole = role; }, handlerRoleDeleteConfirm(){ let data = new FormData(); data.append('roleid', this.deletedRole.id); data.append('action', "delrole"); AxiosOscar.post(this.url, data).then( ok => { this.deletedRole = null; this.fetch(); }, ko => { console.log(ko); }) }, handlerRoleNew(){ this.editedRole = { id: null, roleId: "", ldapFilter: "", description: "", principal: false, spot: 0 } }, //////////////////////////////////////////////////////////////// // // OPERATIONS REST Loading