mirror of https://github.com/nextcloud/contacts
Store state in db
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
4cc212be06
commit
3a61e22ba6
|
@ -193,7 +193,7 @@ angular.module('contactsApp')
|
|||
};
|
||||
|
||||
ctrl.toggleState = function() {
|
||||
ctrl.enabled = AddressBookService.toggleState(ctrl.addressBook);
|
||||
ctrl.enabled = AddressBookService.toggleState(ctrl.addressBook).enabled;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1620,7 +1620,7 @@ var listAddressBooks = _co2['default'].wrap(regeneratorRuntime.mark(function cal
|
|||
req = request.propfind({
|
||||
props: [{ name: 'displayname', namespace: ns.DAV }, { name: 'owner', namespace: ns.DAV }, { name: 'getctag', namespace: ns.CALENDAR_SERVER }, { name: 'resourcetype', namespace: ns.DAV }, { name: 'sync-token', namespace: ns.DAV }, { name: 'read-only', namespace: ns.OC },
|
||||
//{ name: 'groups', namespace: ns.OC },
|
||||
{ name: 'invite', namespace: ns.OC }],
|
||||
{ name: 'invite', namespace: ns.OC }, { name: 'enabled', namespace: ns.OC }],
|
||||
depth: 1
|
||||
});
|
||||
context$1$0.next = 4;
|
||||
|
|
|
@ -23,7 +23,8 @@ export let listAddressBooks = co.wrap(function *(account, options) {
|
|||
{ name: 'sync-token', namespace: ns.DAV },
|
||||
{ name: 'read-only', namespace: ns.OC },
|
||||
//{ name: 'groups', namespace: ns.OC },
|
||||
{ name: 'invite', namespace: ns.OC }
|
||||
{ name: 'invite', namespace: ns.OC },
|
||||
{ name: 'enabled', namespace: ns.OC }
|
||||
],
|
||||
depth: 1
|
||||
});
|
||||
|
|
|
@ -2,16 +2,14 @@ angular.module('contactsApp')
|
|||
.factory('AddressBook', function()
|
||||
{
|
||||
return function AddressBook(data) {
|
||||
var storageKey = btoa(data.data.href.split('/').splice(-3, 2).join('_'));
|
||||
angular.extend(this, {
|
||||
|
||||
displayName: '',
|
||||
contacts: [],
|
||||
groups: data.data.props.groups,
|
||||
readOnly: data.data.props.readOnly === '1',
|
||||
// use only owner and url, convert ''/remote.php/dav/addressbooks/users/admin/Test1/'' to 'admin.Test'
|
||||
key: storageKey,
|
||||
enabled: window.localStorage.getItem('contacts_ab_'+storageKey) !== 'false',
|
||||
// In case of not defined
|
||||
enabled: data.data.props.enabled !== '0',
|
||||
|
||||
sharedWith: {
|
||||
users: [],
|
||||
|
|
|
@ -89,12 +89,6 @@ angular.module('contactsApp')
|
|||
});
|
||||
},
|
||||
|
||||
toggleState: function(addressBook) {
|
||||
window.localStorage.setItem('contacts_ab_'+addressBook.key, !addressBook.enabled);
|
||||
notifyObservers('toggleState');
|
||||
return !addressBook.enabled;
|
||||
},
|
||||
|
||||
rename: function(addressBook, displayName) {
|
||||
return DavService.then(function(account) {
|
||||
return DavClient.renameAddressBook(addressBook, {displayName:displayName, url:account.homeUrl});
|
||||
|
@ -113,6 +107,37 @@ angular.module('contactsApp')
|
|||
return DavClient.syncAddressBook(addressBook);
|
||||
},
|
||||
|
||||
|
||||
toggleState: function(addressBook) {
|
||||
var xmlDoc = document.implementation.createDocument('', '', null);
|
||||
var dPropUpdate = xmlDoc.createElement('d:propertyupdate');
|
||||
dPropUpdate.setAttribute('xmlns:d', 'DAV:');
|
||||
dPropUpdate.setAttribute('xmlns:o', 'http://owncloud.org/ns');
|
||||
xmlDoc.appendChild(dPropUpdate);
|
||||
|
||||
var dSet = xmlDoc.createElement('d:set');
|
||||
dPropUpdate.appendChild(dSet);
|
||||
|
||||
var dProp = xmlDoc.createElement('d:prop');
|
||||
dSet.appendChild(dProp);
|
||||
|
||||
var oEnabled = xmlDoc.createElement('o:enabled');
|
||||
oEnabled.textContent = !addressBook.enabled ? '1' : '0';
|
||||
dProp.appendChild(oEnabled);
|
||||
|
||||
var body = dPropUpdate.outerHTML;
|
||||
|
||||
return DavClient.xhr.send(
|
||||
dav.request.basic({method: 'PROPPATCH', data: body}),
|
||||
addressBook.url
|
||||
).then(function(response) {
|
||||
if (response.status === 200) {
|
||||
addressBook.enabled = !addressBook.enabled;
|
||||
}
|
||||
return addressBook;
|
||||
});
|
||||
},
|
||||
|
||||
share: function(addressBook, shareType, shareWith, writable, existingShare) {
|
||||
var xmlDoc = document.implementation.createDocument('', '', null);
|
||||
var oShare = xmlDoc.createElement('o:share');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="contacts-list" ng-class="{loading: ctrl.loading, 'mobile-show': ctrl.show}">
|
||||
<div class="app-content-list-item"
|
||||
ng-repeat="contact in ctrl.filteredContacts = (ctrl.contactList | filter:{'data':{'addressBook':{'enabled': true}}} | contactGroupFilter:ctrl.routeParams.gid | localeOrderBy:ctrl.sortBy | filter:query | limitTo:ctrl.limitTo) as filtered track by contact.uid()"
|
||||
ng-repeat="contact in ctrl.filteredContacts = (ctrl.contactList | contactGroupFilter:ctrl.routeParams.gid | localeOrderBy:ctrl.sortBy | filter:query | limitTo:ctrl.limitTo) as filtered track by contact.uid()"
|
||||
contact data="contact"
|
||||
ng-click="setSelected(contact.uid())"
|
||||
ng-class="{active: contact.uid() === ctrl.getSelectedId()}">
|
||||
|
|
Loading…
Reference in New Issue