CRM-16173 - crmCxn - When reconnecting, display the *new* details/permissions.
authorCiviCRM <info@civicrm.org>
Sat, 19 Dec 2015 04:08:46 +0000 (20:08 -0800)
committerCiviCRM <info@civicrm.org>
Sat, 19 Dec 2015 04:15:38 +0000 (20:15 -0800)
ang/crmCxn/ConfirmReconnectCtrl.html
ang/crmCxn/ManageCtrl.html
ang/crmCxn/ManageCtrl.js

index 04f7252c6bf42e7955d9aa5f2dbcb20117770396..0b60bd8792b0776c2a5aafcd9d72267af1a351b7 100644 (file)
@@ -1,5 +1,5 @@
 <div ng-controller="CrmCxnConfirmReconnectCtrl">
-  <p>{{ts('Are you sure you want to reconnect \"%1\"?', {1: cxn.app_meta.title})}}</p>
+  <p>{{ts('Are you sure you want to reconnect \"%1\"?', {1: appMeta.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>
 
@@ -7,16 +7,17 @@
     <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>
+    <li>{{ts('After the application has a major failure or reset.')}}</li>
   </ul>
 
   <div crm-ui-accordion="{title: ts('Permissions: Summary'), collapsed: true}">
-    <div ng-bind-html="cxn.app_meta.perm.desc"></div>
+    <div ng-bind-html="appMeta.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 crm-cxn-perm-table="{perm: appMeta.perm}"></div>
   </div>
   <div crm-ui-accordion="{title: ts('Advanced'), collapsed: true}">
-    <div crm-cxn-adv-table="{appMeta: cxn.app_meta}"></div>
+    <div crm-cxn-adv-table="{appMeta: appMeta}"></div>
   </div>
 
 </div>
index 032bc3160d579b7344ba24fd294c366dbd99950e..9fd99a57aba2f045503dc5f98f7e155dbe9fd769 100644 (file)
@@ -55,7 +55,7 @@
                 </li>
                 <li>
                   <a class="action-item crm-hover-button"
-                     crm-confirm='{width: "65%", resizable: true, title:ts("%1: Reconnect", {1: cxn.app_meta.title}), templateUrl: "~/crmCxn/ConfirmReconnectCtrl.html", export: {cxn: cxn}}'
+                     crm-confirm='{width: "65%", resizable: true, title:ts("%1: Reconnect", {1: cxn.app_meta.title}), templateUrl: "~/crmCxn/ConfirmReconnectCtrl.html", export: {cxn: cxn, appMeta: findAppByAppId(cxn.app_guid)}}'
                      on-yes="reregister(cxn.app_meta)"
                       >{{ts('Reconnect')}}</a>
                 </li>
index f8929e5895e8be07e4e77d97cd9384f8384aca1e..97615f0fb83eb24c5ae2484944b017d31b7795e9 100644 (file)
       crmUiAlert({text: alert.message, title: alert.title, type: 'error'});
     });
 
-    $scope.findCxnByAppId = function(appId) {
-      var result = _.where($scope.cxns, {
-        app_guid: appId
-      });
+    // Convert array [x] to x|null|error
+    function asOne(result, msg) {
       switch (result.length) {
         case 0:
           return null;
         case 1:
           return result[0];
         default:
-          throw "Error: Too many connections for appId: " + appId;
+          throw msg;
       }
+    }
+
+    $scope.findCxnByAppId = function(appId) {
+      var result = _.where($scope.cxns, {
+        app_guid: appId
+      });
+      return asOne(result, "Error: Too many connections for appId: " + appId);
+    };
+
+    $scope.findAppByAppId = function(appId) {
+      var result = _.where($scope.appMetas, {
+        appId: appId
+      });
+      return asOne(result, "Error: Too many apps for appId: " + appId);
     };
 
     $scope.hasAvailApps = function() {