From 625cc51c594cab523515f5869647614d27a44e72 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 27 Oct 2015 16:55:57 +0000 Subject: [PATCH] Fix categories would not always refresh Fix calendar categories would never refresh --- admin/inc/class.admin_categories.inc.php | 83 +++++++++++++----------- calendar/js/app.js | 8 +++ 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/admin/inc/class.admin_categories.inc.php b/admin/inc/class.admin_categories.inc.php index 7c4b89f294..21342e4838 100644 --- a/admin/inc/class.admin_categories.inc.php +++ b/admin/inc/class.admin_categories.inc.php @@ -149,43 +149,7 @@ class admin_categories if ($content['id'] && self::$acl_edit) { - // If color changed, we need to do an edit 'refresh' instead of 'update' - // to reload the whole nextmatch instead of just the row $data = $cats->id2name($content['id'],'data'); - $change_color = ($data['color'] != $content['data']['color']); - // Nicely reload just the category window / iframe - if($change_color) - { - if(egw_json_response::isJSONResponse()) - { - // Update category styles - egw_json_response::get()->apply('opener.egw.includeCSS',array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app))); - if($this->appname != 'admin') - { - egw_json_response::get()->apply('opener.egw.show_preferences',array( - 'cats', - $this->appname == 'admin' ? categories::GLOBAL_APPNAME : array($refresh_app) - )); - $change_color = false; - } - else - { - categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app); - egw_json_response::get()->apply('opener.app.admin.load',array( - egw_framework::link('/index.php', array( - 'menuaction' => $this->list_link, - 'appname' => $appname - ) - ))); - } - } - else - { - categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app); - egw_framework::refresh_opener('', null, null); - return; - } - } try { $cats->edit($content); $msg = lang('Category saved.'); @@ -207,9 +171,51 @@ class admin_categories $msg = lang('Permission denied!'); unset($button); } + // If color changed, we need to do an edit 'refresh' instead of 'update' + // to reload the whole nextmatch instead of just the row + $change_color = ($data['color'] != $content['data']['color']); + // Nicely reload just the category window / iframe + if($change_color) + { + if(egw_json_response::isJSONResponse()) + { + // Update category styles + egw_json_response::get()->apply('opener.egw.includeCSS',array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app))); + if($this->appname != 'admin') + { + egw_json_response::get()->apply('opener.egw.show_preferences',array( + 'cats', + $this->appname == 'admin' ? categories::GLOBAL_APPNAME : array($refresh_app) + )); + $change_color = false; + } + else + { + categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app); + // Need to forcably re-load the iframe to avoid smart etemplate refresh + egw_json_response::get()->apply('opener.app.admin.load',array( + egw_framework::link('/index.php', array( + 'menuaction' => $this->list_link, + 'appname' => $appname + ) + ))); + } + } + else + { + categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app); + egw_framework::refresh_opener('', null, null); + if ($button == 'save') + { + egw_framework::window_close(); + } + return; + } + } + if ($button == 'save') { - egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $change_color ? null : $content['id'], $change_color ? null : 'update', $this->appname); + egw_framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname); egw_framework::window_close(); } break; @@ -231,7 +237,8 @@ class admin_categories } break; } - egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname); + // This should probably refresh the application $this->appname in the target tab $refresh_app, but that breaks pretty much everything + egw_framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname); } $content['msg'] = $msg; if(!$content['appname']) $content['appname'] = $appname; diff --git a/calendar/js/app.js b/calendar/js/app.js index 31190eaab1..1ba19b16b6 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -255,6 +255,14 @@ app.classes.calendar = AppJS.extend( } break; case 'calendar': + // Categories + if(this.state.view == '') + { + var iframe = this.sidebox_et2.getWidgetById('iframe'); + if(!iframe) return; + iframe.set_src(iframe.node.src); + return false; + } // Regular refresh if(_id) {