Resources: Additional changes to get submit on changing category to work

This commit is contained in:
nathan 2022-11-23 15:24:08 -07:00
parent 5c3d35aa05
commit 24118a2a9c

View File

@ -419,7 +419,7 @@ class resources_ui
{ {
if (is_array($content)) if (is_array($content))
{ {
$button = @key($content['button']); $button = is_array($content['button']) ? @key($content['button']) : null;
unset($content['button']); unset($content['button']);
switch($button) switch($button)
{ {
@ -468,7 +468,7 @@ class resources_ui
} }
Framework::refresh_opener($msg, 'resources',$content['res_id'],($button == 'delete'?'delete':'edit')); Framework::refresh_opener($msg, 'resources',$content['res_id'],($button == 'delete'?'delete':'edit'));
if($button != 'apply') if($button && $button != 'apply')
{ {
Framework::window_close(); Framework::window_close();
} }
@ -480,13 +480,13 @@ class resources_ui
if (isset($_GET['res_id'])) $res_id = $_GET['res_id']; if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2']; if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2'];
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of']; if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
$content = array('res_id' => $res_id); $content = $content ?? array('res_id' => $res_id);
if ($res_id > 0) if ($res_id > 0)
{ {
$content = $this->bo->read($res_id); $content = array_merge($this->bo->read($res_id), $content);
$content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src']; $content['picture_src'] = strpos($content['picture_src'], '.') !== false ? 'gen_src' : $content['picture_src'];
$content['link_to'] = array( $content['link_to'] = array(
'to_id' => $res_id, 'to_id' => $res_id,
'to_app' => 'resources' 'to_app' => 'resources'
); );
} elseif ($accessory_of > 0) { } elseif ($accessory_of > 0) {
@ -500,12 +500,15 @@ class resources_ui
} }
$content['cat_id'] = $owner['cat_id']; $content['cat_id'] = $owner['cat_id'];
$content['bookable'] = true; $content['bookable'] = true;
} else { }
elseif(!$content['cat_id'])
{
// New resource // New resource
$content['cat_id'] = $nm_session_data['filter']; $content['cat_id'] = $nm_session_data['filter'];
$content['bookable'] = true; $content['bookable'] = true;
} }
if($msg) { if($msg)
{
$content['msg'] = $msg; $content['msg'] = $msg;
} }