update version id + currentDatabase when switching department
This commit is contained in:
parent
3dfa1cc525
commit
13e545e5f9
|
@ -75,11 +75,29 @@ class departmentController
|
|||
|
||||
foreach($deps as $dep){
|
||||
|
||||
if( $dep['idDep'] == $department){
|
||||
if( $dep['idDep'] == $department ){
|
||||
|
||||
$_SESSION['AvailableDepartments'] = $deps;
|
||||
$_SESSION['CurrentDatabase'] = $dep['dbName'];
|
||||
$_SESSION['CurrentDepartmentId'] = $dep['idDep'];
|
||||
$_SESSION['VERSION'] = [
|
||||
'list' => $dep['versions'],
|
||||
'current' => null
|
||||
];
|
||||
|
||||
// select version with default = 1
|
||||
foreach($_SESSION['VERSION']['list'] as $v){
|
||||
if( $v['default'] == 1 ){
|
||||
$_SESSION['VERSION']['current'] = intval($v['iddatabase']);
|
||||
$_SESSION['CurrentDatabase'] = $v['dbName'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if no default -> select first
|
||||
if( !is_int($_SESSION['VERSION']) ){
|
||||
$_SESSION['VERSION']['current'] = intval($_SESSION['VERSION']['list'][0]['iddatabase']);
|
||||
$_SESSION['CurrentDatabase'] = $_SESSION['VERSION']['list'][0]['dbName'];
|
||||
}
|
||||
|
||||
return ['switched' => true];
|
||||
|
||||
|
|
|
@ -125,7 +125,6 @@ export default {
|
|||
|
||||
// 3. Ask for department change
|
||||
api.call(`GET department/version/switch/${id}`, {}, function(rs){
|
||||
console.log(rs);
|
||||
|
||||
// 1. error -> do nothing
|
||||
if( rs.error !== 0 )
|
||||
|
@ -169,8 +168,8 @@ export default {
|
|||
if( rs.error !== 0 || !rs.hasOwnProperty('created_id') ){
|
||||
|
||||
return popup.ask({
|
||||
title: 'Error ('+err_code+')',
|
||||
content: 'La création de sauvegarde à échoué.',
|
||||
title: 'Erreur ('+err_code+')',
|
||||
content: 'La création de version à échoué.',
|
||||
action: 'OK',
|
||||
type: 'neutral'
|
||||
}, () => {});
|
||||
|
|
Loading…
Reference in New Issue