MOBILE-2877 glossary: Include comments into glossary
parent
33f2abcee1
commit
e6fd969855
|
@ -35,6 +35,9 @@
|
||||||
<ion-item text-wrap *ngIf="entry.approved != 1">
|
<ion-item text-wrap *ngIf="entry.approved != 1">
|
||||||
<p><em>{{ 'addon.mod_glossary.entrypendingapproval' | translate }}</em></p>
|
<p><em>{{ 'addon.mod_glossary.entrypendingapproval' | translate }}</em></p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
<ion-item *ngIf="glossary && glossary.allowcomments && entry && entry.id > 0 && commentsEnabled">
|
||||||
|
<core-comments contextLevel="module" [instanceId]="glossary.coursemodule" component="mod_glossary" [itemId]="entry.id" area="glossary_entry" [courseId]="glossary.courseid"></core-comments>
|
||||||
|
</ion-item>
|
||||||
<core-rating-rate *ngIf="glossary && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="glossary.coursemodule" [itemId]="entry.id" [itemSetId]="0" [courseId]="glossary.courseid" [aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale" [userId]="entry.userid" (onUpdate)="ratingUpdated()"></core-rating-rate>
|
<core-rating-rate *ngIf="glossary && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="glossary.coursemodule" [itemId]="entry.id" [itemSetId]="0" [courseId]="glossary.courseid" [aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale" [userId]="entry.userid" (onUpdate)="ratingUpdated()"></core-rating-rate>
|
||||||
<core-rating-aggregate *ngIf="glossary && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="glossary.coursemodule" [itemId]="entry.id" [courseId]="glossary.courseid" [aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale"></core-rating-aggregate>
|
<core-rating-aggregate *ngIf="glossary && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="glossary.coursemodule" [itemId]="entry.id" [courseId]="glossary.courseid" [aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale"></core-rating-aggregate>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { CoreComponentsModule } from '@components/components.module';
|
import { CoreComponentsModule } from '@components/components.module';
|
||||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||||
import { CorePipesModule } from '@pipes/pipes.module';
|
import { CorePipesModule } from '@pipes/pipes.module';
|
||||||
|
import { CoreCommentsComponentsModule } from '@core/comments/components/components.module';
|
||||||
import { CoreRatingComponentsModule } from '@core/rating/components/components.module';
|
import { CoreRatingComponentsModule } from '@core/rating/components/components.module';
|
||||||
import { CoreTagComponentsModule } from '@core/tag/components/components.module';
|
import { CoreTagComponentsModule } from '@core/tag/components/components.module';
|
||||||
import { AddonModGlossaryEntryPage } from './entry';
|
import { AddonModGlossaryEntryPage } from './entry';
|
||||||
|
@ -32,6 +33,7 @@ import { AddonModGlossaryEntryPage } from './entry';
|
||||||
CorePipesModule,
|
CorePipesModule,
|
||||||
IonicPageModule.forChild(AddonModGlossaryEntryPage),
|
IonicPageModule.forChild(AddonModGlossaryEntryPage),
|
||||||
TranslateModule.forChild(),
|
TranslateModule.forChild(),
|
||||||
|
CoreCommentsComponentsModule,
|
||||||
CoreRatingComponentsModule,
|
CoreRatingComponentsModule,
|
||||||
CoreTagComponentsModule
|
CoreTagComponentsModule
|
||||||
],
|
],
|
||||||
|
|
|
@ -12,11 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { IonicPage, NavParams } from 'ionic-angular';
|
import { IonicPage, NavParams } from 'ionic-angular';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreRatingInfo } from '@core/rating/providers/rating';
|
import { CoreRatingInfo } from '@core/rating/providers/rating';
|
||||||
import { CoreTagProvider } from '@core/tag/providers/tag';
|
import { CoreTagProvider } from '@core/tag/providers/tag';
|
||||||
|
import { CoreCommentsProvider } from '@core/comments/providers/comments';
|
||||||
|
import { CoreCommentsCommentsComponent } from '@core/comments/components/comments/comments';
|
||||||
import { AddonModGlossaryProvider } from '../../providers/glossary';
|
import { AddonModGlossaryProvider } from '../../providers/glossary';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +30,8 @@ import { AddonModGlossaryProvider } from '../../providers/glossary';
|
||||||
templateUrl: 'entry.html',
|
templateUrl: 'entry.html',
|
||||||
})
|
})
|
||||||
export class AddonModGlossaryEntryPage {
|
export class AddonModGlossaryEntryPage {
|
||||||
|
@ViewChild(CoreCommentsCommentsComponent) comments: CoreCommentsCommentsComponent;
|
||||||
|
|
||||||
component = AddonModGlossaryProvider.COMPONENT;
|
component = AddonModGlossaryProvider.COMPONENT;
|
||||||
componentId: number;
|
componentId: number;
|
||||||
entry: any;
|
entry: any;
|
||||||
|
@ -37,23 +41,27 @@ export class AddonModGlossaryEntryPage {
|
||||||
showDate = false;
|
showDate = false;
|
||||||
ratingInfo: CoreRatingInfo;
|
ratingInfo: CoreRatingInfo;
|
||||||
tagsEnabled: boolean;
|
tagsEnabled: boolean;
|
||||||
|
commentsEnabled: boolean;
|
||||||
|
|
||||||
protected courseId: number;
|
protected courseId: number;
|
||||||
protected entryId: number;
|
protected entryId: number;
|
||||||
|
|
||||||
constructor(navParams: NavParams,
|
constructor(navParams: NavParams,
|
||||||
private domUtils: CoreDomUtilsProvider,
|
protected domUtils: CoreDomUtilsProvider,
|
||||||
private glossaryProvider: AddonModGlossaryProvider,
|
protected glossaryProvider: AddonModGlossaryProvider,
|
||||||
private tagProvider: CoreTagProvider) {
|
protected tagProvider: CoreTagProvider,
|
||||||
|
protected commentsProvider: CoreCommentsProvider) {
|
||||||
this.courseId = navParams.get('courseId');
|
this.courseId = navParams.get('courseId');
|
||||||
this.entryId = navParams.get('entryId');
|
this.entryId = navParams.get('entryId');
|
||||||
this.tagsEnabled = this.tagProvider.areTagsAvailableInSite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View loaded.
|
* View loaded.
|
||||||
*/
|
*/
|
||||||
ionViewDidLoad(): void {
|
ionViewDidLoad(): void {
|
||||||
|
this.tagsEnabled = this.tagProvider.areTagsAvailableInSite();
|
||||||
|
this.commentsEnabled = !this.commentsProvider.areCommentsDisabledInSite();
|
||||||
|
|
||||||
this.fetchEntry().then(() => {
|
this.fetchEntry().then(() => {
|
||||||
this.glossaryProvider.logEntryView(this.entry.id, this.componentId, this.glossary.name).catch(() => {
|
this.glossaryProvider.logEntryView(this.entry.id, this.componentId, this.glossary.name).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
|
@ -70,6 +78,14 @@ export class AddonModGlossaryEntryPage {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
doRefresh(refresher?: any): Promise<any> {
|
doRefresh(refresher?: any): Promise<any> {
|
||||||
|
if (this.glossary && this.glossary.allowcomments && this.entry && this.entry.id > 0 && this.commentsEnabled &&
|
||||||
|
this.comments) {
|
||||||
|
// Refresh comments. Don't add it to promises because we don't want the comments fetch to block the entry fetch.
|
||||||
|
this.comments.doRefresh().catch(() => {
|
||||||
|
// Ignore errors.
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return this.glossaryProvider.invalidateEntry(this.entry.id).catch(() => {
|
return this.glossaryProvider.invalidateEntry(this.entry.id).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
|
import { CoreCommentsProvider } from '@core/comments/providers/comments';
|
||||||
import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler';
|
import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler';
|
||||||
import { AddonModGlossaryProvider } from './glossary';
|
import { AddonModGlossaryProvider } from './glossary';
|
||||||
import { AddonModGlossarySyncProvider } from './sync';
|
import { AddonModGlossarySyncProvider } from './sync';
|
||||||
|
@ -43,8 +44,9 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseActivityPrefetchH
|
||||||
sitesProvider: CoreSitesProvider,
|
sitesProvider: CoreSitesProvider,
|
||||||
domUtils: CoreDomUtilsProvider,
|
domUtils: CoreDomUtilsProvider,
|
||||||
filterHelper: CoreFilterHelperProvider,
|
filterHelper: CoreFilterHelperProvider,
|
||||||
private glossaryProvider: AddonModGlossaryProvider,
|
protected glossaryProvider: AddonModGlossaryProvider,
|
||||||
private syncProvider: AddonModGlossarySyncProvider) {
|
protected commentsProvider: CoreCommentsProvider,
|
||||||
|
protected syncProvider: AddonModGlossarySyncProvider) {
|
||||||
|
|
||||||
super(translate, appProvider, utils, courseProvider, filepoolProvider, sitesProvider, domUtils, filterHelper);
|
super(translate, appProvider, utils, courseProvider, filepoolProvider, sitesProvider, domUtils, filterHelper);
|
||||||
}
|
}
|
||||||
|
@ -160,8 +162,9 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseActivityPrefetchH
|
||||||
// Fetch all entries to get information from.
|
// Fetch all entries to get information from.
|
||||||
promises.push(this.glossaryProvider.fetchAllEntries(this.glossaryProvider.getEntriesByLetter,
|
promises.push(this.glossaryProvider.fetchAllEntries(this.glossaryProvider.getEntriesByLetter,
|
||||||
[glossary.id, 'ALL'], false, false, siteId).then((entries) => {
|
[glossary.id, 'ALL'], false, false, siteId).then((entries) => {
|
||||||
const promises = [];
|
const promises = [],
|
||||||
const avatars = {}; // List of user avatars, preventing duplicates.
|
commentsEnabled = !this.commentsProvider.areCommentsDisabledInSite(),
|
||||||
|
avatars = {}; // List of user avatars, preventing duplicates.
|
||||||
|
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
// Don't fetch individual entries, it's too many WS calls.
|
// Don't fetch individual entries, it's too many WS calls.
|
||||||
|
@ -169,6 +172,11 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseActivityPrefetchH
|
||||||
if (entry.userpictureurl) {
|
if (entry.userpictureurl) {
|
||||||
avatars[entry.userpictureurl] = true;
|
avatars[entry.userpictureurl] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (glossary.allowcomments && commentsEnabled) {
|
||||||
|
promises.push(this.commentsProvider.getComments('module', glossary.coursemodule, 'mod_glossary', entry.id,
|
||||||
|
'glossary_entry', 0, siteId));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prefetch intro files, entries files and user avatars.
|
// Prefetch intro files, entries files and user avatars.
|
||||||
|
|
Loading…
Reference in New Issue