mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +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
|
|
@ -1,38 +0,0 @@
|
|||
(rl => {
|
||||
if (rl) {
|
||||
addEventListener('rl-view-model', e => {
|
||||
if ('SettingsContacts' === e.detail.viewModelTemplateID) {
|
||||
const container = e.detail.viewModelDom.querySelector('.form-horizontal');
|
||||
if (container) {
|
||||
rl.pluginRemoteRequest((iError, oData) => {
|
||||
if (!iError) {
|
||||
const mainDivElement = Element.fromHTML('<div class="control-group">'
|
||||
+ '<label>' + rl.i18n("NEXTCLOUD/ADDRESS_BOOK") + '</label>'
|
||||
+ '</div>');
|
||||
|
||||
const selectElement = Element.fromHTML('<select></select>');
|
||||
|
||||
const books = JSON.parse(oData.Result.addressbooks);
|
||||
books.forEach(book => {
|
||||
if (book.selected) {
|
||||
selectElement.append(Element.fromHTML('<option value="' + book.uri + '" selected="selected">' + book.name + '</option>'));
|
||||
} else {
|
||||
selectElement.append(Element.fromHTML('<option value="' + book.uri + '">' + book.name + '</option>'));
|
||||
}
|
||||
});
|
||||
|
||||
selectElement.onchange = function() {
|
||||
rl.pluginRemoteRequest(() => { }, 'NextcloudUpdateAddressBook', {
|
||||
uri: selectElement.value
|
||||
});
|
||||
}
|
||||
|
||||
mainDivElement.append(selectElement);
|
||||
container.append(mainDivElement);
|
||||
}
|
||||
}, "NextcloudGetAddressBooks");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})(window.rl);
|
||||
|
|
@ -13,14 +13,16 @@
|
|||
addEventListener('rl-view-model', e => {
|
||||
if ('SystemDropDown' === e.detail.viewModelTemplateID) {
|
||||
const container = e.detail.viewModelDom.querySelector('.dropdown-menu');
|
||||
if (container) {
|
||||
for (i = 0; i < container.children.length; i++) {
|
||||
const element = container.children[i];
|
||||
const attr = element.getAttribute("data-bind");
|
||||
if (attr && attr.includes("visible: allowContacts")) {
|
||||
element.remove();
|
||||
break;
|
||||
}
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < container.children.length; i++) {
|
||||
const element = container.children[i];
|
||||
const attr = element.getAttribute("data-bind");
|
||||
if (attr && attr.includes("visible: allowContacts")) {
|
||||
element.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,14 +31,16 @@
|
|||
addEventListener('rl-view-model', e => {
|
||||
if ('PopupsCompose' === e.detail.viewModelTemplateID) {
|
||||
const container = e.detail.viewModelDom.querySelector('.pull-right');
|
||||
if (container) {
|
||||
for (i = 0; i < container.children.length; i++) {
|
||||
const element = container.children[i];
|
||||
const attr = element.getAttribute("data-bind");
|
||||
if (attr && attr.includes("visible: allowContacts")) {
|
||||
element.remove();
|
||||
break;
|
||||
}
|
||||
if(!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < container.children.length; i++) {
|
||||
const element = container.children[i];
|
||||
const attr = element.getAttribute("data-bind");
|
||||
if (attr && attr.includes("visible: allowContacts")) {
|
||||
element.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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