Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default JSONAPIAdapter.extend({
currentProjectVersion: '',

metaStore: service(),
projectService: service('project'),

async findRecord(store, {modelName}, id) {
let url;
Expand All @@ -30,7 +31,7 @@ export default JSONAPIAdapter.extend({
let revId = this.get('metaStore').getRevId(projectName, version, modelName, id);
url = `json-docs/${projectName}/${version}/${inflector.pluralize(modelName)}/${revId}`;
} else if (modelName === 'missing') {
let version = Ember.getOwner(this).lookup('controller:project-version').get('model.version');
let version = this.get('projectService.version');
let revId = this.get('metaStore').getRevId(projectName, version, modelName, id);
url = `json-docs/${projectName}/${version}/${inflector.pluralize(modelName)}/${revId}`;
} else if (modelName === 'project') {
Expand Down
35 changes: 34 additions & 1 deletion app/models/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ import Ember from 'ember';
const {computed} = Ember;
const {attr, belongsTo} = DS;

const projectNameFromClassName = key => {
return computed(key, function() {
const value = this.get(key) || "";
if (value.indexOf('Ember.') > -1) {
return 'ember';
}

if (value.indexOf('DS.') > 1) {
return 'ember-data';
}

return this.get('project.id');
});
};

// ideally this computed property would not be needed and we'd have extendsVersion, extendsProject attrs from json-api-docs
const guessVersionFor = key => {
return computed(key, 'project.id', function() {

if (this.get('extendedClassProjectName') === this.get('project.id')) {
return this.get('projectVersion.version');
}

// try linking to latest version at least
return 'release';
});
};

export default DS.Model.extend({
name: attr(),
methods: attr(),
Expand All @@ -21,6 +49,11 @@ export default DS.Model.extend({
projectVersion: belongsTo('project-version', {inverse: 'classes'}),
project: computed('projectVersion.id', function() {
return this.get('projectVersion').get('project');
})
}),

extendedClassProjectName: projectNameFromClassName('extends'),
extendedClassVersion: guessVersionFor('extends'),
usedClassProjectName: projectNameFromClassName('uses'),
usedClassVersion: guessVersionFor('uses')

});
4 changes: 2 additions & 2 deletions app/templates/project-version/classes/class.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{#if model.extends}}
<div class="attribute">
<span class="attribute-label">Extends:</span>
<span class="attribute-value">{{#link-to 'project-version.classes.class' model.projectVersion.version model.extends}}{{model.extends}}{{/link-to}}</span>
<span class="attribute-value">{{#link-to 'project-version.classes.class' model.extendedClassProjectName model.extendedClassVersion model.extends}}{{model.extends}}{{/link-to}}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name is available from the route. we should be able to pass it to the template instead of guessing in the model object. you can get it from transition.params['project-version'].project in the model hook.

Copy link
Contributor Author

@MartinMalinda MartinMalinda Jul 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is, transitioning from Ember Data 2.14 to Ember 2.14 can break the app if Ember 2.14 is not released yet.

Copy link
Contributor

@toddjordan toddjordan Jul 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't talking about version, but referring to model.extendedClassProjectName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, well then it would not solve anything, we'd be linking to from ember-data to ember-data same as before, having broken link. We need to be able to link from ember-data to ember back and forth.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I get what's happening now. this is the link to a class that the current one is exteded from cross project. disregard 👍

</div>
{{/if}}
{{#if model.uses}}
Expand All @@ -17,7 +17,7 @@
<span class="attribute-value">
{{#each model.uses as |parentClass idx|}}
{{#unless (eq idx 0)}}<span class="comma">,</span>{{/unless}}
{{#link-to 'project-version.classes.class' model.projectVersion.version parentClass}}{{parentClass}}{{/link-to}}
{{#link-to 'project-version.classes.class' model.usedClassProjectName model.usedClassVersion parentClass}}{{parentClass}}{{/link-to}}
{{/each}}
</span>
</div>
Expand Down