af-api4-action - Rename 'msg-' and 'on-' options
authorTim Otten <totten@civicrm.org>
Thu, 12 Sep 2019 23:07:59 +0000 (19:07 -0400)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:19 +0000 (19:13 -0700)
Here's the bash script...

```
for REGEX in \
        s/msg-start/af-api4-start-msg/g \
        s/msgStart/afApi4StartMsg/g \
        s/msg-error/af-api4-error-msg/g \
        s/msgError/afApi4ErrorMsg/g \
        s/msg-success/af-api4-success-msg/g \
        s/msgSuccess/afApi4SuccessMsg/g \
        s/on-success/af-api4-success/g \
        s/onSuccess/afApi4Success/g \
        s/on-error/af-api4-error/g \
        s/on-error/afApi4Error/g
do
  DIRS="core docs gui html mock auditor"
  echo "Processing regex [$REGEX] in [$DIRS]"
  find $DIRS -name '*.js' -o -name '*.html' -o -name '*.json' -o -name '*.md' \
    | grep -v /node_modules/ \
    | xargs -L1 sed -i.bak "$REGEX"
  find $DIRS -name '*.bak' -delete
done
```

ext/afform/core/ang/afCore/Api4Action.js
ext/afform/core/ang/afCore/Api4Action.md
ext/afform/html/ang/afHtmlList.aff.html

index da8ed8d22b8bf3ce64d0ab885d09218727a376d4..20c47c824a58c6308abf59da02c55761eabd98fb 100644 (file)
@@ -5,10 +5,10 @@
       restrict: 'A',
       scope: {
         afApi4Action: '@',
-        msgStart: '=',
-        msgError: '=',
-        msgSuccess: '=',
-        onSuccess: '@',
+        afApi4StartMsg: '=',
+        afApi4ErrorMsg: '=',
+        afApi4SuccessMsg: '=',
+        afApi4Success: '@',
         onError: '@'
       },
       link: function($scope, $el, $attr) {
         running(false);
         $el.click(function(){
           var parts = $parse($scope.afApi4Action)($scope.$parent);
-          var msgs = {start: $scope.msgStart || ts('Submitting...'), success: $scope.msgSuccess, error: $scope.msgError};
+          var msgs = {start: $scope.afApi4StartMsg || ts('Submitting...'), success: $scope.afApi4SuccessMsg, error: $scope.afApi4ErrorMsg};
           running(true);
           crmStatus(msgs, crmApi4(parts[0], parts[1], parts[2]))
             .finally(function(){running(false);})
-            .then(function(response){$scope.$parent.$eval($scope.onSuccess, {response: response});})
+            .then(function(response){$scope.$parent.$eval($scope.afApi4Success, {response: response});})
             .catch(function(error){$scope.$parent.$eval($scope.onError, {error: error});});
         });
       }
index 7e43867850bee301ac2532b95fb3c98f4d3db826..7d62d740ff61b3b97effbc93b1b115fe978026c7 100644 (file)
@@ -17,10 +17,10 @@ trigger further actions on failure or success.
 ```html
 <button
   af-api4-action="['Contact','delete',{where:['id','=','100]}}]"
-  msg-start="ts('Deleting...')"
-  msg-success="ts('Deleted')"
-  on-success="crmUiAlert({text:'Received ' + response.length + ' items'})"
-  on-error="crmUiAlert({text:'Failure: ' + error})"
+  af-api4-start-msg="ts('Deleting...')"
+  af-api4-success-msg="ts('Deleted')"
+  af-api4-success="crmUiAlert({text:'Received ' + response.length + ' items'})"
+  af-api4-error="crmUiAlert({text:'Failure: ' + error})"
 >Delete</button>
 <!-- Automated flag with af-api4-action-{running -->
 ```
index f78ca5362ced379adf4dd1c72a020e9a1615453c..e0e5f950ee203b036576cf107e5c55183f1e60b7 100644 (file)
@@ -27,8 +27,8 @@
       <td>
         <!--<a ng-click="crmStatus({start: ts('Reverting...'), success: ts('Reverted')}, crmApi4('Afform', 'revert', {where: [['name', '=', availForm.name]]}))">{{ts('Revert')}}</a>-->
         <a af-api4-action="['Afform', 'revert', {where: [['name','=', availForm.name]]}]"
-           msg-start="ts('Reverting...')"
-           msg-success="ts('Reverted')"
+           af-api4-start-msg="ts('Reverting...')"
+           af-api4-success-msg="ts('Reverted')"
           >{{ts('Revert')}}</a>
       </td>
     </tr>