This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Component.extend({ | |
layout, | |
tagName: 'ol', | |
linkable: true, | |
reverse: false, | |
classNameBindings: [ 'breadCrumbClass' ], | |
hasBlock: computed.bool('template').readOnly(), | |
currentRouteName: computed.readOnly('applicationController.currentRouteName'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
routeHierarchy: computed('currentRouteName', 'reverse', { | |
get() { | |
const currentRouteName = getWithDefault(this, 'currentRouteName', false); | |
assert('[ember-crumbly] Could not find a curent route', currentRouteName); | |
const routeNames = this._splitCurrentRouteName(currentRouteName); | |
const filteredRouteNames = this._filterIndexRoutes(routeNames); | |
const crumbs = this._lookupBreadCrumb(routeNames, filteredRouteNames); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_splitCurrentRouteName(currentRouteName) { | |
return currentRouteName.split('.'); | |
}, | |
_filterIndexRoutes(routeNames) { | |
return filter(routeNames, (name) => { | |
return name !== 'index'; | |
}); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_lookupBreadCrumb(routeNames, filteredRouteNames) { | |
const defaultLinkable = get(this, 'linkable'); | |
const breadCrumbs = map(filteredRouteNames, (name, index) => { | |
const path = this._guessRoutePath(routeNames, name, index); | |
let breadCrumb = this._lookupRoute(path).getWithDefault('breadCrumb', undefined); | |
const breadCrumbType = typeOf(breadCrumb); | |
if (breadCrumbType === 'undefined') { | |
breadCrumb = { | |
path, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_guessRoutePath(routeNames, name, index) { | |
const routes = routeNames.slice(0, index + 1); | |
if (routes.length === 1) { | |
return `${name}.index`; | |
} else { | |
return routes.join('.'); | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_lookupRoute(routeName) { | |
const container = get(this, 'container'); | |
const route = container.lookup(`route:${routeName}`); | |
assert(`[ember-crumbly] \`route:${routeName}\` was not found`, route); | |
return route; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let breadCrumb = this._lookupRoute(path).getWithDefault('breadCrumb', undefined); | |
const breadCrumbType = typeOf(breadCrumb); | |
if (breadCrumbType === 'undefined') { | |
breadCrumb = { | |
path, | |
linkable: defaultLinkable, | |
title: classify(name) | |
}; | |
} else if (breadCrumbType === 'null') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return emberArray(filter(breadCrumbs, (breadCrumb) => { | |
return typeOf(breadCrumb) !== 'undefined'; | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { module } from 'qunit'; | |
import startApp from 'livin/tests/helpers/start-app'; | |
import OnboardPage from 'livin/tests/helpers/page-objects/onboard'; | |
import { test } from 'qunit'; | |
const { run } = Ember; | |
let application; | |
module('Acceptance | onboard', { |