Loading module/Oscar/src/Oscar/Controller/ActivityMotsClesController.php +32 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Laminas\View\Model\JsonModel; use Oscar\Entity\ActivityMotCle; use Oscar\Provider\Privileges; use Oscar\Service\ProjectGrantService; use Oscar\Service\ProjectService; use Oscar\Traits\UseLoggerService; use Oscar\Traits\UseLoggerServiceTrait; use Throwable; Loading @@ -31,6 +32,22 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL $this->activityService = $activityService; } /** * @return ProjectService */ public function getProjectService(): ProjectService { return $this->projectService; } /** * @param ProjectService $projectService */ public function setProjectService(ProjectService $projectService): void { $this->projectService = $projectService; } public function apiAction() { try { Loading @@ -40,19 +57,24 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL if ($activityId) { $activity = $this->getActivityService()->getGrant($activityId); } $project = NULL; $projectId = $this->params()->fromQuery('project_id'); if ($projectId) { $project = $this->getProjectService()->getProject($projectId); } if ($this->getRequest()->getMethod() == "GET") { $includeActivityCountQueryParam = $this->params()->fromQuery('include_activity_count'); $includeActivityCount = $includeActivityCountQueryParam && $includeActivityCountQueryParam === "true"; return $this->getMotsCles($includeActivityCount, $activity); return $this->getMotsCles($includeActivityCount, $activity, $project); } if ($this->getRequest()->getMethod() == "POST") { $action_mot_cle_json = json_decode($this->getRequest()->getContent()); if ($action_mot_cle_json->action == "create") { return $this->createMotCle($action_mot_cle_json, $activity); return $this->createMotCle($action_mot_cle_json, $activity, $project); } if ($action_mot_cle_json->action == "delete") { Loading Loading @@ -81,9 +103,11 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL } } private function getMotsCles($includeCount, $activity) { private function getMotsCles($includeCount, $activity, $project) { if ($activity) { if ($project) { $this->getOscarUserContextService()->check(Privileges::PROJECT_ACTIVITY_ADD, $project); } else if ($activity) { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_EDIT, $activity); } else { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_CREATE); Loading Loading @@ -117,9 +141,11 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL return $response; } private function createMotCle($action_mot_cle_json, $activity) { private function createMotCle($action_mot_cle_json, $activity, $project) { if ($activity) { if ($project) { $this->getOscarUserContextService()->check(Privileges::PROJECT_ACTIVITY_ADD, $project); } else if ($activity) { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_EDIT, $activity); } else { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_CREATE); Loading module/Oscar/src/Oscar/Controller/ActivityMotsClesControllerFactory.php +2 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Oscar\Service\OscarUserContext; use Oscar\Service\ProjectGrantService; use Oscar\Service\ProjectService; class ActivityMotsClesControllerFactory implements FactoryInterface { Loading @@ -17,6 +18,7 @@ class ActivityMotsClesControllerFactory implements FactoryInterface $c->setOscarUserContextService($container->get(OscarUserContext::class)); $c->setLoggerService($container->get('Logger')); $c->setActivityService($container->get(ProjectGrantService::class)); $c->setProjectService($container->get(ProjectService::class)); return $c; } } module/Oscar/view/oscar/project-grant/form.phtml +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ use Oscar\OscarText; <div id="activity-mots-cles" data-url="<?= $this->url('activity-mots-cles/api') ?>" data-activityid="<?= $activity->getId() ?>" data-projectid="<?= $project ? $project->getId() : "" ?>" data-motsclesselectionnes="<?php echo '['; $count = count($activity->getMotscles()); Loading ui/src/ActivityMotsCles.js +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ let elemDatas = document.querySelector(elemId); const app = createApp(ActivityMotsCles, { "url": elemDatas.dataset.url, "activityid": elemDatas.dataset.activityid, "projectid": elemDatas.dataset.projectid, "motsclesselectionnes": elemDatas.dataset.motsclesselectionnes }); Loading ui/src/views/ActivityMotsCles.vue +3 −2 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ export default { props: { url: {default: null}, activityid: {default: null}, projectid: {default: null}, motsclesselectionnes: {default: []}, }, Loading Loading @@ -114,7 +115,7 @@ export default { this.affichertouslesmotscles = false; this.loading = "Création du mot clé"; axios.post(this.url + '?activity_id=' + this.activityid, { action: "create", label: this.userInput.trim() }).then( axios.post(this.url + '?activity_id=' + this.activityid + '&project_id=' + this.projectid, { action: "create", label: this.userInput.trim() }).then( (ok) => { let nouveauMotCle = ok.data; nouveauMotCle.selected = true; Loading Loading @@ -154,7 +155,7 @@ export default { fetch() { this.loading = "Chargement des mots clés"; axios.get(this.url + '?activity_id=' + this.activityid).then(ok => { axios.get(this.url + '?activity_id=' + this.activityid + '&project_id=' + this.projectid).then(ok => { this.touslesmotscles = ok.data.motscles; const dejaSelectionnes = JSON.parse(this.motsclesselectionnes); for (let unMotCle of this.touslesmotscles) { Loading Loading
module/Oscar/src/Oscar/Controller/ActivityMotsClesController.php +32 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Laminas\View\Model\JsonModel; use Oscar\Entity\ActivityMotCle; use Oscar\Provider\Privileges; use Oscar\Service\ProjectGrantService; use Oscar\Service\ProjectService; use Oscar\Traits\UseLoggerService; use Oscar\Traits\UseLoggerServiceTrait; use Throwable; Loading @@ -31,6 +32,22 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL $this->activityService = $activityService; } /** * @return ProjectService */ public function getProjectService(): ProjectService { return $this->projectService; } /** * @param ProjectService $projectService */ public function setProjectService(ProjectService $projectService): void { $this->projectService = $projectService; } public function apiAction() { try { Loading @@ -40,19 +57,24 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL if ($activityId) { $activity = $this->getActivityService()->getGrant($activityId); } $project = NULL; $projectId = $this->params()->fromQuery('project_id'); if ($projectId) { $project = $this->getProjectService()->getProject($projectId); } if ($this->getRequest()->getMethod() == "GET") { $includeActivityCountQueryParam = $this->params()->fromQuery('include_activity_count'); $includeActivityCount = $includeActivityCountQueryParam && $includeActivityCountQueryParam === "true"; return $this->getMotsCles($includeActivityCount, $activity); return $this->getMotsCles($includeActivityCount, $activity, $project); } if ($this->getRequest()->getMethod() == "POST") { $action_mot_cle_json = json_decode($this->getRequest()->getContent()); if ($action_mot_cle_json->action == "create") { return $this->createMotCle($action_mot_cle_json, $activity); return $this->createMotCle($action_mot_cle_json, $activity, $project); } if ($action_mot_cle_json->action == "delete") { Loading Loading @@ -81,9 +103,11 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL } } private function getMotsCles($includeCount, $activity) { private function getMotsCles($includeCount, $activity, $project) { if ($activity) { if ($project) { $this->getOscarUserContextService()->check(Privileges::PROJECT_ACTIVITY_ADD, $project); } else if ($activity) { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_EDIT, $activity); } else { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_CREATE); Loading Loading @@ -117,9 +141,11 @@ class ActivityMotsClesController extends AbstractOscarController implements UseL return $response; } private function createMotCle($action_mot_cle_json, $activity) { private function createMotCle($action_mot_cle_json, $activity, $project) { if ($activity) { if ($project) { $this->getOscarUserContextService()->check(Privileges::PROJECT_ACTIVITY_ADD, $project); } else if ($activity) { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_EDIT, $activity); } else { $this->getOscarUserContextService()->check(Privileges::ACTIVITY_CREATE); Loading
module/Oscar/src/Oscar/Controller/ActivityMotsClesControllerFactory.php +2 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Oscar\Service\OscarUserContext; use Oscar\Service\ProjectGrantService; use Oscar\Service\ProjectService; class ActivityMotsClesControllerFactory implements FactoryInterface { Loading @@ -17,6 +18,7 @@ class ActivityMotsClesControllerFactory implements FactoryInterface $c->setOscarUserContextService($container->get(OscarUserContext::class)); $c->setLoggerService($container->get('Logger')); $c->setActivityService($container->get(ProjectGrantService::class)); $c->setProjectService($container->get(ProjectService::class)); return $c; } }
module/Oscar/view/oscar/project-grant/form.phtml +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ use Oscar\OscarText; <div id="activity-mots-cles" data-url="<?= $this->url('activity-mots-cles/api') ?>" data-activityid="<?= $activity->getId() ?>" data-projectid="<?= $project ? $project->getId() : "" ?>" data-motsclesselectionnes="<?php echo '['; $count = count($activity->getMotscles()); Loading
ui/src/ActivityMotsCles.js +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ let elemDatas = document.querySelector(elemId); const app = createApp(ActivityMotsCles, { "url": elemDatas.dataset.url, "activityid": elemDatas.dataset.activityid, "projectid": elemDatas.dataset.projectid, "motsclesselectionnes": elemDatas.dataset.motsclesselectionnes }); Loading
ui/src/views/ActivityMotsCles.vue +3 −2 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ export default { props: { url: {default: null}, activityid: {default: null}, projectid: {default: null}, motsclesselectionnes: {default: []}, }, Loading Loading @@ -114,7 +115,7 @@ export default { this.affichertouslesmotscles = false; this.loading = "Création du mot clé"; axios.post(this.url + '?activity_id=' + this.activityid, { action: "create", label: this.userInput.trim() }).then( axios.post(this.url + '?activity_id=' + this.activityid + '&project_id=' + this.projectid, { action: "create", label: this.userInput.trim() }).then( (ok) => { let nouveauMotCle = ok.data; nouveauMotCle.selected = true; Loading Loading @@ -154,7 +155,7 @@ export default { fetch() { this.loading = "Chargement des mots clés"; axios.get(this.url + '?activity_id=' + this.activityid).then(ok => { axios.get(this.url + '?activity_id=' + this.activityid + '&project_id=' + this.projectid).then(ok => { this.touslesmotscles = ok.data.motscles; const dejaSelectionnes = JSON.parse(this.motsclesselectionnes); for (let unMotCle of this.touslesmotscles) { Loading