Browse Source

- fixed alphabetical order by rostername (rosterview.name aka getTruename)

pull/16/head
Christine Ho 11 years ago
parent
commit
4daf356bfe
  1. 37
      app/widgets/Roster/roster.js
  2. 1
      app/widgets/Roster/roster.tpl

37
app/widgets/Roster/roster.js

@ -44,6 +44,7 @@
if(!(list[i].jid in $scope.lookupjid)){
el = {
'ajid': list[i].jid,
'atruename': list[i].rosterview.name,
'aval': list[i].value,
'ajiditems': [],
'tombstone': false,
@ -66,13 +67,13 @@
if(!$scope.contacts[i].agroupitems[j].tombstone)
$scope.lookupjid[$scope.contacts[i].agroupitems[j].ajid] = $scope.contacts[i].agroupitems[j];
else // Cleanup tombstoned jid
$scope.contacts[i].agroupitems.splice(j, 1); }
$scope.contacts[i].agroupitems.splice(j, 1);
}
}
else // Cleanup tombstoned groups
$scope.contacts.splice(i, 1);
}
}*/
$scope.$apply();
};
@ -117,7 +118,7 @@
index = locationOf(element, array, comparer);
array.splice(index, 0, element);
/* Update dictionnary from the appropriate index */
/* Update dictionary from the appropriate index */
for(var i=index; i<array.length; i++){
dico[array[i][key]] = array[i];
}
@ -134,13 +135,10 @@
$scope.lookupgroups[oldgroupname].tombstone = true;
else{
$scope.lookupjid[list[0].jid].tombstone = true;
console.log("Tombstone TRUE for " + list[0].jid);
}
}
/* New group is not in the list */
if(!(list[0].groupname in $scope.lookupgroups)) {
console.log("New groupname" + list[0].groupname);
/* Create group */
el = {
'agroup': list[0].groupname,
@ -157,12 +155,14 @@
&& ($scope.lookupjid[list[0].jid].ajiditems[0].groupname == list[0].groupname))
{
$scope.lookupjid[list[0].jid].aval = list[0].value;
$scope.lookupjid[list[0].jid].atruename = list[0].rosterview.name;
$scope.lookupjid[list[0].jid].ajiditems = list;
$scope.lookupgroups[list[0].groupname].agroupitems.sort(jidAvalCompare);
}
else{
el = {
'ajid': list[0].jid,
'atruename': list[0].rosterview.name,
'aval': list[0].value,
'ajiditems': list,
'tombstone': false,
@ -209,11 +209,8 @@
};
this.getContactTitle = function(c){
status = c.status || "";
ressource = c.ressource || "";
title = c.jid;
if(status != "") title += " - " + status;
if(ressource != "") title += " - " + ressource;
title = c.rosterview.name + " - " + c.jid;
if(c.status) title += " - " + c.status;
return title;
};
@ -309,10 +306,24 @@ var ressourceCompare = function(a, b) {
};
/* Presence + alphabetical comparison */
var jidAvalCompare = function(a, b) {
if(a.ajid=="christine.ho@etu.univ-nantes.fr"){
console.log("jidAvalCompare");
console.log(a.aval);
console.log(b.ajid);
console.log(b.aval);
}
n = a.aval - b.aval;
if(n == 0 && a.ajiditems.length > 0){ /* if the array is empty keep the 0 value */
n = a.ajiditems[0].rosterview.name.localeCompare(b.ajiditems[0].rosterview.name);
if(n == 0){
n = a.atruename.localeCompare(b.atruename);
if(a.ajid == "christine.ho@etu.univ-nantes.fr"){
console.log("name a "+a.atruename);
console.log("name b "+b.atruename);
}
}
if(a.ajid=="christine.ho@etu.univ-nantes.fr")
console.log(n ? n < 0 ? -1 : 1 : 0);
return n ? n < 0 ? -1 : 1 : 0;
};

1
app/widgets/Roster/roster.tpl

@ -14,7 +14,6 @@
<!-- Rostersearch look this way for an angularJS solution http://www.bennadel.com/blog/2487-filter-vs-nghide-with-ngrepeat-in-angularjs.htm -->
<ul class="contact">
<li ng-repeat="contact in myjid.ajiditems" class="{{contact.rosterview.presencetxt}} {{contact.rosterview.inactive}}" ng-class="rosterCtrl.getContactClient(contact)" >
<!-- add title to li so search works again-->
<div class="chat on" ng-click="rosterCtrl.postChatAction(contact)" ></div>
<div ng-if="contact.rosterview.type == 'handheld'" class="infoicon mobile"></div>
<div ng-if="contact.rosterview.type == 'web'" class="infoicon web"></div>

Loading…
Cancel
Save