2017-10-30 10:38:01 +01:00
|
|
|
import Controller, {inject as controller} from '@ember/controller';
|
2019-08-27 15:51:31 +02:00
|
|
|
import {alias, sort} from '@ember/object/computed';
|
2018-04-30 14:54:09 +02:00
|
|
|
import {computed} from '@ember/object';
|
2015-10-23 19:18:39 +02:00
|
|
|
|
2016-06-11 18:52:36 +02:00
|
|
|
export default Controller.extend({
|
2014-12-01 23:45:45 +01:00
|
|
|
|
2019-06-18 12:47:21 +02:00
|
|
|
tagController: controller('tags.tag'),
|
2015-10-23 19:18:39 +02:00
|
|
|
|
2019-08-27 15:51:31 +02:00
|
|
|
queryParams: ['type'],
|
|
|
|
type: 'public',
|
2018-01-10 23:57:43 +01:00
|
|
|
tags: alias('model'),
|
2015-10-23 19:18:39 +02:00
|
|
|
selectedTag: alias('tagController.tag'),
|
|
|
|
|
2019-08-27 15:51:31 +02:00
|
|
|
filteredTags: computed('tags.@each.isNew', 'type', function () {
|
|
|
|
return this.tags.filter((tag) => {
|
|
|
|
return (!tag.isNew && (!this.type || tag.visibility === this.type));
|
|
|
|
});
|
2018-04-30 14:54:09 +02:00
|
|
|
}),
|
|
|
|
|
2018-11-07 16:06:28 +01:00
|
|
|
// tags are sorted by name
|
|
|
|
sortedTags: sort('filteredTags', function (tagA, tagB) {
|
2019-01-02 10:58:55 +01:00
|
|
|
// ignorePunctuation means the # in internal tag names is ignored
|
|
|
|
return tagA.name.localeCompare(tagB.name, undefined, {ignorePunctuation: true});
|
2015-10-23 19:18:39 +02:00
|
|
|
}),
|
|
|
|
|
2018-01-11 18:43:23 +01:00
|
|
|
actions: {
|
2019-08-27 15:51:31 +02:00
|
|
|
changeType(type) {
|
|
|
|
this.set('type', type);
|
2018-01-11 18:43:23 +01:00
|
|
|
}
|
2015-10-23 19:18:39 +02:00
|
|
|
}
|
2014-11-20 01:27:45 +01:00
|
|
|
});
|