Skip to content

Commit

Permalink
Add hideable option to columns (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
offirgolan authored Jun 9, 2016
1 parent e817369 commit 3c3fccd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions addon/classes/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ const {
* @class Column
*/
export default class Column extends Ember.Object.extend({
/**
* @property hideable
* @type {Boolean}
* @default true
*/
hideable: true,

/**
* @property hidden
* @type {Boolean}
Expand Down
16 changes: 14 additions & 2 deletions addon/classes/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,29 @@ export default class Table extends Ember.Object.extend({
*/
visibleRows: computed.filterBy('rows', 'hidden', false).readOnly(),

/**
* @property sortableColumns
* @type {Ember.Array}
*/
sortableColumns: computed.filterBy('visibleColumns', 'sortable', true).readOnly(),

/**
* @property sortedColumns
* @type {Ember.Array}
*/
sortedColumns: computed.filterBy('visibleColumns', 'sorted', true).readOnly(),

/**
* @property sortableColumns
* @property hideableColumns
* @type {Ember.Array}
*/
sortableColumns: computed.filterBy('visibleColumns', 'sortable', true).readOnly(),
hideableColumns: computed.filterBy('flattenedColumns', 'hideable', true).readOnly(),

/**
* @property hiddenColumns
* @type {Ember.Array}
*/
hiddenColumns: computed.filterBy('flattenedColumns', 'hidden', true).readOnly(),

/**
* @property visibleColumns
Expand Down
3 changes: 2 additions & 1 deletion addon/components/columns/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ const Column = Ember.Component.extend({
tagName: 'th',
classNames: ['lt-column'],
attributeBindings: ['width', 'colspan', 'rowspan'],
classNameBindings: ['align', 'isGroupColumn:lt-group-column', 'isSortable', 'isSorted', 'column.classNames'],
classNameBindings: ['align', 'isGroupColumn:lt-group-column', 'isHideable', 'isSortable', 'isSorted', 'column.classNames'],

width: computed.readOnly('column.width'),
isGroupColumn: computed.readOnly('column.isGroupColumn'),
isSortable: computed.readOnly('column.sortable'),
isSorted: computed.readOnly('column.sorted'),
isHideable: computed.readOnly('column.hideable'),

align: computed('column.align', function() {
return `align-${this.get('column.align')}`;
Expand Down

0 comments on commit 3c3fccd

Please sign in to comment.