diff --git a/scripts/langindex.json b/scripts/langindex.json index 6103e27f7..75ad66948 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -96,6 +96,7 @@ "addon.calendar.errorloadevents": "local_moodlemobileapp", "addon.calendar.eventduration": "calendar", "addon.calendar.eventendtime": "calendar", + "addon.calendar.eventkind": "calendar", "addon.calendar.eventname": "calendar", "addon.calendar.eventstarttime": "calendar", "addon.calendar.eventtype": "calendar", @@ -106,6 +107,9 @@ "addon.calendar.noevents": "local_moodlemobileapp", "addon.calendar.nopermissiontoupdatecalendar": "error", "addon.calendar.reminders": "local_moodlemobileapp", + "addon.calendar.repeatedevents": "calendar", + "addon.calendar.repeateditall": "calendar", + "addon.calendar.repeateditthis": "calendar", "addon.calendar.repeatevent": "calendar", "addon.calendar.repeatweeksl": "calendar", "addon.calendar.setnewreminder": "local_moodlemobileapp", diff --git a/src/addon/calendar/lang/en.json b/src/addon/calendar/lang/en.json index a7a531836..d5cf329a2 100644 --- a/src/addon/calendar/lang/en.json +++ b/src/addon/calendar/lang/en.json @@ -12,6 +12,7 @@ "errorloadevents": "Error loading events.", "eventduration": "Duration", "eventendtime": "End time", + "eventkind": "Type of event", "eventname": "Event title", "eventstarttime": "Start time", "eventtype": "Event type", @@ -22,6 +23,9 @@ "noevents": "There are no events", "nopermissiontoupdatecalendar": "Sorry, but you do not have permission to update the calendar event", "reminders": "Reminders", + "repeatedevents": "Repeated events", + "repeateditall": "Also apply changes to the other {{$a}} events in this repeat series", + "repeateditthis": "Apply changes to this event only", "repeatevent": "Repeat this event", "repeatweeksl": "Repeat weekly, creating altogether", "setnewreminder": "Set a new reminder", diff --git a/src/addon/calendar/pages/edit-event/edit-event.html b/src/addon/calendar/pages/edit-event/edit-event.html index 7330b752e..f57a84915 100644 --- a/src/addon/calendar/pages/edit-event/edit-event.html +++ b/src/addon/calendar/pages/edit-event/edit-event.html @@ -26,7 +26,7 @@ -

{{ 'addon.calendar.eventtype' | translate }}

+

{{ 'addon.calendar.eventkind' | translate }}

{{ type.name | translate }} @@ -96,8 +96,8 @@
-
-

{{ 'addon.calendar.eventduration' | translate }}

+
+

{{ 'addon.calendar.eventduration' | translate }}

{{ 'addon.calendar.durationnone' | translate }} @@ -118,15 +118,30 @@
- - -

{{ 'addon.calendar.repeatevent' | translate }}

- -
- -

{{ 'addon.calendar.repeatweeksl' | translate }}

- -
+ + + +

{{ 'addon.calendar.repeatevent' | translate }}

+ +
+ +

{{ 'addon.calendar.repeatweeksl' | translate }}

+ +
+
+ + +
+

{{ 'addon.calendar.repeatedevents' | translate }}

