mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
parent
b78e213e73
commit
8d39d761a5
@ -17,7 +17,7 @@ import {TableData} from 'app/client/models/TableData';
|
||||
import {ColumnFilterCalendarView} from 'app/client/ui/ColumnFilterCalendarView';
|
||||
import {relativeDatesControl} from 'app/client/ui/ColumnFilterMenuUtils';
|
||||
import {cssInput} from 'app/client/ui/cssInput';
|
||||
import {DateRangeOptions, IDateRangeOption} from 'app/client/ui/DateRangeOptions';
|
||||
import {getDateRangeOptions, IDateRangeOption} from 'app/client/ui/DateRangeOptions';
|
||||
import {cssPinButton} from 'app/client/ui/RightPanelStyles';
|
||||
import {basicButton, primaryButton, textButton} from 'app/client/ui2018/buttons';
|
||||
import {cssLabel as cssCheckboxLabel, cssCheckboxSquare,
|
||||
@ -176,16 +176,16 @@ export function columnFilterMenu(owner: IDisposableOwner, opts: IFilterMenuOptio
|
||||
cssLinkRow(
|
||||
testId('presets-links'),
|
||||
cssLink(
|
||||
DateRangeOptions[0].label,
|
||||
dom.on('click', () => action(DateRangeOptions[0]))
|
||||
getDateRangeOptions()[0].label,
|
||||
dom.on('click', () => action(getDateRangeOptions()[0]))
|
||||
),
|
||||
cssLink(
|
||||
DateRangeOptions[1].label,
|
||||
dom.on('click', () => action(DateRangeOptions[1]))
|
||||
getDateRangeOptions()[1].label,
|
||||
dom.on('click', () => action(getDateRangeOptions()[1]))
|
||||
),
|
||||
cssLink(
|
||||
'More ', icon('Dropdown'),
|
||||
menu(() => DateRangeOptions.map(
|
||||
menu(() => getDateRangeOptions().map(
|
||||
(option) => menuItem(() => action(option), option.label)
|
||||
), {attach: '.' + cssMenu.className})
|
||||
),
|
||||
|
@ -1,41 +1,55 @@
|
||||
import {makeT} from 'app/client/lib/localization';
|
||||
import { CURRENT_DATE, IRelativeDateSpec } from "app/common/RelativeDates";
|
||||
|
||||
const t = makeT('DateRangeOptions');
|
||||
|
||||
export interface IDateRangeOption {
|
||||
label: string;
|
||||
min: IRelativeDateSpec;
|
||||
max: IRelativeDateSpec;
|
||||
}
|
||||
|
||||
export const DateRangeOptions: IDateRangeOption[] = [{
|
||||
label: 'Today',
|
||||
export function getDateRangeOptions(): IDateRangeOption[] {
|
||||
return [
|
||||
{
|
||||
label: t('Today'),
|
||||
min: CURRENT_DATE,
|
||||
max: CURRENT_DATE,
|
||||
}, {
|
||||
label: 'Last 7 days',
|
||||
},
|
||||
{
|
||||
label: t('Last 7 days'),
|
||||
min: [{quantity: -7, unit: 'day'}],
|
||||
max: [{quantity: -1, unit: 'day'}],
|
||||
}, {
|
||||
label: 'Next 7 days',
|
||||
},
|
||||
{
|
||||
label: t('Next 7 days'),
|
||||
min: [{quantity: 1, unit: 'day'}],
|
||||
max: [{quantity: 7, unit: 'day'}],
|
||||
}, {
|
||||
label: 'Last Week',
|
||||
},
|
||||
{
|
||||
label: t('Last Week'),
|
||||
min: [{quantity: -1, unit: 'week'}],
|
||||
max: [{quantity: -1, unit: 'week', endOf: true}],
|
||||
}, {
|
||||
label: 'Last 30 days',
|
||||
},
|
||||
{
|
||||
label: t('Last 30 days'),
|
||||
min: [{quantity: -30, unit: 'day'}],
|
||||
max: [{quantity: -1, unit: 'day'}],
|
||||
}, {
|
||||
label: 'This week',
|
||||
},
|
||||
{
|
||||
label: t('This week'),
|
||||
min: [{quantity: 0, unit: 'week'}],
|
||||
max: [{quantity: 0, unit: 'week', endOf: true}],
|
||||
}, {
|
||||
label: 'This month',
|
||||
},
|
||||
{
|
||||
label: t('This month'),
|
||||
min: [{quantity: 0, unit: 'month'}],
|
||||
max: [{quantity: 0, unit: 'month', endOf: true}],
|
||||
}, {
|
||||
label: 'This year',
|
||||
},
|
||||
{
|
||||
label: t('This year'),
|
||||
min: [{quantity: 0, unit: 'year'}],
|
||||
max: [{quantity: 0, unit: 'year', endOf: true}],
|
||||
}];
|
||||
},
|
||||
];
|
||||
}
|
Loading…
Reference in New Issue
Block a user