CRM-19169 - ang/crmCxn - If `welcome` link defined, open it
authorTim Otten <totten@civicrm.org>
Wed, 3 Aug 2016 02:00:21 +0000 (19:00 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 3 Aug 2016 02:00:21 +0000 (19:00 -0700)
ang/crmCxn.js
ang/crmCxn/ManageCtrl.js

index 2d2193959a82c64023e7bdf9ea04512ddf641067..c2fa6ec28785c1d5082091472c6c1d1e22528109 100644 (file)
@@ -14,7 +14,7 @@
           apiCalls: function(crmApi){
             var reqs = {};
             reqs.cxns = ['Cxn', 'get', {sequential: 1}];
-            reqs.appMetas = ['CxnApp', 'get', {sequential: 1, return: ['id', 'title', 'desc', 'appId', 'appUrl', 'perm']}];
+            reqs.appMetas = ['CxnApp', 'get', {sequential: 1, return: ['id', 'title', 'desc', 'appId', 'appUrl', 'links', 'perm']}];
             reqs.cfg = ['Cxn', 'getcfg', {}];
             reqs.sysCheck = ['System', 'check', {}]; // FIXME: filter on checkCxnOverrides
             return crmApi(reqs);
index b23901b0cf4fc6413309efbbed114d641361e6d3..cd843c3304ae7a70508bef764e9dbff60be9131c 100644 (file)
     };
 
     $scope.register = function(appMeta) {
-      var reg = crmApi('Cxn', 'register', {app_guid: appMeta.appId}).then($scope.refreshCxns);
+      var reg = crmApi('Cxn', 'register', {app_guid: appMeta.appId}).then($scope.refreshCxns).then(function() {
+        if (appMeta.links.welcome) {
+          return $scope.openLink(appMeta, 'welcome', {title: ts('%1: Welcome (External)', {1: appMeta.title})});
+        }
+      });
       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);
+      var reg = crmApi('Cxn', 'register', {app_guid: appMeta.appId}).then($scope.refreshCxns).then(function() {
+        if (appMeta.links.welcome) {
+          return $scope.openLink(appMeta, 'welcome', {title: ts('%1: Welcome (External)', {1: appMeta.title})});
+        }
+      });
       return block(crmStatus({start: ts('Reconnecting...'), success: ts('Reconnected')}, reg));
     };