+ + {{ 'addon.calendar.repeateditall' | translate:{$a: event.othereventscount} }} + + + + {{ 'addon.calendar.repeateditthis' | translate }} + + +
diff --git a/src/addon/calendar/pages/edit-event/edit-event.scss b/src/addon/calendar/pages/edit-event/edit-event.scss index 3c43c635e..6426ce3f1 100644 --- a/src/addon/calendar/pages/edit-event/edit-event.scss +++ b/src/addon/calendar/pages/edit-event/edit-event.scss @@ -1,5 +1,5 @@ ion-app.app-root page-addon-calendar-edit-event { - .addon-calendar-duration-container ion-item:not(.addon-calendar-duration-title) { + .addon-calendar-radio-container ion-item:not(.addon-calendar-radio-title) { &.item-ios { @include padding-horizontal($item-ios-padding-start * 2, null); diff --git a/src/addon/calendar/pages/edit-event/edit-event.ts b/src/addon/calendar/pages/edit-event/edit-event.ts index 0017a81ea..97049a034 100644 --- a/src/addon/calendar/pages/edit-event/edit-event.ts +++ b/src/addon/calendar/pages/edit-event/edit-event.ts @@ -57,6 +57,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { courseGroupSet = false; advanced = false; errors: any; + event: any; // The event object (when editing an event). // Form variables. eventForm: FormGroup; @@ -72,6 +73,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { protected showAll: boolean; protected isDestroyed = false; protected error = false; + protected gotEventData = false; constructor(navParams: NavParams, private navCtrl: NavController, @@ -126,6 +128,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { this.eventForm.addControl('timedurationminutes', this.fb.control('')); this.eventForm.addControl('repeat', this.fb.control(false)); this.eventForm.addControl('repeats', this.fb.control('1')); + this.eventForm.addControl('repeateditall', this.fb.control(1)); } /** @@ -164,7 +167,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { return Promise.reject(this.translate.instant('addon.calendar.nopermissiontoupdatecalendar')); } - if (this.eventId && !refresh) { + if (this.eventId && !this.gotEventData) { // Editing an event, get the event data. Wait for sync first. promises.push(this.calendarSync.waitForSync(AddonCalendarSyncProvider.SYNC_ID).then(() => { @@ -173,20 +176,35 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { this.syncProvider.blockOperation(AddonCalendarProvider.COMPONENT, this.eventId); } + const promises = []; + // Get the event offline data if there's any. - return this.calendarOffline.getEvent(this.eventId).then((event) => { + promises.push(this.calendarOffline.getEvent(this.eventId).then((event) => { this.hasOffline = true; return event; }).catch(() => { // No offline data. this.hasOffline = false; + })); + + if (this.eventId > 0) { + // It's an online event. get its data from server. + promises.push(this.calendarProvider.getEventById(this.eventId).then((event) => { + this.event = event; + if (event && event.repeatid) { + event.othereventscount = event.eventcount ? event.eventcount - 1 : ''; + } + + return event; + })); + } + + return Promise.all(promises).then((result) => { + this.gotEventData = true; + + const event = result[0] || result[1]; // Use offline data first. - if (this.eventId > 0) { - // It's an online event. get its data from server. - return this.calendarProvider.getEventById(this.eventId); - } - }).then((event) => { if (event) { // Load the data in the form. this.eventForm.controls.name.setValue(event.name); @@ -204,6 +222,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { this.eventForm.controls.timedurationminutes.setValue(event.timedurationminutes || ''); this.eventForm.controls.repeat.setValue(!!event.repeat); this.eventForm.controls.repeats.setValue(event.repeats || '1'); + this.eventForm.controls.repeateditall.setValue(event.repeateditall || 1); } }); })); @@ -394,6 +413,11 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { data.repeats = formData.repeats; } + if (this.event && this.event.repeatid) { + data.repeatid = this.event.repeatid; + data.repeateditall = formData.repeateditall; + } + // Send the data. const modal = this.domUtils.showModalLoading('core.sending', true); diff --git a/src/addon/calendar/providers/calendar-offline.ts b/src/addon/calendar/providers/calendar-offline.ts index 833ca7d4b..a929113bc 100644 --- a/src/addon/calendar/providers/calendar-offline.ts +++ b/src/addon/calendar/providers/calendar-offline.ts @@ -94,6 +94,14 @@ export class AddonCalendarOfflineProvider { name: 'repeats', type: 'TEXT', }, + { + name: 'repeatid', + type: 'INTEGER', + }, + { + name: 'repeateditall', + type: 'INTEGER', + }, { name: 'userid', type: 'INTEGER', @@ -202,6 +210,8 @@ export class AddonCalendarOfflineProvider { timedurationminutes: data.timedurationminutes, repeat: data.repeat ? 1 : 0, repeats: data.repeats, + repeatid: data.repeatid, + repeateditall: data.repeateditall ? 1 : 0, timecreated: timeCreated, userid: site.getUserId() }; diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index e8a1c8227..63974e503 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -96,6 +96,7 @@ "addon.calendar.errorloadevents": "Error loading events.", "addon.calendar.eventduration": "Duration", "addon.calendar.eventendtime": "End time", + "addon.calendar.eventkind": "Type of event", "addon.calendar.eventname": "Event title", "addon.calendar.eventstarttime": "Start time", "addon.calendar.eventtype": "Event type", @@ -106,6 +107,9 @@ "addon.calendar.noevents": "There are no events", "addon.calendar.nopermissiontoupdatecalendar": "Sorry, but you do not have permission to update the calendar event", "addon.calendar.reminders": "Reminders", + "addon.calendar.repeatedevents": "Repeated events", + "addon.calendar.repeateditall": "Also apply changes to the other {{$a}} events in this repeat series", + "addon.calendar.repeateditthis": "Apply changes to this event only", "addon.calendar.repeatevent": "Repeat this event", "addon.calendar.repeatweeksl": "Repeat weekly, creating altogether", "addon.calendar.setnewreminder": "Set a new reminder",