Export UI - Only present "save mapping" button to permissioned users
authorColeman Watts <coleman@civicrm.org>
Thu, 4 Mar 2021 21:53:21 +0000 (16:53 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 4 Mar 2021 21:53:21 +0000 (16:53 -0500)
The button was showing for all users which would result in confusion when it didn't work because they lacked permission.
Currently the APIv3 Mapping.create api requires "administer CiviCRM." I don't know if that's right or if there's another
permission it ought to be checking, but at least this brings the UI in alignment with what's currently allowed.

ang/exportui.ang.php
ang/exportui/export.html
ang/exportui/exportui.js

index cb0871ed30735901d4b58beb8aefb4708bc1dfb7..f340a018f60a02983d0f18fe8ccd25d227681e7a 100644 (file)
@@ -13,6 +13,7 @@ return [
     'ang/exportui',
   ],
   'basePages' => [],
+  'permissions' => ['administer CiviCRM'],
   'requires' => [
     'crmUi',
     'crmUtil',
index 8a3e0936194b887d3c75ae89feffce782d252093..2cca22fc9ebbfd329bcf1f6f721c6d1e8d864ba2 100644 (file)
@@ -19,7 +19,7 @@
     <tr>
       <td colspan="6">
         <input class="crm-action-menu fa-plus crm-export-add-field" crm-ui-select="{data: getFields, placeholder: ts('Add field')}" ng-model="new.col" />
-        <span ng-if="data.columns.length">
+        <span ng-if="data.columns.length && perms.admin">
           <button type="button" ng-click="saveMappingDialog()" crm-icon="fa-save">
             {{:: ts('Save Fields') }}
           </button>
index 88bb01a268a131dde8127d94e16e2eb93a537e4b..91a8ee5e7316526049049cfb78499c7bfd1fd395 100644 (file)
@@ -22,6 +22,9 @@
       contact_type: '',
       columns: []
     };
+    $scope.perms = {
+      admin: CRM.checkPerm('administer CiviCRM')
+    };
     // For the "add new field" dropdown
     $scope.new = {col: ''};
     var contactTypes = _.transform($scope.contact_types, function(result, type) {