Skip to content

Commit 34820ad

Browse files
Gaurav0fivetanley
authored andcommitted
Display properties and events (#43)
1 parent 8fc9a75 commit 34820ad

File tree

16 files changed

+128
-39
lines changed

16 files changed

+128
-39
lines changed

app/controllers/events.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Ember from "ember";
2+
import AnchorControllerSupport from "ember-anchor/mixins/controller-support";
3+
4+
export default Ember.Controller.extend(AnchorControllerSupport, {
5+
queryParams: ['anchor']
6+
});

app/controllers/properties.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Ember from "ember";
2+
import AnchorControllerSupport from "ember-anchor/mixins/controller-support";
3+
4+
export default Ember.Controller.extend(AnchorControllerSupport, {
5+
queryParams: ['anchor']
6+
});

app/models/class.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const {attr, belongsTo} = DS;
66
export default DS.Model.extend({
77
name: attr(),
88
methods: attr(),
9+
properties: attr(),
10+
events: attr(),
911
description: attr(),
1012
ogDescription: attr(),
1113
parentClass: belongsTo('class', {async: true, inverse: null}),

app/router.js

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Router.map(function() {
1313
this.route('methods', {resetNamespace: true}, function() {
1414
this.route('method', {path: '/:method'});
1515
});
16+
this.route('properties', {resetNamespace: true}, function() {
17+
this.route('property', {path: '/:property'});
18+
});
19+
this.route('events', {resetNamespace: true}, function() {
20+
this.route('event', {path: '/:event'});
21+
});
1622
});
1723
});
1824
});

app/routes/project-version.js

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export default Ember.Route.extend({
4040
case 'project-version.class':
4141
endingRoute = `classes/${this.modelFor(routeName).get('name')}`;
4242
break;
43+
case 'project-version.class.index':
44+
endingRoute = `classes/${this.modelFor('project-version.class').get('name')}`;
45+
break;
4346
default:
4447
break;
4548
}

app/routes/project-version/class.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default Ember.Route.extend({
1414
const version = transition.params['project-version'].project_version;
1515
const klass = params.class;
1616

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

2022
afterModel(klass) {

app/styles/_class.scss

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
article.chapter ul {
2+
list-style-type: none;
3+
-webkit-column-count: 2;
4+
column-count: 2;
5+
-webkit-column-gap: 1em;
6+
column-count: 1em;
7+
vertical-align: baseline;
8+
9+
li {
10+
margin-top: 0;
11+
margin-bottom: 0;
12+
}
13+
}

app/styles/app.scss

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
@import "neat";
44
@import "./components/all";
55

6+
@import "class";
7+
68
body {
79
margin: 0;
810
}

app/styles/base/_lists.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ dl {
8181
}
8282
}
8383

84-
.method {
84+
.method, .property, .event {
8585
border-bottom: $base-border;
8686

87-
.method-name {
87+
.method-name, .property-name, .event-name {
8888
font-family: $monospace-font-family;
8989
}
9090
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<section class="{{type}}">
2+
<h3 data-anchor="{{field.name}}">
3+
<span class="{{field}}-name">{{field.name}}</span>
4+
{{#if field.params}}
5+
<span class="args">
6+
({{join ", " (map-by "name" field.params)}})
7+
</span>
8+
{{/if}}
9+
</h3>
10+
<dl class="parameters">
11+
{{#each field.params as |param|}}
12+
<div class="parameter">
13+
<dt>{{param.name}}</dt>
14+
<dd>{{param.type}}</dd>
15+
<dd>{{param.description}}</dd>
16+
</div>
17+
{{/each}}
18+
</dl>
19+
{{{field.description}}}
20+
</section>

app/templates/events.hbs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ember-anchor a="anchor" anchor=anchor}}
2+
3+
{{#each model.events as |event|}}
4+
{{class-field-description type="event" field=event}}
5+
{{/each}}

app/templates/methods.hbs

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
11
{{ember-anchor a="anchor" anchor=anchor}}
22

33
{{#each model.methods as |method|}}
4-
<section class="method">
5-
<h3 data-anchor="{{method.name}}">
6-
<span class="method-name">{{method.name}}</span>
7-
{{#if method.params}}
8-
<span class="args">
9-
({{join ", " (map-by "name" method.params)}})
10-
</span>
11-
{{/if}}
12-
</h3>
13-
<dl class="parameters">
14-
{{#each method.params as |param|}}
15-
<div class="parameter">
16-
<dt>{{param.name}}</dt>
17-
<dd>{{param.type}}</dd>
18-
<dd>{{param.description}}</dd>
19-
</div>
20-
{{/each}}
21-
</dl>
22-
{{{method.description}}}
23-
</section>
4+
{{class-field-description type="method" field=method}}
245
{{/each}}

app/templates/project-version/class.hbs

+26
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
</ul>
1717
</section>
1818

19+
<section>
20+
<h2>Properties</h2>
21+
<ul class="spec-property-list">
22+
{{#each model.properties as |property|}}
23+
<li>
24+
{{#link-to 'properties.property' model.project.id model.projectVersion.version model.name property.name (query-params anchor=property.name)}}
25+
{{property.name}}
26+
{{/link-to}}
27+
</li>
28+
{{/each}}
29+
</ul>
30+
</section>
31+
32+
<section>
33+
<h2>Events</h2>
34+
<ul class="spec-event-list">
35+
{{#each model.events as |event|}}
36+
<li>
37+
{{#link-to 'events.event' model.project.id model.projectVersion.version model.name event.name (query-params anchor=event.name)}}
38+
{{event.name}}
39+
{{/link-to}}
40+
</li>
41+
{{/each}}
42+
</ul>
43+
</section>
44+
1945
{{outlet}}
2046

2147
</article>

app/templates/properties.hbs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ember-anchor a="anchor" anchor=anchor}}
2+
3+
{{#each model.properties as |property|}}
4+
{{class-field-description type="property" field=property}}
5+
{{/each}}

tests/acceptance/class-test.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-acceptance';
2+
import {test} from 'qunit';
3+
import $ from 'jquery';
4+
5+
moduleForAcceptance('Class', {
6+
beforeEach() {
7+
return visit('/ember/1.0.0/classes/Container');
8+
}
9+
});
10+
11+
test('lists all the methods on the class page', function (assert) {
12+
const store = this.application.__container__.lookup('service:store');
13+
const container = store.peekRecord('class', 'ember-1.0.0-Container');
14+
assert.equal($(findWithAssert('.spec-method-list li')).length, container.get('methods.length'));
15+
});
16+
17+
test('lists all the properties on the class page', function (assert) {
18+
const store = this.application.__container__.lookup('service:store');
19+
const container = store.peekRecord('class', 'ember-1.0.0-Container');
20+
assert.equal($(findWithAssert('.spec-property-list li')).length, container.get('properties.length'));
21+
});
22+
23+
test('lists all the events on the class page', function (assert) {
24+
const store = this.application.__container__.lookup('service:store');
25+
const container = store.peekRecord('class', 'ember-1.0.0-Container');
26+
assert.equal($(find('.spec-event-list li')).length, container.get('events.length'));
27+
});
28+

tests/acceptance/methods-test.js

-16
This file was deleted.

0 commit comments

Comments
 (0)