From ca9ca6e29078edf8ae4f2042722b1cf92a4cb9ad Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 8 May 2018 14:45:26 +0200 Subject: [PATCH 1/6] [POST cours|td|tp] adds the default formation if exists + given formations as arguments - also it returns as output the added formation id list --- build/api/module/ue/coursController.php | 24 +++++++++++++++++++++++- build/api/module/ue/tdController.php | 25 +++++++++++++++++++++++-- build/api/module/ue/tpController.php | 23 ++++++++++++++++++++++- config/modules.json | 9 ++++++--- 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/build/api/module/ue/coursController.php b/build/api/module/ue/coursController.php index f4ecc76..198a237 100644 --- a/build/api/module/ue/coursController.php +++ b/build/api/module/ue/coursController.php @@ -25,10 +25,31 @@ class coursController{ $formations = []; extract($args); - /* Get the cours repo */ + /* Get the repos */ /** @var cours $cours_repo */ $cours_repo = Repo::getRepo('cours'); + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) Fetch default formation from UE + ---------------------------------------------------------*/ + /* (1) Try to fetch the cours' UE */ + $fetched_ue = $ue_repo->get($code); + + /* (2) Manage error */ + if( !is_array($fetched_ue) || count($fetched_ue) < 1 ) + return ['error' => new Error(Err::RepoError)]; + + $defaultForm = intval($fetched_ue[0]['idForm']); + + /* (3) Add to formation list if got a valid default formation */ + if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) ) + $formations[] = $defaultForm; + + + /* (2) Create the cours + ---------------------------------------------------------*/ /* (1) Try to create cours */ $created_id = $cours_repo->create($code, $idProf, $volume, $formations); @@ -36,6 +57,7 @@ class coursController{ if( is_null($created_id) || !is_int($created_id) ) return ['error' => new Error(Err::RepoError)]; + return ['created_id' => $created_id]; } diff --git a/build/api/module/ue/tdController.php b/build/api/module/ue/tdController.php index f617005..fb19c99 100644 --- a/build/api/module/ue/tdController.php +++ b/build/api/module/ue/tdController.php @@ -25,10 +25,31 @@ class tdController{ $formations = []; extract($args); - /* Get the td repo */ + /* Get the repos */ /** @var td $td_repo */ $td_repo = Repo::getRepo('td'); + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) Fetch default formation from UE + ---------------------------------------------------------*/ + /* (1) Try to fetch the TD' UE */ + $fetched_ue = $ue_repo->get($code); + + /* (2) Manage error */ + if( !is_array($fetched_ue) || count($fetched_ue) < 1 ) + return ['error' => new Error(Err::RepoError)]; + + $defaultForm = intval($fetched_ue[0]['idForm']); + + /* (3) Add to formation list if got a valid default formation */ + if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) ) + $formations[] = $defaultForm; + + + /* (2) Create the TD + ---------------------------------------------------------*/ /* (1) Try to create td */ $created_id = $td_repo->create($code, $idProf, $volume, $formations); @@ -36,7 +57,7 @@ class tdController{ if( is_null($created_id) || !is_int($created_id) ) return ['error' => new Error(Err::RepoError)]; - return ['created_id' => $created_id]; + return ['created_id' => $created_id, 'formations' => $formations]; } diff --git a/build/api/module/ue/tpController.php b/build/api/module/ue/tpController.php index 4fe66e1..dc36c81 100644 --- a/build/api/module/ue/tpController.php +++ b/build/api/module/ue/tpController.php @@ -25,10 +25,31 @@ class tpController{ $formations = []; extract($args); - /* Get the tp repo */ + /* Get the repos */ /** @var tp $tp_repo */ $tp_repo = Repo::getRepo('tp'); + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) Fetch default formation from UE + ---------------------------------------------------------*/ + /* (1) Try to fetch the TP' UE */ + $fetched_ue = $ue_repo->get($code); + + /* (2) Manage error */ + if( !is_array($fetched_ue) || count($fetched_ue) < 1 ) + return ['error' => new Error(Err::RepoError)]; + + $defaultForm = intval($fetched_ue[0]['idForm']); + + /* (3) Add to formation list if got a valid default formation */ + if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) ) + $formations[] = $defaultForm; + + + /* (2) Create the TP + ---------------------------------------------------------*/ /* (1) Try to create tp */ $created_id = $tp_repo->create($code, $idProf, $volume, $formations); diff --git a/config/modules.json b/config/modules.json index ec5aa3d..0596718 100644 --- a/config/modules.json +++ b/config/modules.json @@ -316,7 +316,8 @@ "formations": { "des": "List of formations (ids)", "typ": "array", "opt": true, "def": [] } }, "output": { - "created_id" : { "des": "The id of the created Cours", "typ": "id" } + "created_id" : { "des": "The id of the created Cours", "typ": "id" }, + "formations" : { "des": "The ids of the linked formations", "typ": "array" } } }, @@ -368,7 +369,8 @@ "formations": { "des": "List of formations (ids)", "typ": "array", "opt": true, "def": [] } }, "output": { - "created_id" : { "des": "The id of the created TD", "typ": "id" } + "created_id" : { "des": "The id of the created TD", "typ": "id" }, + "formations" : { "des": "The ids of the linked formations", "typ": "array" } } }, @@ -420,7 +422,8 @@ "formations": { "des": "List of formations (ids)", "typ": "array", "opt": true, "def": [] } }, "output": { - "created_id" : { "des": "The id of the created TP", "typ": "id" } + "created_id" : { "des": "The id of the created TP", "typ": "id" }, + "formations" : { "des": "The ids of the linked formations", "typ": "array" } } }, From 4e1ca634ff849618611c6a5d6f2d547f500550e6 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 8 May 2018 14:46:50 +0200 Subject: [PATCH 2/6] fixed [ue.manage] list style + added ordering basis (TODO: order algorithm) --- webpack/component/ue/manage.vue | 18 +++++++++--------- webpack/data/ue.js | 32 ++++++++++++++++++++++++++++++++ webpack/scss/container/list.scss | 13 ++++++------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/webpack/component/ue/manage.vue b/webpack/component/ue/manage.vue index 7adca42..572f910 100644 --- a/webpack/component/ue/manage.vue +++ b/webpack/component/ue/manage.vue @@ -12,9 +12,9 @@
-
enseignant
-
volume horaire
-
formations
+
enseignant
+
volume horaire
+
formations
@@ -54,9 +54,9 @@ data-anim-incoming='1' :data-anim-bounce='gstore.nav_anim.out?1:0' + :data-prof='c.idProf' :data-vol='c.volume' - :data-form='c.formations.join(`|`)' - data-typ='cm'> + :data-form='c.formations.join(`|`)'>
@@ -130,9 +130,9 @@ data-anim-incoming='1' :data-anim-bounce='gstore.nav_anim.out?1:0' + :data-prof='tp.idProf' :data-vol='tp.volume' - :data-form='tp.formations.join(`|`)' - data-typ='td'> + :data-form='tp.formations.join(`|`)'>