Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week view #329

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,26 @@ export class HomePage {

### CalendarComponentOptions

| Name | Type | Default | Description |
| ----------------- | ----------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------- |
| from | Date | `new Date()` | start date |
| to | Date | 0 (Infinite) | end date |
| color | string | `'primary'` | 'primary', 'secondary', 'danger', 'light', 'dark' |
| pickMode | string | `single` | 'multi', 'range', 'single' |
| showToggleButtons | boolean | `true` | show toggle buttons |
| showMonthPicker | boolean | `true` | show month picker |
| monthPickerFormat | Array<string> | `['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']` | month picker format |
| defaultTitle | string | '' | default title in days |
| defaultSubtitle | string | '' | default subtitle in days |
| disableWeeks | Array<number> | `[]` | week to be disabled (0-6) |
| monthFormat | string | `'MMM YYYY'` | month title format |
| weekdays | Array<string> | `['S', 'M', 'T', 'W', 'T', 'F', 'S']` | weeks text |
| weekStart | number | `0` (0 or 1) | set week start day |
| daysConfig | Array<**_DaysConfig_**> | `[]` | days configuration |
| Name | Type | Default | Description |
| ----------------- | ----------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------- |
| from | Date | `new Date()` | start date |
| to | Date | 0 (Infinite) | end date |
| color | string | `'primary'` | 'primary', 'secondary', 'danger', 'light', 'dark' |
| pickMode | string | `single` | 'multi', 'range', 'single' |
| showToggleButtons | boolean | `true` | show toggle buttons |
| showMonthPicker | boolean | `true` | show month picker |
| monthPickerFormat | Array<string> | `['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']` | month picker format |
| defaultTitle | string | '' | default title in days |
| defaultSubtitle | string | '' | default subtitle in days |
| disableWeeks | Array<number> | `[]` | week to be disabled (0-6) |
| monthFormat | string | `'MMM YYYY'` | month title format |
| weekdays | Array<string> | `['S', 'M', 'T', 'W', 'T', 'F', 'S']` | weeks text |
| weekStart | number | `0` (0 or 1) | set week start day |
| daysConfig | Array<**_DaysConfig_**> | `[]` | days configuration |
| showAdjacentMonthDay | boolean | `true` | show days of other months |
| displayMode | string | `month` | 'month', 'week' |
| weeks | number | `1` | number of week to show in week display mode |
| continuous | boolean | `false` | how should be navigated when the week change |

# Modal Mode

Expand Down
68 changes: 66 additions & 2 deletions demo/src/demos/demo-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
</ion-item>
<ion-item>
<ion-label>disableWeeks</ion-label>
<ion-select [(ngModel)]="_disableWeeks"
<ion-select [(ngModel)]="_disableWeeks"
(ngModelChange)="_changeDisableWeeks($event)"
multiple="true">
<ion-option value="0">0</ion-option>
Expand All @@ -50,6 +50,34 @@ import {
<ion-label>showMonthPicker</ion-label>
<ion-checkbox [(ngModel)]="_showMonthPicker" (ngModelChange)="_changeShowMonthPicker($event)"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>showAdjacentMonthDay</ion-label>
<ion-checkbox [(ngModel)]="_showAdjacentMonthDay" (ngModelChange)="_changeShowAdjacentMonthDay($event)"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>displayMode</ion-label>
<ion-radio-group [(ngModel)]="_displayMode" (ngModelChange)="_changeDisplayMode($event)">
<ion-row>
<ion-item lines="none">
<ion-label>month &nbsp;</ion-label>
<ion-radio value="month"></ion-radio>
</ion-item>
<ion-item lines="none">
<ion-label>week &nbsp;</ion-label>
<ion-radio value="week"></ion-radio>
</ion-item>
</ion-row>
</ion-radio-group>
</ion-item>
<ion-item>
<ion-label position="floating">weeks</ion-label>
<ion-input [disabled]="_displayMode !== 'week'" type="number" inputmode="numeric" min="1" step="1" [(ngModel)]="_weeks"
(ngModelChange)="_changeNumberWeeks($event)"></ion-input>
</ion-item>
<ion-item>
<ion-label>continuous</ion-label>
<ion-checkbox [disabled]="_displayMode !== 'week'" [(ngModel)]="_continuous" (ngModelChange)="_changeContinuous($event)"></ion-checkbox>
</ion-item>
</ion-list>

<ion-calendar [(ngModel)]="date"
Expand All @@ -67,6 +95,10 @@ export class DemoOptionsComponent {
_showMonthPicker: boolean = true;
_disableWeeks: number[] = [0, 6];
_weekStart: number = 0;
_weeks: number = 1;
_continuous: boolean = false;
_displayMode: string = 'month';
_showAdjacentMonthDay: boolean = true;
date: string = '2018-01-01';
options: CalendarComponentOptions = {
from: new Date(2000, 0, 1),
Expand Down Expand Up @@ -113,6 +145,38 @@ export class DemoOptionsComponent {
this.options = {
...this.options,
weekStart: parseInt(weekStart)
};
}
}

_changeDisplayMode(displayMode: string) {
if (displayMode === 'week' || displayMode === 'month'){
this.options = {
...this.options,
displayMode: displayMode
}
}
}

_changeNumberWeeks(weeks: number) {
if (weeks > 0){
this.options = {
...this.options,
weeks: weeks
}
}
}

_changeContinuous(continuous: boolean) {
this.options = {
...this.options,
continuous
}
}

_changeShowAdjacentMonthDay(showAdjacentMonthDay: boolean) {
this.options = {
...this.options,
showAdjacentMonthDay
}
}
}
66 changes: 65 additions & 1 deletion dev/src/demos/demo-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { CalendarComponentOptions } from '../ion2-calendar';
</ion-item>
<ion-item>
<ion-label>disableWeeks</ion-label>
<ion-select [(ngModel)]="_disableWeeks"
<ion-select [(ngModel)]="_disableWeeks"
(ngModelChange)="_changeDisableWeeks($event)"
multiple="true">
<ion-select-option color="0">0</ion-select-option>
Expand All @@ -48,6 +48,34 @@ import { CalendarComponentOptions } from '../ion2-calendar';
<ion-label>showMonthPicker</ion-label>
<ion-checkbox [(ngModel)]="_showMonthPicker" (ngModelChange)="_changeShowMonthPicker($event)"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>showAdjacentMonthDay</ion-label>
<ion-checkbox [(ngModel)]="_showAdjacentMonthDay" (ngModelChange)="_changeShowAdjacentMonthDay($event)"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>displayMode</ion-label>
<ion-radio-group [(ngModel)]="_displayMode" (ngModelChange)="_changeDisplayMode($event)">
<ion-row>
<ion-item lines="none">
<ion-label>month &nbsp;</ion-label>
<ion-radio value="month"></ion-radio>
</ion-item>
<ion-item lines="none">
<ion-label>week &nbsp;</ion-label>
<ion-radio value="week"></ion-radio>
</ion-item>
</ion-row>
</ion-radio-group>
</ion-item>
<ion-item>
<ion-label position="floating">weeks</ion-label>
<ion-input [disabled]="_displayMode !== 'week'" type="number" inputmode="numeric" min="1" step="1" [(ngModel)]="_weeks"
(ngModelChange)="_changeNumberWeeks($event)"></ion-input>
</ion-item>
<ion-item>
<ion-label>continuous</ion-label>
<ion-checkbox [disabled]="_displayMode !== 'week'" [(ngModel)]="_continuous" (ngModelChange)="_changeContinuous($event)"></ion-checkbox>
</ion-item>
</ion-list>

<ion-calendar [(ngModel)]="date"
Expand All @@ -64,6 +92,10 @@ export class DemoOptionsComponent {
_showMonthPicker: boolean = true;
_disableWeeks: number[] = [0, 6];
_weekStart: number = 0;
_weeks: number = 1;
_continuous: boolean = false;
_displayMode: string = 'month';
_showAdjacentMonthDay: boolean = true;
date: string = '2018-01-01';
options: CalendarComponentOptions = {
from: new Date(2000, 0, 1),
Expand Down Expand Up @@ -110,4 +142,36 @@ export class DemoOptionsComponent {
weekStart: parseInt(weekStart),
};
}

_changeDisplayMode(displayMode: string) {
if (displayMode === 'week' || displayMode === 'month'){
this.options = {
...this.options,
displayMode: displayMode,
};
}
}

_changeNumberWeeks(weeks: number) {
if (weeks > 0){
this.options = {
...this.options,
weeks: weeks,
};
}
}

_changeContinuous(continuous: boolean) {
this.options = {
...this.options,
continuous,
};
}

_changeShowAdjacentMonthDay(showAdjacentMonthDay: boolean) {
this.options = {
...this.options,
showAdjacentMonthDay,
};
}
}
9 changes: 9 additions & 0 deletions dev/src/ion2-calendar/calendar.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export interface CalendarOptions {
* show last month & next month days fill six weeks
*/
showAdjacentMonthDay?: boolean;
displayMode?: DisplayMode;
weeks?: number;
continuous?: boolean;
}

export interface CalendarComponentOptions extends CalendarOptions {
Expand All @@ -113,8 +116,14 @@ export class CalendarComponentMonthChange {
newMonth: CalendarResult;
}

export class CalendarComponentWeekChange {
oldWeek: CalendarResult;
newWeek: CalendarResult;
}

export type DefaultDate = Date | string | number | null;
export type Colors = 'primary' | 'secondary' | 'danger' | 'light' | 'dark' | string;
export type PickMode = 'multi' | 'single' | 'range';
export type CalendarComponentTypeProperty = 'string' | 'js-date' | 'moment' | 'time' | 'object';
export type CalendarComponentPayloadTypes = string | Date | number | {};
export type DisplayMode = 'month' | 'week';
Loading