Commit 1ef9234b authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

Added side bar menu for more consistent navigation

parent 2da8ae6b
{
"name": "mc_frontend",
"version": "1.3.8",
"version": "1.3.9",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......
<ion-app>
<ion-router-outlet></ion-router-outlet>
<ion-menu contentId="content1" side="start" menuId="{{HelperService.menuId}}">
<ion-header>
<ion-toolbar>
<ion-title>{{ 'MACHINA_CALLIDA' | translate }}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-button
(click)="HelperService.goToAuthorPage(navCtrl).then(closeMenu.bind(this))">{{ 'EXERCISE_GENERATE' | translate }}</ion-button>
</ion-content>
</ion-menu>
<ion-router-outlet id="content1"></ion-router-outlet>
</ion-app>
import {Component} from '@angular/core';
import {StatusBar} from '@ionic-native/status-bar/ngx';
import {Config, Platform} from '@ionic/angular';
import {Config, MenuController, NavController, Platform} from '@ionic/angular';
import {SplashScreen} from '@ionic-native/splash-screen/ngx';
import {TranslateService} from '@ngx-translate/core';
import {HelperService} from 'src/app/helper.service';
......@@ -10,13 +10,16 @@ import {HelperService} from 'src/app/helper.service';
templateUrl: 'app.component.html'
})
export class AppComponent {
public HelperService = HelperService;
constructor(platform: Platform,
public statusBar: StatusBar,
private translate: TranslateService,
private config: Config,
private splashScreen: SplashScreen,
public helperService: HelperService
public helperService: HelperService,
public navCtrl: NavController,
public menuCtrl: MenuController
) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
......@@ -27,6 +30,10 @@ export class AppComponent {
this.initTranslate();
}
closeMenu(result: boolean) {
this.menuCtrl.close(HelperService.menuId).then();
}
initTranslate() {
// Set the default language for translation strings, and the current language.
this.translate.setDefaultLang('en');
......@@ -43,5 +50,4 @@ export class AppComponent {
// this.config.set('backButtonText', values.BACK_BUTTON_TEXT); // 'ios',
// });
}
}
......@@ -24,6 +24,6 @@ export class AuthorDetailPage {
showPossibleReferences(corpus: CorpusMC) {
this.corpusService.currentCorpus = corpus;
this.corpusService.currentTextRange = new TextRange({start: ['', '', ''], end: ['', '', '']});
HelperService.goToTextRangePage(this.navCtrl);
HelperService.goToTextRangePage(this.navCtrl).then();
}
}
......@@ -21,7 +21,7 @@
<br>
</ion-col>
</ion-row>
<ion-row *ngIf="HelperService.mostRecentSetup.currentCorpus && HelperService.mostRecentSetup.currentUrn">
<ion-row *ngIf="HelperService.mostRecentSetup?.currentCorpus && HelperService.mostRecentSetup?.currentUrn">
<ion-col>
<a (click)="restoreLastSetup()">{{ [HelperService.mostRecentSetup.currentCorpus.author,
HelperService.mostRecentSetup.currentCorpus.title,
......
......@@ -60,9 +60,9 @@ export class AuthorPage {
restoreLastSetup() {
this.corpusService.restoreLastCorpus().then(() => {
if (HelperService.isVocabularyCheck) {
HelperService.goToVocabularyCheckPage(this.navCtrl);
HelperService.goToVocabularyCheckPage(this.navCtrl).then();
} else {
HelperService.goToShowTextPage(this.navCtrl);
HelperService.goToShowTextPage(this.navCtrl).then();
}
}, () => {
});
......
......@@ -16,12 +16,12 @@ export class ConfirmCancelPage implements OnInit {
}
exit() {
HelperService.currentPopover.dismiss();
HelperService.currentPopover.dismiss().then();
HelperService.currentPopover = null;
}
confirm() {
HelperService.goToHomePage(this.navCtrl);
HelperService.goToHomePage(this.navCtrl).then();
this.exit();
}
}
......@@ -120,7 +120,7 @@ export class ExerciseListPage implements OnInit {
this.corpusService.annisResponse = ar;
const met: MoodleExerciseType = MoodleExerciseType[exercise.exercise_type];
this.corpusService.exercise.type = ExerciseType[met.toString()];
HelperService.goToPreviewPage(this.navCtrl);
HelperService.goToPreviewPage(this.navCtrl).then();
}, () => {
});
}
......
......@@ -136,7 +136,7 @@ export class ExerciseParametersPage implements OnInit {
this.corpusService.annisResponse.exercise_id = ar.exercise_id;
this.corpusService.annisResponse.uri = ar.uri;
this.corpusService.annisResponse.solutions = ar.solutions;
HelperService.goToPreviewPage(this.navCtrl);
HelperService.goToPreviewPage(this.navCtrl).then();
}, async (error: HttpErrorResponse) => {
HelperService.isLoading = false;
HelperService.currentError = error;
......
......@@ -80,6 +80,7 @@ export class HelperService {
name: 'English',
shortcut: 'en'
}), new Language({name: 'Deutsch', shortcut: 'de'})];
public static menuId = 'menu1';
public static mostRecentSetup: ApplicationState = null;
public static partOfSpeechMap: { [rawValue: string]: PartOfSpeechValue } = {
ADJ: PartOfSpeechValue.adjective,
......@@ -135,55 +136,62 @@ export class HelperService {
});
}
static goToAuthorPage(navCtrl: NavController) {
navCtrl.navigateForward('/author').then();
static goToAuthorPage(navCtrl: NavController): Promise<boolean> {
HelperService.isVocabularyCheck = false;
return navCtrl.navigateForward('/author');
}
static goToExerciseListPage(navCtrl: NavController) {
navCtrl.navigateForward('/exercise-list').then();
static goToExerciseListPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('/exercise-list');
}
static goToExerciseParametersPage(navCtrl: NavController) {
navCtrl.navigateForward('exercise-parameters').then();
static goToExerciseParametersPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('exercise-parameters');
}
static goToHomePage(navCtrl: NavController) {
navCtrl.navigateRoot('/home').then();
static goToHomePage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateRoot('/home');
}
static goToImprintPage(navCtrl: NavController) {
navCtrl.navigateForward('/imprint').then();
static goToImprintPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('/imprint');
}
static goToInfoPage(navCtrl: NavController) {
navCtrl.navigateForward('/info').then();
static goToInfoPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('/info');
}
static goToPreviewPage(navCtrl: NavController) {
navCtrl.navigateForward('preview').then();
static goToPreviewPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('preview');
}
static goToShowTextPage(navCtrl: NavController, isVocabularyCheck: boolean = false) {
navCtrl.navigateForward('/show-text').then(() => {
HelperService.isVocabularyCheck = isVocabularyCheck;
static goToShowTextPage(navCtrl: NavController, isVocabularyCheck: boolean = false): Promise<boolean> {
return new Promise<boolean>((resolve) => {
navCtrl.navigateForward('/show-text').then((result: boolean) => {
HelperService.isVocabularyCheck = isVocabularyCheck;
return resolve(result);
});
});
}
static goToSourcesPage(navCtrl: NavController) {
navCtrl.navigateForward('/sources').then();
static goToSourcesPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('/sources');
}
static goToTestPage(navCtrl: NavController) {
navCtrl.navigateRoot('/test').then();
static goToTestPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateRoot('/test');
}
static goToTextRangePage(navCtrl: NavController) {
navCtrl.navigateForward('/text-range').then();
static goToTextRangePage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward('/text-range');
}
static goToVocabularyCheckPage(navCtrl: NavController) {
navCtrl.navigateForward('/vocabulary-check').then(() => {
HelperService.isVocabularyCheck = true;
static goToVocabularyCheckPage(navCtrl: NavController): Promise<boolean> {
return new Promise<boolean>((resolve) => {
navCtrl.navigateForward('/vocabulary-check').then((result: boolean) => {
HelperService.isVocabularyCheck = true;
return resolve(result);
});
});
}
......
<ion-header>
<ion-toolbar>
<div class="toolbar-left">
<img src="assets/imgs/logo.png" width="32px" height="32px" alt="Logo von Callidus: Fuchs">
</div>
<div class="toolbar-left">
<ion-title>{{ 'MACHINA_CALLIDA' | translate }}</ion-title>
</div>
<div class="toolbar-right">
<ion-spinner *ngIf="HelperService.isLoading"></ion-spinner>
<ion-select [(ngModel)]="HelperService.currentLanguage" (ngModelChange)="changeLanguage($event)"
name="currentLanguage" placeholder="{{HelperService.currentLanguage?.name}}">
<ion-select-option *ngFor="let lang of HelperService.languages"
value="{{lang.shortcut}}">{{lang.name}}</ion-select-option>
</ion-select>
<ion-buttons slot="start">
<ion-menu-button autoHide="false"></ion-menu-button>
</ion-buttons>
<div class="home-logo">
<img src="assets/imgs/logo.png" width="32px" height="32px" alt="CALLIDUS Logo">
</div>
<ion-buttons slot="end">
<div>
<ion-spinner *ngIf="HelperService.isLoading"></ion-spinner>
<ion-select [(ngModel)]="HelperService.currentLanguage" (ngModelChange)="changeLanguage($event)"
name="currentLanguage" placeholder="{{HelperService.currentLanguage?.name}}">
<ion-select-option *ngFor="let lang of HelperService.languages"
value="{{lang.shortcut}}">{{lang.name}}</ion-select-option>
</ion-select>
</div>
</ion-buttons>
</ion-toolbar>
</ion-header>
......@@ -21,7 +23,8 @@
<ion-grid *ngIf="!isCorpusUpdateInProgress; else loading">
<ion-row>
<ion-col>
<ion-button (click)="goToAuthorPage()">{{ 'EXERCISE_GENERATE' | translate }}</ion-button>
<ion-button
(click)="HelperService.goToAuthorPage(navCtrl).then()">{{ 'EXERCISE_GENERATE' | translate }}</ion-button>
</ion-col>
</ion-row>
<ion-row>
......@@ -32,7 +35,7 @@
<ion-row>
<ion-col>
<ion-button
(click)="HelperService.goToExerciseListPage(navCtrl)">{{ 'EXERCISE_LIST' | translate }}</ion-button>
(click)="HelperService.goToExerciseListPage(navCtrl).then()">{{ 'EXERCISE_LIST' | translate }}</ion-button>
</ion-col>
</ion-row>
<ion-row>
......
.home-logo {
text-align: center;
}
.lastMainElement {
height: 40%;
}
......
......@@ -50,11 +50,6 @@ export class HomePage implements OnInit {
}
}
goToAuthorPage() {
HelperService.isVocabularyCheck = false;
this.navCtrl.navigateForward('/author').then();
}
refreshCorpora() {
this.isCorpusUpdateInProgress = true;
this.corpusService.getCorpora(0).then(async () => {
......
......@@ -33,7 +33,7 @@ export class RankingPage {
const urnEnd: string = ar.nodes.slice(-1)[0].id.split('/')[1];
this.corpusService.currentUrn = urnStart.concat('-', urnEnd.split(':').slice(-1)[0]);
this.corpusService.processAnnisResponse(ar);
HelperService.goToShowTextPage(this.navCtrl, true);
HelperService.goToShowTextPage(this.navCtrl, true).then();
}, async (error: HttpErrorResponse) => {
});
}
......
......@@ -21,7 +21,7 @@
<ion-row>
<ion-col>
<ion-button
(click)="HelperService.goToExerciseParametersPage(navCtrl)">{{ "EXERCISE_SET_PARAMETERS" | translate}}</ion-button>
(click)="HelperService.goToExerciseParametersPage(navCtrl).then()">{{ "EXERCISE_SET_PARAMETERS" | translate}}</ion-button>
</ion-col>
<ion-col>
<ion-button
......
......@@ -174,7 +174,7 @@
<ion-icon name="send"></ion-icon>
<ion-label>{{ 'TEST_MODULE_SEND_DATA' | translate }}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="HelperService.goToAuthorPage(navCtrl)">
<ion-tab-button (click)="HelperService.goToAuthorPage(navCtrl).then()">
<ion-icon name="walk"></ion-icon>
<ion-label>{{ 'EXERCISE_GENERATE' | translate }}</ion-label>
</ion-tab-button>
......
......@@ -238,11 +238,11 @@ export class TextRangePage {
this.corpusService.isTextRangeCorrect = true;
this.corpusService.getText().then(() => {
if (skipText) {
HelperService.goToExerciseParametersPage(this.navCtrl);
HelperService.goToExerciseParametersPage(this.navCtrl).then();
} else if (HelperService.isVocabularyCheck) {
HelperService.goToVocabularyCheckPage(this.navCtrl);
HelperService.goToVocabularyCheckPage(this.navCtrl).then();
} else {
HelperService.goToShowTextPage(this.navCtrl);
HelperService.goToShowTextPage(this.navCtrl).then();
}
}, () => {
});
......
......@@ -56,9 +56,6 @@
}
ion-buttons {
position: absolute;
right: 0;
top: 0;
color: var(--ion-color-primary);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment