MOBILE-2877 glossary: Include comments into glossary
parent
33f2abcee1
commit
e6fd969855
|
@ -35,6 +35,9 @@
|
|||
<ion-item text-wrap *ngIf="entry.approved != 1">
|
||||
<p><em>{{ 'addon.mod_glossary.entrypendingapproval' | translate }}</em></p>
|
||||
</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-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>
|
||||
|
|
|
@ -18,6 +18,7 @@ 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 { CoreCommentsComponentsModule } from '@core/comments/components/components.module';
|
||||
import { CoreRatingComponentsModule } from '@core/rating/components/components.module';
|
||||
import { CoreTagComponentsModule } from '@core/tag/components/components.module';
|
||||
import { AddonModGlossaryEntryPage } from './entry';
|
||||
|
@ -32,6 +33,7 @@ import { AddonModGlossaryEntryPage } from './entry';
|
|||
CorePipesModule,
|
||||
IonicPageModule.forChild(AddonModGlossaryEntryPage),
|
||||
TranslateModule.forChild(),
|
||||
CoreCommentsComponentsModule,
|
||||
CoreRatingComponentsModule,
|
||||
CoreTagComponentsModule
|
||||
],
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { IonicPage, NavParams } from 'ionic-angular';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreRatingInfo } from '@core/rating/providers/rating';
|
||||
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';
|
||||
|
||||
/**
|
||||
|
@ -28,6 +30,8 @@ import { AddonModGlossaryProvider } from '../../providers/glossary';
|
|||
templateUrl: 'entry.html',
|
||||
})
|
||||
export class AddonModGlossaryEntryPage {
|
||||
@ViewChild(CoreCommentsCommentsComponent) comments: CoreCommentsCommentsComponent;
|
||||
|
||||
component = AddonModGlossaryProvider.COMPONENT;
|
||||
componentId: number;
|
||||
entry: any;
|
||||
|
@ -37,23 +41,27 @@ export class AddonModGlossaryEntryPage {
|
|||
showDate = false;
|
||||
ratingInfo: CoreRatingInfo;
|
||||
tagsEnabled: boolean;
|
||||
commentsEnabled: boolean;
|
||||
|
||||
protected courseId: number;
|
||||
protected entryId: number;
|
||||
|
||||
constructor(navParams: NavParams,
|
||||
private domUtils: CoreDomUtilsProvider,
|
||||
private glossaryProvider: AddonModGlossaryProvider,
|
||||
private tagProvider: CoreTagProvider) {
|
||||
protected domUtils: CoreDomUtilsProvider,
|
||||
protected glossaryProvider: AddonModGlossaryProvider,
|
||||
protected tagProvider: CoreTagProvider,
|
||||
protected commentsProvider: CoreCommentsProvider) {
|
||||
this.courseId = navParams.get('courseId');
|
||||
this.entryId = navParams.get('entryId');
|
||||
this.tagsEnabled = this.tagProvider.areTagsAvailableInSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* View loaded.
|
||||
*/
|
||||
ionViewDidLoad(): void {
|
||||
this.tagsEnabled = this.tagProvider.areTagsAvailableInSite();
|
||||
this.commentsEnabled = !this.commentsProvider.areCommentsDisabledInSite();
|
||||
|
||||
this.fetchEntry().then(() => {
|
||||
this.glossaryProvider.logEntryView(this.entry.id, this.componentId, this.glossary.name).catch(() => {
|
||||
// Ignore errors.
|
||||
|
@ -70,6 +78,14 @@ export class AddonModGlossaryEntryPage {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
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(() => {
|
||||
// Ignore errors.
|
||||
}).then(() => {
|
||||
|
|
|
@ -20,6 +20,7 @@ import { CoreSitesProvider } from '@providers/sites';
|
|||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
import { CoreCommentsProvider } from '@core/comments/providers/comments';
|
||||
import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler';
|
||||
import { AddonModGlossaryProvider } from './glossary';
|
||||
import { AddonModGlossarySyncProvider } from './sync';
|
||||
|
@ -43,8 +44,9 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseActivityPrefetchH
|
|||
sitesProvider: CoreSitesProvider,
|
||||
domUtils: CoreDomUtilsProvider,
|
||||
filterHelper: CoreFilterHelperProvider,
|
||||
private glossaryProvider: AddonModGlossaryProvider,
|
||||
private syncProvider: AddonModGlossarySyncProvider) {
|
||||
protected glossaryProvider: AddonModGlossaryProvider,
|
||||
protected commentsProvider: CoreCommentsProvider,
|
||||
protected syncProvider: AddonModGlossarySyncProvider) {
|
||||
|
||||
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.
|
||||
promises.push(this.glossaryProvider.fetchAllEntries(this.glossaryProvider.getEntriesByLetter,
|
||||
[glossary.id, 'ALL'], false, false, siteId).then((entries) => {
|
||||
const promises = [];
|
||||
const avatars = {}; // List of user avatars, preventing duplicates.
|
||||
const promises = [],
|
||||
commentsEnabled = !this.commentsProvider.areCommentsDisabledInSite(),
|
||||
avatars = {}; // List of user avatars, preventing duplicates.
|
||||
|
||||
entries.forEach((entry) => {
|
||||
// Don't fetch individual entries, it's too many WS calls.
|
||||
|
@ -169,6 +172,11 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseActivityPrefetchH
|
|||
if (entry.userpictureurl) {
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue