From 843251449f5e061b0c80ea7e158409e786b7e67b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 13 Mar 2018 23:52:09 +0100 Subject: [PATCH] [repo.ue] fixed get(code), get(null) already worked | [webpack.ue.view] fixed 'form_by_id' that is now declared before fetching UEs --- build/database/repo/ue.php | 4 +-- webpack/component/ue/view.vue | 2 +- webpack/data/ue.js | 50 ++++++++++++++++++++--------------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/build/database/repo/ue.php b/build/database/repo/ue.php index 060e65a..86cd956 100644 --- a/build/database/repo/ue.php +++ b/build/database/repo/ue.php @@ -174,7 +174,7 @@ class ue extends Repo_i { public function get(?String $code=null) : array{ /* (1) Manage if no id given */ - $cond = is_null($code) ? '' : 'AND `ue.`code` = :code'; + $cond = is_null($code) ? '' : 'HAVING `ue`.`code` = :code'; $parm = is_null($code) ? [] : [':code' => $code]; /* (2) Prepare Statement */ @@ -206,8 +206,8 @@ class ue extends Repo_i { OR TP2.Formation_idFormation = Formation.idFormation GROUP BY `ue2`.`code` ) formlist ON formlist.code = ue.code - ##$cond GROUP BY `ue`.`code` + $cond ORDER BY `ue`.`label` ASC"); /* (3) Bind params and execute statement */ diff --git a/webpack/component/ue/view.vue b/webpack/component/ue/view.vue index 3d0c66b..a4e1d4e 100644 --- a/webpack/component/ue/view.vue +++ b/webpack/component/ue/view.vue @@ -76,7 +76,7 @@
{{ ue.required ? 'UE obligatoire' : 'UE optionnelle' }}
{{ ue.volumeCours + ue.volumeTD + ue.volumeTP }}h totales
- {{ gstore.form_by_id(form_id).labelForm }} + {{ gstore.form_by_id(form_id).labelForm || '???' }} M2 INFO (S1) LPRO
diff --git a/webpack/data/ue.js b/webpack/data/ue.js index 4af039a..d364a1c 100644 --- a/webpack/data/ue.js +++ b/webpack/data/ue.js @@ -1,23 +1,4 @@ -/* (1) Load ues ----------------------------------------------------------*/ -/* (1) Initialize list */ -gstore.add('ues', []); - -/* (2) Get ues */ -api.call('GET ue/', { vh: true }, function(rs){ - - // {1} If error -> abort // - if( rs.error !== 0 )return console.log('No UE found, error: '+rs.error); - console.log(rs); - - // {2} Store ues // - gstore.get.ues = rs.ues; - -}); - - - -/* (2) Load formations +/* (1) Load formations ---------------------------------------------------------*/ /* (1) Initialize list */ gstore.add('formations', []); @@ -40,14 +21,14 @@ gstore.add('form_by_id', function(form_id){ /* (1) Abort if wrong form_id */ if( form_id == null ) - return null; + return { idForm: null, labelForm: null }; /* (2.1) Find index in gstore */ var gi = gstore.get.formations.map( (data, i) => { return ( data.idForm && data.idForm == form_id ) ? i : ''; }).join(''); /* (2.2) Exit if not found */ if( isNaN(gi) ) - return null; + return { idForm: null, labelForm: null }; return gstore.get.formations[gi]; @@ -56,6 +37,31 @@ gstore.add('form_by_id', function(form_id){ + +/* (2) Load ues +---------------------------------------------------------*/ +/* (1) Initialize list */ +gstore.add('ues', []); + +/* (2) Get ues */ +api.call('GET ue/', { vh: true }, function(rs){ + + // {1} If error -> abort // + if( rs.error !== 0 )return console.log('No UE found, error: '+rs.error); + console.log(rs); + + // {2} Store ues // + gstore.get.ues = rs.ues; + +}); + + + + + + + + /* (2) Manage Instant Search (IS) ---------------------------------------------------------*/ /* (1) Define global timeout index */