Skip to content
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

Sort model properties #622

Merged
merged 2 commits into from
Oct 21, 2017
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
18 changes: 17 additions & 1 deletion app/components/mixin-detail.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from "ember";
const { computed, Component } = Ember;
const { readOnly } = computed;
const { readOnly, sort } = computed;

export default Component.extend({
/**
Expand All @@ -17,6 +17,22 @@ export default Component.extend({
return this.get('model.expand') && this.get('model.properties.length') > 0;
}),

/**
* Used by the `sort` computed macro.
*
* @property sortProperties
* @type {Array<String>}
*/
sortProperties: ['name'],

/**
* Sort the properties by name to make them easier to find in the object inspector.
*
* @property sortedProperties
* @type {Array<Object>}
*/
sortedProperties: sort('model.properties', 'sortProperties'),

actions: {
calculate({ name }) {
let objectId = this.get('objectId');
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/mixin-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{/if}}
{{#if mixin.isExpanded}}
<ul class="mixin__properties">
{{#each mixin.model.properties as |prop|}}
{{#each mixin.sortedProperties as |prop|}}
{{#mixin-property model=prop mixin=mixin as |property|}}
<li class="{{if property.model.overridden 'mixin__property_state_overridden'}} mixin__property js-object-property">
{{#if property.model.value.computed}}
Expand Down