- Fix apply button clearing new resources

- Fix deleting accessories not actually removing them
This commit is contained in:
Nathan Gray 2012-11-27 16:47:12 +00:00
parent 6f37d9b608
commit a821b7a567
2 changed files with 18 additions and 5 deletions

View File

@ -320,7 +320,8 @@ class resources_bo
} }
} }
return $this->so->save($resource) ? false : lang('Something went wrong by saving resource'); $res_id = $this->so->save($resource);
return $res_id ? $res_id : lang('Something went wrong by saving resource');
} }
/** /**

View File

@ -350,6 +350,7 @@ class resources_ui
$action_msg = lang('booked'); $action_msg = lang('booked');
break; break;
case 'delete': case 'delete':
case 'delete-acc':
$action_msg = lang('deleted'); $action_msg = lang('deleted');
foreach((array)$checked as $n => $id) foreach((array)$checked as $n => $id)
{ {
@ -397,27 +398,38 @@ class resources_ui
case 'save': case 'save':
case 'apply': case 'apply':
unset($content['save']); unset($content['save']);
unset($content['apply']);
// if($content['id'] != 0) // if($content['id'] != 0)
// { // {
// // links are already saved by eTemplate // // links are already saved by eTemplate
// unset($resource['link_to']['to_id']); // unset($resource['link_to']['to_id']);
// } // }
$content['msg'] = $this->bo->save($content); $result = $this->bo->save($content);
if(is_numeric($result))
{
$content['res_id'] = $result;
}
else
{
$content['msg'] = $result;
}
break; break;
case 'delete': case 'delete':
unset($content['delete']); unset($content['delete']);
$content['msg'] = $this->bo->delete($content['res_id']); $content['msg'] = $this->bo->delete($content['res_id']);
break; break;
} }
$js = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook',{$content['res_id']});";
if($button != 'apply' && !$content['msg']) if($button != 'apply' && !$content['msg'])
{ {
$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',
array('menuaction' => 'resources.resources_ui.index'))."';";
$js .= 'window.close();'; $js .= 'window.close();';
echo "<html><body><script>$js</script></body></html>\n"; echo "<html><body><script>$js</script></body></html>\n";
$GLOBALS['egw']->common->egw_exit(); $GLOBALS['egw']->common->egw_exit();
} }
else
{
$GLOBALS['egw_info']['flags']['java_script'] .= "<script>$js</script>";
}
} }
$res_id = is_numeric($content) ? (int)$content : $content['res_id']; $res_id = is_numeric($content) ? (int)$content : $content['res_id'];