mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 19:35:41 +03:00
This is mostly a direct application of the ember-angle-brackets-codemod. I manually restored newlines in multi-line component invocations, usually preserving file line length except for now-non-positional link-to @route. I needed to rename task to taskState in some cases to avoid Ember Concurrency naming conflicts.
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
import Component from '@ember/component';
|
|
import { computed } from '@ember/object';
|
|
import { filterBy } from '@ember/object/computed';
|
|
|
|
export default Component.extend({
|
|
tagName: '',
|
|
|
|
model: null,
|
|
|
|
allocation: computed('model', function() {
|
|
if (this.model.allocation) {
|
|
return this.model.allocation;
|
|
} else {
|
|
return this.model;
|
|
}
|
|
}),
|
|
|
|
taskState: computed('model', function() {
|
|
if (this.model.allocation) {
|
|
return this.model;
|
|
}
|
|
}),
|
|
|
|
type: computed('taskState', function() {
|
|
if (this.taskState) {
|
|
return 'task';
|
|
} else {
|
|
return 'allocation';
|
|
}
|
|
}),
|
|
|
|
directories: filterBy('directoryEntries', 'IsDir'),
|
|
files: filterBy('directoryEntries', 'IsDir', false),
|
|
|
|
sortedDirectoryEntries: computed(
|
|
'directoryEntries.[]',
|
|
'sortProperty',
|
|
'sortDescending',
|
|
function() {
|
|
const sortProperty = this.sortProperty;
|
|
|
|
const directorySortProperty = sortProperty === 'Size' ? 'Name' : sortProperty;
|
|
|
|
const sortedDirectories = this.directories.sortBy(directorySortProperty);
|
|
const sortedFiles = this.files.sortBy(sortProperty);
|
|
|
|
const sortedDirectoryEntries = sortedDirectories.concat(sortedFiles);
|
|
|
|
if (this.sortDescending) {
|
|
return sortedDirectoryEntries.reverse();
|
|
} else {
|
|
return sortedDirectoryEntries;
|
|
}
|
|
}
|
|
),
|
|
|
|
});
|