Skip to content

Commit b521e6f

Browse files
committed
Event listener updates, UI and bug fixes.
1 parent c5daefd commit b521e6f

File tree

3 files changed

+51
-50
lines changed

3 files changed

+51
-50
lines changed

src/Umbraco.Cms.Integrations.Search.Algolia/App_Plugins/UmbracoCms.Integrations/Search/Algolia/css/algolia.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@
2020
padding: var(--uui-size-layout-4);
2121
}
2222

23-
2423
.alg-dialog {
2524
display: none;
2625
left: 50%;
2726
top: 50%;
2827
position: absolute;
2928
transform: translate(-70%,-70%);
3029
z-index: 1;
30+
}
31+
32+
.alg-description {
33+
color: #515054;
34+
font-size: 12px;
35+
box-sizing: border-box;
36+
resize: none;
37+
width: 100%;
3138
}

src/Umbraco.Cms.Integrations.Search.Algolia/App_Plugins/UmbracoCms.Integrations/Search/Algolia/js/dashboard.controller.js

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
vm.addIndex = addIndex;
1919
vm.saveIndex = saveIndex;
2020
vm.viewIndex = viewIndex;
21-
vm.buildIndex = buildIndex;
21+
vm.buildIndexConfirm = buildIndexConfirm;
2222
vm.searchIndex = searchIndex;
2323
vm.deleteIndex = deleteIndex;
2424
vm.search = search;
@@ -65,6 +65,7 @@
6565
],
6666
contentData: [],
6767
showProperties: function (contentType) {
68+
6869
this.selectedContentType = contentType;
6970

7071
algoliaService.getPropertiesByContentTypeId(contentType.id, (response) => {
@@ -82,10 +83,6 @@
8283
}
8384
});
8485
},
85-
hideProperties: function () {
86-
this.selectedContentType = {};
87-
this.propertiesList = [];
88-
},
8986
removeContentType: function (contentType) {
9087

9188
const contentTypeIndex = this.contentData.map(obj => obj.contentType.alias).indexOf(contentType.alias);
@@ -248,7 +245,7 @@
248245
});
249246
}
250247

251-
function buildIndex(index) {
248+
function buildIndexConfirm(index) {
252249
vm.showBuildDialog(index);
253250
}
254251

@@ -358,35 +355,39 @@
358355
btnCancel.addEventListener('click', closeBuildDialog);
359356

360357
var btnBuild = dialog.querySelector('#btnBuild');
361-
btnBuild.addEventListener('click', function () {
362-
vm.loading = true;
363-
364-
umbracoCmsIntegrationsSearchAlgoliaResource.buildIndex(index.id).then(function (response) {
365-
if (response.failure) {
366-
vm.showToast({
367-
color: 'warning',
368-
headline: 'Algolia',
369-
message: 'An error has occurred while building the index: ' + response.error
370-
});
371-
}
372-
else {
373-
vm.showToast({
374-
color: 'positive',
375-
headline: 'Algolia',
376-
message: 'Index built successfully'
377-
});
378-
vm.loading = false;
379-
}
380-
});
381-
382-
closeBuildDialog();
383-
});
358+
btnBuild.removeEventListener('click', buildIndex);
359+
btnBuild.addEventListener('click', buildIndex, false);
360+
btnBuild.indexId = index.id;
384361
}
385362

386363
function closeBuildDialog() {
387364
const dialog = document.getElementById('buildDialog');
388365
dialog.style.display = "none";
389366
}
367+
368+
function buildIndex(event) {
369+
vm.loading = true;
370+
371+
umbracoCmsIntegrationsSearchAlgoliaResource.buildIndex(event.currentTarget.indexId).then(function (response) {
372+
if (response.failure) {
373+
vm.showToast({
374+
color: 'warning',
375+
headline: 'Algolia',
376+
message: 'An error has occurred while building the index: ' + response.error
377+
});
378+
}
379+
else {
380+
vm.showToast({
381+
color: 'positive',
382+
headline: 'Algolia',
383+
message: 'Index built successfully'
384+
});
385+
vm.loading = false;
386+
}
387+
});
388+
389+
closeBuildDialog();
390+
}
390391
}
391392

392393
angular.module("umbraco")

