From 5db0114da3f195503c72f8c34f0af81e8d2b07b8 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 16 Nov 2015 20:38:53 -0500 Subject: [PATCH] CRM-13823 - Display hidden_until date on status page --- ang/crmStatusPage.css | 11 +++++++- ang/crmStatusPage.js | 2 +- ang/crmStatusPage/StatusPage.html | 3 +++ ang/crmStatusPage/StatusPageCtrl.js | 42 ++++++++++++++++++----------- ang/crmUtil.js | 2 +- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/ang/crmStatusPage.css b/ang/crmStatusPage.css index bc59cc2452..bf18ce9205 100644 --- a/ang/crmStatusPage.css +++ b/ang/crmStatusPage.css @@ -38,9 +38,18 @@ margin: 1em 0; } +#crm-status-list .hidden-until { + font-weight: normal; + font-size: .8em; + margin-right: 1em; +} + +#tab-status-visible-1 .hush-menu > div { + width: 20em; /* determines max-width of popup menu */ +} + #crm-status-list .hush-menu > div { position: relative; - width: 20em; /* determines max-width of popup menu */ font-size: .8em; } diff --git a/ang/crmStatusPage.js b/ang/crmStatusPage.js index b472efb237..a1f40162e5 100644 --- a/ang/crmStatusPage.js +++ b/ang/crmStatusPage.js @@ -12,7 +12,7 @@ resolve: { statusData: function(crmApi) { - return crmApi('System', 'check', {sequential: 1, options: {limit: 0}}); + return crmApi('System', 'check', {sequential: 1}); } } }); diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html index 95fb62daaf..7517e50a91 100644 --- a/ang/crmStatusPage/StatusPage.html +++ b/ang/crmStatusPage/StatusPage.html @@ -17,6 +17,9 @@ {{status.title}}
+
+ ({{status.hidden_until ? ts('Hidden until %1', {1: status.hidden_until}) : ts('Hidden permanently')}}) +
diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index 48242a59ea..629681f755 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -3,24 +3,36 @@ angular.module('statuspage').controller('statuspageStatusPage', function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) { - var ts = $scope.ts = CRM.ts(); - $scope.alert = CRM.alert; - $scope.statuses = statusData.values; + function preprocessStatuses(apiData) { + _.each(apiData.values, function(status) { + status.severity_id = status.severity; + status.severity = statuspageSeverityList[status.severity]; + if (status.hidden_until) { + var date = $.datepicker.parseDate('yy-mm-dd', status.hidden_until); + status.hidden_until = $.datepicker.formatDate(CRM.config.dateInputFormat, date); + } + }); + $scope.statuses = apiData.values; + } + preprocessStatuses(statusData); - _.each($scope.statuses, function(status) { - status.severity_id = status.severity; - status.severity = statuspageSeverityList[status.severity]; - }); + $scope.ts = CRM.ts(); + $scope.alert = CRM.alert; - // updates a status preference + // updates a status preference and refreshes status data $scope.setPref = function(status, until, visible) { - crmApi('StatusPreference', 'create', { - "name": status.name, - "ignore_severity": visible ? 0 : status.severity, - "hush_until": until - }, true) - .then(function() { - status.is_visible = visible; + // Use an array because it's important that one api call executes before the other + var apiCalls = [ + ['StatusPreference', 'create', { + "name": status.name, + "ignore_severity": visible ? 0 : status.severity, + "hush_until": until + }], + ['System', 'check', {sequential: 1}] + ]; + crmApi(apiCalls, true) + .then(function(result) { + preprocessStatuses(result[1]); }); }; diff --git a/ang/crmUtil.js b/ang/crmUtil.js index b6a0d01310..b58a5c5ad8 100644 --- a/ang/crmUtil.js +++ b/ang/crmUtil.js @@ -19,7 +19,7 @@ if (_.isObject(entity)) { // eval content is locally generated. /*jshint -W061 */ - p = backend(eval('('+angular.toJson(entity)+')'), message); + p = backend(eval('('+angular.toJson(entity)+')'), action); } else { // eval content is locally generated. /*jshint -W061 */ -- 2.25.1