- Remove 'Add accessory button'

- Fix bug in delete confirm
- Fix link url
This commit is contained in:
Nathan Gray 2012-11-26 21:04:31 +00:00
parent 90d5428b9e
commit 147b926490
5 changed files with 86 additions and 43 deletions

View File

@ -188,9 +188,17 @@ class resources_bo
$resource['class'] .= 'no_buy ';
}
$readonlys["view_acc[{$resource['res_id']}]"] = ($resource['acc_count'] == 0);
$resource['class'] .= ($resource['accessory_of']==-1 ? 'resource ' : 'accessory ');
if($resource['acc_count'])
{
$resource['class'] .= 'hasAccessories ';
$accessories = $this->get_acc_list($resource['res_id']);
foreach($accessories as $acc_id => $acc_name)
{
$resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $acc_name);
}
} elseif ($resource['accessory_of'] > 0) {
$resource['accessory_of_label'] = $this->link_title($resource['accessory_of']);
}
$rows[$num]['picture_thumb'] = $this->get_picture($resource);
@ -232,11 +240,16 @@ class resources_bo
{
return lang('You are not permitted to edit this resource!');
}
$old = array();
// we need an id to save pictures and make links...
if(!$resource['res_id'])
{
$resource['res_id'] = $this->so->save($resource);
}
else
{
$old = $this->read($resource['res_id']);
}
switch ($resource['picture_src'])
{
@ -279,11 +292,17 @@ class resources_bo
$this->remove_picture($resource['res_id']);
}
// Update link title
egw_link::notify_update('resources',$resource['res_id'], $resource);
// save links
if(is_array($resource['link_to']['to_id']))
{
egw_link::link('resources',$resource['res_id'],$resource['link_to']['to_id']);
}
if($resource['accessory_of'] != $old['accessory_of'])
{
egw_link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
}
if($resource['accessory_of'] != -1)
{
egw_link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']);

View File

@ -88,7 +88,7 @@ class resources_hooks
'title' => 'resources.resources_bo.link_title',
'titles' => 'resources.resources_bo.link_titles',
'view' => array(
'menuaction' => 'resources.resources_ui.show'
'menuaction' => 'resources.resources_ui.edit'
),
'view_id' => 'res_id',
'view_popup' => '850x600',
@ -126,7 +126,7 @@ class resources_hooks
* Resources' ACL _requires_ a category.
* Moves all resources to parent, if it exists. If it doesn't, another category is created.
*/
function delete_category($args)
function delete_category($args)
{
$cat = categories::read($args['cat_id']);

View File

@ -186,6 +186,8 @@ class resources_ui
}
$preserv = $content;
$options = array();
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$content['nm']);
$this->tmpl->read('resources.show');
return $this->tmpl->exec('resources.resources_ui.index',$content,$sel_options,$no_button,$preserv);
@ -264,8 +266,20 @@ class resources_ui
'caption' => 'Delete',
'group' => ++$group,
'disableClass' => 'no_delete',
'nm_action' => 'open_popup'
'enableClass' => 'resource',
'nm_action' => 'open_popup',
'hideOnDisabled' => true
),
'delete-acc' => array(
'caption' => 'Delete',
'icon' => 'delete',
'group' => ++$group,
'disableClass' => 'no_delete',
'confirm' => 'Delete this accessory',
'confirm_multiple' => 'Delete these accessories',
'enableClass' => 'accessory',
'hideOnDisabled' => true
)
);
return $actions;
}
@ -376,10 +390,12 @@ class resources_ui
{
if (is_array($content))
{
if(isset($content['save']) || isset($content['delete']))
list($button) = @each($content['button']);
unset($content['button']);
switch($button)
{
if(isset($content['save']))
{
case 'save':
case 'apply':
unset($content['save']);
// if($content['id'] != 0)
// {
@ -387,17 +403,15 @@ class resources_ui
// unset($resource['link_to']['to_id']);
// }
$content['msg'] = $this->bo->save($content);
}
if(isset($content['delete']))
{
break;
case 'delete':
unset($content['delete']);
$content['msg'] = $this->bo->delete($content['res_id']);
}
if($content['msg'])
{
return $this->edit($content);
}
break;
}
if($button != 'apply' && !$content['msg'])
{
$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',
array('menuaction' => 'resources.resources_ui.index'))."';";
$js .= 'window.close();';
@ -405,25 +419,24 @@ class resources_ui
$GLOBALS['egw']->common->egw_exit();
}
}
else
{
$res_id = $content;
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
$content = array('res_id' => $res_id);
if ($res_id > 0)
{
$content = $this->bo->read($res_id);
$content['gen_src_list'] = strpos($content['picture_src'],'.') !== false ? $content['picture_src'] : false;
$content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src'];
$content['link_to'] = array(
'to_id' => $res_id,
'to_app' => 'resources'
);
}
if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);
$res_id = is_numeric($content) ? (int)$content : $content['res_id'];
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
$content = array('res_id' => $res_id);
if ($res_id > 0)
{
$content = $this->bo->read($res_id);
$content['gen_src_list'] = strpos($content['picture_src'],'.') !== false ? $content['picture_src'] : false;
$content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src'];
$content['link_to'] = array(
'to_id' => $res_id,
'to_app' => 'resources'
);
}
if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);
// some presetes
$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
@ -433,15 +446,13 @@ class resources_ui
$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
$sel_options['cat_id'] = $this->bo->acl->get_cats(EGW_ACL_ADD);
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] :
$content['cat_id'] ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id'];
array('' => lang('select one')) + $sel_options['cat_id'];
if($accessory_of > 0 || $content['accessory_of'] > 0)
{
$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of;
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
}
$search_options = array('accessory_of' => -1);
$sel_options['accessory_of'] = $this->bo->link_query('',$search_options);
$sel_options['accessory_of'] = array(-1 => lang('none')) + $this->bo->link_query('',$search_options);
if($res_id) unset($sel_options['accessory_of'][$res_id]);
// $content['general|page|pictures|links'] = 'resources.edit_tabs.page'; //debug

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,7 @@
<column/>
<column/>
<column/>
<column/>
<column width="5%"/>
</columns>
<rows>
@ -43,6 +44,7 @@
<nextmatch-sortheader label="Location" id="location"/>
<description value="Storage information"/>
</vbox>
<nextmatch-header label="Resource / Accessories"/>
<nextmatch-customfields id="customfields"/>
<hbox align="right">
<nextmatch-header label="Actions" id="legacy_actions"/>
@ -73,6 +75,19 @@
<description id="${row}[location]" no_lang="1"/>
<description id="${row}[storage_info]" no_lang="1"/>
</vbox>
<vbox no_lang="1">
<description id="${row}[accessory_of_label]" no_lang="1" href="resources.resources_ui.edit&amp;res_id=$row_cont[accessory_of]" extra_link_popup="850x600"/>
<grid width="100%" id="${row}[accessories]">
<columns>
<column/>
</columns>
<rows>
<row>
<description id="${row}[name]" no_lang="1" href="resources.resources_ui.edit&amp;res_id=$row_cont[acc_id]" extra_link_popup="850x600"/>
</row>
</rows>
</grid>
</vbox>
<customfields-list id="$row"/>
<grid id="${row}">
<columns>
@ -124,8 +139,6 @@
<row>
<hbox>
<button label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=resources.resources_ui.edit'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false; return false;"/>
<button label="Add accessory" id="add_sub" onclick="window.open(egw::link('/index.php','menuaction=resources.resources_ui.edit&amp;content=0&amp;accessory_of=$cont[view_accs_of]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"/>
<button label="Back" id="back"/>
</hbox>
</row>
<row>