mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
chore: refactor nexcloud plugin- related to NC-addressbook
This commit is contained in:
parent
2e3fbe0a12
commit
552a91acc2
5 changed files with 200 additions and 163 deletions
42
plugins/nextcloud/js/nextcloudAddressbook.js
Normal file
42
plugins/nextcloud/js/nextcloudAddressbook.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
(rl => {
|
||||
if (rl) {
|
||||
addEventListener('rl-view-model', e => {
|
||||
if ('SettingsContacts' === e.detail.viewModelTemplateID) {
|
||||
const container = e.detail.viewModelDom.querySelector('.form-horizontal');
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
rl.pluginRemoteRequest((iError, oData) => {
|
||||
if (iError) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mainDivElement = Element.fromHTML('<div class="control-group">'
|
||||
+ '<label>' + rl.i18n("NEXTCLOUD/ADDRESS_BOOK") + '</label>'
|
||||
+ '</div>');
|
||||
|
||||
const selectElement = Element.fromHTML('<select></select>');
|
||||
|
||||
const addressbooks = JSON.parse(oData.Result.addressbooks);
|
||||
addressbooks.forEach(addressbook => {
|
||||
if (addressbook.selected) {
|
||||
selectElement.append(Element.fromHTML('<option value="' + addressbook.uri + '" selected="selected">' + addressbook.name + '</option>'));
|
||||
} else {
|
||||
selectElement.append(Element.fromHTML('<option value="' + addressbook.uri + '">' + addressbook.name + '</option>'));
|
||||
}
|
||||
});
|
||||
|
||||
selectElement.onchange = function() {
|
||||
rl.pluginRemoteRequest(() => { }, 'NextcloudUpdateAddressBook', {
|
||||
uri: selectElement.value
|
||||
});
|
||||
}
|
||||
|
||||
mainDivElement.append(selectElement);
|
||||
container.append(mainDivElement);
|
||||
}, "NextcloudGetAddressBooks");
|
||||
}
|
||||
});
|
||||
}
|
||||
})(window.rl);
|
||||
Loading…
Add table
Add a link
Reference in a new issue