Bug 42150: add sort direction
This commit is contained in:
parent
88d883163e
commit
cc271cd723
|
@ -210,19 +210,24 @@ define([
|
|||
if (this.collection) {
|
||||
var sort = (type !== undefined);
|
||||
if (type === undefined) {
|
||||
type = Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date';
|
||||
type = Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date-desc';
|
||||
}
|
||||
Common.localStorage.setItem(this.appPrefix + "comments-sort", type);
|
||||
Common.Utils.InternalSettings.set(this.appPrefix + "comments-sort", type);
|
||||
|
||||
if (type=='position') {
|
||||
} else if (type=='author') {
|
||||
this.collection.comparator = function (collection) {
|
||||
return collection.get('parsedName').toLowerCase();
|
||||
} else if (type=='author-asc' || type=='author-desc') {
|
||||
var direction = (type=='author-asc') ? 1 : -1;
|
||||
this.collection.comparator = function(item1, item2) {
|
||||
var n1 = item1.get('parsedName').toLowerCase(),
|
||||
n2 = item2.get('parsedName').toLowerCase();
|
||||
if (n1==n2) return 0;
|
||||
return (n1<n2) ? -direction : direction;
|
||||
};
|
||||
} else { // date
|
||||
var direction = (type=='date-asc') ? 1 : -1;
|
||||
this.collection.comparator = function (collection) {
|
||||
return -collection.get('time');
|
||||
return direction * collection.get('time');
|
||||
};
|
||||
}
|
||||
sort && this.updateComments(true);
|
||||
|
@ -805,7 +810,7 @@ define([
|
|||
((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime())));
|
||||
|
||||
var user = this.userCollection.findOriginalUser(data.asc_getUserId());
|
||||
var needSort = (this.getComparator() == 'author') && (data.asc_getUserName() !== comment.get('username'));
|
||||
var needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username'));
|
||||
comment.set('comment', data.asc_getText());
|
||||
comment.set('userid', data.asc_getUserId());
|
||||
comment.set('username', data.asc_getUserName());
|
||||
|
|
|
@ -342,17 +342,31 @@ define([
|
|||
// toggleGroup: 'sortcomments'
|
||||
// },
|
||||
{
|
||||
caption: this.mniAuthor,
|
||||
value: 'author',
|
||||
caption: this.mniDateDesc,
|
||||
value: 'date-desc',
|
||||
checkable: true,
|
||||
checked: Common.localStorage.getItem(this.appPrefix + "comments-sort") === 'author',
|
||||
checked: (Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date-desc') === 'date-desc',
|
||||
toggleGroup: 'sortcomments'
|
||||
},
|
||||
{
|
||||
caption: this.mniDate,
|
||||
value: 'date',
|
||||
caption: this.mniDateAsc,
|
||||
value: 'date-asc',
|
||||
checkable: true,
|
||||
checked: (Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date') === 'date',
|
||||
checked: (Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date-desc') === 'date-asc',
|
||||
toggleGroup: 'sortcomments'
|
||||
},
|
||||
{
|
||||
caption: this.mniAuthorAsc,
|
||||
value: 'author-asc',
|
||||
checkable: true,
|
||||
checked: Common.localStorage.getItem(this.appPrefix + "comments-sort") === 'author-asc',
|
||||
toggleGroup: 'sortcomments'
|
||||
},
|
||||
{
|
||||
caption: this.mniAuthorDesc,
|
||||
value: 'author-desc',
|
||||
checkable: true,
|
||||
checked: Common.localStorage.getItem(this.appPrefix + "comments-sort") === 'author-desc',
|
||||
toggleGroup: 'sortcomments'
|
||||
}
|
||||
]
|
||||
|
@ -805,8 +819,10 @@ define([
|
|||
textHintAddComment : 'Add Comment',
|
||||
textSort: 'Sort comments',
|
||||
mniPosition: 'Sort by Position',
|
||||
mniAuthor: 'Sort by Authors',
|
||||
mniDate: 'Sort by Date',
|
||||
mniAuthorAsc: 'Sort by Author A to Z',
|
||||
mniAuthorDesc: 'Sort by Author Z to A',
|
||||
mniDateDesc: 'Sort by Newest',
|
||||
mniDateAsc: 'Sort by Oldest',
|
||||
textClosePanel: 'Close comments'
|
||||
}, Common.Views.Comments || {}))
|
||||
});
|
|
@ -248,8 +248,10 @@
|
|||
"Common.Views.Comments.textResolved": "Resolved",
|
||||
"Common.Views.Comments.textSort": "Sort comments",
|
||||
"Common.Views.Comments.mniPosition": "Sort by Position",
|
||||
"Common.Views.Comments.mniAuthor": "Sort by Authors",
|
||||
"Common.Views.Comments.mniDate": "Sort by Date",
|
||||
"Common.Views.Comments.mniAuthorAsc": "Sort by Author A to Z",
|
||||
"Common.Views.Comments.mniAuthorDesc": "Sort by Author Z to A",
|
||||
"Common.Views.Comments.mniDateDesc": "Sort by Newest",
|
||||
"Common.Views.Comments.mniDateAsc": "Sort by Oldest",
|
||||
"Common.Views.Comments.textClosePanel": "Close comments",
|
||||
"Common.Views.CopyWarningDialog.textDontShow": "Don't show this message again",
|
||||
"Common.Views.CopyWarningDialog.textMsg": "Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.<br><br>To copy or paste to or from applications outside the editor tab use the following keyboard combinations:",
|
||||
|
|
|
@ -141,8 +141,10 @@
|
|||
"Common.Views.Comments.textResolved": "Resolved",
|
||||
"Common.Views.Comments.textSort": "Sort comments",
|
||||
"Common.Views.Comments.mniPosition": "Sort by Position",
|
||||
"Common.Views.Comments.mniAuthor": "Sort by Authors",
|
||||
"Common.Views.Comments.mniDate": "Sort by Date",
|
||||
"Common.Views.Comments.mniAuthorAsc": "Sort by Author A to Z",
|
||||
"Common.Views.Comments.mniAuthorDesc": "Sort by Author Z to A",
|
||||
"Common.Views.Comments.mniDateDesc": "Sort by Newest",
|
||||
"Common.Views.Comments.mniDateAsc": "Sort by Oldest",
|
||||
"Common.Views.Comments.textClosePanel": "Close comments",
|
||||
"Common.Views.CopyWarningDialog.textDontShow": "Don't show this message again",
|
||||
"Common.Views.CopyWarningDialog.textMsg": "Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.<br><br>To copy or paste to or from applications outside the editor tab use the following keyboard combinations:",
|
||||
|
|
|
@ -189,8 +189,10 @@
|
|||
"Common.Views.Comments.textResolved": "Resolved",
|
||||
"Common.Views.Comments.textSort": "Sort comments",
|
||||
"Common.Views.Comments.mniPosition": "Sort by Position",
|
||||
"Common.Views.Comments.mniAuthor": "Sort by Authors",
|
||||
"Common.Views.Comments.mniDate": "Sort by Date",
|
||||
"Common.Views.Comments.mniAuthorAsc": "Sort by Author A to Z",
|
||||
"Common.Views.Comments.mniAuthorDesc": "Sort by Author Z to A",
|
||||
"Common.Views.Comments.mniDateDesc": "Sort by Newest",
|
||||
"Common.Views.Comments.mniDateAsc": "Sort by Oldest",
|
||||
"Common.Views.Comments.textClosePanel": "Close comments",
|
||||
"Common.Views.CopyWarningDialog.textDontShow": "Don't show this message again",
|
||||
"Common.Views.CopyWarningDialog.textMsg": "Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.<br><br>To copy or paste to or from applications outside the editor tab use the following keyboard combinations:",
|
||||
|
|
Loading…
Reference in a new issue