Skip to content

Commit

Permalink
Upgraded to ember 1.12.0
Browse files Browse the repository at this point in the history
Upgraded ember list view to v 0.0.6
Moved required properties into list-view mixin
Added SafeString to style bindings
Part of emberjs#360
  • Loading branch information
patsy-issa committed Oct 15, 2015
1 parent b35f015 commit c436c9f
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 65 deletions.
7 changes: 3 additions & 4 deletions app/components/drag-handle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from "ember";
const { computed } = Ember;
const { computed, Handlebars: { SafeString } } = Ember;
export default Ember.Component.extend({
classNames: ['drag-handle'],
classNameBindings: ['isLeft:drag-handle--left', 'isRight:drag-handle--right', 'class'],
Expand Down Expand Up @@ -49,9 +49,8 @@ export default Ember.Component.extend({

style: computed('side', 'position', function () {
if (this.get('side')) {
return this.get('side') + ':' + this.get('position') + 'px';
} else {
return '';
return new SafeString(`${this.get('side')}: ${this.get('position')}px;`);
}
return '';
})
});
6 changes: 3 additions & 3 deletions app/components/record-item.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
const { Component, computed } = Ember;
const { Component, computed, Handlebars: { SafeString }, isEmpty } = Ember;
const COLOR_MAP = {
red: '#ff2717',
blue: '#174fff',
Expand All @@ -18,10 +18,10 @@ export default Component.extend({
// TODO: Color record based on `color` property.
style: computed('model.color', function() {
let colorName = this.get('model.color');
if (!Ember.isEmpty(colorName)) {
if (!isEmpty(colorName)) {
let color = COLOR_MAP[colorName];
if (color) {
return 'color:' + color + ';';
return new SafeString(`color: ${color};`);
}
}
return '';
Expand Down
6 changes: 3 additions & 3 deletions app/components/resizable-column.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Ember from "ember";
const { computed } = Ember;
export default Ember.Component.extend({
const { Component, computed, Handlebars: { SafeString } } = Ember;
export default Component.extend({
width: null,

attributeBindings: ['style'],

style: computed('width', function () {
return '-webkit-flex: none; flex: none; width:' + this.get('width') + 'px;';
return new SafeString(`-webkit-flex: none; flex: none; width: ${this.get('width')}px;`);
}),

didInsertElement() {
Expand Down
5 changes: 2 additions & 3 deletions app/components/route-item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';
import checkCurrentRoute from "ember-inspector/utils/check-current-route";
const { Component, computed } = Ember;
const { Component, computed, Handlebars: { SafeString } } = Ember;

export default Component.extend({
// passed as an attribute to the component
Expand All @@ -13,7 +13,7 @@ export default Component.extend({
label: 'route-node',

labelStyle: computed('model.parentCount', function() {
return 'padding-left: ' + ((+this.get('model.parentCount') * 20) + 5) + "px";
return new SafeString(`padding-left: ${+this.get('model.parentCount') * 20 + 5}px;`);
}),

isCurrent: computed('currentRoute', 'model.value.name', function() {
Expand All @@ -25,4 +25,3 @@ export default Component.extend({
return checkCurrentRoute( currentRoute, this.get('model.value.name') );
})
});

4 changes: 2 additions & 2 deletions app/components/view-item.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from "ember";
const { computed, Component } = Ember;
const { computed, Component, Handlebars: { SafeString } } = Ember;
const { not, bool } = computed;

export default Component.extend({
Expand All @@ -25,7 +25,7 @@ export default Component.extend({
}),

labelStyle: computed('model.parentCount', function() {
return 'padding-left: ' + ((+this.get('model.parentCount') * 20) + 5) + "px";
return new SafeString(`padding-left: ${+this.get('model.parentCount') * 20 + 5}px;`);
}),

actions: {
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/promise-item.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from "ember";
const { computed } = Ember;
const { computed, Handlebars: { SafeString } } = Ember;
const { alias, notEmpty, empty, gt, equal } = computed;

const COLOR_MAP = {
Expand Down Expand Up @@ -29,7 +29,7 @@ export default Ember.ObjectProxy.extend({
} else {
color = 'blue';
}
return 'background-color:' + COLOR_MAP[color] + ';color:white;';
return new SafeString(`background-color: ${COLOR_MAP[color]};color: white;'`);
}),


Expand All @@ -52,12 +52,12 @@ export default Ember.ObjectProxy.extend({
relevant = this.get('model').matchesExactly(this.get('effectiveSearch'));
}
if (!relevant) {
return 'opacity: 0.3';
return new SafeString('opacity: 0.3');
}
}),

labelStyle: computed('level', function() {
return 'padding-left: ' + ((+this.get('level') * 20) + 5) + "px";
return new SafeString(`padding-left: ${+this.get('level') * 20 + 5}px;`);
}),

expandedClass: computed('hasChildren', 'isExpanded', function() {
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/render-item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from "ember";
import escapeRegExp from "ember-inspector/utils/escape-reg-exp";
const { ObjectController, computed, isEmpty, run, on, observer } = Ember;
const { ObjectController, computed, isEmpty, run, on, observer, Handlebars: { SafeString } } = Ember;
const { gt, readOnly } = computed;
const { once } = run;

Expand Down Expand Up @@ -34,7 +34,7 @@ export default ObjectController.extend({

nodeStyle: computed('searchMatch', function() {
if (!this.get('searchMatch')) {
return 'opacity: 0.5';
return new SafeString('opacity: 0.5');
}
}),

Expand All @@ -47,7 +47,7 @@ export default ObjectController.extend({
}),

nameStyle: computed('level', function() {
return 'padding-left: ' + ((+this.get('level') * 20) + 5) + "px";
return new SafeString(`padding-left: ${+this.get('level') * 20 + 5}px;`);
}),

hasChildren: gt('children.length', 0),
Expand Down
3 changes: 1 addition & 2 deletions app/styles/list_view.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

.list-view {
.list-view {
position: relative;
font-size: 11px;
height: 100%;
Expand Down
22 changes: 18 additions & 4 deletions app/views/instance-list.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import ListView from "ember-inspector/views/list";
import ListItemView from "ember-inspector/views/list-item";
import ListView from 'ember-inspector/views/list';
import ListItemView from 'ember-inspector/views/list-item';

/**
* @module Views
* @extends Views.List
* @class InstanceList
* @namespace Views
*/
export default ListView.extend({
/**
* @property itemViewClass
* @type {Ember.View}
*/
itemViewClass: ListItemView.extend({
templateName: "instance_item"
/**
* @property templateName
* @type {String}
* @default 'instance_item'
*/
templateName: 'instance_item'
})

});
13 changes: 12 additions & 1 deletion app/views/list-item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import ListItemView from "list-view/list-item-view";
import ListItemView from 'ember-list-view/list-item-view';

/**
* @module Views
* @extends ListItemView
* @class ListItem
* @namespace Views
*/
export default ListItemView.extend({
/**
* @property classNames
* @type {Array}
*/
classNames: ["list-tree__item-wrapper", "row-wrapper"]
});
42 changes: 37 additions & 5 deletions app/views/list.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
import Ember from "ember";
import ListItemView from "ember-inspector/views/list-item";
import ListView from "list-view/list-view";
const { computed } = Ember;
import Ember from 'ember';
import ListView from 'ember-list-view';
import ListItemView from 'ember-inspector/views/list-item';

const { computed, computed: { alias } } = Ember;

/**
* Base list view config
*
* @module Views
* @extends ListView
* @class List
* @namespace Views
*/
export default ListView.extend({
/**
* @property classNames
* @type {Array}
*/
classNames: ["list-tree"],

contentHeight: Ember.computed.alias('controller.controllers.application.contentHeight'),
/**
* @property contentHeight
* @type {Integer}
*/
contentHeight: alias('controller.controllers.application.contentHeight'),

/**
* @property height
* @type {Integer}
*/
height: computed('contentHeight', function() {
let headerHeight = 31;
let contentHeight = this.get('contentHeight');
Expand All @@ -19,6 +40,17 @@ export default ListView.extend({
}
return contentHeight - headerHeight;
}),

/**
* @property rowHeight
* @type {Integer}
* @default 30
*/
rowHeight: 30,

/**
* @property itemViewClass
* @type {Ember.View}
*/
itemViewClass: ListItemView
});
20 changes: 17 additions & 3 deletions app/views/promise-list.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import ListView from "ember-inspector/views/list";
import ListView from 'ember-inspector/views/list';
import ListItemView from "ember-inspector/views/list-item";

/**
* @module Views
* @extends Views.List
* @class PromiseList
* @namespace Views
*/
export default ListView.extend({
/**
* @property itemViewClass
* @type {Ember.View}
*/
itemViewClass: ListItemView.extend({
templateName: "promise_item"
/**
* @property templateName
* @type {String}
* @default 'promise_item'
*/
templateName: 'promise_item'
})

});
31 changes: 25 additions & 6 deletions app/views/record-list.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
import Ember from 'ember';
import ListView from "ember-inspector/views/list";
import ListItemView from "ember-inspector/views/list-item";
import ListView from 'ember-inspector/views/list';
import ListItemView from 'ember-inspector/views/list-item';

const { computed } = Ember;
const { readOnly } = computed;
const { computed: { readOnly } } = Ember;

/**
* @module Views
* @extends Views.List
* @class RecordList
* @namespace Views
*/
export default ListView.extend({
/**
* @property itemViewClass
* @type {Ember.View}
*/
itemViewClass: ListItemView.extend({
templateName: "record_item",
/**
* @property templateName
* @type {String}
* @default 'record_item'
*/
templateName: 'record_item',

// TODO: Look for a better way
/**
* TODO: Need a better way to pass this
*
* @property columns
* @type {Array}
*/
columns: readOnly('parentView.columns')
})
});
4 changes: 2 additions & 2 deletions app/views/render-list.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Ember from "ember";
const { View, computed } = Ember;
const { View, computed, Handlebars: { SafeString } } = Ember;

export default View.extend({
attributeBindings: ['style'],

classNames: ["list-tree", "list-tree_scrollable"],

style: computed('height', function() {
return 'height:' + this.get('height') + 'px';
return new SafeString(`height: ${this.get('height')}px;`);
}),

contentHeight: Ember.computed.alias('controller.controllers.application.contentHeight'),
Expand Down
32 changes: 26 additions & 6 deletions app/views/route-list.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import Ember from 'ember';
import ListView from "ember-inspector/views/list";
import ListItemView from "ember-inspector/views/list-item";
const { computed } = Ember;
const { readOnly } = computed;
import ListView from 'ember-inspector/views/list';
import ListItemView from 'ember-inspector/views/list-item';

const { computed: { readOnly } } = Ember;

/**
* @module Views
* @extends Views.List
* @class RouteList
* @namespace Views
*/
export default ListView.extend({
/**
* @property itemViewClass
* @type {Ember.View}
*/
itemViewClass: ListItemView.extend({
templateName: "route_item",
/**
* @property templateName
* @type {String}
* @default 'route_item'
*/
templateName: 'route_item',

// TODO: Need a better way to pass this
/**
* TODO: Need a better way to pass this
*
* @property currentRoute
* @type {String}
*/
currentRoute: readOnly('parentView.currentRoute')
})
});
Loading

0 comments on commit c436c9f

Please sign in to comment.