src/Umbraco.Cms.Integrations.Search.Algolia/App_Plugins/UmbracoCms.Integrations/Search/Algolia/views/dashboard.html

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h5>Manage Algolia Indices</h5>
5555
<uui-button label="edit" look="default" color="default" ng-click="vm.viewIndex(index)">
5656
<uui-icon name="edit"></uui-icon>
5757
</uui-button>
58-
<uui-button label="build" look="default" color="danger" ng-click="vm.buildIndex(index)">
58+
<uui-button label="build" look="default" color="danger" ng-click="vm.buildIndexConfirm(index)">
5959
<uui-icon name="sync"></uui-icon>
6060
</uui-button>
6161
<uui-button label="search" look="default" color="positive" ng-click="vm.searchIndex(index)">
@@ -84,34 +84,29 @@ <h5>Manage Algolia Indices</h5>
8484
<form id="manageIndexFrm" name="manageIndexFrm">
8585
<uui-form-layout-item>
8686
<uui-label slot="label" for="inName" required="">Name</uui-label>
87+
<span class="alg-description" slot="description">Please enter a name for the index. After save,<br /> you will not be able to change it.</span>
8788
<div>
88-
<input type="text" ng-model="vm.manageIndex.name" />
89+
<input type="text" ng-model="vm.manageIndex.name" ng-disabled="vm.manageIndex.id != 0" style="width:17%" no-dirty-check />
8990
</div>
9091
</uui-form-layout-item>
9192

9293
<div class="alg-col-2">
9394
<uui-form-layout-item>
9495
<uui-label slot="label">Document Types</uui-label>
95-
<span slot="description">Please select the document types you would like to index, and choose the fields to include.</span>
96+
<span class="alg-description" slot="description">Please select the document types you would like to index, and choose the fields to include.</span>
9697
<uui-icon-registry-essential>
97-
<uui-ref-node selectable
98+
<uui-ref-node id="{{ contentType.alias }}"
9899
ng-attr-selected="{{contentType.selected || undefined}}"
99100
ng-repeat="contentType in vm.manageIndex.contentTypesList"
100-
ng-on-selected="vm.manageIndex.showProperties(contentType)"
101-
ng-on-unselected="vm.manageIndex.hideProperties()"
102-
name="{{ contentType.name }}"
103-
detail="{{ contentType.alias }}">
101+
ng-on-open="vm.manageIndex.showProperties(contentType)"
102+
name="{{ contentType.name }}">
104103
<umb-icon slot="icon" icon="{{ contentType.icon }}"></umb-icon>
105-
<uui-tag ng-if="contentType.selected" size="s" slot="tag" color="positive">Selected</uui-tag>
104+
<uui-tag ng-if="contentType.selected" size="s" slot="tag" color="primary">Selected</uui-tag>
106105
<uui-action-bar slot="actions">
107-
<uui-button label="Choose properties"
108-
color="positive"
109-
ng-click="vm.manageIndex.showProperties(contentType)">
110-
<uui-icon name="see"></uui-icon>
111-
</uui-button>
112106
<uui-button label="Remove"
113107
color="danger"
114-
ng-if="contentType.allowRemove">
108+
ng-if="contentType.allowRemove"
109+
ng-click="vm.manageIndex.removeContentType(contentType)">
115110
<uui-icon name="delete"></uui-icon>
116111
</uui-button>
117112
</uui-action-bar>
@@ -128,9 +123,8 @@ <h5>Manage Algolia Indices</h5>
128123
ng-on-unselected="vm.manageIndex.removeProperty(property)"
129124
ng-repeat="property in vm.manageIndex.propertiesList"
130125
name="{{ property.name }}">
131-
<uui-tag ng-if="property.selected" size="s" slot="tag" color="positive">Selected</uui-tag>
126+
<uui-tag ng-if="property.selected" size="s" slot="tag" color="primary">Selected</uui-tag>
132127
<ul style="list-style: none; padding-inline-start: 0px; margin: 0;">
133-
<li><span style="font-weight: 700">Alias:</span> {{ property.alias }}</li>
134128
<li><span style="font-weight: 700">Group: </span> {{ property.group }}</li>
135129
</ul>
136130
</uui-card-content-node>
@@ -160,8 +154,7 @@ <h5>Manage Algolia Indices</h5>
160154
<form id="searchFrm" name="searchFrm">
161155
<uui-form-layout-item>
162156
<div>
163-
<uui-input id="inSearch" type="text" name="indexName" placeholder="" label="search" ng-model="vm.searchQuery" style="width: 50%">
164-
</uui-input>
157+
<input type="text" ng-model="vm.searchQuery" class="mt2" style="width:50%" no-dirty-check />
165158
<uui-icon-registry-essential>
166159
<uui-button type="button" label="Search" look="primary" color="positive" ng-click="vm.search()">
167160
<uui-icon name="search"></uui-icon>
@@ -188,7 +181,7 @@ <h5>Manage Algolia Indices</h5>
188181
</div>
189182

190183
<!-- Notifications -->
191-
<uui-toast-notification-container auto-close="5000" bottom-up="" class="alg-toast">
184+
<uui-toast-notification-container auto-close="3000" bottom-up="" class="alg-toast">
192185
</uui-toast-notification-container>
193186

194187
<uui-icon-registry-essential>

0 commit comments

Comments
 (0)