[webpack.teacher.view] show all professors when (no filter|empty filter)
This commit is contained in:
parent
f0ea6cf494
commit
4352f02dc9
|
@ -28,8 +28,8 @@ class filterController{
|
|||
---------------------------------------------------------*/
|
||||
public static function post($args){
|
||||
|
||||
$formations = null;
|
||||
$ues = null;
|
||||
$formations = [];
|
||||
$ues = [];
|
||||
extract($args);
|
||||
|
||||
/** @var ue $ue_repo */
|
||||
|
@ -38,18 +38,22 @@ class filterController{
|
|||
|
||||
/* (1) If no filter -> return error
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Exit if no filter */
|
||||
if( is_null($formations) && is_null($ues) )
|
||||
/* (1) Pre-process conditions */
|
||||
$no_ue = !is_array($ues) || count($ues) < 1;
|
||||
$no_formation = !is_array($formations) || count($formations) < 1;
|
||||
|
||||
/* (2) Exit if no filter */
|
||||
if( $no_ue && $no_formation )
|
||||
return ['error' => new Error(Err::MissingParam, 'You must give at least 1 parameter')];
|
||||
|
||||
/* (2) Init. result array (only keys used for unicity) */
|
||||
/* (3) Init. result array (only keys used for unicity) */
|
||||
$matches_uniq = [];
|
||||
|
||||
|
||||
|
||||
/* (2) Filter by formation
|
||||
---------------------------------------------------------*/
|
||||
if( !is_null($formations) ){
|
||||
if( is_array($formations) ){
|
||||
|
||||
/** @var formation $form_repo */
|
||||
$form_repo = Repo::getRepo('formation');
|
||||
|
@ -58,15 +62,15 @@ class filterController{
|
|||
foreach($formations as $form_id){
|
||||
|
||||
// 1. Ignore if wrong format
|
||||
if( !is_numeric($form_id) || intval($form_id) !== $form_id )
|
||||
if( !is_numeric($form_id) || !is_int($form_id) )
|
||||
continue;
|
||||
|
||||
// 2. Get from repo
|
||||
$fetched_ids = $form_repo->getProfessors($form_id);
|
||||
$fetched_ids = $form_repo->getProfessors( intval($form_id) );
|
||||
|
||||
// 3. Add in unique set
|
||||
foreach($fetched_ids as $prof_id)
|
||||
$matches_uniq[ intval($prof_id["idProfesseur"]) ] = null;
|
||||
$matches_uniq[ intval($prof_id['idProfesseur']) ] = null;
|
||||
|
||||
|
||||
}
|
||||
|
@ -77,7 +81,7 @@ class filterController{
|
|||
|
||||
/* (3) Filter by ue
|
||||
---------------------------------------------------------*/
|
||||
if( !is_null($ues) ){
|
||||
if( is_array($ues) ){
|
||||
|
||||
/** @var ue $ue_repo */
|
||||
$ue_repo = Repo::getRepo('ue');
|
||||
|
@ -94,7 +98,7 @@ class filterController{
|
|||
|
||||
// 3. Add in unique set
|
||||
foreach($fetched_ids as $prof_id)
|
||||
$matches_uniq[ intval($prof_id["idProfesseur"]) ] = null;
|
||||
$matches_uniq[ intval($prof_id['idProfesseur']) ] = null;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,13 @@ gstore.add('filter_handler', function(){
|
|||
|
||||
}
|
||||
|
||||
|
||||
/* (3) Get professor id for matching filter */
|
||||
api.call('POST professor/filter', request, function(rs){
|
||||
|
||||
// 1. Abort on error
|
||||
if( rs.error !== 0 ) return console.log('No filter result found, error: '+rs.error);
|
||||
// 1. Display all on error
|
||||
if( rs.error !== 0 )
|
||||
rs.matches = gstore.get.professors.map(function(prof,i){ return i; });
|
||||
|
||||
console.log(rs);
|
||||
|
||||
// 2. Fetch professor elements
|
||||
|
|
Loading…
Reference in New Issue