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

0.23 #420

Merged
merged 29 commits into from
Jan 2, 2018
Merged

0.23 #420

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
775a62e
feat: upgrade to angular 5
Dec 27, 2017
bd68045
feat(date-formatter): use the angular date formatter by default
Dec 27, 2017
26e2b53
feat: upgrade angular resizable element
Dec 27, 2017
fd30c39
feat: upgrade angular draggable droppable package
Dec 27, 2017
9c830dc
refactor: remove redundant check
Dec 27, 2017
5744e9b
feat: use ng-packagr for bundling the package
Dec 27, 2017
266029f
test: remove redundant tests
Dec 27, 2017
dba1fd3
build: remove the intl polyfill
Dec 27, 2017
0b94a31
docs: update now angular is the default formatter
Dec 27, 2017
8d18c5b
docs(demos): remove Intl usage from demos
Dec 27, 2017
579a51a
feat: export drag+drop and resizable modules for use in custom templates
Dec 28, 2017
d9c7f3a
build: only run ngc on separate modules
Dec 28, 2017
29b4237
build: fix individual module imports
Dec 28, 2017
fe59aad
feat: upgrade calendar-utils
Dec 30, 2017
418828c
docs(demos): upgrade bootstrap to beta 2
Dec 30, 2017
22f14b3
build: reinstall dependencies
Dec 30, 2017
a9ab6d9
feat(month-view): call beforeViewRender with the view period
Jan 1, 2018
3aabaa7
refactor: prefix month view event with calendar
Jan 1, 2018
a6619bf
test: split out beforeViewRender test logic into 2 tests
Jan 1, 2018
cb73eff
feat(week-view): expose the view period on beforeViewRender
Jan 1, 2018
24739ce
feat(day-view): expose the period on the beforeViewRender output
Jan 1, 2018
0ffe3d1
refactor(month-view): remove redundant workaround
Jan 1, 2018
6954a55
refactor: expose missing interfaces
Jan 1, 2018
a3ed9bc
docs(demos): add the no-events-label demo
Jan 1, 2018
7948d74
docs(demos): fix date-time-picker model value
Jan 1, 2018
8ae8419
fix(universal): make the calendar work with universal (again)
Jan 1, 2018
9290f81
docs: remove now redundant universal comment
Jan 1, 2018
d025456
docs: remove usage without a module bundler
Jan 1, 2018
71e9210
docs: update faq
Jan 1, 2018
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
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# angular 4.0+ calendar
# angular 5.0+ calendar

