+
+
+
+
+
+ {{ 'addon.mod_glossary.errorloadingentry' | translate }}
+
+
+
+
diff --git a/src/addon/mod/glossary/pages/entry/entry.module.ts b/src/addon/mod/glossary/pages/entry/entry.module.ts
new file mode 100644
index 000000000..83b3642cf
--- /dev/null
+++ b/src/addon/mod/glossary/pages/entry/entry.module.ts
@@ -0,0 +1,35 @@
+// (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 { CoreComponentsModule } from '@components/components.module';
+import { CoreDirectivesModule } from '@directives/directives.module';
+import { CorePipesModule } from '@pipes/pipes.module';
+import { AddonModGlossaryEntryPage } from './entry';
+
+@NgModule({
+ declarations: [
+ AddonModGlossaryEntryPage,
+ ],
+ imports: [
+ CoreComponentsModule,
+ CoreDirectivesModule,
+ CorePipesModule,
+ IonicPageModule.forChild(AddonModGlossaryEntryPage),
+ TranslateModule.forChild()
+ ],
+})
+export class AddonModForumDiscussionPageModule {}
diff --git a/src/addon/mod/glossary/pages/entry/entry.ts b/src/addon/mod/glossary/pages/entry/entry.ts
new file mode 100644
index 000000000..f6aa7df41
--- /dev/null
+++ b/src/addon/mod/glossary/pages/entry/entry.ts
@@ -0,0 +1,110 @@
+// (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 } from '@angular/core';
+import { IonicPage, NavParams } from 'ionic-angular';
+import { CoreDomUtilsProvider } from '@providers/utils/dom';
+import { AddonModGlossaryProvider } from '../../providers/glossary';
+
+/**
+ * Page that displays a glossary entry.
+ */
+@IonicPage({ segment: 'addon-mod-glossary-entry' })
+@Component({
+ selector: 'page-addon-mod-glossary-entry',
+ templateUrl: 'entry.html',
+})
+export class AddonModGlossaryEntryPage {
+ component = AddonModGlossaryProvider.COMPONENT;
+ componentId: number;
+ entry: any;
+ loaded = false;
+ showAuthor = false;
+ showDate = false;
+
+ protected courseId: number;
+ protected entryId: number;
+
+ constructor(navParams: NavParams,
+ private domUtils: CoreDomUtilsProvider,
+ private glossaryProvider: AddonModGlossaryProvider) {
+ this.courseId = navParams.get('courseId');
+ this.entryId = navParams.get('entryId');
+ }
+
+ /**
+ * View loaded.
+ */
+ ionViewDidLoad(): void {
+ this.fetchEntry().then(() => {
+ this.glossaryProvider.logEntryView(this.entry.id);
+ }).finally(() => {
+ this.loaded = true;
+ });
+ }
+
+ /**
+ * Refresh the data.
+ *
+ * @param {any} [refresher] Refresher.
+ * @return {Promise} Promise resolved when done.
+ */
+ doRefresh(refresher?: any): Promise {
+ return this.glossaryProvider.invalidateEntry(this.entry.id).catch(() => {
+ // Ignore errors.
+ }).then(() => {
+ return this.fetchEntry(true);
+ }).finally(() => {
+ refresher && refresher.complete();
+ });
+ }
+
+ /**
+ * Convenience function to get the glossary entry.
+ *
+ * @param {boolean} [refresh] Whether we're refreshing data.
+ * @return {Promise} Promise resolved when done.
+ */
+ protected fetchEntry(refresh?: boolean): Promise {
+ return this.glossaryProvider.getEntry(this.entryId).then((result) => {
+ this.entry = result;
+
+ if (!refresh) {
+ // Load the glossary.
+ return this.glossaryProvider.getGlossaryById(this.courseId, this.entry.glossaryid).then((glossary) => {
+ this.componentId = glossary.coursemodule;
+
+ switch (glossary.displayformat) {
+ case 'fullwithauthor':
+ case 'encyclopedia':
+ this.showAuthor = true;
+ this.showDate = true;
+ break;
+ case 'fullwithoutauthor':
+ this.showAuthor = false;
+ this.showDate = true;
+ break;
+ default: // Default, and faq, simple, entrylist, continuous.
+ this.showAuthor = false;
+ this.showDate = false;
+ }
+ });
+ }
+ }).catch((error) => {
+ this.domUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingentry', true);
+
+ return Promise.reject(null);
+ });
+ }
+}
diff --git a/src/addon/mod/glossary/pages/index/index.html b/src/addon/mod/glossary/pages/index/index.html
new file mode 100644
index 000000000..02c599875
--- /dev/null
+++ b/src/addon/mod/glossary/pages/index/index.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/addon/mod/glossary/pages/index/index.module.ts b/src/addon/mod/glossary/pages/index/index.module.ts
new file mode 100644
index 000000000..415f45272
--- /dev/null
+++ b/src/addon/mod/glossary/pages/index/index.module.ts
@@ -0,0 +1,33 @@
+// (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 { CoreDirectivesModule } from '@directives/directives.module';
+import { AddonModGlossaryComponentsModule } from '../../components/components.module';
+import { AddonModGlossaryIndexPage } from './index';
+
+@NgModule({
+ declarations: [
+ AddonModGlossaryIndexPage,
+ ],
+ imports: [
+ CoreDirectivesModule,
+ AddonModGlossaryComponentsModule,
+ IonicPageModule.forChild(AddonModGlossaryIndexPage),
+ TranslateModule.forChild()
+ ],
+})
+export class AddonModGlossaryIndexPageModule {}
diff --git a/src/addon/mod/glossary/pages/index/index.ts b/src/addon/mod/glossary/pages/index/index.ts
new file mode 100644
index 000000000..a812235fe
--- /dev/null
+++ b/src/addon/mod/glossary/pages/index/index.ts
@@ -0,0 +1,48 @@
+// (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, ViewChild } from '@angular/core';
+import { IonicPage, NavParams } from 'ionic-angular';
+import { AddonModGlossaryIndexComponent } from '../../components/index/index';
+
+/**
+ * Page that displays a glossary.
+ */
+@IonicPage({ segment: 'addon-mod-glossary-index' })
+@Component({
+ selector: 'page-addon-mod-glossary-index',
+ templateUrl: 'index.html',
+})
+export class AddonModGlossaryIndexPage {
+ @ViewChild(AddonModGlossaryIndexComponent) glossaryComponent: AddonModGlossaryIndexComponent;
+
+ title: string;
+ module: any;
+ courseId: number;
+
+ constructor(navParams: NavParams) {
+ this.module = navParams.get('module') || {};
+ this.courseId = navParams.get('courseId');
+ this.title = this.module.name;
+ }
+
+ /**
+ * Update some data based on the glossary instance.
+ *
+ * @param {any} glossary Glossary instance.
+ */
+ updateData(glossary: any): void {
+ this.title = glossary.name || this.title;
+ }
+}