diff --git a/README.md b/README.md index 37ee3ac..fbb4a2b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ You'll need to include the following files in your project: * loadMoreAction: "[Action Name]" *// (the action that should be fired when user scrolls to bottom of page - only used when infiniteScrollEnabled is true, and isLoadingRows is false)* * noContentView: [Instance of Em.View] *// (this view will be rendered instead of the table if there are no rows.)* * useRenderingIndicator: (true || false) *// (True by default. When true, this will disable the adding of a rendering indicator to the table when the table is taking a while to render)* +* disableSortDirection: (true || false) *// (False by default.) When true, the sortAscending property will not change when the user clicks a column header (The sortAscending property will remain unchanged)* #### Column Configurations: Here are the options for configuring columns: @@ -121,5 +122,7 @@ export default Ember.Controller.extend({ isLoadingRows=isLoadingData loadMoreAction='loadMore' customSortAction='sortTheTable' + sortAscending=false + disableSortDirection=false }} ``` diff --git a/bower.json b/bower.json index 3edf618..da36eb8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ember-bootstrap-table", - "version": "0.1.0", + "version": "0.1.1", "homepage": "https://github.com/grese/ember-bootstrap-table", "authors": [ "grese " diff --git a/dist/ember-bootstrap-table.js b/dist/ember-bootstrap-table.js index bf1b25b..12b07b7 100644 --- a/dist/ember-bootstrap-table.js +++ b/dist/ember-bootstrap-table.js @@ -337,11 +337,11 @@ var TFootContainerView = Em.ContainerView.extend({ init: function(){ - this.set('loadingRow', LoadingRow.create()); this._super(); + this.set('loadingRow', LoadingRow.create()); + this.pushObject(this.get('loadingRow')); }, tagName: 'tfoot', - childViews: ['loadingRow'], loadingRow: null, component: function(){ return this.get('_parentView.component'); @@ -350,15 +350,15 @@ var TableContainerView = Em.ContainerView.extend({ init: function(){ + this._super(); this.setProperties({ thead: THeadContainerView.create(), tbody: TBodyContainerView.create(), tfoot: TFootContainerView.create() }); - this._super(); + this.pushObjects([this.get('thead'), this.get('tbody'), this.get('tfoot')]); }, tagName: 'table', - childViews: ['thead', 'tbody', 'tfoot'], classNames: ['table-component-table', 'table'], component: function(){ return this.get('_parentView._parentView'); @@ -416,6 +416,7 @@ infiniteScrollEnabled: false, isLoadingRows: false, loadMoreAction: null, + disableSortDirection: false, // [END] User-Defined Options: @@ -558,7 +559,10 @@ _sortTable: function(colIdx){ // If the colIdx is same as current sortIndex, reverse sorting order. if(colIdx === this.get('sortIndex')){ - this.set('sortAscending', !this.get('sortAscending')); + // If disableSortDirection is false, we update sortAscending. If not, do nothing. + if(!this.get('disableSortDirection')){ + this.set('sortAscending', !this.get('sortAscending')); + } }else{ this.set('sortIndex', colIdx); } diff --git a/dist/ember-bootstrap-table.min.js b/dist/ember-bootstrap-table.min.js index 497d048..ac82c9d 100644 --- a/dist/ember-bootstrap-table.min.js +++ b/dist/ember-bootstrap-table.min.js @@ -1 +1 @@ -!function(){"use strict";var a=Em.get,b=Em.Object.extend({sortable:"fa fa-sort",sortAsc:"fa fa-sort-asc",sortDesc:"fa fa-sort-desc",detailsClosed:"fa fa-chevron-right",detailsOpen:"fa fa-chevron-down",loadingRows:"fa fa-spinner fa-pulse fa-2x"}),c=Em.Object.extend({headerCellName:"",headerCellClassName:null,headerCellCustomViewClass:null,headerCellInfo:null,cellValuePath:null,cellClassName:null,cellCustomViewClass:null,getCellContent:null,columnWidth:null,sortAscending:!0,_columnIndex:null,sortOn:null,sort:function(b,c,d){c=c||[],b=b||Em.Object.create();var e=a(b,"getCellContent"),f=a(b,"cellValuePath"),g=a(b,"sortOn")&&"cellValuePath"===a(b,"sortOn"),h=e&&!g;return!c.sort&&c.get("content")&&(c=c.get("content")),f||e?c.sort(function(c,g){var i=h?e(c,b):a(c,f),j=h?e(g,b):a(g,f);if(d){if(j>i)return-1;if(i>j)return 1}else{if(i>j)return-1;if(j>i)return 1}return 0}):(Em.Logger.warn(" Table component's default sorting function requires that either cellValuePath or getCellContent are specified for each sortable column. You must either specify one of these params to return the value for this column, or override this column's sort function. ",b),c)},_hasTooltipText:function(){return this.get("headerCellInfo")?!0:!1}.property("headerCellInfo")}),d=Em.View.extend({tagName:"td",classNames:["table-component-row-toggle-cell"],rowData:null,component:function(){return this.get("_parentView.component")}.property(),toggleIconClass:function(){return this.get(this.get("rowData._detailRowEnabled")?"component._icons.detailsOpen":"component._icons.detailsClosed")}.property("rowData._detailRowEnabled"),template:function(){var a="{{action '_toggledDetailRow' view.rowData._rowIndex view.rowData._detailRowEnabled}}",b="class='table-cell-button'",c="{{bind-attr class='view.toggleIconClass'}}";return Em.Handlebars.compile("")}.property("rowData._detailRowEnabled","rowData._rowIndex","toggleIconClass")}),e=Em.View.extend({tagName:"tr",classNames:["table-component-loading-row"],component:function(){return this.get("_parentView.component")}.property(),template:function(){var a=this.get("component._icons.loadingRows"),b=this.get("component._colspan");return Em.Handlebars.compile("{{#if view.component._showLoadingRow}}{{/if}}")}.property("component.isLoadingRows")}),f=Em.View.extend({tagName:"th",classNames:["table-component-header-cell"],classNameBindings:["colConfig.headerCellClassName"],attributeBindings:["width"],width:function(){return a(this,"colConfig.columnWidth")}.property("colConfig.columnWidth"),component:function(){return this.get("_parentView.component")}.property(),colConfig:null,sortIconClass:function(){var a=this.get("component.sortIndex"),b=this.get("colConfig._columnIndex");return this.get(a===b?this.get("component.sortAscending")?"component._icons.sortAsc":"component._icons.sortDesc":"component._icons.sortable")}.property("component.sortIndex","component.sortAscending"),template:function(){var a,b,c,d=this.get("colConfig"),e=d.get("headerCellName"),f=d.get("sortable"),g=d.get("headerCellInfo"),h=g?"title='"+g+"' data-toggle='tooltip'":"",i="class='table-component-header-text'",j=e;return f?(a="{{action '_sortTable' view.colConfig._columnIndex}}",b="class='table-cell-button table-component-header-cell-sort'",c="{{bind-attr class=':table-component-sort-icon view.sortIconClass'}}",j=""):j=""+e+"",Em.Handlebars.compile(j)}.property("colConfig","component.sortIndex","component.sortAscending"),didInsertElement:function(){this.get("component.showTooltips")&&this.$().find("[data-toggle='tooltip']").tooltip()}}),g=Em.ContainerView.extend({tagName:"tr",classNames:["table-component-header-row"],component:function(){return this.get("_parentView.component")}.property()}),h=Em.ContainerView.extend({tagName:"thead",component:function(){return this.get("_parentView.component")}.property(),insertHeaderCells:function(a){var b=[],c=this.get("component._cols");this.get("component._insertDefaultDetailToggle")&&b.push(Em.View.create({tagName:"th"})),c.forEach(function(c){var d=c.get("headerCellCustomViewClass")||f;b.push(d.create({colConfig:c,container:a}))});var d=g.create();d.pushObjects(b),this.pushObject(d)}}),i=Em.View.extend({tagName:"td",classNames:["table-component-cell"],classNameBindings:["colConfig.cellClassName"],attributeBindings:["width"],width:function(){return this.get("colConfig.columnWidth")}.property("colConfig.columnWidth"),colConfig:null,row:null,template:function(){var a=this.get("colConfig"),b=a.get("getCellContent"),c=a.get("cellValuePath"),d=this.get("rowData"),e="";return b?e=b(d,a):c&&(e=null!==c?d.get(c):""),Em.Handlebars.compile(e.toString())}.property()}),j=Em.View.extend({tagName:"td",classNames:["table-component-detail-row-cell"],attributeBindings:["colspan"],colspan:function(){return this.get("component._colspan")}.property("component._colspan"),component:function(){return this.get("_parentView.component")}.property(),detailViewClass:function(){return this.get("component.detailRowViewClass")}.property(),rowData:null,row:function(){return this.get("rowData.content")}.property("rowData.content"),template:Em.Handlebars.compile("
{{view view.detailViewClass row=view.row}}
")}),k=Em.ContainerView.extend({init:function(){this._super(),this.pushObject(j.create({rowData:this.get("rowData")}))},tagName:"tr",classNames:["table-component-detail-row","collapse"],classNameBindings:["isEnabled:in"],isEnabled:function(){return this.get("rowData._detailRowEnabled")}.property("rowData._detailRowEnabled"),rowData:null,component:function(){return this.get("_parentView.component")}.property()}),l=Em.ContainerView.extend({tagName:"tr",classNames:["table-component-row"],component:function(){return this.get("_parentView.component")}.property(),rowData:null,insertCells:function(a){var b=this.get("component._cols"),c=[];this.get("component._insertDefaultDetailToggle")&&c.push(d.create({rowData:this.get("rowData")}));var e=this.get("rowData.content"),f=this.get("rowData");b.forEach(function(b){var d=b.get("cellCustomViewClass")||i,g=d.create({colConfig:b,rowData:f,row:e,container:a});c.push(g)}),this.pushObjects(c)}}),m=Em.ContainerView.extend({tagName:"tbody",component:function(){return this.get("_parentView.component")}.property(),insertRows:function(){var a=this,b=this.get("component._rows")||[],c=[],d=this.get("_parentView.container");b.forEach(function(b){var e=l.create({rowData:b,component:a.get("component")});e.insertCells(d),c.push(e),a.get("component._detailRowsEnabled")&&c.push(k.create({rowData:b,container:d}))}),this.pushObjects(c)}}),n=Em.ContainerView.extend({init:function(){this.set("loadingRow",e.create()),this._super()},tagName:"tfoot",childViews:["loadingRow"],loadingRow:null,component:function(){return this.get("_parentView.component")}.property()}),o=Em.ContainerView.extend({init:function(){this.setProperties({thead:h.create(),tbody:m.create(),tfoot:n.create()}),this._super()},tagName:"table",childViews:["thead","tbody","tfoot"],classNames:["table-component-table","table"],component:function(){return this.get("_parentView._parentView")}.property(),classNameBindings:["component.condensed:table-condensed","component.striped:table-striped","component.bordered:table-bordered","component.hoverable:table-hoverable"],thead:null,tbody:null,tfoot:null,setup:function(){this.get("component.showHeader")&&this.get("thead").insertHeaderCells(this.container)},update:function(){this.get("tbody").removeAllChildren(),this.get("tbody").insertRows()}}),p=Em.ObjectProxy.extend({_rowIndex:null,_detailRowEnabled:!1}),q=Em.Component.extend({init:function(){this.set("_table",o.create()),this._super()},sortIndex:0,sortAscending:!0,rows:[],columns:[],icons:null,hoverable:!0,striped:!1,condensed:!1,responsive:!0,bordered:!1,customSortAction:null,noContentView:null,showHeader:!0,showTooltips:!0,useDefaultDetailRowToggle:!0,customDetailRowToggleAction:null,detailRowViewClass:null,hasDetailRows:!1,infiniteScrollEnabled:!1,isLoadingRows:!1,loadMoreAction:null,tagName:"div",classNames:["table-component"],classNameBindings:["responsive:table-responsive"],_table:null,layout:Em.Handlebars.compile("{{#if _showNoContentView}}{{view noContentView}}{{else}}{{view _table}}{{/if}}"),_cols:function(){var a=this.get("columns")||[],b=0;return a.map(function(a){var d=c.create(a);return d.set("_columnIndex",b++),d})}.property("columns.[]"),_rows:function(){var a=this.get("rows")||[],b=0;return this.get("_useNativeSort")&&this.get("_hasRows")&&(a=this._performNativeSort(a)),a.map(function(a){return p.create({content:a,_rowIndex:b++})})}.property("rows.[]"),_rowsChanged:function(){var a=this;Em.run.once(function(){a.get("_table").update()})}.observes("_rows.[]"),_detailRowsEnabled:function(){var a=!1;return this.get("hasDetailRows")&&(null!==this.get("detailRowViewClass")?a=!0:Em.Logger.warn(": when hasDetailRows is true, you must also provide a view for the detailRowViewClass")),a}.property("hasDetailRows","detailRowViewClass"),_useNativeSort:function(){return null===this.get("customSortAction")}.property("customSortAction"),_performNativeSort:function(b){var c,d=this.get("sortAscending"),e=this.get("_cols").objectAt(this.get("sortIndex"));return e.get("sortable")?(c=a(e,"sort"))(e,b,d):b},_sortingPropertiesChanged:function(){var a=this;Em.run.once(function(){a.get("_useNativeSort")?a.notifyPropertyChange("rows"):a.sendAction("customSortAction",a.get("sortIndex"),a.get("sortAscending"))})}.observes("sortAscending","sortIndex"),_showNoContentView:function(){return null!==this.get("noContentView")&&!this.get("_hasRows")}.property("_hasNoContentView","rows.[]"),_icons:function(){var a=this.get("icons")||{};return b.create(a)}.property("icons"),_hasRows:function(){return this.get("rows")&&this.get("rows.length")>0}.property("rows.[]"),_hasColumns:function(){return this.get("columns")&&this.get("columns.length")>0}.property("columns.[]"),_numColumns:function(){return this.get("columns").length}.property("columns.[]"),_colspan:function(){return this.get("_detailRowsEnabled")&&this.get("useDefaultDetailRowToggle")?this.get("_numColumns")+1:this.get("_numColumns")}.property("columns.[]","useDefaultDetailRowToggle","_detailRowsEnabled"),_loadMoreRows:function(){this.get("loadMoreAction")&&!this.get("isLoadingRows")&&this.sendAction("loadMoreAction")},_showLoadingRow:function(){return this.get("infiniteScrollEnabled")&&this.get("isLoadingRows")}.property("isLoadingRows","infiniteScrollEnabled"),_insertDefaultDetailToggle:function(){return this.get("_detailRowsEnabled")&&this.get("useDefaultDetailRowToggle")}.property(),_sortIndex:function(){return this.get("_insertDefaultDetailToggle")?this.get("sortIndex")+1:this.get("sortIndex")}.property("sortIndex"),_attachInfiniteScrollListener:function(){var a=this;$(window).scroll(function(){$(window).scrollTop()===$(document).height()-$(window).height()&&a._loadMoreRows()})},willInsertElement:function(){this.get("_table").setup(),this.get("_table").update()},didInsertElement:function(){this.get("infiniteScrollEnabled")&&this._attachInfiniteScrollListener()},actions:{_sortTable:function(a){a===this.get("sortIndex")?this.set("sortAscending",!this.get("sortAscending")):this.set("sortIndex",a)},_toggledDetailRow:function(a,b){if(this.get("useDefaultDetailRowToggle")){var c=this.get("_rows").objectAt(a);c.set("_detailRowEnabled",!b)}}}});Em.TableComponent=q,Em.Handlebars.helper("table-component",Em.TableComponent)}(this); \ No newline at end of file +!function(){"use strict";var a=Em.get,b=Em.Object.extend({sortable:"fa fa-sort",sortAsc:"fa fa-sort-asc",sortDesc:"fa fa-sort-desc",detailsClosed:"fa fa-chevron-right",detailsOpen:"fa fa-chevron-down",loadingRows:"fa fa-spinner fa-pulse fa-2x"}),c=Em.Object.extend({headerCellName:"",headerCellClassName:null,headerCellCustomViewClass:null,headerCellInfo:null,cellValuePath:null,cellClassName:null,cellCustomViewClass:null,getCellContent:null,columnWidth:null,sortAscending:!0,_columnIndex:null,sortOn:null,sort:function(b,c,d){c=c||[],b=b||Em.Object.create();var e=a(b,"getCellContent"),f=a(b,"cellValuePath"),g=a(b,"sortOn")&&"cellValuePath"===a(b,"sortOn"),h=e&&!g;return!c.sort&&c.get("content")&&(c=c.get("content")),f||e?c.sort(function(c,g){var i=h?e(c,b):a(c,f),j=h?e(g,b):a(g,f);if(d){if(j>i)return-1;if(i>j)return 1}else{if(i>j)return-1;if(j>i)return 1}return 0}):(Em.Logger.warn(" Table component's default sorting function requires that either cellValuePath or getCellContent are specified for each sortable column. You must either specify one of these params to return the value for this column, or override this column's sort function. ",b),c)},_hasTooltipText:function(){return this.get("headerCellInfo")?!0:!1}.property("headerCellInfo")}),d=Em.View.extend({tagName:"td",classNames:["table-component-row-toggle-cell"],rowData:null,component:function(){return this.get("_parentView.component")}.property(),toggleIconClass:function(){return this.get(this.get("rowData._detailRowEnabled")?"component._icons.detailsOpen":"component._icons.detailsClosed")}.property("rowData._detailRowEnabled"),template:function(){var a="{{action '_toggledDetailRow' view.rowData._rowIndex view.rowData._detailRowEnabled}}",b="class='table-cell-button'",c="{{bind-attr class='view.toggleIconClass'}}";return Em.Handlebars.compile("")}.property("rowData._detailRowEnabled","rowData._rowIndex","toggleIconClass")}),e=Em.View.extend({tagName:"tr",classNames:["table-component-loading-row"],component:function(){return this.get("_parentView.component")}.property(),template:function(){var a=this.get("component._icons.loadingRows"),b=this.get("component._colspan");return Em.Handlebars.compile("{{#if view.component._showLoadingRow}}{{/if}}")}.property("component.isLoadingRows")}),f=Em.View.extend({tagName:"th",classNames:["table-component-header-cell"],classNameBindings:["colConfig.headerCellClassName"],attributeBindings:["width"],width:function(){return a(this,"colConfig.columnWidth")}.property("colConfig.columnWidth"),component:function(){return this.get("_parentView.component")}.property(),colConfig:null,sortIconClass:function(){var a=this.get("component.sortIndex"),b=this.get("colConfig._columnIndex");return this.get(a===b?this.get("component.sortAscending")?"component._icons.sortAsc":"component._icons.sortDesc":"component._icons.sortable")}.property("component.sortIndex","component.sortAscending"),template:function(){var a,b,c,d=this.get("colConfig"),e=d.get("headerCellName"),f=d.get("sortable"),g=d.get("headerCellInfo"),h=g?"title='"+g+"' data-toggle='tooltip'":"",i="class='table-component-header-text'",j=e;return f?(a="{{action '_sortTable' view.colConfig._columnIndex}}",b="class='table-cell-button table-component-header-cell-sort'",c="{{bind-attr class=':table-component-sort-icon view.sortIconClass'}}",j=""):j=""+e+"",Em.Handlebars.compile(j)}.property("colConfig","component.sortIndex","component.sortAscending"),didInsertElement:function(){this.get("component.showTooltips")&&this.$().find("[data-toggle='tooltip']").tooltip()}}),g=Em.ContainerView.extend({tagName:"tr",classNames:["table-component-header-row"],component:function(){return this.get("_parentView.component")}.property()}),h=Em.ContainerView.extend({tagName:"thead",component:function(){return this.get("_parentView.component")}.property(),insertHeaderCells:function(a){var b=[],c=this.get("component._cols");this.get("component._insertDefaultDetailToggle")&&b.push(Em.View.create({tagName:"th"})),c.forEach(function(c){var d=c.get("headerCellCustomViewClass")||f;b.push(d.create({colConfig:c,container:a}))});var d=g.create();d.pushObjects(b),this.pushObject(d)}}),i=Em.View.extend({tagName:"td",classNames:["table-component-cell"],classNameBindings:["colConfig.cellClassName"],attributeBindings:["width"],width:function(){return this.get("colConfig.columnWidth")}.property("colConfig.columnWidth"),colConfig:null,row:null,template:function(){var a=this.get("colConfig"),b=a.get("getCellContent"),c=a.get("cellValuePath"),d=this.get("rowData"),e="";return b?e=b(d,a):c&&(e=null!==c?d.get(c):""),Em.Handlebars.compile(e.toString())}.property()}),j=Em.View.extend({tagName:"td",classNames:["table-component-detail-row-cell"],attributeBindings:["colspan"],colspan:function(){return this.get("component._colspan")}.property("component._colspan"),component:function(){return this.get("_parentView.component")}.property(),detailViewClass:function(){return this.get("component.detailRowViewClass")}.property(),rowData:null,row:function(){return this.get("rowData.content")}.property("rowData.content"),template:Em.Handlebars.compile("
{{view view.detailViewClass row=view.row}}
")}),k=Em.ContainerView.extend({init:function(){this._super(),this.pushObject(j.create({rowData:this.get("rowData")}))},tagName:"tr",classNames:["table-component-detail-row","collapse"],classNameBindings:["isEnabled:in"],isEnabled:function(){return this.get("rowData._detailRowEnabled")}.property("rowData._detailRowEnabled"),rowData:null,component:function(){return this.get("_parentView.component")}.property()}),l=Em.ContainerView.extend({tagName:"tr",classNames:["table-component-row"],component:function(){return this.get("_parentView.component")}.property(),rowData:null,insertCells:function(a){var b=this.get("component._cols"),c=[];this.get("component._insertDefaultDetailToggle")&&c.push(d.create({rowData:this.get("rowData")}));var e=this.get("rowData.content"),f=this.get("rowData");b.forEach(function(b){var d=b.get("cellCustomViewClass")||i,g=d.create({colConfig:b,rowData:f,row:e,container:a});c.push(g)}),this.pushObjects(c)}}),m=Em.ContainerView.extend({tagName:"tbody",component:function(){return this.get("_parentView.component")}.property(),insertRows:function(){var a=this,b=this.get("component._rows")||[],c=[],d=this.get("_parentView.container");b.forEach(function(b){var e=l.create({rowData:b,component:a.get("component")});e.insertCells(d),c.push(e),a.get("component._detailRowsEnabled")&&c.push(k.create({rowData:b,container:d}))}),this.pushObjects(c)}}),n=Em.ContainerView.extend({init:function(){this._super(),this.set("loadingRow",e.create()),this.pushObject(this.get("loadingRow"))},tagName:"tfoot",loadingRow:null,component:function(){return this.get("_parentView.component")}.property()}),o=Em.ContainerView.extend({init:function(){this._super(),this.setProperties({thead:h.create(),tbody:m.create(),tfoot:n.create()}),this.pushObjects([this.get("thead"),this.get("tbody"),this.get("tfoot")])},tagName:"table",classNames:["table-component-table","table"],component:function(){return this.get("_parentView._parentView")}.property(),classNameBindings:["component.condensed:table-condensed","component.striped:table-striped","component.bordered:table-bordered","component.hoverable:table-hoverable"],thead:null,tbody:null,tfoot:null,setup:function(){this.get("component.showHeader")&&this.get("thead").insertHeaderCells(this.container)},update:function(){this.get("tbody").removeAllChildren(),this.get("tbody").insertRows()}}),p=Em.ObjectProxy.extend({_rowIndex:null,_detailRowEnabled:!1}),q=Em.Component.extend({init:function(){this.set("_table",o.create()),this._super()},sortIndex:0,sortAscending:!0,rows:[],columns:[],icons:null,hoverable:!0,striped:!1,condensed:!1,responsive:!0,bordered:!1,customSortAction:null,noContentView:null,showHeader:!0,showTooltips:!0,useDefaultDetailRowToggle:!0,customDetailRowToggleAction:null,detailRowViewClass:null,hasDetailRows:!1,infiniteScrollEnabled:!1,isLoadingRows:!1,loadMoreAction:null,disableSortDirection:!1,tagName:"div",classNames:["table-component"],classNameBindings:["responsive:table-responsive"],_table:null,layout:Em.Handlebars.compile("{{#if _showNoContentView}}{{view noContentView}}{{else}}{{view _table}}{{/if}}"),_cols:function(){var a=this.get("columns")||[],b=0;return a.map(function(a){var d=c.create(a);return d.set("_columnIndex",b++),d})}.property("columns.[]"),_rows:function(){var a=this.get("rows")||[],b=0;return this.get("_useNativeSort")&&this.get("_hasRows")&&(a=this._performNativeSort(a)),a.map(function(a){return p.create({content:a,_rowIndex:b++})})}.property("rows.[]"),_rowsChanged:function(){var a=this;Em.run.once(function(){a.get("_table").update()})}.observes("_rows.[]"),_detailRowsEnabled:function(){var a=!1;return this.get("hasDetailRows")&&(null!==this.get("detailRowViewClass")?a=!0:Em.Logger.warn(": when hasDetailRows is true, you must also provide a view for the detailRowViewClass")),a}.property("hasDetailRows","detailRowViewClass"),_useNativeSort:function(){return null===this.get("customSortAction")}.property("customSortAction"),_performNativeSort:function(b){var c,d=this.get("sortAscending"),e=this.get("_cols").objectAt(this.get("sortIndex"));return e.get("sortable")?(c=a(e,"sort"))(e,b,d):b},_sortingPropertiesChanged:function(){var a=this;Em.run.once(function(){a.get("_useNativeSort")?a.notifyPropertyChange("rows"):a.sendAction("customSortAction",a.get("sortIndex"),a.get("sortAscending"))})}.observes("sortAscending","sortIndex"),_showNoContentView:function(){return null!==this.get("noContentView")&&!this.get("_hasRows")}.property("_hasNoContentView","rows.[]"),_icons:function(){var a=this.get("icons")||{};return b.create(a)}.property("icons"),_hasRows:function(){return this.get("rows")&&this.get("rows.length")>0}.property("rows.[]"),_hasColumns:function(){return this.get("columns")&&this.get("columns.length")>0}.property("columns.[]"),_numColumns:function(){return this.get("columns").length}.property("columns.[]"),_colspan:function(){return this.get("_detailRowsEnabled")&&this.get("useDefaultDetailRowToggle")?this.get("_numColumns")+1:this.get("_numColumns")}.property("columns.[]","useDefaultDetailRowToggle","_detailRowsEnabled"),_loadMoreRows:function(){this.get("loadMoreAction")&&!this.get("isLoadingRows")&&this.sendAction("loadMoreAction")},_showLoadingRow:function(){return this.get("infiniteScrollEnabled")&&this.get("isLoadingRows")}.property("isLoadingRows","infiniteScrollEnabled"),_insertDefaultDetailToggle:function(){return this.get("_detailRowsEnabled")&&this.get("useDefaultDetailRowToggle")}.property(),_sortIndex:function(){return this.get("_insertDefaultDetailToggle")?this.get("sortIndex")+1:this.get("sortIndex")}.property("sortIndex"),_attachInfiniteScrollListener:function(){var a=this;$(window).scroll(function(){$(window).scrollTop()===$(document).height()-$(window).height()&&a._loadMoreRows()})},willInsertElement:function(){this.get("_table").setup(),this.get("_table").update()},didInsertElement:function(){this.get("infiniteScrollEnabled")&&this._attachInfiniteScrollListener()},actions:{_sortTable:function(a){a===this.get("sortIndex")?this.get("disableSortDirection")||this.set("sortAscending",!this.get("sortAscending")):this.set("sortIndex",a)},_toggledDetailRow:function(a,b){if(this.get("useDefaultDetailRowToggle")){var c=this.get("_rows").objectAt(a);c.set("_detailRowEnabled",!b)}}}});Em.TableComponent=q,Em.Handlebars.helper("table-component",Em.TableComponent)}(this); \ No newline at end of file diff --git a/package.json b/package.json index f58465c..7542c2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-bootstrap-table", - "version": "0.1.0", + "version": "0.1.1", "description": "An Ember Component for creating dynamic bootstrap tables.", "repository": { "type": "git", diff --git a/src/javascript/main.js b/src/javascript/main.js index 24ef431..12b07b7 100644 --- a/src/javascript/main.js +++ b/src/javascript/main.js @@ -416,6 +416,7 @@ infiniteScrollEnabled: false, isLoadingRows: false, loadMoreAction: null, + disableSortDirection: false, // [END] User-Defined Options: @@ -558,7 +559,10 @@ _sortTable: function(colIdx){ // If the colIdx is same as current sortIndex, reverse sorting order. if(colIdx === this.get('sortIndex')){ - this.set('sortAscending', !this.get('sortAscending')); + // If disableSortDirection is false, we update sortAscending. If not, do nothing. + if(!this.get('disableSortDirection')){ + this.set('sortAscending', !this.get('sortAscending')); + } }else{ this.set('sortIndex', colIdx); }