1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import Ember from 'ember';
- import Resolver from 'ember/resolver';
- export default Resolver.extend({
- _startsWith: function(string, beginning) {
- return string.indexOf(beginning) === 0;
- },
- _endsWith: function(string, tail) {
- return string.indexOf(tail, string.length - tail.length) !== -1;
- },
- misagoFormModuleName: function(parsedName) {
- if (this._endsWith(parsedName.name, '-form')) {
- var isComponent = parsedName.type === 'component';
- var isComponentTemplate = this._startsWith(parsedName.name, 'components/');
- if (isComponent || isComponentTemplate) {
- var path = parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/';
- if (isComponentTemplate) {
- path += 'components/forms/' + parsedName.fullNameWithoutType.substr(11);
- } else {
- path += 'forms/' + parsedName.fullNameWithoutType;
- }
- return path;
- }
- }
- },
- misagoModalModuleName: function(parsedName) {
- if (this._endsWith(parsedName.name, '-modal')) {
- var isComponent = parsedName.type === 'component';
- var isComponentTemplate = this._startsWith(parsedName.name, 'components/');
- if (isComponent || isComponentTemplate) {
- var path = parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/';
- if (isComponentTemplate) {
- path += 'components/modals/' + parsedName.fullNameWithoutType.substr(11);
- } else {
- path += 'modals/' + parsedName.fullNameWithoutType;
- }
- return path;
- }
- }
- },
- // register custom lookup
- moduleNameLookupPatterns: Ember.computed(function(){
- return Ember.A([
- this.misagoFormModuleName,
- this.misagoModalModuleName,
- this.podBasedModuleName,
- this.podBasedComponentsInSubdir,
- this.mainModuleName,
- this.defaultModuleName
- ]);
- })
- });
|