diff --git a/cosmoz-omnitable-column-amount.js b/cosmoz-omnitable-column-amount.js index 70ea9257..dd7d6b26 100644 --- a/cosmoz-omnitable-column-amount.js +++ b/cosmoz-omnitable-column-amount.js @@ -31,6 +31,7 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) { return { min: { type: Number, value: null, notify: true }, max: { type: Number, value: null, notify: true }, + limits: { type: Function }, locale: { type: String, value: null, notify: true }, autoupdate: { type: Boolean, value: false, notify: true }, currency: { type: String, notify: true }, @@ -42,6 +43,10 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) { }; } + getConfig(column) { + return { limits: column.limits }; + } + getFilterFn(column, filter) { const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter); @@ -119,7 +124,17 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) { } renderHeader( - { title, min, max, locale, rates, currency, autoupdate, autodetect }, + { + title, + min, + max, + limits, + locale, + rates, + currency, + autoupdate, + autodetect, + }, { filter }, setState, source, @@ -131,6 +146,7 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) { .rates=${rates} .min=${min} .max=${max} + .limits=${limits} .locale=${locale} .currency=${currency} .autoupdate=${autoupdate} diff --git a/cosmoz-omnitable-column-date.js b/cosmoz-omnitable-column-date.js index 16c5c6c9..dc13b7d1 100644 --- a/cosmoz-omnitable-column-date.js +++ b/cosmoz-omnitable-column-date.js @@ -10,24 +10,37 @@ import { html } from 'lit-html'; import { columnMixin } from './cosmoz-omnitable-column-mixin'; import './lib/cosmoz-omnitable-date-range-input'; import { defaultComputeSource } from './lib/utils-data'; -import { getString, getComparableValue, toDate, toHashString, toXlsxValue, applySingleFilter, getInputString, fromInputString } from './lib/utils-date'; +import { + getString, + getComparableValue, + toDate, + toHashString, + toXlsxValue, + applySingleFilter, + getInputString, + fromInputString, +} from './lib/utils-date'; class OmnitableColumnDate extends columnMixin(PolymerElement) { static get properties() { return { min: { type: Number, value: null, notify: true }, max: { type: Number, value: null, notify: true }, + limits: { type: Function }, locale: { type: String, value: null, notify: true }, headerCellClass: { type: String, value: 'date-header-cell' }, width: { type: String, value: '100px' }, minWidth: { type: String, value: '82px' }, - flex: { type: String, value: '0' } + flex: { type: String, value: '0' }, }; } + getConfig(column) { + return { limits: column.limits }; + } + getFilterFn(column, filter) { - const - min = getComparableValue({ ...column, valuePath: 'min' }, filter), + const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter); if (min == null && max == null) { @@ -77,7 +90,7 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) { return { min: toDate(matches[1]), - max: toDate(matches[2]) + max: toDate(matches[2]), }; } @@ -86,34 +99,35 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) { } renderEditCell(column, { item }, onItemChange) { - const onChange = event => onItemChange(fromInputString(event.target.value)); + const onChange = (event) => + onItemChange(fromInputString(event.target.value)); return html``; } renderHeader( - { title, - min, - max, - locale }, + { title, min, max, limits, locale }, { filter }, setState, - source + source, ) { return html` setState(state => ({ ...state, filter: value })) } - @header-focused-changed=${ ({ detail: { value }}) => setState(state => ({ ...state, headerFocused: value })) } + .title=${title} + .filter=${filter} + .values=${source} + .min=${min} + .max=${max} + .limits=${limits} + .locale=${locale} + @filter-changed=${({ detail: { value } }) => + setState((state) => ({ ...state, filter: value }))} + @header-focused-changed=${({ detail: { value } }) => + setState((state) => ({ ...state, headerFocused: value }))} >`; } diff --git a/cosmoz-omnitable-column-datetime.js b/cosmoz-omnitable-column-datetime.js index 0b97d6ef..0eb585da 100644 --- a/cosmoz-omnitable-column-datetime.js +++ b/cosmoz-omnitable-column-datetime.js @@ -6,8 +6,18 @@ import './ui-helpers/cosmoz-clear-button'; import { columnMixin } from './cosmoz-omnitable-column-mixin'; import { PolymerElement } from '@polymer/polymer/polymer-element'; import { html } from 'lit-html'; -import { fromHashString, getString, toHashString, toXlsxValue } from './lib/utils-datetime'; -import { applySingleFilter, fromInputString, getComparableValue, toDate } from './lib/utils-date'; +import { + fromHashString, + getString, + toHashString, + toXlsxValue, +} from './lib/utils-datetime'; +import { + applySingleFilter, + fromInputString, + getComparableValue, + toDate, +} from './lib/utils-date'; import { defaultComputeSource } from './lib/utils-data'; import './lib/cosmoz-omnitable-datetime-range-input'; @@ -25,18 +35,22 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) { return { min: { type: Number, value: null, notify: true }, max: { type: Number, value: null, notify: true }, + limits: { type: Function }, locale: { type: String, value: null, notify: true }, headerCellClass: { type: String, value: 'datetime-header-cell' }, width: { type: String, value: '210px' }, minWidth: { type: String, value: '128px' }, flex: { type: String, value: '0' }, - filterStep: { type: Number, value: 1 } + filterStep: { type: Number, value: 1 }, }; } + getConfig(column) { + return { limits: column.limits }; + } + getFilterFn(column, filter) { - const - min = getComparableValue({ ...column, valuePath: 'min' }, filter), + const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter); if (min == null && max == null) { @@ -86,7 +100,7 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) { return { min: fromHashString(matches[1]), - max: fromHashString(matches[2]) + max: fromHashString(matches[2]), }; } @@ -95,31 +109,36 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) { } renderEditCell(column, { item }, onItemChange) { - const onChange = event => onItemChange(fromInputString(event.target.value)); - return html``; + const onChange = (event) => + onItemChange(fromInputString(event.target.value)); + return html``; } // eslint-disable-next-line max-lines-per-function renderHeader( - { title, - min, - max, - locale, - filterStep }, + { title, min, max, limits, locale, filterStep }, { filter }, setState, - source + source, ) { return html` setState(state => ({ ...state, filter: value })) } - @header-focused-changed=${ ({ detail: { value }}) => setState(state => ({ ...state, headerFocused: value })) } + .title=${title} + .filter=${filter} + .values=${source} + .min=${min} + .max=${max} + .limits=${limits} + .locale=${locale} + .filterStep=${filterStep} + @filter-changed=${({ detail: { value } }) => + setState((state) => ({ ...state, filter: value }))} + @header-focused-changed=${({ detail: { value } }) => + setState((state) => ({ ...state, headerFocused: value }))} >`; } diff --git a/cosmoz-omnitable-column-number.js b/cosmoz-omnitable-column-number.js index 396d339f..e5d484cf 100644 --- a/cosmoz-omnitable-column-number.js +++ b/cosmoz-omnitable-column-number.js @@ -29,6 +29,7 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) { return { min: { type: Number, value: null, notify: true }, max: { type: Number, value: null, notify: true }, + limits: { type: Function }, locale: { type: String, value: null, notify: true }, autoupdate: { type: Boolean, value: false, notify: true }, cellClass: { type: String, value: 'number-cell align-right' }, @@ -40,6 +41,10 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) { }; } + getConfig(column) { + return { limits: column.limits }; + } + getFilterFn(column, filter) { const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter); @@ -117,6 +122,7 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) { title, min, max, + limits, locale, maximumFractionDigits, minimumFractionDigits, @@ -132,6 +138,7 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) { .values=${source} .min=${min} .max=${max} + .limits=${limits} .locale=${locale} .maximumFractionDigits=${maximumFractionDigits} .minimumFractionDigsits=${minimumFractionDigits}