mirror of
https://github.com/documize/community.git
synced 2025-07-22 06:39:43 +02:00
Allow sorting of search results and space contents
Closes #187 Sort search results and space contents by Name, Created or Revised.
This commit is contained in:
parent
0985dbf5b6
commit
1d00f8ac6e
19 changed files with 1182 additions and 807 deletions
|
@ -9,11 +9,13 @@
|
|||
//
|
||||
// https://documize.com
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import { computed } from '@ember/object';
|
||||
import { A } from '@ember/array';
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({
|
||||
localStorage: service(),
|
||||
showDeleteDialog: false,
|
||||
showMoveDialog: false,
|
||||
selectedDocuments: A([]),
|
||||
|
@ -36,9 +38,53 @@ export default Component.extend({
|
|||
let targets = _.reject(this.get('spaces'), {id: space.get('id')});
|
||||
this.set('moveOptions', A(targets));
|
||||
this.set('selectedDocuments', A([]));
|
||||
|
||||
let sortBy = this.get('localStorage').getSessionItem('space.sortBy');
|
||||
if (!_.isNull(sortBy) && !_.isUndefined(sortBy)) {
|
||||
this.send('onSetSort', sortBy);
|
||||
}
|
||||
|
||||
let sortOrder = this.get('localStorage').getSessionItem('space.sortOrder');
|
||||
if (!_.isNull(sortOrder) && !_.isUndefined(sortOrder)) {
|
||||
this.send('onSetSort', sortOrder);
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
actions: {
|
||||
onSetSort(val) {
|
||||
switch (val) {
|
||||
case 'name':
|
||||
this.set('sortBy.name', true);
|
||||
this.set('sortBy.created', false);
|
||||
this.set('sortBy.updated', false);
|
||||
break;
|
||||
case 'created':
|
||||
this.set('sortBy.name', false);
|
||||
this.set('sortBy.created', true);
|
||||
this.set('sortBy.updated', false);
|
||||
break;
|
||||
case 'updated':
|
||||
this.set('sortBy.name', false);
|
||||
this.set('sortBy.created', false);
|
||||
this.set('sortBy.updated', true);
|
||||
break;
|
||||
case 'asc':
|
||||
this.set('sortBy.asc', true);
|
||||
this.set('sortBy.desc', false);
|
||||
break;
|
||||
case 'desc':
|
||||
this.set('sortBy.asc', false);
|
||||
this.set('sortBy.desc', true);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onSortBy(attacher) {
|
||||
// attacher.hide();
|
||||
this.get('onFiltered')(this.get('documents'));
|
||||
},
|
||||
|
||||
onShowDeleteDocuments() {
|
||||
this.set('showDeleteDialog', true);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue