Merge branch 'master' into verions-new

This commit is contained in:
xdrm-brackets 2018-05-09 11:44:02 +02:00
commit 63fdcc012d
8 changed files with 156 additions and 28 deletions

View File

@ -25,10 +25,31 @@ class coursController{
$formations = []; $formations = [];
extract($args); extract($args);
/* Get the cours repo */ /* Get the repos */
/** @var cours $cours_repo */ /** @var cours $cours_repo */
$cours_repo = Repo::getRepo('cours'); $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 */ /* (1) Try to create cours */
$created_id = $cours_repo->create($code, $idProf, $volume, $formations); $created_id = $cours_repo->create($code, $idProf, $volume, $formations);
@ -36,7 +57,7 @@ class coursController{
if( is_null($created_id) || !is_int($created_id) ) if( is_null($created_id) || !is_int($created_id) )
return ['error' => new Error(Err::RepoError)]; return ['error' => new Error(Err::RepoError)];
return ['created_id' => $created_id]; return ['created_id' => $created_id, 'formations' => $formations];
} }

View File

@ -25,10 +25,31 @@ class tdController{
$formations = []; $formations = [];
extract($args); extract($args);
/* Get the td repo */ /* Get the repos */
/** @var td $td_repo */ /** @var td $td_repo */
$td_repo = Repo::getRepo('td'); $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 */ /* (1) Try to create td */
$created_id = $td_repo->create($code, $idProf, $volume, $formations); $created_id = $td_repo->create($code, $idProf, $volume, $formations);
@ -36,7 +57,7 @@ class tdController{
if( is_null($created_id) || !is_int($created_id) ) if( is_null($created_id) || !is_int($created_id) )
return ['error' => new Error(Err::RepoError)]; return ['error' => new Error(Err::RepoError)];
return ['created_id' => $created_id]; return ['created_id' => $created_id, 'formations' => $formations];
} }

View File

@ -25,10 +25,31 @@ class tpController{
$formations = []; $formations = [];
extract($args); extract($args);
/* Get the tp repo */ /* Get the repos */
/** @var tp $tp_repo */ /** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp'); $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 */ /* (1) Try to create tp */
$created_id = $tp_repo->create($code, $idProf, $volume, $formations); $created_id = $tp_repo->create($code, $idProf, $volume, $formations);
@ -36,7 +57,7 @@ class tpController{
if( is_null($created_id) || !is_int($created_id) ) if( is_null($created_id) || !is_int($created_id) )
return ['error' => new Error(Err::RepoError)]; return ['error' => new Error(Err::RepoError)];
return ['created_id' => $created_id]; return ['created_id' => $created_id, 'formations' => $formations];
} }

View File

@ -321,7 +321,7 @@ class professor extends Repo_i {
$parm = is_null($prof_id) ? [] : [':id' => $prof_id]; $parm = is_null($prof_id) ? [] : [':id' => $prof_id];
/* (2) Prepare Statement */ /* (2) Prepare Statement */
$st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY abreviation ASC"); $st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY firstName, lastName ASC");
/* (3) Bind params and execute statement */ /* (3) Bind params and execute statement */
if( is_bool($st) ) return []; if( is_bool($st) ) return [];
@ -433,7 +433,8 @@ class professor extends Repo_i {
AND VHTp.idProf = Prof.idProfesseur AND VHTp.idProf = Prof.idProfesseur
AND VHTd.idProf = Prof.idProfesseur AND VHTd.idProf = Prof.idProfesseur
GROUP BY GROUP BY
Prof.idProfesseur;"); Prof.idProfesseur
ORDER BY Prof.firstName, Prof.lastName ASC;");
/* (3) Bind params and execute statement */ /* (3) Bind params and execute statement */
if( is_bool($st) ) return []; if( is_bool($st) ) return [];

View File

@ -331,7 +331,8 @@
"formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] } "formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] }
}, },
"output": { "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<id>" }
} }
}, },
@ -383,7 +384,8 @@
"formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] } "formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] }
}, },
"output": { "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<id>" }
} }
}, },
@ -435,7 +437,8 @@
"formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] } "formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] }
}, },
"output": { "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<id>" }
} }
}, },

View File

