MOBILE-2308 calendar: Change static declarations and minor
parent
2cdeda17ee
commit
8794a06b9f
|
@ -1,3 +1,3 @@
|
|||
page-addon-calendar-list {
|
||||
page-addon-calendar-event {
|
||||
|
||||
}
|
|
@ -86,8 +86,6 @@ export class AddonCalendarEventPage {
|
|||
|
||||
/**
|
||||
* Fetches the event and updates the view.
|
||||
*
|
||||
* @param {boolean} refresh Empty events array first.
|
||||
*/
|
||||
fetchEvent() {
|
||||
return this.calendarProvider.getEvent(this.eventId).then((event) => {
|
||||
|
|
|
@ -103,7 +103,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Fetch all the data required for the view.
|
||||
*
|
||||
* @param {boolean} refresh Empty events array first.
|
||||
* @param {boolean} [refresh] Empty events array first.
|
||||
*/
|
||||
fetchData(refresh = false) {
|
||||
this.daysLoaded = 0;
|
||||
|
@ -121,7 +121,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Fetches the events and updates the view.
|
||||
*
|
||||
* @param {boolean} refresh Empty events array first.
|
||||
* @param {boolean} [refresh] Empty events array first.
|
||||
*/
|
||||
fetchEvents(refresh = false) {
|
||||
return this.calendarProvider.getEventsList(this.daysLoaded, AddonCalendarProvider.DAYS_INTERVAL).then((events) => {
|
||||
|
@ -144,7 +144,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
return a.timestart - b.timestart;
|
||||
});
|
||||
|
||||
events.forEach(this.calendarHelper.formatEventData);
|
||||
events.forEach(this.calendarHelper.formatEventData.bind(this.calendarHelper));
|
||||
this.getCategories = this.shouldLoadCategories(events);
|
||||
|
||||
if (refresh) {
|
||||
|
@ -253,7 +253,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
this.categoriesRetrieved = true;
|
||||
this.categories = {};
|
||||
// Index categories by ID.
|
||||
cats.forEach(function(category) {
|
||||
cats.forEach((category) => {
|
||||
this.categories[category.id] = category;
|
||||
});
|
||||
}).catch(() => {
|
||||
|
@ -291,7 +291,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
openCourseFilter(event: MouseEvent) : void {
|
||||
let popover = this.popoverCtrl.create(CoreCoursePickerMenuPopoverComponent, {courses: this.courses,
|
||||
courseId: this.filter.course.id});
|
||||
popover.onDidDismiss(course => {
|
||||
popover.onDidDismiss((course) => {
|
||||
if (course) {
|
||||
this.filter.course = course;
|
||||
this.content.scrollToTop();
|
||||
|
@ -322,6 +322,6 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
* Page destroyed.
|
||||
*/
|
||||
ngOnDestroy() {
|
||||
this.obsDefaultTimeChange && this.obsDefaultTimeChange.off && this.obsDefaultTimeChange.off();
|
||||
this.obsDefaultTimeChange && this.obsDefaultTimeChange.off();
|
||||
}
|
||||
}
|
|
@ -31,14 +31,15 @@ export class AddonCalendarProvider {
|
|||
public static DAYS_INTERVAL = 30;
|
||||
public static COMPONENT = 'AddonCalendarEvents';
|
||||
public static DEFAULT_NOTIFICATION_TIME_CHANGED = 'AddonCalendarDefaultNotificationTimeChangedEvent';
|
||||
protected static DEFAULT_NOTIFICATION_TIME_SETTING = 'mmaCalendarDefaultNotifTime';
|
||||
protected static DEFAULT_NOTIFICATION_TIME = 60;
|
||||
protected DEFAULT_NOTIFICATION_TIME_SETTING = 'mmaCalendarDefaultNotifTime';
|
||||
protected ROOT_CACHE_KEY = 'mmaCalendar:';
|
||||
protected DEFAULT_NOTIFICATION_TIME = 60;
|
||||
|
||||
// Variables for database.
|
||||
protected static EVENTS_TABLE = 'calendar_events'; // Queue of files to download.
|
||||
protected static tablesSchema = [
|
||||
protected EVENTS_TABLE = 'calendar_events';
|
||||
protected tablesSchema = [
|
||||
{
|
||||
name: AddonCalendarProvider.EVENTS_TABLE,
|
||||
name: this.EVENTS_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'id',
|
||||
|
@ -108,7 +109,7 @@ export class AddonCalendarProvider {
|
|||
private coursesProvider: CoreCoursesProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private localNotificationsProvider: CoreLocalNotificationsProvider, private configProvider: CoreConfigProvider) {
|
||||
this.logger = logger.getInstance('AddonCalendarProvider');
|
||||
this.sitesProvider.createTablesFromSchema(AddonCalendarProvider.tablesSchema);
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,8 +121,8 @@ export class AddonCalendarProvider {
|
|||
getDefaultNotificationTime(siteId?: string) : Promise<number> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
||||
let key = AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME_SETTING + '#' + siteId;
|
||||
return this.configProvider.get(key, AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME);
|
||||
let key = this.DEFAULT_NOTIFICATION_TIME_SETTING + '#' + siteId;
|
||||
return this.configProvider.get(key, this.DEFAULT_NOTIFICATION_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +160,7 @@ export class AddonCalendarProvider {
|
|||
* @return {string} Cache key.
|
||||
*/
|
||||
protected getEventCacheKey(id: number): string {
|
||||
return 'mmaCalendar:events:' + id;
|
||||
return this.ROOT_CACHE_KEY + 'events:' + id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +172,7 @@ export class AddonCalendarProvider {
|
|||
*/
|
||||
getEventFromLocalDb(id: number, siteId?: string) : Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().getRecord(AddonCalendarProvider.EVENTS_TABLE, {id: id});
|
||||
return site.getDb().getRecord(this.EVENTS_TABLE, {id: id});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -263,6 +264,15 @@ export class AddonCalendarProvider {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get prefix cache key for events list WS calls.
|
||||
*
|
||||
* @return {string} Prefix Cache key.
|
||||
*/
|
||||
protected getEventsListPrefixCacheKey() : string {
|
||||
return this.ROOT_CACHE_KEY + 'eventslist:';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache key for events list WS calls.
|
||||
*
|
||||
|
@ -271,16 +281,7 @@ export class AddonCalendarProvider {
|
|||
* @return {string} Cache key.
|
||||
*/
|
||||
protected getEventsListCacheKey(daysToStart: number, daysInterval: number) : string {
|
||||
return this.getRootCacheKey() + 'eventslist:' + daysToStart + ':' + daysInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root cache key for the WS calls related to this provider.
|
||||
*
|
||||
* @return {string} Root cache key.
|
||||
*/
|
||||
protected getRootCacheKey() : string {
|
||||
return 'mmaCalendar:';
|
||||
return this.getEventsListPrefixCacheKey() + daysToStart + ':' + daysInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +299,7 @@ export class AddonCalendarProvider {
|
|||
|
||||
promises.push(this.coursesProvider.invalidateUserCourses(siteId));
|
||||
promises.push(this.groupsProvider.invalidateUserGroups(courses, siteId));
|
||||
promises.push(site.invalidateWsCacheForKeyStartingWith(this.getRootCacheKey()));
|
||||
promises.push(site.invalidateWsCacheForKeyStartingWith(this.getEventsListPrefixCacheKey()));
|
||||
return Promise.all(promises);
|
||||
});
|
||||
}
|
||||
|
@ -393,8 +394,8 @@ export class AddonCalendarProvider {
|
|||
let promise = time == -1 ? this.getDefaultNotificationTime(siteId) : Promise.resolve(time);
|
||||
|
||||
return promise.then((time) => {
|
||||
let timeend = (event.timestart + event.timeduration) * 1000;
|
||||
if (timeend <= new Date().getTime()) {
|
||||
let timeEnd = (event.timestart + event.timeduration) * 1000;
|
||||
if (timeEnd <= new Date().getTime()) {
|
||||
// The event has finished already, don't schedule it.
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
@ -455,7 +456,7 @@ export class AddonCalendarProvider {
|
|||
setDefaultNotificationTime(time: number, siteId?: string) : Promise<any[]> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
||||
let key = AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME_SETTING + '#' + siteId;
|
||||
let key = this.DEFAULT_NOTIFICATION_TIME_SETTING + '#' + siteId;
|
||||
return this.configProvider.set(key, time);
|
||||
}
|
||||
|
||||
|
@ -496,7 +497,7 @@ export class AddonCalendarProvider {
|
|||
notificationtime: e.notificationtime || -1
|
||||
};
|
||||
|
||||
return db.insertOrUpdateRecord(AddonCalendarProvider.EVENTS_TABLE, eventRecord, {id: eventRecord.id});
|
||||
return db.insertOrUpdateRecord(this.EVENTS_TABLE, eventRecord, {id: eventRecord.id});
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -521,7 +522,7 @@ export class AddonCalendarProvider {
|
|||
|
||||
event.notificationtime = time;
|
||||
|
||||
return site.getDb().insertOrUpdateRecord(AddonCalendarProvider.EVENTS_TABLE, event, {id: event.id}).then(() => {
|
||||
return site.getDb().insertOrUpdateRecord(this.EVENTS_TABLE, event, {id: event.id}).then(() => {
|
||||
return this.scheduleEventNotification(event, time);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../../../core/main
|
|||
*/
|
||||
@Injectable()
|
||||
export class AddonCalendarMainMenuHandler implements CoreMainMenuHandler {
|
||||
name = 'mmaCalendar';
|
||||
name = 'AddonCalendar';
|
||||
priority = 400;
|
||||
|
||||
constructor(private calendarProvider: AddonCalendarProvider) {}
|
||||
|
@ -46,7 +46,7 @@ export class AddonCalendarMainMenuHandler implements CoreMainMenuHandler {
|
|||
icon: 'calendar',
|
||||
title: 'addon.calendar.calendar',
|
||||
page: 'AddonCalendarListPage',
|
||||
class: 'mma-calendar-handler'
|
||||
class: 'addon-calendar-handler'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreSitesProvider } from '../../../providers/sites';
|
|||
export class AddonCalendarHelperProvider {
|
||||
protected logger;
|
||||
|
||||
private static eventicons = {
|
||||
private EVENTICONS = {
|
||||
'course': 'ionic',
|
||||
'group': 'people',
|
||||
'site': 'globe',
|
||||
|
@ -42,7 +42,7 @@ export class AddonCalendarHelperProvider {
|
|||
* @param {any} e Event to format.
|
||||
*/
|
||||
formatEventData(e: any) {
|
||||
e.icon = AddonCalendarHelperProvider.eventicons[e.eventtype] || false;
|
||||
e.icon = this.EVENTICONS[e.eventtype] || false;
|
||||
if (!e.icon) {
|
||||
// @todo: It's a module event.
|
||||
//e.icon = this.courseProvider.getModuleIconSrc(e.modulename);
|
||||
|
|
|
@ -153,16 +153,16 @@ core-format-text[maxHeight], *[core-format-text][maxHeight] {
|
|||
display: none;
|
||||
}
|
||||
|
||||
&:not(.mm-shortened) {
|
||||
&:not(.core-shortened) {
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
&.mm-shortened {
|
||||
&.core-shortened {
|
||||
color: $gray-darker;
|
||||
overflow: hidden;
|
||||
min-height: 50px;
|
||||
|
||||
.mm-show-more {
|
||||
.core-show-more {
|
||||
color: color($colors, dark);
|
||||
text-align: right;
|
||||
font-size: 14px;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code based on https://github.com/martinpritchardelevate/ionic-split-pane-demo
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from 'ionic-angular';
|
||||
import { CoreSplitViewPlaceholderPage } from './placeholder';
|
||||
|
|
|
@ -1,8 +1,21 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code based on https://github.com/martinpritchardelevate/ionic-split-pane-demo
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import {
|
||||
IonicPage,
|
||||
NavController,
|
||||
NavParams } from 'ionic-angular';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
|
||||
@IonicPage({segment: "core-placeholder"})
|
||||
@Component({
|
||||
|
@ -11,6 +24,6 @@ import {
|
|||
})
|
||||
export class CoreSplitViewPlaceholderPage {
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams) { }
|
||||
constructor() { }
|
||||
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ import { CoreSplitViewPlaceholderPage } from './placeholder/placeholder';
|
|||
export class CoreSplitViewComponent implements OnInit {
|
||||
// @todo Mix both panels header buttons
|
||||
|
||||
@ViewChild('detailNav') _detailNav: Nav;
|
||||
@ViewChild('detailNav') detailNav: Nav;
|
||||
@Input() when?: string | boolean = "md"; //
|
||||
protected _isOn: boolean = false;
|
||||
protected isEnabled: boolean = false;
|
||||
protected masterPageName: string = "";
|
||||
protected loadDetailPage: any = false;
|
||||
protected element: HTMLElement; // Current element.
|
||||
|
@ -54,7 +54,7 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
// Empty placeholder for the 'detail' page.
|
||||
detailPage: any = null;
|
||||
|
||||
constructor(private _masterNav: NavController, element: ElementRef) {
|
||||
constructor(private masterNav: NavController, element: ElementRef) {
|
||||
this.element = element.nativeElement;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
*/
|
||||
ngOnInit() {
|
||||
// Get the master page name and set an empty page as a placeholder.
|
||||
this.masterPageName = this._masterNav.getActive().component.name;
|
||||
this.masterPageName = this.masterNav.getActive().component.name;
|
||||
this.emptyDetails();
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
* @return {boolean} If split view is enabled.
|
||||
*/
|
||||
isOn(): boolean {
|
||||
return this._isOn;
|
||||
return this.isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,14 +83,14 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
* @param {any} params Any NavParams you want to pass along to the next view.
|
||||
*/
|
||||
push(page: any, params?: any, element?: HTMLElement) {
|
||||
if (this._isOn) {
|
||||
this._detailNav.setRoot(page, params);
|
||||
if (this.isEnabled) {
|
||||
this.detailNav.setRoot(page, params);
|
||||
} else {
|
||||
this.loadDetailPage = {
|
||||
component: page,
|
||||
data: params
|
||||
};
|
||||
this._masterNav.push(page, params);
|
||||
this.masterNav.push(page, params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
*/
|
||||
emptyDetails() {
|
||||
this.loadDetailPage = false;
|
||||
this._detailNav.setRoot('CoreSplitViewPlaceholderPage');
|
||||
this.detailNav.setRoot('CoreSplitViewPlaceholderPage');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,8 +108,8 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
* @param {Boolean} isOn If it fits both panels at the same time.
|
||||
*/
|
||||
onSplitPaneChanged(isOn) {
|
||||
this._isOn = isOn;
|
||||
if (this._masterNav && this._detailNav) {
|
||||
this.isEnabled = isOn;
|
||||
if (this.masterNav && this.detailNav) {
|
||||
(isOn) ? this.activateSplitView() : this.deactivateSplitView();
|
||||
}
|
||||
}
|
||||
|
@ -118,17 +118,17 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
* Enable the split view, show both panels and do some magical navigation.
|
||||
*/
|
||||
activateSplitView() {
|
||||
let currentView = this._masterNav.getActive(),
|
||||
let currentView = this.masterNav.getActive(),
|
||||
currentPageName = currentView.component.name;
|
||||
if (currentPageName != this.masterPageName) {
|
||||
// CurrentView is a 'Detail' page remove it from the 'master' nav stack.
|
||||
this._masterNav.pop();
|
||||
this.masterNav.pop();
|
||||
|
||||
// and add it to the 'detail' nav stack.
|
||||
this._detailNav.setRoot(currentView.component, currentView.data);
|
||||
this.detailNav.setRoot(currentView.component, currentView.data);
|
||||
} else if (this.loadDetailPage) {
|
||||
// MasterPage is shown, load the last detail page if found.
|
||||
this._detailNav.setRoot(this.loadDetailPage.component, this.loadDetailPage.data);
|
||||
this.detailNav.setRoot(this.loadDetailPage.component, this.loadDetailPage.data);
|
||||
}
|
||||
this.loadDetailPage = false;
|
||||
}
|
||||
|
@ -137,11 +137,11 @@ export class CoreSplitViewComponent implements OnInit {
|
|||
* Disabled the split view, show only one panel and do some magical navigation.
|
||||
*/
|
||||
deactivateSplitView() {
|
||||
let detailView = this._detailNav.getActive(),
|
||||
let detailView = this.detailNav.getActive(),
|
||||
currentPageName = detailView.component.name;
|
||||
if (currentPageName != 'CoreSplitViewPlaceholderPage') {
|
||||
// Current detail view is a 'Detail' page so, not the placeholder page, push it on 'master' nav stack.
|
||||
this._masterNav.push(detailView.component, detailView.data);
|
||||
this.masterNav.push(detailView.component, detailView.data);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import { CoreCoursesMyOverviewProvider } from '../providers/my-overview';
|
|||
*/
|
||||
@Injectable()
|
||||
export class CoreCoursesMainMenuHandler implements CoreMainMenuHandler {
|
||||
name = 'mmCourses';
|
||||
name = 'CoreCourses';
|
||||
priority = 1100;
|
||||
isOverviewEnabled: boolean;
|
||||
|
||||
|
|
Loading…
Reference in New Issue