standalone: add role list and (basic) edit UI
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 3 Jul 2023 11:12:10 +0000 (12:12 +0100)
committerRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 3 Jul 2023 11:12:10 +0000 (12:12 +0100)
ext/afform/core/CRM/Afform/ArrayHtml.php
ext/standaloneusers/CRM/Standaloneusers/DAO/Role.php
ext/standaloneusers/afformEntities/Role.php [new file with mode: 0644]
ext/standaloneusers/ang/afformX.aff.html [new file with mode: 0644]
ext/standaloneusers/ang/afformX.aff.json [new file with mode: 0644]
ext/standaloneusers/ang/afsearchUserRoles.aff.html [new file with mode: 0644]
ext/standaloneusers/ang/afsearchUserRoles.aff.json [new file with mode: 0644]
ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php [new file with mode: 0644]
ext/standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml

index 2425de090a2c0dbd11487878777fa98c3ff06dba..92a2caca84c2c962fd797155282d8101513cd4b1 100644 (file)
@@ -111,7 +111,7 @@ class CRM_Afform_ArrayHtml {
         continue;
       }
       if (!preg_match('/^[a-zA-Z0-9\-]+$/', $attrName)) {
-        throw new \RuntimeException("Malformed HTML attribute");
+        throw new \RuntimeException("Malformed HTML attribute $attrName → $attrValue");
       }
 
       $type = $this->pickAttrType($tag, $attrName);
index f673ef54943f644a961be6d2961251ff158ec244..585f241f2f16af0355a92e0a2d2bdb740bb462c2 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:d28fa09f872be30740de728c9e344a6d)
+ * (GenCodeChecksum:d5053ae97fba22b13adecdce76ebb30f)
  */
 use CRM_Standaloneusers_ExtensionUtil as E;
 
