* feat: 🎸 Update Channel identifiers and breadcrumb * refactor: 💡 updates after PR feedback * refactor: 💡 remove unneeded function * refactor: 💡 move all of indexedDisplayName into plain function
28 lines
880 B
JavaScript
28 lines
880 B
JavaScript
import Helper from '@ember/component/helper';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export function indexedDisplayName(intl, translation, array, item) {
|
|
let index = array.indexOf(item) + 1;
|
|
if (index === 0) index = null;
|
|
|
|
return intl.t(translation, { index });
|
|
}
|
|
|
|
export default class IndexedDisplayName extends Helper {
|
|
// =services
|
|
@service intl;
|
|
|
|
// =methods
|
|
/**
|
|
*
|
|
* @param {string} translation
|
|
* @param {Array} array parent array of item
|
|
* @param {object} item object that you want to find the index of
|
|
* indexOf will not do a deep equality check with item, just if the object exist in the array
|
|
* @returns localized name for resource with indexed position. For example, "Channel 1" for first item in a list.
|
|
*/
|
|
compute([translation, array, item]) {
|
|
return indexedDisplayName(this.intl, translation, array, item);
|
|
}
|
|
}
|