@ -12,9 +12,9 @@
<!-- FILTERS --> <!-- FILTERS -->
<section class='filter'> <section class='filter'>
<div style='flex-basis: 3.2em'></div> <div style='flex-basis: 3.2em'></div>
<div data-filter='1'>enseignant <span class='arrow' data-way='down'></span></div> <div :data-filter='gstore.order.current===0?1:0' @click='gstore.order_toggle(0)'>enseignant <span class='arrow' :data-way='gstore.order.way'></span></div>
<div data-filter='0'>volume horaire <span class='arrow' data-way='down'></span></div> <div :data-filter='gstore.order.current===1?1:0' @click='gstore.order_toggle(1)'>volume horaire <span class='arrow' :data-way='gstore.order.way'></span></div>
<div data-filter='0'>formations <span class='arrow' data-way='down'></span></div> <div :data-filter='gstore.order.current===2?1:0' @click='gstore.order_toggle(2)'>formations <span class='arrow' :data-way='gstore.order.way'></span></div>
</section> </section>
@ -54,9 +54,9 @@
data-anim-incoming='1' data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0' :data-anim-bounce='gstore.nav_anim.out?1:0'
:data-prof='c.idProf'
:data-vol='c.volume' :data-vol='c.volume'
:data-form='c.formations.join(`|`)' :data-form='c.formations.join(`|`)'>
data-typ='cm'>
<div class='icon remove' @click='gstore.rem(0, i)'></div> <div class='icon remove' @click='gstore.rem(0, i)'></div>
<select v-model='c.new_prof' @change='gstore.upd_prof(0, i)'> <select v-model='c.new_prof' @change='gstore.upd_prof(0, i)'>
@ -92,9 +92,9 @@
data-anim-incoming='1' data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0' :data-anim-bounce='gstore.nav_anim.out?1:0'
:data-prof='td.idProf'
:data-vol='td.volume' :data-vol='td.volume'
:data-form='td.formations.join(`|`)' :data-form='td.formations.join(`|`)'>
data-typ='td'>
<div class='icon remove' @click='gstore.rem(1, i)'></div> <div class='icon remove' @click='gstore.rem(1, i)'></div>
<select v-model='td.new_prof' @change='gstore.upd_prof(1, i)'> <select v-model='td.new_prof' @change='gstore.upd_prof(1, i)'>
@ -130,9 +130,9 @@
data-anim-incoming='1' data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0' :data-anim-bounce='gstore.nav_anim.out?1:0'
:data-prof='tp.idProf'
:data-vol='tp.volume' :data-vol='tp.volume'
:data-form='tp.formations.join(`|`)' :data-form='tp.formations.join(`|`)'>
data-typ='td'>
<div class='icon remove' @click='gstore.rem(2, i)'></div> <div class='icon remove' @click='gstore.rem(2, i)'></div>
<select v-model='tp.new_prof' @change='gstore.upd_prof(2, i)'> <select v-model='tp.new_prof' @change='gstore.upd_prof(2, i)'>

View File

@ -1078,6 +1078,66 @@ gstore.add('upd_prof', function(type, res_i){
}); });
});
/* (4) Ordering filters */
gstore.add('order', {
available: ['prof', 'volume', 'forms'],
current: 0,
way: 1 // 1 ASC, -1 DESC
});
gstore.add('order_toggle', function(ord_i){
// 1. Check params types
if( isNaN(ord_i) || gstore.get.order.available[ord_i] == null )
return;
// 2. If new ordering field -> toggle it
if( ord_i !== gstore.get.order.current )
gstore.get.order.current = ord_i;
// 3. If already selected -> toggle way
else
gstore.get.order.way *= -1;
// 4. Get all elements to order
let els = document.querySelectorAll('section[data-prof][data-vol][data-form]');
// 5. Ordering by formations
if( gstore.get.order.current === 2 ){
return els.forEach((el) => {
el.style.order = el.getAttribute('data-form').split('|').length * gstore.get.order.way
});
}
// 6. Ordering by 'volume'
if( gstore.get.order.current === 1 )
return els.forEach((el) => {
el.style.order = parseInt( el.getAttribute('data-vol') ) * gstore.get.order.way
});
// 7. Ordering by 'prof'
els.forEach((el) => {
var profId = parseInt( el.getAttribute('data-prof') );
// outside by default if no prof set
el.style.order = - gstore.get.order.way;
// professors are already sorted
for( pi in gstore.get.manage.prof ) {
if( gstore.get.manage.prof[pi].idProfesseur == profId ){
el.style.order = pi * gstore.get.order.way;
break;
}
}
});
}); });
@ -1250,7 +1310,7 @@ gstore.add('ccreate', function(){
newRes[`id${restyp2}`] = rs.created_id; newRes[`id${restyp2}`] = rs.created_id;
newRes[`idProf`] = prof; newRes[`idProf`] = prof;
newRes[`volume`] = vol; newRes[`volume`] = vol;
newRes[`formations`] = []; newRes[`formations`] = rs.formations;
newRes[`add_form`] = '-'; newRes[`add_form`] = '-';
newRes[`new_prof`] = prof; newRes[`new_prof`] = prof;

View File

@ -22,6 +22,8 @@
/* (1) List element */ /* (1) List element */
& > section{ & > section{
order: -100000;
flex: 1 1 90%; flex: 1 1 90%;
display: flex; display: flex;
@ -157,6 +159,8 @@
& > div{ & > div{
cursor: default;
& > span.arrow{ & > span.arrow{
display: inline-block; display: inline-block;
position: relative; position: relative;
@ -165,13 +169,9 @@
margin-bottom: -.3em; margin-bottom: -.3em;
background: url('/asset/svg/down_arrow.svg@aaaaaa') center center no-repeat; background: url() center center no-repeat;
background-size: auto 100%; background-size: auto 100%;
&[data-way='up']{ background-image: url('/asset/svg/up_arrow.svg@aaaaaa'); }
&[data-way='down']{ background-image: url('/asset/svg/down_arrow.svg@aaaaaa'); }
cursor: pointer; cursor: pointer;
} }
@ -180,8 +180,9 @@
color: $primary-color; color: $primary-color;
& > span.arrow{ & > span.arrow{
&[data-way='up']{ background-image: url('/asset/svg/up_arrow.svg@555555'); }
&[data-way='down']{ background-image: url('/asset/svg/down_arrow.svg@555555'); } &[data-way='-1']{ background-image: url('/asset/svg/up_arrow.svg@555555'); }
&[data-way='1']{ background-image: url('/asset/svg/down_arrow.svg@555555'); }
} }
} }