From 39d927247122a9c4f2a753d592f85a444d3a7166 Mon Sep 17 00:00:00 2001 From: dizzy Date: Wed, 29 Jun 2022 06:29:57 -0700 Subject: Make sure active reporting category can be toggled off. (#19422) --- plugins/CoreHome/vue/dist/CoreHome.umd.js | 5 ++--- plugins/CoreHome/vue/dist/CoreHome.umd.min.js | 2 +- .../vue/src/ReportingMenu/ReportingMenu.store.ts | 19 +++++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'plugins/CoreHome') diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js index f2cbbb42dc..7ba559baa0 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js @@ -9006,7 +9006,6 @@ var ReportingMenu_store_ReportingMenuStore = /*#__PURE__*/function () { ReportingMenu_store_classCallCheck(this, ReportingMenuStore); ReportingMenu_store_defineProperty(this, "privateState", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["reactive"])({ - activeCategoryId: null, activeSubcategoryId: null, activeSubsubcategoryId: null })); @@ -9016,7 +9015,7 @@ var ReportingMenu_store_ReportingMenuStore = /*#__PURE__*/function () { })); ReportingMenu_store_defineProperty(this, "activeCategory", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { - return _this.state.value.activeCategoryId || src_MatomoUrl_MatomoUrl.parsed.value.category; + return typeof _this.state.value.activeCategoryId !== 'undefined' ? _this.state.value.activeCategoryId : src_MatomoUrl_MatomoUrl.parsed.value.category; })); ReportingMenu_store_defineProperty(this, "activeSubcategory", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { @@ -9166,7 +9165,7 @@ var ReportingMenu_store_ReportingMenuStore = /*#__PURE__*/function () { this.privateState.activeSubcategoryId = null; this.privateState.activeSubsubcategoryId = null; - if (this.privateState.activeCategoryId === category.id) { + if (this.activeCategory.value === category.id) { this.privateState.activeCategoryId = null; return false; } diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js index 2e62fd9275..02986c0705 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js @@ -422,7 +422,7 @@ window.angular.module("piwikApp").factory("notifications",(function(){return hl} * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */function _l(e){var t=parseFloat(e);return!Number.isNaN(t)&&Number.isFinite(t)}var $l=function(){function e(){var t=this;Ml(this,e),Fl(this,"privateState",Object(a["reactive"])({activeCategoryId:null,activeSubcategoryId:null,activeSubsubcategoryId:null})),Fl(this,"state",Object(a["computed"])((function(){return Object(a["readonly"])(t.privateState)}))),Fl(this,"activeCategory",Object(a["computed"])((function(){return t.state.value.activeCategoryId||Ee.parsed.value.category}))),Fl(this,"activeSubcategory",Object(a["computed"])((function(){return t.state.value.activeSubcategoryId||Ee.parsed.value.subcategory}))),Fl(this,"activeSubsubcategory",Object(a["computed"])((function(){var e=t.state.value.activeSubsubcategoryId;if(e)return e;var n=t.findSubcategory(t.activeCategory.value,t.activeSubcategory.value);return n.subsubcategory&&n.subsubcategory.id===t.activeSubcategory.value?n.subsubcategory.id:null}))),Fl(this,"menu",Object(a["computed"])((function(){return t.buildMenuFromPages()})))}return Rl(e,[{key:"fetchMenuItems",value:function(){var e=this;return El.getAllPages().then((function(){return e.menu.value}))}},{key:"reloadMenuItems",value:function(){var e=this;return El.reloadAllPages().then((function(){return e.menu.value}))}},{key:"findSubcategory",value:function(e,t){var n=void 0,r=void 0,i=void 0;return this.menu.value.forEach((function(a){a.id===e&&(xl(a)||[]).forEach((function(e){e.id===t&&(n=a,r=e),e.isGroup&&(Bl(e)||[]).forEach((function(o){o.id===t&&(n=a,r=e,i=o)}))}))})),{category:n,subcategory:r,subsubcategory:i}}},{key:"buildMenuFromPages",value:function(){var e=[],t=Ee.parsed.value.category,n=Ee.parsed.value.subcategory,r=El.pages.value,i={};return r.forEach((function(a){var o=Object.assign({},a.category),l=o.id,c=l===t;if(!i[l]){i[l]=!0,o.subcategories=[];var s=null,u=r.filter((function(e){return e.category.id===l}));u.forEach((function(e){var t=Object.assign({},e.subcategory),r=t.id===n&&c;if(e.widgets&&e.widgets[0]&&_l(e.subcategory.id)){s||(s=Object.assign({},t),s.name=C("CoreHome_ChooseX",[o.name]),s.isGroup=!0,s.subcategories=[],s.order=10),r&&(s.name=t.name);var i=a.subcategory.id;return t.tooltip="".concat(t.name," (id = ").concat(i,")"),void s.subcategories.push(t)}o.subcategories.push(t)})),s&&s.subcategories&&s.subcategories.length<=5?s.subcategories.forEach((function(e){return o.subcategories.push(e)})):s&&o.subcategories.push(s),o.subcategories=Il(xl(o)),e.push(o)}})),Il(e)}},{key:"toggleCategory",value:function(e){return this.privateState.activeSubcategoryId=null,this.privateState.activeSubsubcategoryId=null,this.privateState.activeCategoryId===e.id?(this.privateState.activeCategoryId=null,!1):(this.privateState.activeCategoryId=e.id,!0)}},{key:"enterSubcategory",value:function(e,t,n){e&&t&&(this.privateState.activeCategoryId=e.id,this.privateState.activeSubcategoryId=t.id,n&&(this.privateState.activeSubsubcategoryId=n.id))}}]),e}(),Hl=new $l;function Ul(e){return Ul="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ul(e)}function ql(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wl(e,t){for(var n=0;n({ - activeCategoryId: null, activeSubcategoryId: null, activeSubsubcategoryId: null, }); private state = computed(() => readonly(this.privateState)); - readonly activeCategory = computed(() => this.state.value.activeCategoryId - || MatomoUrl.parsed.value.category as string); + readonly activeCategory = computed( + () => (typeof this.state.value.activeCategoryId !== 'undefined' + ? this.state.value.activeCategoryId + : MatomoUrl.parsed.value.category as string), + ); - readonly activeSubcategory = computed(() => this.state.value.activeSubcategoryId - || MatomoUrl.parsed.value.subcategory as string); + readonly activeSubcategory = computed( + () => this.state.value.activeSubcategoryId || MatomoUrl.parsed.value.subcategory as string, + ); readonly activeSubsubcategory = computed(() => { const manuallySetId = this.state.value.activeSubsubcategoryId; @@ -76,7 +79,7 @@ export class ReportingMenuStore { return ReportingPagesStoreInstance.reloadAllPages().then(() => this.menu.value); } - findSubcategory(categoryId: string, subcategoryId: string): SubcategoryFindResult { + findSubcategory(categoryId: string|null, subcategoryId: string): SubcategoryFindResult { let foundCategory: Category|undefined = undefined; let foundSubcategory: Subcategory|undefined = undefined; let foundSubSubcategory: Subcategory|undefined = undefined; @@ -188,7 +191,7 @@ export class ReportingMenuStore { this.privateState.activeSubcategoryId = null; this.privateState.activeSubsubcategoryId = null; - if (this.privateState.activeCategoryId === category.id) { + if (this.activeCategory.value === category.id) { this.privateState.activeCategoryId = null; return false; } -- cgit v1.2.3