crmCxn - Add "Reconnect" option
authorTim Otten <totten@civicrm.org>
Sat, 5 Dec 2015 21:31:49 +0000 (13:31 -0800)
committerTim Otten <totten@civicrm.org>
Sun, 6 Dec 2015 01:14:30 +0000 (17:14 -0800)
ang/crmCxn/ConfirmReconnectCtrl.html [new file with mode: 0644]
ang/crmCxn/ConfirmReconnectCtrl.js [new file with mode: 0644]
ang/crmCxn/ManageCtrl.html
ang/crmCxn/ManageCtrl.js

diff --git a/ang/crmCxn/ConfirmReconnectCtrl.html b/ang/crmCxn/ConfirmReconnectCtrl.html
new file mode 100644 (file)
index 0000000..d9555d4
--- /dev/null
@@ -0,0 +1,18 @@
+<div ng-controller="CrmCxnConfirmReconnectCtrl">
+  <p>{{ts('Are you sure you want to reconnect \"%1\"?', {1: cxn.app_meta.title})}}</p>
+
+  <p>{{ts('Reconnecting will change the connection details (such as callback URLs and permissions). This can be useful in a few cases, such as:')}}</p>
+
+  <ul>
+    <li>{{ts('After your site has migrated to a new URL.')}}</li>
+    <li>{{ts('After the application has migrated to a new URL.')}}</li>
+    <li>{{ts('After the application has changed permission requirements.')}}</li>
+  </ul>
+
+  <div crm-ui-accordion="{title: ts('Permissions: Summary'), collapsed: true}">
+    <div ng-bind-html="cxn.app_meta.perm.desc"></div>
+  </div>
+  <div crm-ui-accordion="{title: ts('Permissions: Details'), collapsed: true}">
+    <div crm-cxn-perm-table="{perm: cxn.app_meta.perm}"></div>
+  </div>
+</div>
diff --git a/ang/crmCxn/ConfirmReconnectCtrl.js b/ang/crmCxn/ConfirmReconnectCtrl.js
new file mode 100644 (file)
index 0000000..211d415
--- /dev/null
@@ -0,0 +1,5 @@
+(function(angular, $, _) {
+  angular.module('crmCxn').controller('CrmCxnConfirmReconnectCtrl', function($scope) {
+    $scope.ts = CRM.ts(null);
+  });
+})(angular, CRM.$, CRM._);
index b60d68eef44e3732f530e272d86ed1350b86a1b8..b65c27635b3f8ad8f68b6af91d06b388c3df3fb1 100644 (file)
                     {{ts('Support')}}
                   </a>
                 </li>
+                <li>
+                  <a class="action-item crm-hover-button"
+                     crm-confirm='{width: "65%", resizable: true, title:ts("Reconnect"), templateUrl: "~/crmCxn/ConfirmReconnectCtrl.html", export: {cxn: cxn}}'
+                     on-yes="reregister(cxn.app_meta)"
+                      >{{ts('Reconnect')}}</a>
+                </li>
                 <li>
                   <a class="action-item crm-hover-button"
                      crm-confirm='{width: "65%", resizable: true, title: ts("Disconnect"), message: ts("Are you sure you want to disconnect \"%1?\". Doing so may permanently destroy data linkage.", {1: cxn.app_meta.title})}'
index 9e7d127c7545da1c1cb6ec056c19af38b79c1137..f8929e5895e8be07e4e77d97cd9384f8384aca1e 100644 (file)
       return block(crmStatus({start: ts('Connecting...'), success: ts('Connected')}, reg));
     };
 
+    $scope.reregister = function(appMeta) {
+      var reg = crmApi('Cxn', 'register', {app_guid: appMeta.appId}).then($scope.refreshCxns);
+      return block(crmStatus({start: ts('Reconnecting...'), success: ts('Reconnected')}, reg));
+    };
+
     $scope.unregister = function(appMeta) {
       var reg = crmApi('Cxn', 'unregister', {app_guid: appMeta.appId, debug: 1}).then($scope.refreshCxns);
       return block(crmStatus({start: ts('Disconnecting...'), success: ts('Disconnected')}, reg));