Skip to content

Commit 95051b0

Browse files
committed
OAuth configuration directive
1 parent ecfd797 commit 95051b0

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

src/Umbraco.Cms.Integrations.Crm.Dynamics/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/configuration.controller.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

44
vm.oauthConfig = {};
55

6-
umbracoCmsIntegrationsCrmDynamicsResource.checkOAuthConfiguration().then(function(response) {
6+
umbracoCmsIntegrationsCrmDynamicsResource.checkOAuthConfiguration().then(function (response) {
77
if (response && response.isAuthorized) {
88
vm.oauthConfig.isConnected = true;
99
vm.oauthConfig.fullName = response.fullName;
10+
11+
if (typeof $scope.connected === "function")
12+
$scope.connected();
1013
}
1114
});
1215

@@ -23,6 +26,9 @@
2326
umbracoCmsIntegrationsCrmDynamicsResource.revokeAccessToken().then(function () {
2427
vm.oauthConfig.isConnected = false;
2528
notificationsService.success("Dynamics Configuration", "OAuth connection revoked.");
29+
30+
if (typeof $scope.revoked === "function")
31+
$scope.revoked();
2632
});
2733
}
2834

@@ -41,9 +47,11 @@
4147
umbracoCmsIntegrationsCrmDynamicsResource.getSystemUserFullName().then(function(response) {
4248
vm.oauthConfig.fullName = response;
4349
});
50+
51+
if (typeof $scope.connected === "function")
52+
$scope.connected();
4453
}
4554
});
46-
4755
}
4856
}, false);
4957
}

src/Umbraco.Cms.Integrations.Crm.Dynamics/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/formpicker.controller.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
vm.dynamicsFormsList = [];
77
vm.searchTerm = "";
88
vm.iFrameEmbedded = false;
9+
vm.isConnected = false;
910

1011
umbracoCmsIntegrationsCrmDynamicsResource.checkOAuthConfiguration().then(function (response) {
1112
if (response.isAuthorized) {
@@ -59,6 +60,7 @@
5960
};
6061

6162
function loadForms() {
63+
vm.dynamicsFormsList = [];
6264
umbracoCmsIntegrationsCrmDynamicsResource.getForms().then(function (response) {
6365
if (response) {
6466
response.value.forEach(item => {
@@ -72,6 +74,16 @@
7274
}
7375
});
7476
}
77+
78+
$scope.connected = function () {
79+
vm.isConnected = true;
80+
loadForms();
81+
};
82+
83+
$scope.revoked = function () {
84+
vm.isConnected = false;
85+
vm.dynamicsFormsList = [];
86+
};
7587
}
7688

7789
angular.module("umbraco")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
angular.module("umbraco.directives")
2+
.directive("oauthConfiguration", function () {
3+
return {
4+
restrict: "E",
5+
scope: {
6+
"connected": "&onConnected",
7+
"revoked": "&onRevoked"
8+
},
9+
templateUrl: "/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/views/configuration.html"
10+
}
11+
});

src/Umbraco.Cms.Integrations.Crm.Dynamics/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/package.manifest

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"javascript": [
33
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/configuration.controller.js",
4-
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/formpicker.controller.js",
5-
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/dynamics.resource.js"
4+
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/formpicker.controller.js",
5+
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/dynamics.resource.js",
6+
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/js/oauthconfiguration.directive.js"
67
],
78
"css": [
89
"~/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/css/styles.css"

src/Umbraco.Cms.Integrations.Crm.Dynamics/App_Plugins/UmbracoCms.Integrations/Crm/Dynamics/views/formpickereditor.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
<umb-box-header title="{{ model.title }}" description="{{ model.subtitle }}"></umb-box-header>
66
<umb-box-content>
77
<div class="dynOverlayGroup">
8+
<oauth-configuration on-connected="connected()" on-revoked="revoked()"></oauth-configuration>
9+
</div>
10+
<div class="dynOverlayGroup" ng-if="vm.isConnected">
811
<div class="form-search">
912
<i class="icon-search"></i>
1013
<input type="text" class="-full-width-input" ng-model="vm.searchTerm" placeholder="Type to search..." umb-auto-focus="" aria-invalid="false">
1114
</div>
1215
</div>
13-
<div class="dynOverlayGroup">
16+
<div class="dynOverlayGroup" ng-if="vm.isConnected">
1417
<ul class="dynFormsList">
15-
<li ng-repeat="form in vm.dynamicsFormsList | orderBy:'name' | filter:vm.searchTerm" ng-click="model.selectForm(form, vm.iFrameEmbedded)"
18+
<li ng-repeat="form in vm.dynamicsFormsList | orderBy:'name' | filter:vm.searchTerm" ng-click="model.selectForm(form, vm.iFrameEmbedded)"
1619
class="ng-scope" role="button" tabindex="0">
1720
<a href="" ng-attr-title="form.name">
1821
<i class="icon-umb-contour"></i>
@@ -21,7 +24,7 @@
2124
</li>
2225
</ul>
2326
</div>
24-
<div class="dynOverlayGroup">
27+
<div class="dynOverlayGroup" ng-if="vm.isConnected">
2528
<umb-toggle checked="vm.iFrameEmbedded"
2629
on-click="vm.toggleRenderMode()"
2730
show-labels="true"

src/Umbraco.Cms.Integrations.Crm.Dynamics/Umbraco.Cms.Integrations.Crm.Dynamics.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
</ItemGroup>
5252

5353
<ItemGroup>
54+
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Dynamics\js\oauthConfiguration.directive.js" />
5455
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Dynamics\Render\DynamicsForm.cshtml" />
5556
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Dynamics\Render\DynamicsFormV8.cshtml" />
5657
</ItemGroup>

0 commit comments

Comments
 (0)