Added DatePreference admin UI
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 4 Dec 2023 21:02:38 +0000 (21:02 +0000)
committerPradeep Nayak <pradpnayak@gmail.com>
Tue, 5 Dec 2023 16:21:16 +0000 (16:21 +0000)
ext/civicrm_admin_ui/ang/afsearchSettingsDatePreferences.aff.html [new file with mode: 0644]
ext/civicrm_admin_ui/ang/afsearchSettingsDatePreferences.aff.php [new file with mode: 0644]
ext/civicrm_admin_ui/managed/SavedSearch_Settings_Date_Preferences.mgd.php [new file with mode: 0644]

diff --git a/ext/civicrm_admin_ui/ang/afsearchSettingsDatePreferences.aff.html b/ext/civicrm_admin_ui/ang/afsearchSettingsDatePreferences.aff.html
new file mode 100644 (file)
index 0000000..56bf915
--- /dev/null
@@ -0,0 +1,7 @@
+<div af-fieldset="">
+  <div class="af-markup">
+    <div class="help">{{:: ts('Changing the parameters here affects the input and display for specific fields types. Setting the default date format for the entire site is a Localisation setting.') }} <a ng-href="{{:: crmUrl('civicrm/admin/setting/date?action=reset=1') }}">{{:: ts('See Administer > Localization > Date Formats.') }}</a></div>
+
+  </div>
+  <crm-search-display-table search-name="Settings_Date_Preferences" display-name="Settings_Date_Preferences"></crm-search-display-table>
+</div>
diff --git a/ext/civicrm_admin_ui/ang/afsearchSettingsDatePreferences.aff.php b/ext/civicrm_admin_ui/ang/afsearchSettingsDatePreferences.aff.php
new file mode 100644 (file)
index 0000000..195a02e
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+use CRM_CivicrmAdminUi_ExtensionUtil as E;
+
+return [
+  'title' => E::ts('Settings - Date Preferences'),
+  'permission' => [
+    'administer CiviCRM',
+  ],
+  'type' => 'search',
+  'icon' => 'fa-list-alt',
+  'server_route' => 'civicrm/admin/setting/preferences/date',
+  'permission_operator' => 'AND',
+];
diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Settings_Date_Preferences.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Settings_Date_Preferences.mgd.php
new file mode 100644 (file)
index 0000000..5b4bb41
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+use CRM_CivicrmAdminUi_ExtensionUtil as E;
+
+return [
+  [
+    'name' => 'SavedSearch_Settings_Date_Preferences',
+    'entity' => 'SavedSearch',
+    'cleanup' => 'unused',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Settings_Date_Preferences',
+        'label' => E::ts('Settings - Date Preferences'),
+        'api_entity' => 'PreferencesDate',
+        'api_params' => [
+          'version' => 4,
+          'select' => [
+            'name',
+            'description',
+            'date_format',
+            'start',
+            'end',
+          ],
+          'orderBy' => [],
+          'where' => [],
+          'groupBy' => [],
+          'join' => [],
+          'having' => [],
+        ],
+      ],
+      'match' => [
+        'name',
+      ],
+    ],
+  ],
+  [
+    'name' => 'SavedSearch_Settings_Date_Preferences_SearchDisplay_Settings_Date_Preferences',
+    'entity' => 'SearchDisplay',
+    'cleanup' => 'unused',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Settings_Date_Preferences',
+        'label' => E::ts('Settings - Date Preferences'),
+        'saved_search_id.name' => 'Settings_Date_Preferences',
+        'type' => 'table',
+        'settings' => [
+          'description' => NULL,
+          'sort' => [
+            [
+              'name',
+              'ASC',
+            ],
+          ],
+          'limit' => 50,
+          'pager' => [],
+          'placeholder' => 5,
+          'columns' => [
+            [
+              'type' => 'field',
+              'key' => 'name',
+              'dataType' => 'String',
+              'label' => E::ts('Date Class'),
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'description',
+              'dataType' => 'String',
+              'label' => E::ts('Description'),
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'date_format',
+              'dataType' => 'String',
+              'label' => E::ts('Date Format'),
+              'sortable' => TRUE,
+              'rewrite' => '',
+              'empty_value' => 'Default',
+            ],
+            [
+              'type' => 'field',
+              'key' => 'start',
+              'dataType' => 'Integer',
+              'label' => E::ts('Start Offset'),
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'end',
+              'dataType' => 'Integer',
+              'label' => E::ts('End Offset'),
+              'sortable' => TRUE,
+            ],
+            [
+              'links' => [
+                [
+                  'entity' => 'PreferencesDate',
+                  'action' => 'update',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-pencil',
+                  'text' => '',
+                  'style' => 'default',
+                  'path' => '',
+                  'task' => '',
+                  'condition' => [],
+                ],
+              ],
+              'type' => 'links',
+              'alignment' => 'text-right',
+            ],
+          ],
+          'actions' => FALSE,
+          'classes' => [
+            'table',
+            'table-striped',
+          ],
+        ],
+      ],
+      'match' => [
+        'name',
+        'saved_search_id',
+      ],
+    ],
+  ],
+];