@smartsoft001/angular 1.1.812 → 1.1.813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/services/calendar/calendar.service.mjs +6 -7
- package/fesm2015/smartsoft001-angular.mjs +15 -16
- package/fesm2015/smartsoft001-angular.mjs.map +1 -1
- package/fesm2020/smartsoft001-angular.mjs +15 -16
- package/fesm2020/smartsoft001-angular.mjs.map +1 -1
- package/lib/services/calendar/calendar.service.d.ts +2 -2
- package/package.json +5 -5
|
@@ -57,6 +57,7 @@ import { MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS, MomentDateModule }
|
|
|
57
57
|
import * as i6 from '@angular/cdk/table';
|
|
58
58
|
import { CdkTableModule } from '@angular/cdk/table';
|
|
59
59
|
import * as moment from 'moment';
|
|
60
|
+
import moment__default from 'moment';
|
|
60
61
|
import * as i5$2 from '@angular/cdk/overlay';
|
|
61
62
|
import * as i1$5 from '@ngrx/effects';
|
|
62
63
|
import { createEffect, EffectsModule } from '@ngrx/effects';
|
|
@@ -3081,8 +3082,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImpor
|
|
|
3081
3082
|
|
|
3082
3083
|
class CalendarService {
|
|
3083
3084
|
constructor() {
|
|
3085
|
+
this.setState = (nextState) => {
|
|
3086
|
+
this.state = { ...this.state, ...nextState };
|
|
3087
|
+
};
|
|
3084
3088
|
this.state = {
|
|
3085
|
-
date:
|
|
3089
|
+
date: moment__default().add(2, 'year'),
|
|
3086
3090
|
calendar: [
|
|
3087
3091
|
{
|
|
3088
3092
|
dates: null,
|
|
@@ -3092,11 +3096,6 @@ class CalendarService {
|
|
|
3092
3096
|
}
|
|
3093
3097
|
]
|
|
3094
3098
|
};
|
|
3095
|
-
this.setState = (nextState) => {
|
|
3096
|
-
this.state = { ...this.state, ...nextState };
|
|
3097
|
-
};
|
|
3098
|
-
//this service is a singleton therefore its constructor will only
|
|
3099
|
-
//be called once during the application life cycle
|
|
3100
3099
|
this.initCalendar();
|
|
3101
3100
|
}
|
|
3102
3101
|
getCalendar() {
|
|
@@ -3104,7 +3103,7 @@ class CalendarService {
|
|
|
3104
3103
|
}
|
|
3105
3104
|
generatePrevMonths() {
|
|
3106
3105
|
const calendar = this.state.calendar;
|
|
3107
|
-
let date =
|
|
3106
|
+
let date = moment__default(calendar[0].year + '-' + calendar[0].number + '-01');
|
|
3108
3107
|
const dateYearAgo = date.clone().subtract(1, 'year');
|
|
3109
3108
|
while (date.isSameOrAfter(dateYearAgo)) {
|
|
3110
3109
|
date = date.clone().subtract(1, 'month');
|
|
@@ -3114,7 +3113,7 @@ class CalendarService {
|
|
|
3114
3113
|
generateNextMonths() {
|
|
3115
3114
|
const calendar = this.state.calendar;
|
|
3116
3115
|
const dateString = calendar[calendar.length - 1].year + '-' + calendar[calendar.length - 1].number + '-01';
|
|
3117
|
-
let date =
|
|
3116
|
+
let date = moment__default(dateString);
|
|
3118
3117
|
const dateYearNext = date.clone().add(1, 'year');
|
|
3119
3118
|
while (date.isSameOrBefore(dateYearNext)) {
|
|
3120
3119
|
date = date.clone().add(1, 'month');
|
|
@@ -3125,12 +3124,12 @@ class CalendarService {
|
|
|
3125
3124
|
const { date } = this.state;
|
|
3126
3125
|
const firstMonth = this.generateMonth(date);
|
|
3127
3126
|
const calendar = [firstMonth];
|
|
3128
|
-
const currentDate =
|
|
3127
|
+
const currentDate = moment__default().clone();
|
|
3129
3128
|
const dateYearAgo = currentDate.clone().subtract(2, 'year');
|
|
3130
3129
|
while (date.isSameOrAfter(dateYearAgo)) { // creating one year calendar
|
|
3131
3130
|
calendar.unshift(this.previousMonth());
|
|
3132
3131
|
}
|
|
3133
|
-
this.state.date =
|
|
3132
|
+
this.state.date = moment__default();
|
|
3134
3133
|
const currentMonthIndex = calendar.length - 13;
|
|
3135
3134
|
calendar[currentMonthIndex].dates = calendar[currentMonthIndex].dates.filter(this.filterFutureDates);
|
|
3136
3135
|
this.setState({ calendar: calendar });
|
|
@@ -3146,13 +3145,13 @@ class CalendarService {
|
|
|
3146
3145
|
if (!date) {
|
|
3147
3146
|
return true;
|
|
3148
3147
|
}
|
|
3149
|
-
return date.isSameOrBefore(
|
|
3148
|
+
return date.isSameOrBefore(moment__default());
|
|
3150
3149
|
}
|
|
3151
3150
|
generateMonth(date) {
|
|
3152
|
-
const firstDay =
|
|
3153
|
-
const monthName =
|
|
3154
|
-
const year =
|
|
3155
|
-
const number =
|
|
3151
|
+
const firstDay = moment__default(date).startOf('month');
|
|
3152
|
+
const monthName = moment__default(date).format('MMMM');
|
|
3153
|
+
const year = moment__default(date).format('YYYY');
|
|
3154
|
+
const number = moment__default(date).format('MM');
|
|
3156
3155
|
const monthLength = date.daysInMonth();
|
|
3157
3156
|
const totalDatesInMonth = this.generateMonthDates(firstDay, monthLength);
|
|
3158
3157
|
const emptyCellsBeforeFirstDay = Array(firstDay.weekday()).fill(null);
|
|
@@ -3165,7 +3164,7 @@ class CalendarService {
|
|
|
3165
3164
|
};
|
|
3166
3165
|
}
|
|
3167
3166
|
generateMonthDates(firstDay, length) {
|
|
3168
|
-
return Array(length).fill(null).map((v, i) =>
|
|
3167
|
+
return Array(length).fill(null).map((v, i) => moment__default(firstDay).add(i, 'day'));
|
|
3169
3168
|
}
|
|
3170
3169
|
}
|
|
3171
3170
|
/** @nocollapse */ /** @nocollapse */ CalendarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CalendarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|