mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-30 19:52:17 +01:00
Load last selected group on or all if first time.
This commit is contained in:
parent
9a905a2157
commit
051d0f027d
@ -32,6 +32,10 @@ OCP\JSON::success(array(
|
|||||||
'data' => array(
|
'data' => array(
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'favorites' => $favorites,
|
'favorites' => $favorites,
|
||||||
|
'lastgroup' => OCP\Config::getUserValue(
|
||||||
|
OCP\User::getUser(),
|
||||||
|
'contacts',
|
||||||
|
'lastgroup', 'all'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -196,7 +196,7 @@ input.propertytype { float: left; font-size: .8em; width: 8em !important; direct
|
|||||||
/* contact list */
|
/* contact list */
|
||||||
|
|
||||||
#contactlist { position: relative; top: 0; left: 0; right: 0; width: 100%; }
|
#contactlist { position: relative; top: 0; left: 0; right: 0; width: 100%; }
|
||||||
#contactlist tr { height: 3em; }
|
#contactlist tr { height: 3em; display: none; }
|
||||||
#contactlist tr.active, #contactlist tr:hover { background-color: #eee; }
|
#contactlist tr.active, #contactlist tr:hover { background-color: #eee; }
|
||||||
#contactlist tr > td { border-bottom: 1px solid #DDDDDD; font-weight: normal; text-align: left; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }
|
#contactlist tr > td { border-bottom: 1px solid #DDDDDD; font-weight: normal; text-align: left; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }
|
||||||
#contactlist tr > td:hover { overflow: inherit; text-overflow: inherit; background-color: #fff; z-index: 200; }
|
#contactlist tr > td:hover { overflow: inherit; text-overflow: inherit; background-color: #fff; z-index: 200; }
|
||||||
|
82
js/app.js
82
js/app.js
@ -98,6 +98,20 @@ OC.notify = function(params) {
|
|||||||
|
|
||||||
var GroupList = function(groupList, listItemTmpl) {
|
var GroupList = function(groupList, listItemTmpl) {
|
||||||
this.$groupList = groupList;
|
this.$groupList = groupList;
|
||||||
|
var self = this;
|
||||||
|
this.$groupList.on('click', 'h3', function(event) {
|
||||||
|
if(wrongKey(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.$groupList.find('h3').removeClass('active');
|
||||||
|
$(this).addClass('active');
|
||||||
|
self.lastgroup = $(this).data('id');
|
||||||
|
$(document).trigger('status.group.selected', {
|
||||||
|
id: self.lastgroup,
|
||||||
|
type: $(this).data('type'),
|
||||||
|
contacts: $(this).data('contacts'),
|
||||||
|
});
|
||||||
|
});
|
||||||
this.$groupListItemTemplate = listItemTmpl;
|
this.$groupListItemTemplate = listItemTmpl;
|
||||||
this.categories = [];
|
this.categories = [];
|
||||||
}
|
}
|
||||||
@ -114,6 +128,10 @@ GroupList.prototype.isFavorite = function(contactid) {
|
|||||||
return this.inGroup(contactid, 'fav');
|
return this.inGroup(contactid, 'fav');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupList.prototype.selectGroup = function(groupid) {
|
||||||
|
console.log('selectGroup', groupid);
|
||||||
|
}
|
||||||
|
|
||||||
GroupList.prototype.inGroup = function(contactid, groupid) {
|
GroupList.prototype.inGroup = function(contactid, groupid) {
|
||||||
var $groupelem = this.findById(groupid);
|
var $groupelem = this.findById(groupid);
|
||||||
var contacts = $groupelem.data('contacts');
|
var contacts = $groupelem.data('contacts');
|
||||||
@ -301,6 +319,7 @@ GroupList.prototype.loadGroups = function(numcontacts, cb) {
|
|||||||
tmpl.octemplate({id: 'all', type: 'all', num: numcontacts, name: t('contacts', 'All')}).appendTo($groupList);
|
tmpl.octemplate({id: 'all', type: 'all', num: numcontacts, name: t('contacts', 'All')}).appendTo($groupList);
|
||||||
$.getJSON(OC.filePath('contacts', 'ajax', 'categories/list.php'), {}, function(jsondata) {
|
$.getJSON(OC.filePath('contacts', 'ajax', 'categories/list.php'), {}, function(jsondata) {
|
||||||
if (jsondata && jsondata.status == 'success') {
|
if (jsondata && jsondata.status == 'success') {
|
||||||
|
self.lastgroup = jsondata.data.lastgroup;
|
||||||
// Favorites
|
// Favorites
|
||||||
var contacts = $.map(jsondata.data.favorites, function(c) {return parseInt(c)});
|
var contacts = $.map(jsondata.data.favorites, function(c) {return parseInt(c)});
|
||||||
var $elem = tmpl.octemplate({
|
var $elem = tmpl.octemplate({
|
||||||
@ -329,6 +348,13 @@ GroupList.prototype.loadGroups = function(numcontacts, cb) {
|
|||||||
$elem.data('id', category.id)
|
$elem.data('id', category.id)
|
||||||
$elem.appendTo($groupList);
|
$elem.appendTo($groupList);
|
||||||
});
|
});
|
||||||
|
var $elem = self.findById(self.lastgroup);
|
||||||
|
$elem.addClass('active');
|
||||||
|
$(document).trigger('status.group.selected', {
|
||||||
|
id: self.lastgroup,
|
||||||
|
type: $elem.data('type'),
|
||||||
|
contacts: $elem.data('contacts'),
|
||||||
|
});
|
||||||
} // TODO: else
|
} // TODO: else
|
||||||
if(typeof cb === 'function') {
|
if(typeof cb === 'function') {
|
||||||
cb();
|
cb();
|
||||||
@ -568,6 +594,32 @@ OC.Contacts = OC.Contacts || {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// Group selected, only show contacts from that group
|
||||||
|
$(document).bind('status.group.selected', function(e, result) {
|
||||||
|
console.log('status.group.selected', result);
|
||||||
|
self.currentgroup = result.id;
|
||||||
|
// Close any open contact.
|
||||||
|
if(self.currentid) {
|
||||||
|
var id = self.currentid;
|
||||||
|
self.closeContact(id);
|
||||||
|
self.Contacts.jumpToContact(id);
|
||||||
|
}
|
||||||
|
self.$contactList.show();
|
||||||
|
self.$toggleAll.show();
|
||||||
|
self.showActions(['add', 'delete']);
|
||||||
|
if(result.type === 'category' || result.type === 'fav') {
|
||||||
|
console.log('contacts', $(this).data('contacts'));
|
||||||
|
self.Contacts.showContacts(result.contacts);
|
||||||
|
} else {
|
||||||
|
self.Contacts.showContacts(self.currentgroup);
|
||||||
|
}
|
||||||
|
$.post(OC.filePath('contacts', 'ajax', 'setpreference.php'), {'key':'lastgroup', 'value':self.currentgroup}, function(jsondata) {
|
||||||
|
if(jsondata.status !== 'success') {
|
||||||
|
OC.notify({message: jsondata.data.message});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.$rightContent.scrollTop(0);
|
||||||
|
});
|
||||||
// mark items whose title was hid under the top edge as read
|
// mark items whose title was hid under the top edge as read
|
||||||
/*this.$rightContent.scroll(function() {
|
/*this.$rightContent.scroll(function() {
|
||||||
// prevent too many scroll requests;
|
// prevent too many scroll requests;
|
||||||
@ -727,36 +779,6 @@ OC.Contacts = OC.Contacts || {
|
|||||||
});
|
});
|
||||||
console.log('groups', $opt.parent().data('action'), $opt.val(), $opt.text());
|
console.log('groups', $opt.parent().data('action'), $opt.val(), $opt.text());
|
||||||
});
|
});
|
||||||
// Group selected, only show contacts from that group
|
|
||||||
this.$groupList.on('click', 'h3', function() {
|
|
||||||
self.currentgroup = $(this).data('id');
|
|
||||||
console.log('Group click', $(this).data('id'), $(this).data('type'));
|
|
||||||
// Close any open contact.
|
|
||||||
if(self.currentid) {
|
|
||||||
var id = self.currentid;
|
|
||||||
self.closeContact(id);
|
|
||||||
self.Contacts.jumpToContact(id);
|
|
||||||
}
|
|
||||||
self.$groupList.find('h3').removeClass('active');
|
|
||||||
self.$contactList.show();
|
|
||||||
self.$toggleAll.show();
|
|
||||||
self.showActions(['add', 'delete']);
|
|
||||||
$(this).addClass('active');
|
|
||||||
var gtype = $(this).data('type');
|
|
||||||
var gid = $(this).data('id');
|
|
||||||
if(gtype === 'category' || gtype === 'fav') {
|
|
||||||
console.log('contacts', $(this).data('contacts'));
|
|
||||||
self.Contacts.showContacts($(this).data('contacts'));
|
|
||||||
} else {
|
|
||||||
self.Contacts.showContacts(gid);
|
|
||||||
}
|
|
||||||
$.post(OC.filePath('contacts', 'ajax', 'setpreference.php'), {'key':'lastgroup', 'value':gid}, function(jsondata) {
|
|
||||||
if(jsondata.status !== 'success') {
|
|
||||||
OC.notify({message: jsondata.data.message});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
self.$rightContent.scrollTop(0);
|
|
||||||
});
|
|
||||||
// Contact list. Either open a contact or perform an action (mailto etc.)
|
// Contact list. Either open a contact or perform an action (mailto etc.)
|
||||||
this.$contactList.on('click', 'tr', function(event) {
|
this.$contactList.on('click', 'tr', function(event) {
|
||||||
if($(event.target).is('input')) {
|
if($(event.target).is('input')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user