Afform - Add 'Placement' colum to admin screen
authorColeman Watts <coleman@civicrm.org>
Tue, 18 May 2021 17:37:43 +0000 (13:37 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 20 May 2021 12:23:52 +0000 (08:23 -0400)
ext/afform/admin/ang/afAdmin.js
ext/afform/admin/ang/afAdmin/afAdminList.controller.js
ext/afform/admin/ang/afAdmin/afAdminList.html
ext/afform/core/Civi/Api4/Afform.php

index a298306d32e8d5e17a765caa226c7b33f5409c35..50f1715be4e11ef5030b309c6e6769412b937b66 100644 (file)
@@ -11,7 +11,7 @@
           // Load data for lists
           afforms: function(crmApi4) {
             return crmApi4('Afform', 'get', {
-              select: ['name', 'title', 'type', 'is_public', 'server_route', 'has_local', 'has_base'],
+              select: ['name', 'title', 'type', 'server_route', 'has_local', 'has_base', 'is_dashlet', 'contact_summary:label'],
               orderBy: {title: 'ASC'}
             });
           }
index f966af174689cfd2d8891751c41c154e061da544..d0b123bcef41d9e7ce927835c3dcdc0802512a62 100644 (file)
 
     this.afforms = _.transform(afforms, function(afforms, afform) {
       afform.type = afform.type || 'system';
+      // Aggregate a couple fields for the "Placement" column
+      afform.placement = [];
+      if (afform.is_dashlet) {
+        afform.placement.push(ts('Dashboard'));
+      }
+      if (afform['contact_summary:label']) {
+        afform.placement.push(afform['contact_summary:label']);
+      }
       afforms[afform.type] = afforms[afform.type] || [];
       afforms[afform.type].push(afform);
     }, {});
index 276e4d0538ba315ee5ea00e18deff2accba4f3f2..b8a1cca650c63809e47eedc48936359a827ac26e 100644 (file)
       <th>{{:: ts('Title') }}</th>
       <th>{{:: ts('Name') }}</th>
       <th>{{:: ts('Page') }}</th>
-      <th>{{:: ts('Style') }}</th>
+      <th>{{:: ts('Placement') }}</th>
       <th></th>
     </tr>
     </thead>
     <tbody>
     <tr ng-repeat="afform in $ctrl.afforms[$ctrl.tab] | filter:$ctrl.searchAfformList">
-      <td>{{afform.title}}</td>
+      <td>{{ afform.title }}</td>
       <td>
-        <code>{{afform.name}}</code>
+        <code>{{ afform.name }}</code>
       </td>
       <td>
         <a ng-if="afform.server_route" ng-href="{{ crmUrl(afform.server_route) }}" target="_blank">
-          <code>{{afform.server_route}}</code>
+          <code>{{ afform.server_route }}</code>
         </a>
       </td>
-      <td>{{afform.is_public ? ts('Frontend') : ts('Backend')}}</td>
+      <td>{{ afform.placement.join(', ') }}</td>
       <td class="text-right">
-        <a ng-if="afform.type !== 'system'" href="#/edit/{{ afform.name }}" class="btn btn-xs btn-primary">{{ ts('Edit') }}</a>
-        <a ng-if="afform.type !== 'system'" href="#/clone/{{ afform.name }}" class="btn btn-xs btn-primary">{{ ts('Clone') }}</a>
+        <a ng-if="afform.type !== 'system'" href="#/edit/{{ afform.name }}" class="btn btn-xs btn-primary">{{:: ts('Edit') }}</a>
+        <a ng-if="afform.type !== 'system'" href="#/clone/{{ afform.name }}" class="btn btn-xs btn-primary">{{:: ts('Clone') }}</a>
         <a href ng-if="afform.has_local" class="btn btn-xs btn-danger" crm-confirm="{type: afform.has_base ? 'revert' : 'delete', obj: afform}" on-yes="$ctrl.revert(afform)">
           {{ afform.has_base ? ts('Revert') : ts('Delete') }}
         </a>
index 7c63c31e51dff844d8aa962a7d727c896e5b6e15..d498937353ac5e39cb98d86b01460089cdfe9e19 100644 (file)
@@ -161,6 +161,10 @@ class Afform extends Generic\AbstractEntity {
         [
           'name' => 'contact_summary',
           'data_type' => 'String',
+          'options' => [
+            'block' => ts('Contact Summary Block'),
+            'tab' => ts('Contact Summary Tab'),
+          ],
         ],
         [
           'name' => 'repeat',