pull/888/head
Thomas Weaver 3 months ago committed by GitHub
parent b78e213e73
commit 8d39d761a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,7 +17,7 @@ import {TableData} from 'app/client/models/TableData';
import {ColumnFilterCalendarView} from 'app/client/ui/ColumnFilterCalendarView'; import {ColumnFilterCalendarView} from 'app/client/ui/ColumnFilterCalendarView';
import {relativeDatesControl} from 'app/client/ui/ColumnFilterMenuUtils'; import {relativeDatesControl} from 'app/client/ui/ColumnFilterMenuUtils';
import {cssInput} from 'app/client/ui/cssInput'; 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 {cssPinButton} from 'app/client/ui/RightPanelStyles';
import {basicButton, primaryButton, textButton} from 'app/client/ui2018/buttons'; import {basicButton, primaryButton, textButton} from 'app/client/ui2018/buttons';
import {cssLabel as cssCheckboxLabel, cssCheckboxSquare, import {cssLabel as cssCheckboxLabel, cssCheckboxSquare,
@ -176,16 +176,16 @@ export function columnFilterMenu(owner: IDisposableOwner, opts: IFilterMenuOptio
cssLinkRow( cssLinkRow(
testId('presets-links'), testId('presets-links'),
cssLink( cssLink(
DateRangeOptions[0].label, getDateRangeOptions()[0].label,
dom.on('click', () => action(DateRangeOptions[0])) dom.on('click', () => action(getDateRangeOptions()[0]))
), ),
cssLink( cssLink(
DateRangeOptions[1].label, getDateRangeOptions()[1].label,
dom.on('click', () => action(DateRangeOptions[1])) dom.on('click', () => action(getDateRangeOptions()[1]))
), ),
cssLink( cssLink(
'More ', icon('Dropdown'), 'More ', icon('Dropdown'),
menu(() => DateRangeOptions.map( menu(() => getDateRangeOptions().map(
(option) => menuItem(() => action(option), option.label) (option) => menuItem(() => action(option), option.label)
), {attach: '.' + cssMenu.className}) ), {attach: '.' + cssMenu.className})
), ),

@ -1,41 +1,55 @@
import {makeT} from 'app/client/lib/localization';
import { CURRENT_DATE, IRelativeDateSpec } from "app/common/RelativeDates"; import { CURRENT_DATE, IRelativeDateSpec } from "app/common/RelativeDates";
const t = makeT('DateRangeOptions');
export interface IDateRangeOption { export interface IDateRangeOption {
label: string; label: string;
min: IRelativeDateSpec; min: IRelativeDateSpec;
max: IRelativeDateSpec; max: IRelativeDateSpec;
} }
export const DateRangeOptions: IDateRangeOption[] = [{ export function getDateRangeOptions(): IDateRangeOption[] {
label: 'Today', return [
min: CURRENT_DATE, {
max: CURRENT_DATE, label: t('Today'),
}, { min: CURRENT_DATE,
label: 'Last 7 days', max: CURRENT_DATE,
min: [{quantity: -7, unit: 'day'}], },
max: [{quantity: -1, unit: 'day'}], {
}, { label: t('Last 7 days'),
label: 'Next 7 days', min: [{quantity: -7, unit: 'day'}],
min: [{quantity: 1, unit: 'day'}], max: [{quantity: -1, unit: 'day'}],
max: [{quantity: 7, unit: 'day'}], },
}, { {
label: 'Last Week', label: t('Next 7 days'),
min: [{quantity: -1, unit: 'week'}], min: [{quantity: 1, unit: 'day'}],
max: [{quantity: -1, unit: 'week', endOf: true}], max: [{quantity: 7, unit: 'day'}],
}, { },
label: 'Last 30 days', {
min: [{quantity: -30, unit: 'day'}], label: t('Last Week'),
max: [{quantity: -1, unit: 'day'}], min: [{quantity: -1, unit: 'week'}],
}, { max: [{quantity: -1, unit: 'week', endOf: true}],
label: 'This week', },
min: [{quantity: 0, unit: 'week'}], {
max: [{quantity: 0, unit: 'week', endOf: true}], label: t('Last 30 days'),
}, { min: [{quantity: -30, unit: 'day'}],
label: 'This month', max: [{quantity: -1, unit: 'day'}],
min: [{quantity: 0, unit: 'month'}], },
max: [{quantity: 0, unit: 'month', endOf: true}], {
}, { label: t('This week'),
label: 'This year', min: [{quantity: 0, unit: 'week'}],
min: [{quantity: 0, unit: 'year'}], max: [{quantity: 0, unit: 'week', endOf: true}],
max: [{quantity: 0, unit: 'year', endOf: true}], },
}]; {
label: t('This month'),
min: [{quantity: 0, unit: 'month'}],
max: [{quantity: 0, unit: 'month', endOf: true}],
},
{
label: t('This year'),
min: [{quantity: 0, unit: 'year'}],
max: [{quantity: 0, unit: 'year', endOf: true}],
},
];
}
Loading…
Cancel
Save