MOBILE-4623 glossary: Fix issues with single activity format
parent
46c305b563
commit
5643e89c95
|
@ -427,11 +427,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
|||
* Opens new entry editor.
|
||||
*/
|
||||
openNewEntry(): void {
|
||||
CoreNavigator.navigate(
|
||||
this.splitView.outletActivated
|
||||
? '../new'
|
||||
: './entry/new',
|
||||
);
|
||||
CoreNavigator.navigateToSitePath(`${ADDON_MOD_GLOSSARY_PAGE_NAME}/${this.courseId}/${this.module.id}/entry/new`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit, ViewChild, ElementRef, Optional } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CanLeave } from '@guards/can-leave';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
|
@ -83,7 +82,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
|||
protected isDestroyed = false;
|
||||
protected saved = false;
|
||||
|
||||
constructor(protected route: ActivatedRoute, @Optional() protected splitView: CoreSplitViewComponent) {}
|
||||
constructor(protected route: ActivatedRoute) {}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
@ -109,8 +108,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
|||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModal(error);
|
||||
|
||||
this.goBack();
|
||||
CoreNavigator.back();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -144,8 +142,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
|||
});
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingglossary', true);
|
||||
|
||||
this.goBack();
|
||||
CoreNavigator.back();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +220,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
|||
|
||||
CoreForms.triggerFormSubmittedEvent(this.formElement, savedOnline, CoreSites.getCurrentSiteId());
|
||||
|
||||
this.goBack();
|
||||
CoreNavigator.back();
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.cannoteditentry', true);
|
||||
} finally {
|
||||
|
@ -249,17 +246,6 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
|||
return CoreFileUploader.areFileListDifferent(this.data.attachments, this.originalData.attachments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to go back.
|
||||
*/
|
||||
protected goBack(): void {
|
||||
if (this.splitView?.outletActivated) {
|
||||
CoreNavigator.navigate('../../');
|
||||
} else {
|
||||
CoreNavigator.back();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,8 @@ import {
|
|||
} from '../../services/glossary';
|
||||
import { CoreTime } from '@singletons/time';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED } from '../../constants';
|
||||
import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED, ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
|
||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||
|
||||
/**
|
||||
* Page that displays a glossary entry.
|
||||
|
@ -70,9 +71,14 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
courseId!: number;
|
||||
cmId!: number;
|
||||
|
||||
protected entrySlug!: string;
|
||||
protected logView: () => void;
|
||||
|
||||
constructor(@Optional() protected splitView: CoreSplitViewComponent, protected route: ActivatedRoute) {
|
||||
constructor(
|
||||
@Optional() protected splitView: CoreSplitViewComponent,
|
||||
protected route: ActivatedRoute,
|
||||
@Optional() protected courseContentsPage?: CoreCourseContentsPage,
|
||||
) {
|
||||
this.logView = CoreTime.once(async () => {
|
||||
if (!this.onlineEntry || !this.glossary || !this.componentId) {
|
||||
return;
|
||||
|
@ -100,8 +106,8 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
this.tagsEnabled = CoreTag.areTagsAvailableInSite();
|
||||
this.commentsEnabled = CoreComments.areCommentsEnabledInSite();
|
||||
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||
this.entrySlug = CoreNavigator.getRequiredRouteParam<string>('entrySlug');
|
||||
|
||||
const entrySlug = CoreNavigator.getRequiredRouteParam<string>('entrySlug');
|
||||
const routeData = CoreNavigator.getRouteData(this.route);
|
||||
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
||||
AddonModGlossaryEntriesSource,
|
||||
|
@ -112,14 +118,14 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
|
||||
await this.entries.start();
|
||||
|
||||
if (entrySlug.startsWith('new-')) {
|
||||
offlineEntryTimeCreated = Number(entrySlug.slice(4));
|
||||
if (this.entrySlug.startsWith('new-')) {
|
||||
offlineEntryTimeCreated = Number(this.entrySlug.slice(4));
|
||||
} else {
|
||||
onlineEntryId = Number(entrySlug);
|
||||
onlineEntryId = Number(this.entrySlug);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModal(error);
|
||||
CoreNavigator.back();
|
||||
this.goBack();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -160,7 +166,9 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
* Edit entry.
|
||||
*/
|
||||
async editEntry(): Promise<void> {
|
||||
await CoreNavigator.navigate('./edit');
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${ADDON_MOD_GLOSSARY_PAGE_NAME}/${this.courseId}/${this.cmId}/entry/${this.entrySlug}/edit`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,11 +216,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
|
||||
CoreDomUtils.showToast('addon.mod_glossary.entrydeleted', true, ToastDuration.LONG);
|
||||
|
||||
if (this.splitView?.outletActivated) {
|
||||
await CoreNavigator.navigate('../../');
|
||||
} else {
|
||||
await CoreNavigator.back();
|
||||
}
|
||||
await this.goBack();
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errordeleting', true);
|
||||
} finally {
|
||||
|
@ -237,8 +241,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
await CoreUtils.ignoreErrors(AddonModGlossary.invalidateEntry(this.onlineEntry.id));
|
||||
await this.loadOnlineEntry(this.onlineEntry.id);
|
||||
} else if (this.offlineEntry) {
|
||||
const entrySlug = CoreNavigator.getRequiredRouteParam<string>('entrySlug');
|
||||
const timecreated = Number(entrySlug.slice(4));
|
||||
const timecreated = Number(this.entrySlug.slice(4));
|
||||
|
||||
await this.loadOfflineEntry(timecreated);
|
||||
}
|
||||
|
@ -355,6 +358,17 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to go back.
|
||||
*/
|
||||
protected async goBack(): Promise<void> {
|
||||
if (this.splitView?.outletActivated) {
|
||||
await CoreNavigator.navigate((this.courseContentsPage ? '../' : '') + '../../');
|
||||
} else {
|
||||
await CoreNavigator.back();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue