From 6ebf377595818e9165e02d66c185a032de02ebc3 Mon Sep 17 00:00:00 2001 From: Marcin Szemelowski Date: Fri, 3 Aug 2018 19:47:13 +0200 Subject: [PATCH 1/2] added multilanguage from momentjs lang files --- README.md | 2 +- index.js | 6 +- package.json | 4 +- src/calendar/calendar.html | 4 +- src/calendar/calendar.js | 83 +++++++++++--------------- src/calendar/calendar.js.map | 2 +- src/calendar/calendar.module.js | 48 ++++++++------- src/calendar/calendar.module.ts | 7 ++- src/calendar/calendar.ts | 12 +--- src/calendar/pipes/month-name.js | 30 ++++------ src/calendar/pipes/month-name.ts | 10 +--- src/calendar/pipes/weekday-name.js | 26 ++++++++ src/calendar/pipes/weekday-name.js.map | 1 + src/calendar/pipes/weekday-name.ts | 12 ++++ 14 files changed, 134 insertions(+), 113 deletions(-) create mode 100644 src/calendar/pipes/weekday-name.js create mode 100644 src/calendar/pipes/weekday-name.js.map create mode 100644 src/calendar/pipes/weekday-name.ts diff --git a/README.md b/README.md index 381d4cf..639a949 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ionic Calendar (English and Spanish) +# Ionic Calendar Multilanguage ![image](https://raw.githubusercontent.com/gbrits/ionic-calendar/master/calendar.png?raw=true) diff --git a/index.js b/index.js index 16b7a80..3be91ab 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,4 @@ -export { CalendarModule } from './src/calendar/calendar.module'; -//# sourceMappingURL=index.js.map \ No newline at end of file +"use strict"; +exports.__esModule = true; +var calendar_module_1 = require("./src/calendar/calendar.module"); +exports.CalendarModule = calendar_module_1.CalendarModule; diff --git a/package.json b/package.json index b4ead83..d27c0eb 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "url": "https://github.com/gbrits/ionic-calendar/issues" }, "homepage": "https://github.com/gbrits/ionic-calendar#readme", - "dependencies": {}, + "dependencies": { + "moment": "^2.22.2" + }, "devDependencies": { "typescript": "2.3.4" } diff --git a/src/calendar/calendar.html b/src/calendar/calendar.html index 8556172..cfff554 100644 --- a/src/calendar/calendar.html +++ b/src/calendar/calendar.html @@ -12,11 +12,11 @@ - {{head}} + {{head | weekdayName:lang}} - + {{day.date}} diff --git a/src/calendar/calendar.js b/src/calendar/calendar.js index 3483959..2315590 100644 --- a/src/calendar/calendar.js +++ b/src/calendar/calendar.js @@ -1,19 +1,18 @@ +"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -import { Component, Input, Output, EventEmitter } from '@angular/core'; -import * as moment from 'moment'; -import * as _ from "lodash"; -var Calendar = (function () { +exports.__esModule = true; +var core_1 = require("@angular/core"); +var moment = require("moment"); +var _ = require("lodash"); +var Calendar = /** @class */ (function () { function Calendar() { - this.onDaySelect = new EventEmitter(); - this.onMonthSelect = new EventEmitter(); + this.onDaySelect = new core_1.EventEmitter(); + this.onMonthSelect = new core_1.EventEmitter(); this.events = []; this.currentYear = moment().year(); this.currentMonth = moment().month(); @@ -24,22 +23,13 @@ var Calendar = (function () { this.dateArray = []; // Array for all the days of the month this.weekArray = []; // Array for each row of the calendar this.lastSelect = 0; // Record the last clicked location - this.weekHead = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + this.weekHead = [0, 1, 2, 3, 4, 5, 6]; this.today(); this.createMonth(this.displayYear, this.displayMonth); } Calendar.prototype.ngOnChanges = function () { this.createMonth(this.displayYear, this.displayMonth); }; - Calendar.prototype.ngAfterContentInit = function () { - console.info(this.lang); - if (!this.lang) { - this.lang = 'en'; - } - if (this.lang === 'es') { - this.weekHead = ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab']; - } - }; // Jump to today Calendar.prototype.today = function () { this.displayYear = this.currentYear; @@ -88,7 +78,7 @@ var Calendar = (function () { monthDays = moment({ year: year, month: month }).daysInMonth(); // PREVIOUS MONTH // Add the last few days of the previous month to the array - if (firstDay !== 7) { + if (firstDay !== 7) { // Sunday doesn't need to be shown for the previous month var lastMonthStart = preMonthDays - firstDay + 1; // From the last few months start for (var i = 0; i < firstDay; i++) { if (month === 0) { @@ -99,7 +89,7 @@ var Calendar = (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, 11, lastMonthStart + i)) ? true : false, + hasEvent: (this.isInEvents(year, 11, lastMonthStart + i)) ? true : false }); } else { @@ -110,7 +100,7 @@ var Calendar = (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, month - 1, lastMonthStart + i)) ? true : false, + hasEvent: (this.isInEvents(year, month - 1, lastMonthStart + i)) ? true : false }); } } @@ -124,7 +114,7 @@ var Calendar = (function () { isThisMonth: true, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, month, i + 1)) ? true : false, + hasEvent: (this.isInEvents(year, month, i + 1)) ? true : false }); } if (this.currentYear === year && this.currentMonth === month) { @@ -148,7 +138,7 @@ var Calendar = (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, 0, i + 1)) ? true : false, + hasEvent: (this.isInEvents(year, 0, i + 1)) ? true : false }); } else { @@ -159,7 +149,7 @@ var Calendar = (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, month + 1, i + 1)) ? true : false, + hasEvent: (this.isInEvents(year, month + 1, i + 1)) ? true : false }); } } @@ -213,30 +203,25 @@ var Calendar = (function () { this.dateArray[i * 7 + j].isSelect = true; this.onDaySelect.emit(day); }; + __decorate([ + core_1.Output() + ], Calendar.prototype, "onDaySelect"); + __decorate([ + core_1.Output() + ], Calendar.prototype, "onMonthSelect"); + __decorate([ + core_1.Input() + ], Calendar.prototype, "events"); + __decorate([ + core_1.Input() + ], Calendar.prototype, "lang"); + Calendar = __decorate([ + core_1.Component({ + selector: 'ion-calendar', + template: "\n \n \n \n \n \n \n
{{displayYear}} - {{displayMonth + 1 | monthName:lang}}
\n
\n \n \n \n
\n\n \n {{head | weekdayName:lang}}\n \n\n \n \n {{day.date}}\n \n \n \n\n
\n" + }) + ], Calendar); return Calendar; }()); -__decorate([ - Output(), - __metadata("design:type", Object) -], Calendar.prototype, "onDaySelect", void 0); -__decorate([ - Output(), - __metadata("design:type", Object) -], Calendar.prototype, "onMonthSelect", void 0); -__decorate([ - Input(), - __metadata("design:type", Array) -], Calendar.prototype, "events", void 0); -__decorate([ - Input(), - __metadata("design:type", String) -], Calendar.prototype, "lang", void 0); -Calendar = __decorate([ - Component({ - selector: 'ion-calendar', - template: "\n \n \n \n \n \n \n
{{displayYear}} - {{displayMonth + 1 | monthName:lang}}
\n
\n \n \n \n
\n\n \n {{head}}\n \n\n \n \n {{day.date}}\n \n \n \n\n
\n" - }), - __metadata("design:paramtypes", []) -], Calendar); -export { Calendar }; +exports.Calendar = Calendar; //# sourceMappingURL=calendar.js.map \ No newline at end of file diff --git a/src/calendar/calendar.js.map b/src/calendar/calendar.js.map index 1ae5d8d..766c394 100644 --- a/src/calendar/calendar.js.map +++ b/src/calendar/calendar.js.map @@ -1 +1 @@ -{"version":3,"file":"calendar.js","sourceRoot":"","sources":["calendar.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAmC5B,IAAa,QAAQ;IAqBjB;QAnBU,gBAAW,GAAG,IAAI,YAAY,E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,CA0NpB;IAAD,eAAC;CAAA,AA1ND,IA0NC;AA1NY,4BAAQ"} \ No newline at end of file diff --git a/src/calendar/calendar.module.js b/src/calendar/calendar.module.js index d1e2595..6c52ab0 100644 --- a/src/calendar/calendar.module.js +++ b/src/calendar/calendar.module.js @@ -1,32 +1,36 @@ +"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -import { NgModule } from '@angular/core'; -import { IonicModule } from 'ionic-angular'; -import { Calendar } from './calendar'; -import { monthName } from './pipes/month-name'; -var CalendarModule = (function () { +exports.__esModule = true; +var core_1 = require("@angular/core"); +var ionic_angular_1 = require("ionic-angular"); +var calendar_1 = require("./calendar"); +var month_name_1 = require("./pipes/month-name"); +var weekday_name_1 = require("./pipes/weekday-name"); +var CalendarModule = /** @class */ (function () { function CalendarModule() { } + CalendarModule = __decorate([ + core_1.NgModule({ + declarations: [ + calendar_1.Calendar, + month_name_1.monthName, + weekday_name_1.weekdayName + ], + imports: [ + ionic_angular_1.IonicModule, + ], + exports: [ + calendar_1.Calendar, + month_name_1.monthName, + weekday_name_1.weekdayName + ] + }) + ], CalendarModule); return CalendarModule; }()); -CalendarModule = __decorate([ - NgModule({ - declarations: [ - Calendar, - monthName - ], - imports: [ - IonicModule, - ], - exports: [ - Calendar, - monthName - ] - }) -], CalendarModule); -export { CalendarModule }; -//# sourceMappingURL=calendar.module.js.map \ No newline at end of file +exports.CalendarModule = CalendarModule; diff --git a/src/calendar/calendar.module.ts b/src/calendar/calendar.module.ts index 419efcf..be504db 100644 --- a/src/calendar/calendar.module.ts +++ b/src/calendar/calendar.module.ts @@ -2,17 +2,20 @@ import { NgModule } from '@angular/core'; import { IonicModule } from 'ionic-angular'; import { Calendar } from './calendar'; import { monthName } from './pipes/month-name'; +import {weekdayName} from "./pipes/weekday-name"; @NgModule({ declarations: [ Calendar, - monthName + monthName, + weekdayName ], imports: [ IonicModule, ], exports: [ Calendar, - monthName + monthName, + weekdayName ] }) export class CalendarModule { } diff --git a/src/calendar/calendar.ts b/src/calendar/calendar.ts index 043b15d..af19093 100644 --- a/src/calendar/calendar.ts +++ b/src/calendar/calendar.ts @@ -19,13 +19,13 @@ import * as _ from "lodash";
- {{head}} + {{head | weekdayName:lang}} + [ngClass]="[day.isThisMonth?'this-month':'not-this-month',day.isToday?'today':'',day.isSelect?'select':'',day.hasEvent?'has-event':'']"> {{day.date}} @@ -54,7 +54,7 @@ export class Calendar { weekArray = []; // Array for each row of the calendar lastSelect: number = 0; // Record the last clicked location - weekHead: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + weekHead: number[] = [0,1,2,3,4,5,6]; constructor() { this.today(); @@ -65,12 +65,6 @@ export class Calendar { this.createMonth(this.displayYear, this.displayMonth); } - ngAfterContentInit() { - if (!this.lang) { this.lang = 'en'; } - if (this.lang === 'es') { - this.weekHead = ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab']; - } - } // Jump to today today() { diff --git a/src/calendar/pipes/month-name.js b/src/calendar/pipes/month-name.js index 2fd758c..f827cca 100644 --- a/src/calendar/pipes/month-name.js +++ b/src/calendar/pipes/month-name.js @@ -1,29 +1,25 @@ +"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -import { Pipe } from '@angular/core'; -var monthName = (function () { +exports.__esModule = true; +var core_1 = require("@angular/core"); +var moment = require("moment"); +var monthName = /** @class */ (function () { function monthName() { } monthName.prototype.transform = function (value, args) { - if (args === 'es') { - this.lang = 'es'; - } - var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - if (this.lang === 'es') { - monthNames = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']; - } - return monthNames[value - 1]; + var lang = moment().locale(args); + return lang.localeData().months(moment([2012, value - 1])); }; + monthName = __decorate([ + core_1.Pipe({ + name: 'monthName' + }) + ], monthName); return monthName; }()); -monthName = __decorate([ - Pipe({ - name: 'monthName' - }) -], monthName); -export { monthName }; -//# sourceMappingURL=month-name.js.map \ No newline at end of file +exports.monthName = monthName; diff --git a/src/calendar/pipes/month-name.ts b/src/calendar/pipes/month-name.ts index 9ec1e25..d46a319 100644 --- a/src/calendar/pipes/month-name.ts +++ b/src/calendar/pipes/month-name.ts @@ -1,16 +1,12 @@ import {Pipe} from '@angular/core'; +import * as moment from 'moment'; @Pipe({ name: 'monthName' }) export class monthName { - private lang: string; // (es or en) transform(value, args) { - if (args === 'es') { this.lang = 'es'; } - let monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; - if (this.lang === 'es') { - monthNames = [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ]; - } - return monthNames[value - 1]; + var lang = moment().locale(args); + return lang.localeData().months(moment([2012, value - 1])); } } diff --git a/src/calendar/pipes/weekday-name.js b/src/calendar/pipes/weekday-name.js new file mode 100644 index 0000000..1702421 --- /dev/null +++ b/src/calendar/pipes/weekday-name.js @@ -0,0 +1,26 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +exports.__esModule = true; +var core_1 = require("@angular/core"); +var moment = require("moment"); +var weekdayName = /** @class */ (function () { + function weekdayName() { + } + weekdayName.prototype.transform = function (value, args) { + var lang = moment().locale(args); + return lang.localeData().weekdaysShort()[value]; + }; + weekdayName = __decorate([ + core_1.Pipe({ + name: 'weekdayName' + }) + ], weekdayName); + return weekdayName; +}()); +exports.weekdayName = weekdayName; +//# sourceMappingURL=weekday-name.js.map \ No newline at end of file diff --git a/src/calendar/pipes/weekday-name.js.map b/src/calendar/pipes/weekday-name.js.map new file mode 100644 index 0000000..d79ae3c --- /dev/null +++ b/src/calendar/pipes/weekday-name.js.map @@ -0,0 +1 @@ +{"version":3,"file":"weekday-name.js","sourceRoot":"","sources":["weekday-name.ts"],"names":[],"mappings":";;;;;;;;AAAA,sCAAmC;AACnC,+BAAiC;AAKjC;IAAA;IAKA,CAAC;IAJC,+BAAS,GAAT,UAAU,KAAK,EAAE,IAAI;QACnB,IAAI,IAAI,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAJU,WAAW;QAHvB,WAAI,CAAC;YACJ,IAAI,EAAE,aAAa;SACpB,CAAC;OACW,WAAW,CAKvB;IAAD,kBAAC;CAAA,AALD,IAKC;AALY,kCAAW"} \ No newline at end of file diff --git a/src/calendar/pipes/weekday-name.ts b/src/calendar/pipes/weekday-name.ts new file mode 100644 index 0000000..bfaaa4b --- /dev/null +++ b/src/calendar/pipes/weekday-name.ts @@ -0,0 +1,12 @@ +import {Pipe} from '@angular/core'; +import * as moment from 'moment'; + +@Pipe({ + name: 'weekdayName' +}) +export class weekdayName { + transform(value, args) { + var lang = moment().locale(args); + return lang.localeData().weekdaysShort()[value]; + } +} From afe505bc5d313428c7fe5ee8ab8a6c1c30171ad5 Mon Sep 17 00:00:00 2001 From: Marcin Szemelowski Date: Wed, 8 Aug 2018 13:32:57 +0200 Subject: [PATCH 2/2] added onClick, event-css,refresh calendar after changes in event array --- src/calendar/calendar.js | 38 ++++++++++++++++++++++++++------ src/calendar/calendar.js.map | 2 +- src/calendar/calendar.ts | 42 ++++++++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/calendar/calendar.js b/src/calendar/calendar.js index 2315590..29dc541 100644 --- a/src/calendar/calendar.js +++ b/src/calendar/calendar.js @@ -30,6 +30,9 @@ var Calendar = /** @class */ (function () { Calendar.prototype.ngOnChanges = function () { this.createMonth(this.displayYear, this.displayMonth); }; + Calendar.prototype.ngDoCheck = function () { + this.createMonth(this.displayYear, this.displayMonth); + }; // Jump to today Calendar.prototype.today = function () { this.displayYear = this.currentYear; @@ -55,6 +58,12 @@ var Calendar = /** @class */ (function () { } return false; }; + Calendar.prototype.getEventRecord = function (year, month, date) { + var result = this.events.find(function (el) { + return el.year == year && el.month == month && el.date == date; + }); + return result ? result : {}; + }; Calendar.prototype.createMonth = function (year, month) { this.dateArray = []; // Clear last month's data this.weekArray = []; // Clear week data @@ -78,10 +87,13 @@ var Calendar = /** @class */ (function () { monthDays = moment({ year: year, month: month }).daysInMonth(); // PREVIOUS MONTH // Add the last few days of the previous month to the array + //get event record + // let record = this.getEventRecord() if (firstDay !== 7) { // Sunday doesn't need to be shown for the previous month var lastMonthStart = preMonthDays - firstDay + 1; // From the last few months start for (var i = 0; i < firstDay; i++) { if (month === 0) { + var record = this.getEventRecord(year, 11, lastMonthStart + i); this.dateArray.push({ year: year, month: 11, @@ -89,10 +101,13 @@ var Calendar = /** @class */ (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, 11, lastMonthStart + i)) ? true : false + hasEvent: (this.isInEvents(year, 11, lastMonthStart + i)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }); } else { + var record = this.getEventRecord(year, month - 1, lastMonthStart + i); this.dateArray.push({ year: year, month: month - 1, @@ -100,13 +115,16 @@ var Calendar = /** @class */ (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, month - 1, lastMonthStart + i)) ? true : false + hasEvent: (this.isInEvents(year, month - 1, lastMonthStart + i)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }); } } } // Add the numeral for this month to the array for (var i = 0; i < monthDays; i++) { + var record = this.getEventRecord(year, month, i + 1); this.dateArray.push({ year: year, month: month, @@ -114,7 +132,9 @@ var Calendar = /** @class */ (function () { isThisMonth: true, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, month, i + 1)) ? true : false + hasEvent: (this.isInEvents(year, month, i + 1)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }); } if (this.currentYear === year && this.currentMonth === month) { @@ -130,6 +150,7 @@ var Calendar = /** @class */ (function () { if (this.dateArray.length % 7 !== 0) { var nextMonthAdd = 7 - this.dateArray.length % 7; for (var i = 0; i < nextMonthAdd; i++) { + var record = this.getEventRecord(year, 0, i + 1); if (month === 11) { this.dateArray.push({ year: year, @@ -138,10 +159,13 @@ var Calendar = /** @class */ (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, 0, i + 1)) ? true : false + hasEvent: (this.isInEvents(year, 0, i + 1)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }); } else { + var record_1 = this.getEventRecord(year, month + 1, i + 1); this.dateArray.push({ year: year, month: month + 1, @@ -149,7 +173,9 @@ var Calendar = /** @class */ (function () { isThisMonth: false, isToday: false, isSelect: false, - hasEvent: (this.isInEvents(year, month + 1, i + 1)) ? true : false + hasEvent: (this.isInEvents(year, month + 1, i + 1)) ? true : false, + onClick: record_1.onClick, + eventCSS: record_1.eventCSS }); } } @@ -218,7 +244,7 @@ var Calendar = /** @class */ (function () { Calendar = __decorate([ core_1.Component({ selector: 'ion-calendar', - template: "\n \n \n \n \n \n \n
{{displayYear}} - {{displayMonth + 1 | monthName:lang}}
\n
\n \n \n \n
\n\n \n {{head | weekdayName:lang}}\n \n\n \n \n {{day.date}}\n \n \n \n\n
\n" + template: "\n \n \n \n \n \n \n
{{displayYear}} - {{displayMonth + 1 | monthName:lang}}
\n
\n \n \n \n
\n\n \n {{head | weekdayName:lang}}\n \n\n \n \n {{day.date}}\n \n \n\n
\n" }) ], Calendar); return Calendar; diff --git a/src/calendar/calendar.js.map b/src/calendar/calendar.js.map index 766c394..d5ce354 100644 --- a/src/calendar/calendar.js.map +++ b/src/calendar/calendar.js.map @@ -1 +1 @@ -{"version":3,"file":"calendar.js","sourceRoot":"","sources":["calendar.ts"],"names":[],"mappings":";;;;;;;;AAAA,sCAAuE;AACvE,+BAAiC;AACjC,0BAA4B;AAmC5B;IAqBI;QAnBU,gBAAW,GAAG,IAAI,mBAAY,EAAW,CAAC;QAC1C,kBAAa,GAAG,IAAI,mBAAY,EAAO,CAAC;QACzC,WAAM,GAAwB,EAAE,CAAC;QAG1C,gBAAW,GAAW,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;QACtC,iBAAY,GAAW,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;QACxC,gBAAW,GAAW,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;QACtC,eAAU,GAAW,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QAEpC,gBAAW,GAAW,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;QACtC,iBAAY,GAAW,MAAM,EAAE,CAAC,KAAK,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R,YAAK,EAAE;oCAAkC;IACjC;QAAR,YAAK,EAAE;kCAAc;IALb,QAAQ;QAhCpB,gBAAS,CAAC;YACP,QAAQ,EAAE,cAAc;YACxB,QAAQ,EAAE,+sCA2Bb;SACA,CAAC;OAEW,QAAQ,CAyPpB;IAAD,eAAC;CAAA,AAzPD,IAyPC;AAzPY,4BAAQ"} \ No newline at end of file diff --git a/src/calendar/calendar.ts b/src/calendar/calendar.ts index af19093..97901f5 100644 --- a/src/calendar/calendar.ts +++ b/src/calendar/calendar.ts @@ -23,11 +23,10 @@ import * as _ from "lodash";
- + [ngClass]="[day.isThisMonth?'this-month':'not-this-month',day.isToday?'today':'',day.isSelect?'select':'',day.hasEvent&&day.eventCSS?day.eventCSS:'']"> {{day.date}} - @@ -65,6 +64,10 @@ export class Calendar { this.createMonth(this.displayYear, this.displayMonth); } + ngDoCheck() { + this.createMonth(this.displayYear, this.displayMonth); + } + // Jump to today today() { @@ -95,6 +98,14 @@ export class Calendar { return false; } + getEventRecord(year, month, date):any + { + var result = this.events.find((el) => { + return el.year == year && el.month == month && el.date == date; + }); + return result?result:{}; + } + createMonth(year: number, month: number) { this.dateArray = []; // Clear last month's data this.weekArray = []; // Clear week data @@ -121,10 +132,15 @@ export class Calendar { // PREVIOUS MONTH // Add the last few days of the previous month to the array + + //get event record + // let record = this.getEventRecord() + if (firstDay !== 7) { // Sunday doesn't need to be shown for the previous month let lastMonthStart = preMonthDays - firstDay + 1; // From the last few months start for (let i = 0; i < firstDay; i++) { if (month === 0) { + let record = this.getEventRecord(year,11,lastMonthStart + i); this.dateArray.push({ year: year, month: 11, @@ -133,8 +149,11 @@ export class Calendar { isToday: false, isSelect: false, hasEvent: (this.isInEvents(year, 11, lastMonthStart+i)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }) } else { + let record = this.getEventRecord(year,month-1,lastMonthStart + i); this.dateArray.push({ year: year, month: month - 1, @@ -143,6 +162,8 @@ export class Calendar { isToday: false, isSelect: false, hasEvent: (this.isInEvents(year, month-1, lastMonthStart+i)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }) } @@ -151,6 +172,7 @@ export class Calendar { // Add the numeral for this month to the array for (let i = 0; i < monthDays; i++) { + let record = this.getEventRecord(year,month,i + 1); this.dateArray.push({ year: year, month: month, @@ -159,6 +181,8 @@ export class Calendar { isToday: false, isSelect: false, hasEvent: (this.isInEvents(year, month, i+1)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }) } @@ -176,6 +200,7 @@ export class Calendar { if (this.dateArray.length % 7 !== 0) { let nextMonthAdd = 7 - this.dateArray.length % 7 for (let i = 0; i < nextMonthAdd; i++) { + let record = this.getEventRecord(year,0,i + 1); if (month === 11) { this.dateArray.push({ year: year, @@ -185,8 +210,11 @@ export class Calendar { isToday: false, isSelect: false, hasEvent: (this.isInEvents(year, 0, i+1)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }) } else { + let record = this.getEventRecord(year,month + 1,i + 1); this.dateArray.push({ year: year, month: month + 1, @@ -195,6 +223,8 @@ export class Calendar { isToday: false, isSelect: false, hasEvent: (this.isInEvents(year, month+1, i+1)) ? true : false, + onClick: record.onClick, + eventCSS: record.eventCSS }) } @@ -258,7 +288,9 @@ export class Calendar { interface singularDate { year: number, month: number, - date: number + date: number, + onClick?: any, + eventCSS?:string } // Each grid item of a calendar @@ -270,4 +302,6 @@ interface dateObj { isToday?: boolean, isSelect?: boolean, hasEvent?: boolean, + onClick?: any, + eventCSS?: string, }