update version id + currentDatabase when switching department
This commit is contained in:
parent
3dfa1cc525
commit
13e545e5f9
|
@ -78,8 +78,26 @@ class departmentController
|
||||||
if( $dep['idDep'] == $department ){
|
if( $dep['idDep'] == $department ){
|
||||||
|
|
||||||
$_SESSION['AvailableDepartments'] = $deps;
|
$_SESSION['AvailableDepartments'] = $deps;
|
||||||
$_SESSION['CurrentDatabase'] = $dep['dbName'];
|
|
||||||
$_SESSION['CurrentDepartmentId'] = $dep['idDep'];
|
$_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];
|
return ['switched' => true];
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,6 @@ export default {
|
||||||
|
|
||||||
// 3. Ask for department change
|
// 3. Ask for department change
|
||||||
api.call(`GET department/version/switch/${id}`, {}, function(rs){
|
api.call(`GET department/version/switch/${id}`, {}, function(rs){
|
||||||
console.log(rs);
|
|
||||||
|
|
||||||
// 1. error -> do nothing
|
// 1. error -> do nothing
|
||||||
if( rs.error !== 0 )
|
if( rs.error !== 0 )
|
||||||
|
@ -169,8 +168,8 @@ export default {
|
||||||
if( rs.error !== 0 || !rs.hasOwnProperty('created_id') ){
|
if( rs.error !== 0 || !rs.hasOwnProperty('created_id') ){
|
||||||
|
|
||||||
return popup.ask({
|
return popup.ask({
|
||||||
title: 'Error ('+err_code+')',
|
title: 'Erreur ('+err_code+')',
|
||||||
content: 'La création de sauvegarde à échoué.',
|
content: 'La création de version à échoué.',
|
||||||
action: 'OK',
|
action: 'OK',
|
||||||
type: 'neutral'
|
type: 'neutral'
|
||||||
}, () => {});
|
}, () => {});
|
||||||
|
|
Loading…
Reference in New Issue