@@ -151,6 +151,9 @@ class CRM_Standaloneusers_DAO_Role extends CRM_Core_DAO {
           'entity' => 'Role',
           'bao' => 'CRM_Standaloneusers_DAO_Role',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Text',
+          ],
           'add' => NULL,
         ],
         'label' => [
@@ -172,6 +175,9 @@ class CRM_Standaloneusers_DAO_Role extends CRM_Core_DAO {
           'entity' => 'Role',
           'bao' => 'CRM_Standaloneusers_DAO_Role',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Text',
+          ],
           'add' => NULL,
         ],
         'permissions' => [
diff --git a/ext/standaloneusers/afformEntities/Role.php b/ext/standaloneusers/afformEntities/Role.php
new file mode 100644 (file)
index 0000000..7c59603
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+return [
+  'type' => 'primary',
+  'entity' => 'Role',
+  'label' => 'Role',
+  'defaults' => '{}',
+  'icon' => 'fa-graduation-cap',
+  'unique_fields' => ['name'],
+];
diff --git a/ext/standaloneusers/ang/afformX.aff.html b/ext/standaloneusers/ang/afformX.aff.html
new file mode 100644 (file)
index 0000000..0af704b
--- /dev/null
@@ -0,0 +1,10 @@
+<af-form ctrl="afform">
+  <af-entity type="Role" name="Role1" label="Role 1" actions="{create: true, update: true}" security="RBAC" url-autofill="1" />
+  <fieldset af-fieldset="Role1" class="af-container" af-title="Role 1">
+    <af-field name="name" />
+    <af-field name="label" />
+    <af-field name="permissions" />
+    <af-field name="is_active" />
+  </fieldset>
+  <button class="af-button btn btn-primary" crm-icon="fa-check" ng-click="afform.submit()">Submit</button>
+</af-form>
diff --git a/ext/standaloneusers/ang/afformX.aff.json b/ext/standaloneusers/ang/afformX.aff.json
new file mode 100644 (file)
index 0000000..d7979be
--- /dev/null
@@ -0,0 +1,19 @@
+{
+    "type": "form",
+    "title": "Edit Role",
+    "icon": "fa-list-alt",
+    "server_route": "civicrm/admin/role",
+    "permission": "access CiviCRM",
+    "redirect": "civicrm/admin/roles",
+    "create_submission": true,
+    "requires": [],
+    "description": "",
+    "is_dashlet": false,
+    "is_public": false,
+    "is_token": false,
+    "entity_type": null,
+    "join_entity": null,
+    "contact_summary": null,
+    "summary_contact_type": null,
+    "navigation": null
+}
diff --git a/ext/standaloneusers/ang/afsearchUserRoles.aff.html b/ext/standaloneusers/ang/afsearchUserRoles.aff.html
new file mode 100644 (file)
index 0000000..15ecb47
--- /dev/null
@@ -0,0 +1,10 @@
+<p class="af-text">Enter text</p>
+<div class="af-markup">
+  <div class="help">
+  <p>{{:: ts('Roles define sets of permissions for different types of users. You can give users roles to grant them permissions appropriate to their needs.') }}</p>
+  </div>
+
+</div>
+<div af-fieldset="">
+  <crm-search-display-table search-name="Roles" display-name="Roles_Table_1"></crm-search-display-table>
+</div>
diff --git a/ext/standaloneusers/ang/afsearchUserRoles.aff.json b/ext/standaloneusers/ang/afsearchUserRoles.aff.json
new file mode 100644 (file)
index 0000000..cc62bb4
--- /dev/null
@@ -0,0 +1,23 @@
+{
+    "type": "search",
+    "title": "User Roles",
+    "description": "List of roles defined on the system.",
+    "icon": "fa-graduation-cap",
+    "server_route": "civicrm/admin/roles",
+    "permission": "cms:administer users",
+    "navigation": {
+        "parent": "Administer",
+        "label": "User Roles",
+        "weight": 0
+    },
+    "requires": [],
+    "is_dashlet": false,
+    "is_public": false,
+    "is_token": false,
+    "entity_type": null,
+    "join_entity": null,
+    "contact_summary": null,
+    "summary_contact_type": null,
+    "redirect": null,
+    "create_submission": null
+}
diff --git a/ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php b/ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php
new file mode 100644 (file)
index 0000000..692ea56
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+use CRM_Standaloneusers_ExtensionUtil as E;
+
+return [
+  [
+    'name' => 'SavedSearch_Roles',
+    'entity' => 'SavedSearch',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Roles',
+        'label' => E::ts('Roles'),
+        'form_values' => NULL,
+        'mapping_id' => NULL,
+        'search_custom_id' => NULL,
+        'api_entity' => 'Role',
+        'api_params' => [
+          'version' => 4,
+          'select' => [
+            'id',
+            'label',
+            'is_active',
+          ],
+          'orderBy' => [],
+          'where' => [],
+          'groupBy' => [],
+          'join' => [],
+          'having' => [],
+        ],
+        'expires_date' => NULL,
+        'description' => NULL,
+      ],
+      'match' => [
+        'name',
+      ],
+    ],
+  ],
+  [
+    'name' => 'SavedSearch_Roles_SearchDisplay_Roles_Table_1',
+    'entity' => 'SearchDisplay',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Roles_Table_1',
+        'label' => E::ts('Roles Table 1'),
+        'saved_search_id.name' => 'Roles',
+        'type' => 'table',
+        'settings' => [
+          'description' => NULL,
+          'sort' => [],
+          'limit' => 50,
+          'pager' => [],
+          'placeholder' => 5,
+          'columns' => [
+            [
+              'type' => 'field',
+              'key' => 'label',
+              'dataType' => 'String',
+              'label' => E::ts('Label'),
+              'sortable' => TRUE,
+              'link' => [
+                'path' => '/civicrm/admin/role#?Role1=[id]',
+                'entity' => '',
+                'action' => '',
+                'join' => '',
+                'target' => '',
+              ],
+            ],
+            [
+              'type' => 'field',
+              'key' => 'is_active',
+              'dataType' => 'Boolean',
+              'label' => E::ts('Active'),
+              'sortable' => TRUE,
+              'rewrite' => '',
+              'alignment' => '',
+            ],
+          ],
+          'actions' => TRUE,
+          'classes' => [
+            'table',
+            'table-striped',
+          ],
+        ],
+        'acl_bypass' => FALSE,
+      ],
+      'match' => [
+        'name',
+        'saved_search_id',
+      ],
+    ],
+  ],
+];
index 35a3b2c9940628f556d7f98295b79277c7b1635d..4c0e0d0abcc92ca379f19b0991cb1ba07f9e53aa 100644 (file)
@@ -27,6 +27,9 @@
     <type>varchar</type>
     <length>60</length>
     <required>true</required>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
 
   <field>
@@ -35,6 +38,9 @@
     <type>varchar</type>
     <length>128</length>
     <required>true</required>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
 
   <field>