diff --git a/src/addon/calendar/calendar.module.ts b/src/addon/calendar/calendar.module.ts new file mode 100644 index 000000000..38c4411d0 --- /dev/null +++ b/src/addon/calendar/calendar.module.ts @@ -0,0 +1,34 @@ +// (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. + +import { NgModule } from '@angular/core'; +import { AddonCalendarProvider } from './providers/calendar'; +import { AddonCalendarMainMenuHandler } from './providers/handlers'; +import { CoreMainMenuDelegate } from '../../core/mainmenu/providers/delegate'; + +@NgModule({ + declarations: [ + ], + imports: [ + ], + providers: [ + AddonCalendarProvider, + AddonCalendarMainMenuHandler + ] +}) +export class AddonCalendarModule { + constructor(mainMenuDelegate: CoreMainMenuDelegate, calendarHandler: AddonCalendarMainMenuHandler) { + mainMenuDelegate.registerHandler(calendarHandler); + } +} \ No newline at end of file diff --git a/src/addon/calendar/lang/en.json b/src/addon/calendar/lang/en.json new file mode 100644 index 000000000..474af9c02 --- /dev/null +++ b/src/addon/calendar/lang/en.json @@ -0,0 +1,4 @@ +{ + "calendar": "Calendar", + "calendarevents": "Calendar events" +} \ No newline at end of file diff --git a/src/addon/calendar/pages/list/list.html b/src/addon/calendar/pages/list/list.html new file mode 100644 index 000000000..6b26736f8 --- /dev/null +++ b/src/addon/calendar/pages/list/list.html @@ -0,0 +1,7 @@ + + + {{ 'addon.calendar.calendarevents' | translate }} + + + + diff --git a/src/addon/calendar/pages/list/list.module.ts b/src/addon/calendar/pages/list/list.module.ts new file mode 100644 index 000000000..44505a53f --- /dev/null +++ b/src/addon/calendar/pages/list/list.module.ts @@ -0,0 +1,29 @@ +// (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. + +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { AddonCalendarListPage } from './list'; + +@NgModule({ + declarations: [ + AddonCalendarListPage, + ], + imports: [ + IonicPageModule.forChild(AddonCalendarListPage), + TranslateModule.forChild() + ], +}) +export class AddonCalendarListPagePageModule {} diff --git a/src/addon/calendar/pages/list/list.scss b/src/addon/calendar/pages/list/list.scss new file mode 100644 index 000000000..345d0d21c --- /dev/null +++ b/src/addon/calendar/pages/list/list.scss @@ -0,0 +1,3 @@ +page-addon-calendar-list { + +} \ No newline at end of file diff --git a/src/addon/calendar/pages/list/list.ts b/src/addon/calendar/pages/list/list.ts new file mode 100644 index 000000000..2b6bec034 --- /dev/null +++ b/src/addon/calendar/pages/list/list.ts @@ -0,0 +1,44 @@ +// (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. + +import { Component, OnDestroy } from '@angular/core'; +import { IonicPage } from 'ionic-angular'; +//import { AddonCalendarProvider } from '../../providers/calendar'; + +/** + * Page that displays the list of courses the user is enrolled in. + */ +@IonicPage() +@Component({ + selector: 'page-addon-calendar-list', + templateUrl: 'list.html', +}) +export class AddonCalendarListPage implements OnDestroy { + eventsLoaded = false; + + constructor() {} + + /** + * View loaded. + */ + ionViewDidLoad() { + + } + + /** + * Page destroyed. + */ + ngOnDestroy() { + } +} \ No newline at end of file diff --git a/src/addon/calendar/providers/calendar.ts b/src/addon/calendar/providers/calendar.ts new file mode 100644 index 000000000..291232b9c --- /dev/null +++ b/src/addon/calendar/providers/calendar.ts @@ -0,0 +1,42 @@ +// (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. + +import { Injectable } from '@angular/core'; +import { CoreLoggerProvider } from '../../../providers/logger'; +import { CoreSitesProvider } from '../../../providers/sites'; +import { CoreSite } from '../../../classes/site'; + +/** + * Service that provides some features regarding lists of courses and categories. + */ +@Injectable() +export class AddonCalendarProvider { + protected logger; + + constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider) { + this.logger = logger.getInstance('AddonCalendarProvider'); + } + + /** + * Check if Calendar is disabled in a certain site. + * + * @param {CoreSite} [site] Site. If not defined, use current site. + * @return {boolean} Whether it's disabled. + */ + isCalendarDisabledInSite(site?: CoreSite) : boolean { + site = site || this.sitesProvider.getCurrentSite(); + return site.isFeatureDisabled('$mmSideMenuDelegate_mmaCalendar'); + } + +} diff --git a/src/addon/calendar/providers/handlers.ts b/src/addon/calendar/providers/handlers.ts new file mode 100644 index 000000000..c4d71c6c2 --- /dev/null +++ b/src/addon/calendar/providers/handlers.ts @@ -0,0 +1,52 @@ +// (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. + +import { Injectable } from '@angular/core'; +import { AddonCalendarProvider } from './calendar'; +import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../../../core/mainmenu/providers/delegate'; + +/** + * Handler to inject an option into main menu. + */ +@Injectable() +export class AddonCalendarMainMenuHandler implements CoreMainMenuHandler { + name = 'mmaCalendar'; + priority = 400; + + constructor(private calendarProvider: AddonCalendarProvider) {} + + /** + * Check if the handler is enabled on a site level. + * + * @return {boolean} Whether or not the handler is enabled on a site level. + */ + isEnabled(): boolean|Promise { + let isDisabled = this.calendarProvider.isCalendarDisabledInSite(); + return !isDisabled; + } + + /** + * Returns the data needed to render the handler. + * + * @return {CoreMainMenuHandlerData} Data needed to render the handler. + */ + getDisplayData(): CoreMainMenuHandlerData { + return { + icon: 'calendar', + title: 'addon.calendar.calendar', + page: 'AddonCalendarListPage', + class: 'mma-calendar-handler' + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 20b958fd6..807ed7af9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -55,7 +55,7 @@ import { CoreMainMenuModule } from '../core/mainmenu/mainmenu.module'; import { CoreCoursesModule } from '../core/courses/courses.module'; import { CoreFileUploaderModule } from '../core/fileuploader/fileuploader.module'; import { CoreSharedFilesModule } from '../core/sharedfiles/sharedfiles.module'; - +import { AddonCalendarModule } from '../addon/calendar/calendar.module'; // For translate loader. AoT requires an exported function for factories. export function createTranslateLoader(http: HttpClient) { @@ -86,7 +86,8 @@ export function createTranslateLoader(http: HttpClient) { CoreCoursesModule, CoreFileUploaderModule, CoreSharedFilesModule, - CoreComponentsModule + CoreComponentsModule, + AddonCalendarModule ], bootstrap: [IonicApp], entryComponents: [