Skip to content

Commit

Permalink
Fix falsy values disappearing in table cells
Browse files Browse the repository at this point in the history
  • Loading branch information
iamisti committed Jul 22, 2016
1 parent e7c1d38 commit fcd7fc8
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
// so we has to say explicitly that we only want to watch the content and nor the attributes, or the additional metadata.
var val = $parse(attr.mdtAddHtmlContentToCell)($scope);

if(val.value){
return val.value;
}
return val.value;

return val;
}, function(val){
element.empty();
element.append(val);
Expand Down
9 changes: 7 additions & 2 deletions app/modules/main/directives/mdtTableDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
* When column names are: `Product name`, `Creator`, `Last Update`
* The passed data row's structure: `id`, `item_name`, `update_date`, `created_by`
*
* Then the following setup will parese the data to the right columns:
* Then the following setup will parse the data to the right columns:
* <pre>
* <mdt-table
* mdt-row="{
Expand Down Expand Up @@ -193,7 +193,12 @@
columnValues = [];

_.each($scope.mdtRow['column-keys'], function(columnKey){
columnValues.push(_.get(row, columnKey));
columnValues.push({
attributes: {
editableField: false
},
value: _.get(row, columnKey)
});
});

ctrl.tableDataStorageService.addRowData(rowId, columnValues);
Expand Down
3 changes: 1 addition & 2 deletions app/modules/main/templates/generateRows.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
ng-click="showEditDialog($event, cellData, rowData)"></span>

<!-- non editable field -->
<!-- if cellData is a raw value, then 'attributes' doesn't exist. TODO: make sure that the structure will remain the same in this case too -->
<span mdt-add-html-content-to-cell="cellData" ng-if="!cellData.attributes || cellData.attributes.editableField == false"></span>
<span mdt-add-html-content-to-cell="cellData" ng-if="cellData.attributes.editableField == false"></span>
</td>
</tr>
<tr ng-show="mdtPaginationHelper.isLoading">
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mdDataTable",
"version": "1.5.0",
"version": "1.5.1",
"homepage": "https://github.com/iamisti/mdDataTable",
"author":"Istvan Fodor <[email protected]>",
"main": [
Expand Down
1 change: 1 addition & 0 deletions demo/developmentArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
loadPageCallbackWithDebounce = _.debounce(loadPageCallback, 1000);
}
function paginatorCallback(page, pageSize){
return;
var offset = (page-1) * pageSize;
var query = $scope.filterText ? $scope.filterText : '';

Expand Down
2 changes: 1 addition & 1 deletion dist/md-data-table-templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions dist/md-data-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@
* function which returns a promise when it's called. When the function is called, these parameters will be
* passed: `page` and `pageSize` which can help implementing an ajax-based paging.
*
* @param {function(loadPageCallback)=} mdtTriggerRequest provide a callback function for manually triggering an
* ajax request. Can be useful when you want to populate the results in the table manually. (e.g.: having a
* search field in your page which then can trigger a new request in the table to show the results based on
* that filter.
*
* @param {string=} mdtRowPaginatorErrorMessage overrides default error message when promise gets rejected by the
* paginator function.
*
Expand All @@ -186,7 +191,7 @@
* When column names are: `Product name`, `Creator`, `Last Update`
* The passed data row's structure: `id`, `item_name`, `update_date`, `created_by`
*
* Then the following setup will parese the data to the right columns:
* Then the following setup will parse the data to the right columns:
* <pre>
* <mdt-table
* mdt-row="{
Expand Down Expand Up @@ -296,7 +301,12 @@
columnValues = [];

_.each($scope.mdtRow['column-keys'], function(columnKey){
columnValues.push(_.get(row, columnKey));
columnValues.push({
attributes: {
editableField: false
},
value: _.get(row, columnKey)
});
});

ctrl.tableDataStorageService.addRowData(rowId, columnValues);
Expand Down Expand Up @@ -1138,11 +1148,8 @@
// so we has to say explicitly that we only want to watch the content and nor the attributes, or the additional metadata.
var val = $parse(attr.mdtAddHtmlContentToCell)($scope);

if(val.value){
return val.value;
}
return val.value;

return val;
}, function(val){
element.empty();
element.append(val);
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 @@ -46,7 +46,7 @@ NG_DOCS={
"type": "directive",
"moduleName": "mdtTable",
"shortDescription": "The base HTML tag for the component.",
"keywords": "actionicons actions activates additional ajax-based alternateheaders animated animatesorticon api applied approaches argument array assignable assigned attribute base basic benefit bottom callback called card cards change changes checkbox class clicked clicking column column-keys columns component configure contextual controller created_by creator data default delete deleted deleterowcallback deleting directive display dynamic element embedded enable enables error example explicitly fixed function header headers height help html icon identifier implemented implementing initialize input inside intended isenabled item_name items kind list listen ll manipulation md-virtual-repeat-container mdt-header-row mdt-row mdtrow mdtrowpaginator mdtrowpaginatorerrormessage mdttable message names number order overrides pagesize paginatedrows pagination paginator paging parameters parese passed passing persistent persistentactions product promise properly properties property provided providing rejected require returns reverse ripple rippleeffect rotate row rows rowsperpagevalues scrolling selectablerows selected selectedrowcallback selecting set setup sizes sort sortable sortable-rows-default sortablecolumns sorted structure table table-row-id table-row-id-key tablecard tag title titles tools top uniq update update_date values virtual virtualrepeat visible work working"
"keywords": "actionicons actions activates additional ajax ajax-based alternateheaders animated animatesorticon api applied approaches argument array assignable assigned attribute base based basic benefit bottom callback called card cards change changes checkbox class clicked clicking column column-keys columns component configure contextual controller created_by creator data default delete deleted deleterowcallback deleting directive display dynamic element embedded enable enables error example explicitly field filter fixed function header headers height help html icon identifier implemented implementing initialize input inside intended isenabled item_name items kind list listen ll manipulation manually md-virtual-repeat-container mdt-header-row mdt-row mdtrow mdtrowpaginator mdtrowpaginatorerrormessage mdttable mdttriggerrequest message names number order overrides pagesize paginatedrows pagination paginator paging parameters parse passed passing persistent persistentactions populate product promise properly properties property provide provided providing rejected request require returns reverse ripple rippleeffect rotate row rows rowsperpagevalues scrolling search selectablerows selected selectedrowcallback selecting set setup sizes sort sortable sortable-rows-default sortablecolumns sorted structure table table-row-id table-row-id-key tablecard tag title titles tools top trigger triggering uniq update update_date values virtual virtualrepeat visible work working"
}
],
"apis": {
Expand Down
7 changes: 6 additions & 1 deletion docs/partials/api/mdtTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h2 id="usage">Usage</h2>
[paginated-rows="{boolean}"]
[mdt-row="{object}"]
[mdt-row-paginator="{function(page, pageSize)}"]
[mdt-trigger-request="{function(loadPageCallback)}"]
[mdt-row-paginator-error-message="{string}"]&gt;
&lt;/mdt-table&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>tableCard <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-object">object</a></td><td><div class="mdttable-page"><p>when set table will be embedded within a card, with data manipulation tools available
Expand Down Expand Up @@ -72,6 +73,10 @@ <h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table ta
</div></td></tr><tr><td>mdtRowPaginator <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-function">function(page, pageSize</a></td><td><div class="mdttable-page"><p>providing the data for the table by a function. Should set a
function which returns a promise when it&#39;s called. When the function is called, these parameters will be
passed: <code>page</code> and <code>pageSize</code> which can help implementing an ajax-based paging.</p>
</div></td></tr><tr><td>mdtTriggerRequest <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-function">function(loadPageCallback</a></td><td><div class="mdttable-page"><p>provide a callback function for manually triggering an
ajax request. Can be useful when you want to populate the results in the table manually. (e.g.: having a
search field in your page which then can trigger a new request in the table to show the results based on
that filter.</p>
</div></td></tr><tr><td>mdtRowPaginatorErrorMessage <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="mdttable-page"><p>overrides default error message when promise gets rejected by the
paginator function.</p>
</div></td></tr></tbody></table></div>
Expand All @@ -80,7 +85,7 @@ <h2 id="example">Example</h2>

<p>When column names are: <code>Product name</code>, <code>Creator</code>, <code>Last Update</code>
The passed data row&#39;s structure: <code>id</code>, <code>item_name</code>, <code>update_date</code>, <code>created_by</code></p>
<p>Then the following setup will parese the data to the right columns:
<p>Then the following setup will parse the data to the right columns:
<pre class="prettyprint linenums">
&lt;mdt-table
mdt-row="{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "md-data-table",
"version": "1.5.0",
"version": "1.5.1",
"author": "Istvan Fodor <[email protected]>",
"registry": "github",
"repository": {
Expand Down Expand Up @@ -52,6 +52,7 @@
"angular-material-icons": "~v0.6.0",
"angular-sanitize": "~1.4.8",
"jquery": "~2.1.4",
"jshint": "^2.9.2",
"lodash": "~3.10.1",
"phantomjs": "^2.1.7"
}
Expand Down

0 comments on commit fcd7fc8

Please sign in to comment.