Skip to content

Commit

Permalink
Updated rowsTo computed property to have number of rows as max.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgrozav committed Jan 17, 2020
1 parent 1061dfa commit 4febf34
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

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

28 changes: 25 additions & 3 deletions src/components/Datatable/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,29 @@ export default {
pagination: {
type: [Boolean, Object],
default: true
},
searchOptions: {
type: Object,
default: () => ({
shouldSort: false,
includeMatches: true,
includeScore: true,
threshold: 0.25,
location: 0,
distance: 50,
tokenize: true,
maxPatternLength: 32,
minMatchCharLength: 2
})
}
},
data() {
return {
sortBy: this.defaultSortKey,
sortDirection: 'asc',
rowsPerPage: 1,
page: 1
page: 1,
search: new Fuse([], {})
}
},
computed: {
Expand Down Expand Up @@ -140,7 +155,12 @@ export default {
...(this.pagination.i18n || {})
}
} :
{ ...defaultPaginationConfig };
{
...defaultPaginationConfig,
i18n: {
...defaultPaginationConfig.i18n
}
};

config.rowsPerPage = config.rowsPerPage.toString();
config.rowsPerPageOptions = config.rowsPerPageOptions.map((v) => v.toString());
Expand All @@ -158,7 +178,9 @@ export default {
return (this.page - 1) * this.rowsPerPage;
},
rowsTo() {
return this.page * this.rowsPerPage;
const to = this.page * this.rowsPerPage;

return to > this.rowsCount ? this.rowsCount : to;
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Datatable/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ item }}
</i-select-option>
</i-select>
<template v-else> {{part}} </template>
<template v-else>{{part}}</template>
</template>
</div>

Expand Down

0 comments on commit 4febf34

Please sign in to comment.