Skip to content

Commit 3973d8a

Browse files
committed
Show loaders while oauth and loading forms is not completed;
Remove LoadForms from promise to prevent double loading of forms list
1 parent 583ee0e commit 3973d8a

File tree

4 files changed

+40
-21
lines changed

4 files changed

+40
-21
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function configurationController($scope, notificationsService, umbracoCmsIntegrationsCrmDynamicsResource) {
22
var vm = this;
3+
vm.oauthInitialized = false;
34

45
vm.oauthConfig = {};
56

@@ -14,6 +15,8 @@
1415
if (typeof $scope.connected === "undefined")
1516
notificationsService.error("Dynamics Configuration", response.message);
1617
}
18+
}).finally(function () {
19+
vm.oauthInitialized = true;
1720
});
1821

1922
vm.onConnectClick = function () {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
vm.selectedForm = {};
88
vm.iframeEmbedded = false;
99
vm.isConnected = false;
10+
vm.formsLoading = true;
1011

1112
umbracoCmsIntegrationsCrmDynamicsResource.checkOAuthConfiguration().then(function (response) {
12-
if (response.isAuthorized) {
13-
loadForms();
14-
} else {
13+
if (!response.isAuthorized) {
1514
let error = "Unable to connect to Dynamics. Please review the settings of the form picker property's data type.";
1615
notificationsService.error("Dynamics API", error);
1716
vm.error = error;
@@ -67,6 +66,7 @@
6766

6867
function loadForms() {
6968
vm.loading = true;
69+
vm.formsLoading = true;
7070
umbracoCmsIntegrationsCrmDynamicsResource.getForms().then(function (response) {
7171
vm.dynamicsFormsList = [];
7272
if (response) {
@@ -79,7 +79,10 @@
7979
});
8080
});
8181
}
82+
83+
}).finally(function () {
8284
vm.loading = false;
85+
vm.formsLoading = false;
8386
});
8487
}
8588

Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
<div ng-controller="Umbraco.Cms.Integrations.Crm.Dynamics.ConfigurationController as vm">
2-
<p ng-if="vm.oauthConfig && vm.oauthConfig.isConnected"><b>Connected:</b> {{ vm.oauthConfig.fullName }} </p>
3-
<p ng-if="!vm.oauthConfig || !vm.oauthConfig.isConnected"><b>Disconnected</b></p>
4-
<div>
5-
<umb-button action="vm.onConnectClick()"
6-
type="button"
7-
button-style="primary"
8-
state="init"
9-
label="Connect"
10-
disabled="vm.oauthConfig.isConnected">
11-
</umb-button>
12-
<umb-button action="vm.onRevokeToken()"
13-
type="button"
14-
button-style="danger"
15-
state="init"
16-
label="Revoke"
17-
disabled="!vm.oauthConfig.isConnected">
18-
</umb-button>
2+
3+
<umb-box-content style="height: 50px; position: relative;" ng-if="!vm.oauthInitialized">
4+
<umb-load-indicator />
5+
</umb-box-content>
6+
7+
<div ng-if="vm.oauthInitialized">
8+
<p ng-if="vm.oauthConfig && vm.oauthConfig.isConnected"><b>Connected:</b> {{ vm.oauthConfig.fullName }} </p>
9+
<p ng-if="!vm.oauthConfig || !vm.oauthConfig.isConnected"><b>Disconnected</b></p>
10+
<div>
11+
<umb-button action="vm.onConnectClick()"
12+
type="button"
13+
button-style="primary"
14+
state="init"
15+
label="Connect"
16+
disabled="vm.oauthConfig.isConnected">
17+
</umb-button>
18+
<umb-button action="vm.onRevokeToken()"
19+
type="button"
20+
button-style="danger"
21+
state="init"
22+
label="Revoke"
23+
disabled="!vm.oauthConfig.isConnected">
24+
</umb-button>
25+
</div>
1926
</div>
2027
</div>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
<umb-editor-container>
44
<umb-box>
55
<umb-box-header title="{{ model.title }}" description="{{ model.subtitle }}"></umb-box-header>
6-
<umb-box-content>
6+
7+
<umb-box-content style="height: 50px; position: relative;" ng-if="vm.formsLoading && !vm.isConnected">
8+
<umb-load-indicator />
9+
</umb-box-content>
10+
11+
<umb-box-content ng-if="!vm.formsLoading">
12+
713
<div class="dynOverlayGroup" ng-if="vm.isConnected">
814
<div class="form-search">
915
<i class="icon-search"></i>

0 commit comments

Comments
 (0)