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

added a maximum word count and the ability to copy a text choice in the text...

added a maximum word count and the ability to copy a text choice in the text range from start to end
parent 7ee08b8a
......@@ -34,6 +34,7 @@
"SHOW": "Anzeigen",
"START": "Anfang",
"TEST": "Test",
"TEXT_TOO_LONG": "Text zu lang, max. Wortzahl: ",
"WELCOME": "Willkommen!",
"XML": "XML"
}
\ No newline at end of file
......@@ -34,6 +34,7 @@
"SHOW": "Show",
"START": "Start",
"TEST": "Test",
"TEXT_TOO_LONG": "Text too long, max. word count: ",
"WELCOME": "Welcome!",
"XML": "XML"
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ export class ConfigMC {
public static backendApiRawtextPath: string = "rawtext";
public static backendBaseUrl: string = "http://141.20.186.246:5000"; // 141.20.186.246 localhost
public static localStorageKeyCorpora: string = "mc/corpora";
public static maxTextLength: number = 2000;
public static perseidsCTSapiBaseUrl: string = "https://cts.perseids.org/api/cts?request=";
public static perseidsCTSapiGetCapabilities: string = "GetCapabilities";
public static perseidsCTSapiGetValidReff = "GetValidReff";
......
......@@ -14,7 +14,6 @@
<ion-content padding>
<ion-grid>
<ion-row>
<ion-col><h1>{{ 'START' | translate }}</h1></ion-col>
......@@ -46,26 +45,26 @@
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.citation_level_2 != CitationLevel[CitationLevel.default]">
<ion-col
*ngIf="corpusProvider.currentTextRange.start[0] && corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0]]">
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_2}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[1]" name="textRangeStart1"
(ionChange)="showFurtherReferences($event.toString(), 2, true)">
(ionChange)="showFurtherReferences($event.toString(), 2, true)"
disabled="{{corpusProvider.currentTextRange.start[0] && corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0]]}}">
<ion-option
*ngFor="let urn3 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0]]"
value="{{urn3}}">{{urn3}}
</ion-option>
</ion-select>
</ion-col>
<ion-col
*ngIf="corpusProvider.currentTextRange.end[0] && corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.end[0]]">
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_2}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[1]" name="textRangeEnd1"
(ionChange)="showFurtherReferences($event.toString(), 2, false)">
(ionChange)="showFurtherReferences($event.toString(), 2, false)"
disabled="{{corpusProvider.currentTextRange.end[0] && corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.end[0]]}}">
<ion-option
*ngFor="let urn4 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.end[0]]"
value="{{urn4}}">{{urn4}}
......@@ -74,31 +73,38 @@
</ion-col>
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.citation_level_3 != CitationLevel[CitationLevel.default]">
<ion-col
*ngIf="corpusProvider.currentTextRange.start[1] && corpusProvider.currentCorpus.subCorpora[[corpusProvider.currentTextRange.start[0], corpusProvider.currentTextRange.start[1]].join('.')]">
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_3}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[2]" name="textRangeStart2">
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[2]" name="textRangeStart2"
disabled="{{corpusProvider.currentTextRange.start[1] && corpusProvider.currentCorpus.subCorpora[[corpusProvider.currentTextRange.start[0], corpusProvider.currentTextRange.start[1]].join('.')]}}">
<ion-option
*ngFor="let urn5 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0] + '.' + corpusProvider.currentTextRange.start[1]]"
value="{{urn5}}">{{urn5}}
</ion-option>
</ion-select>
</ion-col>
<ion-col
*ngIf="corpusProvider.currentTextRange.end[1] && corpusProvider.currentCorpus.subCorpora[[corpusProvider.currentTextRange.end[0], corpusProvider.currentTextRange.end[1]].join('.')]">
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_3}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[2]" name="textRangeEnd2">
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[2]" name="textRangeEnd2" disabled="{{corpusProvider.currentTextRange.end[1] && corpusProvider.currentCorpus.subCorpora[[corpusProvider.currentTextRange.end[0], corpusProvider.currentTextRange.end[1]].join('.')]}}">
<ion-option
*ngFor="let urn6 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0] + '.' + corpusProvider.currentTextRange.start[1]]"
*ngFor="let urn6 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.end[0] + '.' + corpusProvider.currentTextRange.end[1]]"
value="{{urn6}}">{{urn6}}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row>
<ion-col></ion-col>
<ion-col>
<button type="button" ion-button icon-only (click)="copyStartToEnd()">
<ion-icon name="copy"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-grid>
<button ion-button block (click)="showText()">{{ "SHOW" | translate }}</button>
<ng-template #loading>
......
......@@ -24,7 +24,7 @@ export class CorpusDetailPage {
private noTextRangeChosenString: string;
public CitationLevel = CitationLevel;
private invalidTextRangeString: string;
public isTransitioningToTextPage: boolean = false;
public areReffEditable: boolean = true;
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider,
......@@ -50,8 +50,13 @@ export class CorpusDetailPage {
});
}
ionViewDidEnter() {
// TODO: For some reason, when users use the goBack arrow and come back to this page, areReffEditable is set to false even though it was true when the view left before. As a workaround, we need to set it back to true each time the user enters again.
this.areReffEditable = true;
}
showFurtherReferences(urn: string, currentCitationLevel: number, isStart: boolean) {
if (!this.isTransitioningToTextPage) {
if (this.areReffEditable) {
if (currentCitationLevel === 1 &&
this.corpusProvider.currentCorpus.citation_level_2 !== CitationLevel[CitationLevel.default]) {
// change display for further references
......@@ -111,7 +116,8 @@ export class CorpusDetailPage {
toast.present().then();
}
else {
this.isTransitioningToTextPage = true;
// prevent the reff discovery from kicking in
this.areReffEditable = false;
this.adjustCurrentTextRange();
let startNumber: number = +this.corpusProvider.currentTextRange.start.join("");
let endNumber: number = +this.corpusProvider.currentTextRange.end.join("");
......@@ -158,4 +164,13 @@ export class CorpusDetailPage {
}
this.corpusProvider.currentLastUrnPart = newUrnStart + "-" + newUrnEnd;
}
async copyStartToEnd() {
// prevent the reff discovery from kicking in
this.areReffEditable = false;
this.corpusProvider.currentTextRange.end = [this.corpusProvider.currentTextRange.start[0], this.corpusProvider.currentTextRange.start[1], this.corpusProvider.currentTextRange.start[2]];
// dirty hack to prevent the ionChange events from triggering unwanted behaviour
await new Promise(resolve => setTimeout(resolve, 50));
this.areReffEditable = true;
}
}
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
import {CorpusProvider} from "../../providers/corpus/corpus";
import {ExerciseType, PartOfSpeech, Phenomenon} from "../../models/enum";
import {ExerciseProvider} from "../../providers/exercise/exercise";
import {PreviewPage} from "../preview/preview";
import {TranslateService} from "@ngx-translate/core";
import {ConfigMC} from "../../config";
/**
* Generated class for the ShowTextPage page.
......@@ -22,17 +24,33 @@ export class ShowTextPage {
public Phenomenon = Phenomenon;
public PartOfSpeech = PartOfSpeech;
public currentText: string = "";
private textTooLongString: string;
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider,
public exerciseProvider: ExerciseProvider) {
public exerciseProvider: ExerciseProvider,
public toastCtrl: ToastController,
public translateService: TranslateService) {
this.corpusProvider.getCTStextPassage(this.corpusProvider.currentUrn).subscribe((data: object) => {
this.corpusProvider.currentText = data["text"];
});
this.translateService.get("TEXT_TOO_LONG").subscribe((value) => {
this.textTooLongString = value + ConfigMC.maxTextLength;
});
}
generateExercise() {
this.exerciseProvider.annisResponse = null;
this.navCtrl.push(PreviewPage).then();
if (this.corpusProvider.currentText.length > ConfigMC.maxTextLength) {
let toast = this.toastCtrl.create({
message: this.textTooLongString,
duration: 3000,
position: 'top'
});
toast.present().then();
}
else {
this.exerciseProvider.annisResponse = null;
this.navCtrl.push(PreviewPage).then();
}
}
}
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