From 63d713f9f0fb2e1c2f8ebca35945017fb4395636 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Wed, 16 Aug 2023 11:26:10 +0200 Subject: [PATCH 1/3] display selectors as list in profiles view --- CRM/Twingle/Page/Profiles.php | 7 +++++-- templates/CRM/Twingle/Page/Profiles.tpl | 12 +++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CRM/Twingle/Page/Profiles.php b/CRM/Twingle/Page/Profiles.php index eb5bf0c..49396d4 100644 --- a/CRM/Twingle/Page/Profiles.php +++ b/CRM/Twingle/Page/Profiles.php @@ -20,8 +20,11 @@ class CRM_Twingle_Page_Profiles extends CRM_Core_Page { public function run() { CRM_Utils_System::setTitle(E::ts("Twingle API Profiles")); $profiles = []; - foreach (CRM_Twingle_Profile::getProfiles() as $profile_name => $profile) { - $profiles[$profile_name]['name'] = $profile_name; + foreach (CRM_Twingle_Profile::getProfiles() as $profile_id => $profile) { + $profiles[$profile_id]['id'] = $profile_id; + $profiles[$profile_id]['name'] = $profile->getName(); + $profiles[$profile_id]['is_default'] = $profile->is_default(); + $profiles[$profile_id]['selectors'] = $profile->getProjectIds(); foreach (CRM_Twingle_Profile::allowedAttributes() as $attribute) { $profiles[$profile_name][$attribute] = $profile->getAttribute($attribute); } diff --git a/templates/CRM/Twingle/Page/Profiles.tpl b/templates/CRM/Twingle/Page/Profiles.tpl index b5b869e..992fe64 100644 --- a/templates/CRM/Twingle/Page/Profiles.tpl +++ b/templates/CRM/Twingle/Page/Profiles.tpl @@ -25,7 +25,7 @@ {ts domain="de.systopia.twingle"}Profile name{/ts} - {ts domain="de.systopia.twingle"}Properties{/ts} + {ts domain="de.systopia.twingle"}Selectors{/ts} {ts domain="de.systopia.twingle"}Used{/ts} {ts domain="de.systopia.twingle"}Last Used{/ts} {ts domain="de.systopia.twingle"}Operations{/ts} @@ -34,10 +34,16 @@ {foreach from=$profiles item=profile} {assign var="profile_name" value=$profile.name} - + {$profile.name} -
{ts domain="de.systopia.twingle"}Selector{/ts}: {$profile.selector}
+ {if not $profile.is_default} + + {/if} {ts domain="de.systopia.twingle"}{$profile_stats.$profile_name.access_counter_txt}{/ts} {ts domain="de.systopia.twingle"}{$profile_stats.$profile_name.last_access_txt}{/ts} From ab5b0b3929b4cd32444bc44bcb0240e376e15f3c Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Tue, 29 Aug 2023 16:39:28 +0200 Subject: [PATCH 2/3] use correct array key --- CRM/Twingle/Page/Profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Twingle/Page/Profiles.php b/CRM/Twingle/Page/Profiles.php index 49396d4..4c96456 100644 --- a/CRM/Twingle/Page/Profiles.php +++ b/CRM/Twingle/Page/Profiles.php @@ -26,7 +26,7 @@ class CRM_Twingle_Page_Profiles extends CRM_Core_Page { $profiles[$profile_id]['is_default'] = $profile->is_default(); $profiles[$profile_id]['selectors'] = $profile->getProjectIds(); foreach (CRM_Twingle_Profile::allowedAttributes() as $attribute) { - $profiles[$profile_name][$attribute] = $profile->getAttribute($attribute); + $profiles[$profile_id][$attribute] = $profile->getAttribute($attribute); } } $this->assign('profiles', $profiles); From b7b0e6d610a2c1c0387ed7c78041c4fcebfee787 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Tue, 29 Aug 2023 17:02:05 +0200 Subject: [PATCH 3/3] use custom css file instead of inline style --- CRM/Twingle/Page/Profiles.php | 3 +++ css/twingle.css | 3 +++ templates/CRM/Twingle/Page/Profiles.tpl | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 css/twingle.css diff --git a/CRM/Twingle/Page/Profiles.php b/CRM/Twingle/Page/Profiles.php index 4c96456..3387d07 100644 --- a/CRM/Twingle/Page/Profiles.php +++ b/CRM/Twingle/Page/Profiles.php @@ -32,6 +32,9 @@ class CRM_Twingle_Page_Profiles extends CRM_Core_Page { $this->assign('profiles', $profiles); $this->assign('profile_stats', CRM_Twingle_Profile::getProfileStats()); + // Add custom css + Civi::resources()->addStyleFile(E::LONG_NAME, 'css/twingle.css'); + parent::run(); } diff --git a/css/twingle.css b/css/twingle.css new file mode 100644 index 0000000..341a393 --- /dev/null +++ b/css/twingle.css @@ -0,0 +1,3 @@ +.twingle-profile-list { + border-bottom: 1px solid #cfcec3; +} diff --git a/templates/CRM/Twingle/Page/Profiles.tpl b/templates/CRM/Twingle/Page/Profiles.tpl index 992fe64..7ce718e 100644 --- a/templates/CRM/Twingle/Page/Profiles.tpl +++ b/templates/CRM/Twingle/Page/Profiles.tpl @@ -34,7 +34,7 @@ {foreach from=$profiles item=profile} {assign var="profile_name" value=$profile.name} - + {$profile.name} {if not $profile.is_default}