-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting contacts #21
Comments
yes! thank you to remind me that! |
obviously the task is for me a bit more complex than i through, i may need some help from a cozy front dev edit: see code here app.js#L716 Try to use of the lib underscore to sort contacts here : for (i = 0; i < res.length; i++) {
var mAd = _.findWhere(res[i].key.datapoints, {name: 'adr'}, {type: 'main'});
if (mAd !== undefined && mAd.value !== undefined) {
// mAd.value.join('\n');
var adrr = mAd.value.join('');
var mAdz = adrr.replace(/\n/g, ' ');
console.log('Success: Get Contacts Address'); |
If you are using underscore's collection to manage the list of contact you can use sortBy : http://underscorejs.org/#sortBy _.sortBy(yourContactListFiltered, 'name'); Maybe the _.find function is what you need to filter the list (didn't really understand your code and where it comes from) |
yeah i know, it's really not easy to read, in fact the basic is: cozysdk.run('Contact', 'all', {}, function (err, res) and the template for the sidebar var template =
'<tr><th data-id="' + res[i].id +
'" class="contactmap" rowspan="4" align="top">' + altUpics +
'</th><th align="left">' + res[i].key.fn + '</th></tr><tr>' +
'<td class="data-add" id="updatecontact' + res[i].id + '">' +
adrsidebar +
'</td></tr><tr><td></td></tr><tr></tr>';
HTML = HTML + template; where |
Just as a reminder since I don't have much time and will continue on this later`. Breakpoints here : https://github.com/RobyRemzy/cozy-map/blob/db21da17f3683c8e046af35b8b6d4b0a79872aa3/src/app.js#L710 In console enter this var a = _.filter(res, function (num) {return num.key.datapoints[2] && num.key.datapoints[2].name == 'adr';}) Need to check all the values in the datapoints tab instead of just "2" but it's returning me a contact, should return all then just do something like: _.sortBy(res, 'name'); // I think it's not directly name and we will need to use a function here too ;) |
Currently when syncing with contacts, it seems the order is arbitrary. It would be great if the contacts where sorted alphabetically.
The text was updated successfully, but these errors were encountered: