From 0410c9790340d6f5dc2a536855ae700ad988cff5 Mon Sep 17 00:00:00 2001 From: colemanw Date: Mon, 4 Dec 2023 11:55:54 +0000 Subject: [PATCH] Ang - Change crmUiAccordion to use summary/details markup --- ang/crmUi.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ang/crmUi.js b/ang/crmUi.js index 8bc3229ed2..95bbc70a30 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -7,26 +7,30 @@ angular.module('crmUi', CRM.angRequires('crmUi')) - // example
...content...
- // WISHLIST: crmCollapsed should support two-way/continuous binding + // example
...content...
+ // @deprecated: just use
markup .directive('crmUiAccordion', function() { return { scope: { crmUiAccordion: '=' }, - template: '
{{crmUiAccordion.title}}
', + template: '
{{crmUiAccordion.title}}
', transclude: true, link: function (scope, element, attrs) { - scope.cssClasses = { - 'crm-accordion-wrapper': true, - collapsed: scope.crmUiAccordion.collapsed - }; scope.help = null; - scope.$watch('crmUiAccordion', function(crmUiAccordion) { - if (crmUiAccordion && crmUiAccordion.help) { - scope.help = crmUiAccordion.help.clone({}, { - title: crmUiAccordion.title - }); + let openSet = false; + scope.$watch('crmUiAccordion', function(crmUiAccordion, oldVal) { + if (crmUiAccordion) { + // Only process this once + if (!openSet) { + $(element).children('details').prop('open', !crmUiAccordion.collapsed); + openSet = true; + } + if (crmUiAccordion.help) { + scope.help = crmUiAccordion.help.clone({}, { + title: crmUiAccordion.title + }); + } } }); } -- 2.25.1