Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- generateHeadings(): AsyncSubject<CalendarHeading[]> {
- let subjectGenerateHeadings = new AsyncSubject<CalendarHeading[]>();
- /* Calculate month headings */
- let i;
- let currentMonth = this.month;
- // 3 Headings : 93 days
- for (i = 0; i < 3; i++) {
- let heading: CalendarHeading = {
- clickViewType: this.viewType = 'q',
- title: this.getMonthName(currentMonth),
- }
- currentMonth++;
- this.calendarHeadings.push(heading);
- // console.log(this.monthlyHeadings);
- }
- /* Calculate week headings */
- let weekCount = this.weekCount(this.year, this.month);
- this.weekNo = SabreCommon.getISOWeekNumber();
- for (i = 0; i < this.weekCount(this.year, this.month); i++) {
- // 1 heading : 4-5 Weeks
- var mthHeading: CalendarHeading = {
- clickViewType: this.viewType = 'm',
- weekNumber: this.weekNo,
- daysInMonth: this.monthLength,
- numberOfWeeks: this.weekCount(this.year, this.month),
- }
- this.weekNo++
- this.calendarHeadings.push(mthHeading);
- // console.log(this.weeklyHeadings);
- }
- /* Calculate week days */
- let daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
- for (i = 1; i < 7; i++) {
- let wklHeading: CalendarHeading = {
- dayOfWeek: this.dayName,
- clickViewType: this.viewType = 'w'
- }
- switch (this.day) {
- case 0:
- this.dayName = 'Monday';
- break;
- case 1:
- this.dayName = 'Tuesday';
- break;
- case 2:
- this.dayName = 'Wednesday';
- break;
- case 3:
- this.dayName = 'Thursday';
- break;
- case 4:
- this.dayName = 'Friday';
- break;
- case 5:
- this.dayName = 'Saturday';
- case 6:
- this.dayName = 'Sunday';
- break;
- }
- this.day++;
- this.calendarHeadings.push(wklHeading);
- // console.log(this.dailyHeadings);
- }
- // this.calendarHeadings.map(x => {
- // switch (x.clickViewType) {
- // case 'q':
- // this.calendarHeadings = this.monthlyHeadings;
- // break;
- // case 'm':
- // this.calendarHeadings = this.weeklyHeadings;
- // case 'w':
- // this.calendarHeadings = this.dailyHeadings;
- // }
- // })
- subjectGenerateHeadings.next(this.calendarHeadings);
- console.log(this.calendarHeadings);
- subjectGenerateHeadings.complete;
- return subjectGenerateHeadings;
- }
Add Comment
Please, Sign In to add comment