Skip to content

Display properties and events #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2016
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
6 changes: 6 additions & 0 deletions app/controllers/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Ember from "ember";
import AnchorControllerSupport from "ember-anchor/mixins/controller-support";

export default Ember.Controller.extend(AnchorControllerSupport, {
queryParams: ['anchor']
});
6 changes: 6 additions & 0 deletions app/controllers/properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Ember from "ember";
import AnchorControllerSupport from "ember-anchor/mixins/controller-support";

export default Ember.Controller.extend(AnchorControllerSupport, {
queryParams: ['anchor']
});
2 changes: 2 additions & 0 deletions app/models/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const {attr, belongsTo} = DS;
export default DS.Model.extend({
name: attr(),
methods: attr(),
properties: attr(),
events: attr(),
description: attr(),
ogDescription: attr(),
parentClass: belongsTo('class', {async: true, inverse: null}),
Expand Down
6 changes: 6 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Router.map(function() {
this.route('methods', {resetNamespace: true}, function() {
this.route('method', {path: '/:method'});
});
this.route('properties', {resetNamespace: true}, function() {
this.route('property', {path: '/:property'});
});
this.route('events', {resetNamespace: true}, function() {
this.route('event', {path: '/:event'});
});
});
});
});
Expand Down
3 changes: 3 additions & 0 deletions app/routes/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default Ember.Route.extend({
case 'project-version.class':
endingRoute = `classes/${this.modelFor(routeName).get('name')}`;
break;
case 'project-version.class.index':
endingRoute = `classes/${this.modelFor('project-version.class').get('name')}`;
break;
default:
break;
}
Expand Down
4 changes: 3 additions & 1 deletion app/routes/project-version/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default Ember.Route.extend({
const version = transition.params['project-version'].project_version;
const klass = params.class;

return this.store.find('class', `${projectID}-${version}-${klass}`);
return this.store.find('class', `${projectID}-${version}-${klass}`).catch((error) => {
this.transitionTo('project-version'); // class doesn't exist in new version
});
},

afterModel(klass) {
Expand Down
13 changes: 13 additions & 0 deletions app/styles/_class.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
article.chapter ul {
list-style-type: none;
-webkit-column-count: 2;
column-count: 2;
-webkit-column-gap: 1em;
column-count: 1em;
vertical-align: baseline;

li {
margin-top: 0;
margin-bottom: 0;
}
}
2 changes: 2 additions & 0 deletions app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
@import "neat";
@import "./components/all";

@import "class";

body {
margin: 0;
}
Expand Down
4 changes: 2 additions & 2 deletions app/styles/base/_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ dl {
}
}

.method {
.method, .property, .event {
border-bottom: $base-border;

.method-name {
.method-name, .property-name, .event-name {
font-family: $monospace-font-family;
}
}
20 changes: 20 additions & 0 deletions app/templates/components/class-field-description.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<section class="{{type}}">
<h3 data-anchor="{{field.name}}">
<span class="{{field}}-name">{{field.name}}</span>
{{#if field.params}}
<span class="args">
({{join ", " (map-by "name" field.params)}})
</span>
{{/if}}
</h3>
<dl class="parameters">
{{#each field.params as |param|}}
<div class="parameter">
<dt>{{param.name}}</dt>
<dd>{{param.type}}</dd>
<dd>{{param.description}}</dd>
</div>
{{/each}}
</dl>
{{{field.description}}}
</section>
5 changes: 5 additions & 0 deletions app/templates/events.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ember-anchor a="anchor" anchor=anchor}}

{{#each model.events as |event|}}
{{class-field-description type="event" field=event}}
{{/each}}
21 changes: 1 addition & 20 deletions app/templates/methods.hbs
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
{{ember-anchor a="anchor" anchor=anchor}}

{{#each model.methods as |method|}}
<section class="method">
<h3 data-anchor="{{method.name}}">
<span class="method-name">{{method.name}}</span>
{{#if method.params}}
<span class="args">
({{join ", " (map-by "name" method.params)}})
</span>
{{/if}}
</h3>
<dl class="parameters">
{{#each method.params as |param|}}
<div class="parameter">
<dt>{{param.name}}</dt>
<dd>{{param.type}}</dd>
<dd>{{param.description}}</dd>
</div>
{{/each}}
</dl>
{{{method.description}}}
</section>
{{class-field-description type="method" field=method}}
{{/each}}
26 changes: 26 additions & 0 deletions app/templates/project-version/class.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@
</ul>
</section>

<section>
<h2>Properties</h2>
<ul class="spec-property-list">
{{#each model.properties as |property|}}
<li>
{{#link-to 'properties.property' model.project.id model.projectVersion.version model.name property.name (query-params anchor=property.name)}}
{{property.name}}
{{/link-to}}
</li>
{{/each}}
</ul>
</section>

<section>
<h2>Events</h2>
<ul class="spec-event-list">
{{#each model.events as |event|}}
<li>
{{#link-to 'events.event' model.project.id model.projectVersion.version model.name event.name (query-params anchor=event.name)}}
{{event.name}}
{{/link-to}}
</li>
{{/each}}
</ul>
</section>

{{outlet}}

</article>
5 changes: 5 additions & 0 deletions app/templates/properties.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ember-anchor a="anchor" anchor=anchor}}

{{#each model.properties as |property|}}
{{class-field-description type="property" field=property}}
{{/each}}
28 changes: 28 additions & 0 deletions tests/acceptance/class-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-acceptance';
import {test} from 'qunit';
import $ from 'jquery';

moduleForAcceptance('Class', {
beforeEach() {
return visit('/ember/1.0.0/classes/Container');
}
});

test('lists all the methods on the class page', function (assert) {
const store = this.application.__container__.lookup('service:store');
const container = store.peekRecord('class', 'ember-1.0.0-Container');
assert.equal($(findWithAssert('.spec-method-list li')).length, container.get('methods.length'));
});

test('lists all the properties on the class page', function (assert) {
const store = this.application.__container__.lookup('service:store');
const container = store.peekRecord('class', 'ember-1.0.0-Container');
assert.equal($(findWithAssert('.spec-property-list li')).length, container.get('properties.length'));
});

test('lists all the events on the class page', function (assert) {
const store = this.application.__container__.lookup('service:store');
const container = store.peekRecord('class', 'ember-1.0.0-Container');
assert.equal($(find('.spec-event-list li')).length, container.get('events.length'));
});

16 changes: 0 additions & 16 deletions tests/acceptance/methods-test.js

This file was deleted.