Skip to content

Commit

Permalink
Merge pull request #241 from iamisti/feature-uncheck-items-columns-fi…
Browse files Browse the repository at this point in the history
…lter

Added new attribute to exclude columns from the selector filter by de…
  • Loading branch information
iamisti authored Nov 23, 2016
2 parents 8b58bde + 1c43dc3 commit 8c6efbc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions app/modules/main/directives/header/mdtColumnDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*
* @param {boolean=} excludeFromColumnSelector disables the column selection for the applied column for the column select feature.
*
* @param {boolean=} columnSelectorExcludeDefault sets the target column as unselected for the column select feature.
*
* @example
* <pre>
* <mdt-table>
Expand Down Expand Up @@ -66,7 +68,8 @@
columnDefinition: '@',
columnSort: '=?',
columnFilter: '=?',
excludeFromColumnSelector: '=?'
excludeFromColumnSelector: '=?',
hideColumnByDefault: '=?'
},
require: ['^mdtTable'],
link: function ($scope, element, attrs, ctrl, transclude) {
Expand All @@ -83,7 +86,7 @@

ColumnFilterFeature.appendHeaderCellData($scope, cellDataToStore, mdtTableCtrl.dataStorage);
ColumnSortFeature.appendHeaderCellData(cellDataToStore, $scope.columnSort);
ColumnSelectorFeature.appendHeaderCellData(cellDataToStore, mdtTableCtrl.columnSelectorFeature, $scope.excludeFromColumnSelector);
ColumnSelectorFeature.appendHeaderCellData(cellDataToStore, mdtTableCtrl.columnSelectorFeature, $scope.excludeFromColumnSelector, $scope.hideColumnByDefault);

mdtTableCtrl.dataStorage.addHeaderCellData(cellDataToStore);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @param cellDataToStore
*/
service.appendHeaderCellData = function(cellDataToStore, columnSelectorFeature, isColumnExcludedFromColumnSelector) {
service.appendHeaderCellData = function(cellDataToStore, columnSelectorFeature, isColumnExcludedFromColumnSelector, isColumnUnselectedFromColumnSelector) {
if(!columnSelectorFeature.isEnabled){
return;
}
Expand All @@ -24,6 +24,12 @@
}else{
cellDataToStore.columnSelectorFeature.isExcluded = false;
}

if(isColumnUnselectedFromColumnSelector){
cellDataToStore.columnSelectorFeature.isUnchecked = true;
}else{
cellDataToStore.columnSelectorFeature.isUnchecked = false;
}
};

/**
Expand Down Expand Up @@ -56,7 +62,7 @@
service.initFeatureHeaderValues = function(headerRowsData, columnSelectorFeature){
if(columnSelectorFeature && columnSelectorFeature.isEnabled){
_.each(headerRowsData, function(item){
item.columnSelectorFeature.isVisible =true;
item.columnSelectorFeature.isVisible = !item.columnSelectorFeature.isUnchecked;
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

$scope.headerRowsData = _.map($scope.dataStorage.header, function(item){
//excluded content should also be in, since we use the index of the array to apply the changes. Do not exclude them.

return {
columnName: item.columnName,
isVisible: item.columnSelectorFeature.isVisible,
Expand Down
2 changes: 2 additions & 0 deletions demo/developmentArea.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

<mdt-column align-rule="left"
column-sort="true"
hide-column-by-default="true"
column-filter="{
'valuesProviderCallback': fatValuesCallback,
'valuesTransformerCallback': fatValuesTransformer,
Expand All @@ -52,6 +53,7 @@
<mdt-column
align-rule="right"
column-sort="true"
hide-column-by-default="true"
>Carbs (g)</mdt-column>
<mdt-column align-rule="right">Protein (g)</mdt-column>
<mdt-column align-rule="right">Sodium (mg)</mdt-column>
Expand Down
2 changes: 1 addition & 1 deletion docs/js/docs-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NG_DOCS={
"type": "directive",
"moduleName": "mdtColumn",
"shortDescription": "Representing a header column cell which should be placed inside mdt-header-row element directive.",
"keywords": "activate affect align align-rule alignrule api applied array assignable cell cells checkbox chips clicking column column-definition columndefinition columnfilter columnsort comparator compare compared content ctrl data default defines directive disables display displays don dropdown element excludefromcolumnselector false feature filter filtertype function gross header hover icon inside left mdt-header-row mdtcolumn mdttable ng-repeat object objects optional options order parameters passed placeholder placeholdertext price product products promise properties provided representing required resolves result return reverse rotate row select selected selection settings sort sorted sorting strings text tooltip transforms true type types user values valuesprovidercallback valuestransformercallback visually"
"keywords": "activate affect align align-rule alignrule api applied array assignable cell cells checkbox chips clicking column column-definition columndefinition columnfilter columnselectorexcludedefault columnsort comparator compare compared content ctrl data default defines directive disables display displays don dropdown element excludefromcolumnselector false feature filter filtertype function gross header hover icon inside left mdt-header-row mdtcolumn mdttable ng-repeat object objects optional options order parameters passed placeholder placeholdertext price product products promise properties provided representing required resolves result return reverse rotate row select selected selection sets settings sort sorted sorting strings target text tooltip transforms true type types unselected user values valuesprovidercallback valuestransformercallback visually"
},
{
"section": "api",
Expand Down
4 changes: 3 additions & 1 deletion docs/partials/api/mdtColumn.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ <h2 id="usage">Usage</h2>
[column-sort="{boolean=|object}"]
[column-filter="{object}"]
[column-definition="{string}"]
[exclude-from-column-selector="{boolean}"]&gt;
[exclude-from-column-selector="{boolean}"]
[column-selector-exclude-default="{boolean}"]&gt;
&lt;/mdt-column&gt;</pre>
<h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>alignRule <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="mdtcolumn-page"><p>align cell content. This settings will have affect on each data cells in the same
column (e.g. every x.th cell in every row).</p>
Expand All @@ -41,6 +42,7 @@ <h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table ta
- {string=} filterType defines the type of the filter you want to use. Available options are: `chips`, `checkbox`, `dropdown`. If you don&#39;t specify it, the default will be `chips`
</code></pre></div></td></tr><tr><td>columnDefinition <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="mdtcolumn-page"><p>displays a tooltip on hover.</p>
</div></td></tr><tr><td>excludeFromColumnSelector <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-boolean">boolean</a></td><td><div class="mdtcolumn-page"><p>disables the column selection for the applied column for the column select feature.</p>
</div></td></tr><tr><td>columnSelectorExcludeDefault <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-boolean">boolean</a></td><td><div class="mdtcolumn-page"><p>sets the target column as unselected for the column select feature.</p>
</div></td></tr></tbody></table></div>
<h2 id="example">Example</h2>
<div class="example"><div class="mdtcolumn-page"><pre class="prettyprint linenums">
Expand Down

0 comments on commit 8c6efbc

Please sign in to comment.