Skip to content

Commit

Permalink
fix(limel-date-picker): format property overwrites default date format
Browse files Browse the repository at this point in the history
fix #237
  • Loading branch information
BregenzerK authored and adrianschmidt committed Jan 10, 2019
1 parent c442f62 commit 3e0f4dc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/components/date-picker/pickers/DatePicker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { EventEmitter } from '@stencil/core';
import { BaseOptions } from 'flatpickr/dist/types/options';
import { Picker } from './Picker';

export class DatePicker extends Picker {
protected dateFormat = 'L';
public constructor(dateFormat: string = 'L', change: EventEmitter) {
super(dateFormat, change);
}

public getConfig(nativePicker: boolean): Partial<BaseOptions> {
return {
Expand Down
5 changes: 4 additions & 1 deletion src/components/date-picker/pickers/DatetimePicker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { EventEmitter } from '@stencil/core';
import { BaseOptions } from 'flatpickr/dist/types/options';
import { Picker } from './Picker';

export class DatetimePicker extends Picker {
protected dateFormat = 'L - LT';
public constructor(dateFormat: string = 'L - LT', change: EventEmitter) {
super(dateFormat, change);
}

public getConfig(nativePicker: boolean): Partial<BaseOptions> {
return {
Expand Down
3 changes: 1 addition & 2 deletions src/components/date-picker/pickers/MonthPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { Translations } from '../../../global/translations';
const NBROFMONTHS = 12;

export class MonthPicker extends Picker {
protected dateFormat = 'MM/YYYY';
private months = [];

public constructor(
dateFormat: string,
dateFormat: string = 'MM/YYYY',
change: EventEmitter,
private translations: Translations
) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/date-picker/pickers/QuarterPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ const MONTHSPERQUARTER = 3;
const NBROFMONTHS = 12;

export class QuarterPicker extends Picker {
protected dateFormat = '[Q]Q YYYY';
private quarters = [];

public constructor(
dateFormat: string,
dateFormat: string = '[Q]Q YYYY',
protected change: EventEmitter,
private translations: Translations
) {
Expand Down
5 changes: 4 additions & 1 deletion src/components/date-picker/pickers/TimePicker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { EventEmitter } from '@stencil/core';
import { BaseOptions } from 'flatpickr/dist/types/options';
import { Picker } from './Picker';

export class TimePicker extends Picker {
protected dateFormat = 'LT';
public constructor(dateFormat: string = 'LT', change: EventEmitter) {
super(dateFormat, change);
}

public getConfig(): Partial<BaseOptions> {
return {
Expand Down
8 changes: 7 additions & 1 deletion src/components/date-picker/pickers/WeekPicker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { EventEmitter } from '@stencil/core';
import weekSelectPlugin from 'flatpickr/dist/plugins/weekSelect/weekSelect';
import { BaseOptions } from 'flatpickr/dist/types/options';
import { Picker } from './Picker';

export class WeekPicker extends Picker {
protected dateFormat = '[w] W GGGG';
public constructor(
dateFormat: string = '[w] W GGGG',
change: EventEmitter
) {
super(dateFormat, change);
}

public getConfig(nativePicker: boolean): Partial<BaseOptions> {
return {
Expand Down
3 changes: 1 addition & 2 deletions src/components/date-picker/pickers/YearPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { h } from 'jsx-dom';
import { Translations } from '../../../global/translations';

export class YearPicker extends Picker {
protected dateFormat = 'YYYY';
private years = [];

public constructor(
dateFormat: string,
dateFormat: string = 'YYYY',
change: EventEmitter,
private translations: Translations
) {
Expand Down

0 comments on commit 3e0f4dc

Please sign in to comment.