[![Build Status](https://travis-ci.org/mattlewis92/angular-calendar.svg?branch=master)](https://travis-ci.org/mattlewis92/angular-calendar)
[![codecov](https://codecov.io/gh/mattlewis92/angular-calendar/branch/master/graph/badge.svg)](https://codecov.io/gh/mattlewis92/angular-calendar)
Expand All @@ -25,7 +25,7 @@ https://mattlewis92.github.io/angular-calendar/

## About

A calendar component for Angular 4.0+ that can display events on a month, week or day view. The successor of [angular-bootstrap-calendar](https://github.com/mattlewis92/angular-bootstrap-calendar).
A calendar component for Angular 5.0+ that can display events on a month, week or day view. The successor of [angular-bootstrap-calendar](https://github.com/mattlewis92/angular-bootstrap-calendar).

## Getting started

Expand Down Expand Up @@ -65,19 +65,6 @@ Once you are up and running, to access a full list of options for each component

You can find quick start examples for all common module bundlers in the [build-tool-examples](https://github.com/mattlewis92/angular-calendar/tree/master/build-tool-examples) folder.

### Usage without a module bundler

```html
<script src="node_modules/angular-calendar/umd/angular-calendar.js"></script>
<script>
// everything is exported angularCalendar namespace
</script>
```

### Usage with Angular Universal

See [this comment](https://github.com/mattlewis92/angular-calendar/issues/158#issuecomment-285330700) for how to use with Universal.

## Documentation

To see all available API options, take a look at the auto generated [documentation](https://mattlewis92.github.io/angular-calendar/docs/). You may find it helpful to view the examples on the demo page.
Expand All @@ -88,14 +75,17 @@ Where possible this library will strictly adhere to [semver](http://semver.org/)

## FAQ

### Is this library AoT compatible?
### Is this library AoT and universal compatible?

Yes.

### Does this library work with angular 2.x?

The last version of this library that supports 2.x is `0.9.1`. However the upgrade from angular 2.x to 4.x is just a matter of [changing the dependencies in your package.json](https://github.com/mattlewis92/angular2-tv-tracker/commit/9439e3cec40293b2a86bc2222f610ee6ad4b5229) and [adding the `angular/animations` module](https://github.com/mattlewis92/angular2-tv-tracker/commit/9fe0e3158290c2612d20e4c0f54d2204fb70791e)

### Does this library work with angular 4.x?
The last version of this library that supports 4.x is `0.22.3`.

### How do I use this with my favourite module bundler?

See the [examples list](https://github.com/mattlewis92/angular-calendar/tree/master/build-tool-examples).
Expand Down
3 changes: 2 additions & 1 deletion demos/demo-app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ const dependencyVersions: any = {
ngBootstrap: require('@ng-bootstrap/ng-bootstrap/package.json').version,
rrule: require('rrule/package.json').version,
ngxContextmenu: require('ngx-contextmenu/package.json').version,
fontAwesome: require('font-awesome/package.json').version
fontAwesome: require('font-awesome/package.json').version,
angularCdk: require('@angular/cdk/package.json').version
};

@Component({
Expand Down
4 changes: 2 additions & 2 deletions demos/demo-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top" role="navigation">

<a class="navbar-brand" href="#">Angular 4.0+ calendar</a>
<a class="navbar-brand" href="#">Angular 5.0+ calendar</a>

<button
type="button"
Expand Down Expand Up @@ -112,4 +112,4 @@ <h4>Demos</h4>
</div>
</div>
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions demos/demo-app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ import { DemoModule as DefaultDemoModule } from './demo-modules/kitchen-sink/mod
label: 'Disable slide animation'
}
},
{
path: 'no-events-label',
loadChildren: './demo-modules/no-events-label/module#DemoModule',
data: {
label: 'No events label'
}
},
{
path: '**',
redirectTo: 'kitchen-sink'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import { CalendarDateFormatter, DateFormatterParams } from 'angular-calendar';
import { DatePipe } from '@angular/common';

export class CustomDateFormatter extends CalendarDateFormatter {
// you can override any of the methods defined in the parent class

public monthViewColumnHeader({ date, locale }: DateFormatterParams): string {
return new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date);
return new DatePipe(locale).transform(date, 'EEE', locale);
}

public monthViewTitle({ date, locale }: DateFormatterParams): string {
return new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'short'
}).format(date);
return new DatePipe(locale).transform(date, 'MMM y', locale);
}

public weekViewColumnHeader({ date, locale }: DateFormatterParams): string {
return new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date);
return new DatePipe(locale).transform(date, 'EEE', locale);
}

public dayViewHour({ date, locale }: DateFormatterParams): string {
return new Intl.DateTimeFormat(locale, {
hour: 'numeric',
minute: 'numeric'
}).format(date);
return new DatePipe(locale).transform(date, 'HH:mm', locale);
}
}
2 changes: 2 additions & 0 deletions demos/demo-modules/demo-utils/date-time-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class DateTimePickerComponent implements ControlValueAccessor {
),
this.dateStruct.year
);
this.writeValue(newDate);
this.onChangeCallback(newDate);
}

Expand All @@ -113,6 +114,7 @@ export class DateTimePickerComponent implements ControlValueAccessor {
),
this.timeStruct.hour
);
this.writeValue(newDate);
this.onChangeCallback(newDate);
}
}
5 changes: 2 additions & 3 deletions demos/demo-modules/i18n/custom-date-formatter.provider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { CalendarDateFormatter, DateFormatterParams } from 'angular-calendar';
import { getISOWeek } from 'date-fns';
import { DatePipe } from '@angular/common';

export class CustomDateFormatter extends CalendarDateFormatter {
public weekViewTitle({ date, locale }: DateFormatterParams): string {
const year: string = new Intl.DateTimeFormat(locale, {
year: 'numeric'
}).format(date);
const year: string = new DatePipe(locale).transform(date, 'y', locale);
const weekNumber: number = getISOWeek(date);
return `Semaine ${weekNumber} en ${year}`;
}
Expand Down
4 changes: 4 additions & 0 deletions demos/demo-modules/i18n/module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { CalendarModule } from 'angular-calendar';
import { DemoUtilsModule } from '../demo-utils/module';
import { DemoComponent } from './component';

registerLocaleData(localeFr);

@NgModule({
imports: [
CommonModule,
Expand Down
46 changes: 46 additions & 0 deletions demos/demo-modules/no-events-label/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
Component,
ChangeDetectionStrategy,
ChangeDetectorRef
} from '@angular/core';
import {
CalendarEvent,
CalendarViewPeriod,
CalendarMonthViewBeforeRenderEvent,
CalendarWeekViewBeforeRenderEvent,
CalendarDayViewBeforeRenderEvent
} from 'angular-calendar';
import { colors } from '../demo-utils/colors';

@Component({
selector: 'mwl-demo-component',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: 'template.html'
})
export class DemoComponent {
view: string = 'month';

viewDate: Date = new Date();

events: CalendarEvent[] = [
{
title: 'Event 1',
color: colors.yellow,
start: new Date()
}
];

period: CalendarViewPeriod;

constructor(private cdr: ChangeDetectorRef) {}

beforeViewRender(
event:
| CalendarMonthViewBeforeRenderEvent
| CalendarWeekViewBeforeRenderEvent
| CalendarDayViewBeforeRenderEvent
) {
this.period = event.period;
this.cdr.detectChanges();
}
}
18 changes: 18 additions & 0 deletions demos/demo-modules/no-events-label/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { CalendarModule } from 'angular-calendar';
import { DemoUtilsModule } from '../demo-utils/module';
import { DemoComponent } from './component';

@NgModule({
imports: [
CommonModule,
CalendarModule.forRoot(),
DemoUtilsModule,
RouterModule.forChild([{ path: '', component: DemoComponent }])
],
declarations: [DemoComponent],
exports: [DemoComponent]
})
export class DemoModule {}
23 changes: 23 additions & 0 deletions demos/demo-modules/no-events-label/sources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const sources = [
{
filename: 'component.ts',
contents: {
raw: require('!!raw-loader!./component'),
highlighted: require('!!raw-loader!highlightjs-loader?lang=typescript!./component')
}
},
{
filename: 'template.html',
contents: {
raw: require('!!raw-loader!./template.html'),
highlighted: require('!!raw-loader!highlightjs-loader?lang=xml!./template.html')
}
},
{
filename: 'module.ts',
contents: {
raw: require('!!raw-loader!./module'),
highlighted: require('!!raw-loader!highlightjs-loader?lang=typescript!./module')
}
}
];
30 changes: 30 additions & 0 deletions demos/demo-modules/no-events-label/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<mwl-demo-utils-calendar-header
[(view)]="view"
[(viewDate)]="viewDate">
</mwl-demo-utils-calendar-header>

<div class="alert alert-warning" *ngIf="period?.events.length === 0">
There are no events on this {{ view }}
</div>

<div [ngSwitch]="view">
<mwl-calendar-month-view
*ngSwitchCase="'month'"
[viewDate]="viewDate"
[events]="events"
[activeDayIsOpen]="true"
(beforeViewRender)="beforeViewRender($event)">
</mwl-calendar-month-view>
<mwl-calendar-week-view
*ngSwitchCase="'week'"
[viewDate]="viewDate"
[events]="events"
(beforeViewRender)="beforeViewRender($event)">
</mwl-calendar-week-view>
<mwl-calendar-day-view
*ngSwitchCase="'day'"
[viewDate]="viewDate"
[events]="events"
(beforeViewRender)="beforeViewRender($event)">
</mwl-calendar-day-view>
</div>
4 changes: 2 additions & 2 deletions demos/demo-modules/selectable-period/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*ngSwitchCase="'day'"
[viewDate]="viewDate"
[events]="events"
(beforeViewRender)="beforeDayViewRender($event.body)"
(beforeViewRender)="beforeDayViewRender($event.body.hourGrid)"
(hourSegmentClicked)="hourSegmentClicked($event.date)">
</mwl-calendar-day-view>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LOCALE_ID, Inject } from '@angular/core';
import { CalendarEventTitleFormatter, CalendarEvent } from 'angular-calendar';
import { DatePipe } from '@angular/common';

export class CustomEventTitleFormatter extends CalendarEventTitleFormatter {
constructor(@Inject(LOCALE_ID) private locale: string) {
Expand All @@ -9,23 +10,26 @@ export class CustomEventTitleFormatter extends CalendarEventTitleFormatter {
// you can override any of the methods defined in the parent class

month(event: CalendarEvent): string {
return `<b>${new Intl.DateTimeFormat(this.locale, {
hour: 'numeric',
minute: 'numeric'
}).format(event.start)}</b> ${event.title}`;
return `<b>${new DatePipe(this.locale).transform(
event.start,
'h:m a',
this.locale
)}</b> ${event.title}`;
}

week(event: CalendarEvent): string {
return `<b>${new Intl.DateTimeFormat(this.locale, {
hour: 'numeric',
minute: 'numeric'
}).format(event.start)}</b> ${event.title}`;
return `<b>${new DatePipe(this.locale).transform(
event.start,
'h:m a',
this.locale
)}</b> ${event.title}`;
}

day(event: CalendarEvent): string {
return `<b>${new Intl.DateTimeFormat(this.locale, {
hour: 'numeric',
minute: 'numeric'
}).format(event.start)}</b> ${event.title}`;
return `<b>${new DatePipe(this.locale).transform(
event.start,
'h:m a',
this.locale
)}</b> ${event.title}`;
}
}
11 changes: 0 additions & 11 deletions demos/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'hammerjs';
import 'intl';
import 'intl/locale-data/jsonp/en';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { DemoAppModule } from './demo-app.module';
Expand All @@ -31,15 +29,6 @@ if (ENV === 'production') {

const dynamicPolyfills = [];

if (typeof Intl === 'undefined') {
dynamicPolyfills.push(
Promise.all([
import(/* webpackChunkName: "intl" */ 'intl'),
import(/* webpackChunkName: "intl" */ 'intl/locale-data/jsonp/en')
])
);
}

if (
typeof Object.entries === 'undefined' ||
typeof Object.values === 'undefined'
Expand Down
2 changes: 1 addition & 1 deletion demos/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Angular 4.0+ calendar</title>
<title>Angular 5.0+ calendar</title>
</head>
<body>
<mwl-demo-app>Loading demo...</mwl-demo-app>
Expand Down
Loading