cc41c86f30
Various ember addons produced deprecation messages, some in the browser console and some in terminal. Upgrading and replacing some of these has reduced this. Upgrades: - ember-collection - ember-computed-style Replacements: - ember-pluralize replaced with ember-inflector - ember-cli-format-number replaced with custom helper using standard `toLocaleString` Removing ember-cli-format-number also meant some further changes related to decimal places in the tomography graph, done using `toFixed` The ExternalSources background-images have also now been escaped correctly preventing in-development `console` warnings. The only deprecation warnings are now from ember-block-slots, only in terminal, making for a better development experience overall, especially now we have an empty browser console Also adds a `callIfType` 'helper util' which is a util specifically for helpers (it conforms to a helper argument signature) to be expanded upon later.
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import Controller from '@ember/controller';
|
|
import { computed, get } from '@ember/object';
|
|
import WithFiltering from 'consul-ui/mixins/with-filtering';
|
|
import ucfirst from 'consul-ui/utils/ucfirst';
|
|
const countType = function(items, type) {
|
|
return type === '' ? get(items, 'length') : items.filterBy('Type', type).length;
|
|
};
|
|
export default Controller.extend(WithFiltering, {
|
|
queryParams: {
|
|
type: {
|
|
as: 'type',
|
|
},
|
|
s: {
|
|
as: 'filter',
|
|
replace: true,
|
|
},
|
|
},
|
|
typeFilters: computed('items', function() {
|
|
const items = get(this, 'items');
|
|
return ['', 'management', 'client'].map(function(item) {
|
|
return {
|
|
label: `${item === '' ? 'All' : ucfirst(item)} (${countType(
|
|
items,
|
|
item
|
|
).toLocaleString()})`,
|
|
value: item,
|
|
};
|
|
});
|
|
}),
|
|
filter: function(item, { s = '', type = '' }) {
|
|
const sLower = s.toLowerCase();
|
|
return (
|
|
(get(item, 'Name')
|
|
.toLowerCase()
|
|
.indexOf(sLower) !== -1 ||
|
|
get(item, 'ID')
|
|
.toLowerCase()
|
|
.indexOf(sLower) !== -1) &&
|
|
(type === '' || get(item, 'Type') === type)
|
|
);
|
|
},
|
|
actions: {
|
|
sendClone: function(item) {
|
|
this.send('clone', item);
|
|
},
|
|
},
|
|
});
|