MOBILE-2342 glossary: PR fixes

main
Albert Gasset 2018-05-29 11:19:26 +02:00
parent 5f6fabc531
commit 2fc339a055
6 changed files with 9 additions and 31 deletions

View File

@ -229,7 +229,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
this.fetchArguments = [this.glossary.id, 'ALL', 'LASTNAME', 'ASC']; this.fetchArguments = [this.glossary.id, 'ALL', 'LASTNAME', 'ASC'];
this.getDivider = (entry: any): string => entry.userfullname; this.getDivider = (entry: any): string => entry.userfullname;
this.showDivider = (entry: any, previous?: any): boolean => { this.showDivider = (entry: any, previous?: any): boolean => {
return previous === 'undefined' || entry.userid != previous.userid; return typeof previous === 'undefined' || entry.userid != previous.userid;
}; };
break; break;
case 'cat_all': case 'cat_all':

View File

@ -1,9 +1,6 @@
<ion-header> <ion-header>
<ion-navbar> <ion-navbar>
<ion-title *ngIf="entry"><core-format-text [text]="entry.concept"></core-format-text></ion-title> <ion-title *ngIf="entry"><core-format-text [text]="entry.concept"></core-format-text></ion-title>
<ion-buttons end>
<!-- The context menu will be added in here. -->
</ion-buttons>
</ion-navbar> </ion-navbar>
</ion-header> </ion-header>
<ion-content> <ion-content>

View File

@ -609,7 +609,7 @@ export class AddonModGlossaryProvider {
/** /**
* Invalidate the prefetched content for a given glossary, except files. * Invalidate the prefetched content for a given glossary, except files.
* To invalidate files, use $mmaModGlossary#invalidateFiles. * To invalidate files, use AddonModGlossaryProvider#invalidateFiles.
* *
* @param {any} glossary The glossary object. * @param {any} glossary The glossary object.
* @param {boolean} [onlyEntriesList] If true, entries won't be invalidated. * @param {boolean} [onlyEntriesList] If true, entries won't be invalidated.
@ -705,7 +705,8 @@ export class AddonModGlossaryProvider {
* @param {string} definition Glossary entry concept definition. * @param {string} definition Glossary entry concept definition.
* @param {number} courseId Course ID of the glossary. * @param {number} courseId Course ID of the glossary.
* @param {any} [options] Array of options for the entry. * @param {any} [options] Array of options for the entry.
* @param {any} [attach] Attachments ID if sending online, result of $mmFileUploader#storeFilesToUpload otherwise. * @param {any} [attach] Attachments ID if sending online, result of CoreFileUploaderProvider#storeFilesToUpload
* otherwise.
* @param {number} [timeCreated] The time the entry was created. If not defined, current time. * @param {number} [timeCreated] The time the entry was created. If not defined, current time.
* @param {string} [siteId] Site ID. If not defined, current site. * @param {string} [siteId] Site ID. If not defined, current site.
* @param {any} [discardEntry] The entry provided will be discarded if found. * @param {any} [discardEntry] The entry provided will be discarded if found.

View File

@ -39,7 +39,7 @@ export class AddonModGlossaryHelperProvider {
*/ */
deleteStoredFiles(glossaryId: number, entryName: string, timeCreated: number, siteId?: string): Promise<any> { deleteStoredFiles(glossaryId: number, entryName: string, timeCreated: number, siteId?: string): Promise<any> {
return this.glossaryOffline.getEntryFolder(glossaryId, entryName, timeCreated, siteId).then((folderPath) => { return this.glossaryOffline.getEntryFolder(glossaryId, entryName, timeCreated, siteId).then((folderPath) => {
this.fileProvider.removeDir(folderPath).catch(() => { return this.fileProvider.removeDir(folderPath).catch(() => {
// Ignore any errors, CoreFileProvider.removeDir fails if folder doesn't exists. // Ignore any errors, CoreFileProvider.removeDir fails if folder doesn't exists.
}); });
}); });

View File

@ -16,7 +16,6 @@ import { Injectable, Injector } from '@angular/core';
import { CoreCourseModulePrefetchHandlerBase } from '@core/course/classes/module-prefetch-handler'; import { CoreCourseModulePrefetchHandlerBase } from '@core/course/classes/module-prefetch-handler';
import { CoreUserProvider } from '@core/user/providers/user'; import { CoreUserProvider } from '@core/user/providers/user';
import { AddonModGlossaryProvider } from './glossary'; import { AddonModGlossaryProvider } from './glossary';
import { CoreConstants } from '@core/constants';
/** /**
* Handler to prefetch forums. * Handler to prefetch forums.
@ -34,25 +33,6 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseModulePrefetchHan
super(injector); super(injector);
} }
/**
* Return the status to show based on current status. E.g. a module might want to show outdated instead of downloaded.
* If not implemented, the original status will be returned.
*
* @param {any} module Module.
* @param {string} status The current status.
* @param {boolean} canCheck Whether the site allows checking for updates.
* @return {string} Status to display.
*/
determineStatus(module: any, status: string, canCheck: boolean): string {
if (!canCheck && status === CoreConstants.DOWNLOADED) {
/* Glossary are always marked as outdated if updates cannot be checked because we can't tell if there's something
new without having to call all the WebServices. */
return CoreConstants.OUTDATED;
} else {
return status;
}
}
/** /**
* Download the module. * Download the module.
* *

View File

@ -49,7 +49,7 @@ export class AddonModGlossarySyncProvider extends CoreSyncBaseProvider {
textUtils: CoreTextUtilsProvider, textUtils: CoreTextUtilsProvider,
private uploaderProvider: CoreFileUploaderProvider, private uploaderProvider: CoreFileUploaderProvider,
private utils: CoreUtilsProvider, private utils: CoreUtilsProvider,
private glossaruProvider: AddonModGlossaryProvider, private glossaryProvider: AddonModGlossaryProvider,
private glossaryHelper: AddonModGlossaryHelperProvider, private glossaryHelper: AddonModGlossaryHelperProvider,
private glossaryOffline: AddonModGlossaryOfflineProvider) { private glossaryOffline: AddonModGlossaryOfflineProvider) {
@ -181,7 +181,7 @@ export class AddonModGlossarySyncProvider extends CoreSyncBaseProvider {
// First of all upload the attachments (if any). // First of all upload the attachments (if any).
promise = this.uploadAttachments(glossaryId, data, siteId).then((itemId) => { promise = this.uploadAttachments(glossaryId, data, siteId).then((itemId) => {
// Now try to add the entry. // Now try to add the entry.
return this.glossaruProvider.addEntryOnline( return this.glossaryProvider.addEntryOnline(
glossaryId, data.concept, data.definition, data.options, itemId, siteId); glossaryId, data.concept, data.definition, data.options, itemId, siteId);
}); });
@ -213,8 +213,8 @@ export class AddonModGlossarySyncProvider extends CoreSyncBaseProvider {
}).then(() => { }).then(() => {
if (result.updated && courseId) { if (result.updated && courseId) {
// Data has been sent to server. Now invalidate the WS calls. // Data has been sent to server. Now invalidate the WS calls.
return this.glossaruProvider.getGlossaryById(courseId, glossaryId).then((glossary) => { return this.glossaryProvider.getGlossaryById(courseId, glossaryId).then((glossary) => {
return this.glossaruProvider.invalidateGlossaryEntries(glossary, true); return this.glossaryProvider.invalidateGlossaryEntries(glossary, true);
}).catch(() => { }).catch(() => {
// Ignore errors. // Ignore errors.
}); });