Skip to content

Commit

Permalink
fill-in component, help text updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijeinath committed Sep 28, 2020
1 parent 3831c6b commit 012a01b
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 39 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import {AppInitService} from "./app-init.service";
import {KnoraService} from "./services/knora.service";
import {ListService} from "./services/list.service";
import {GravsearchBuilderService} from "./services/gravsearch-builder.service";
import {FillInComponent} from "./search/dialog/fill-in/fill-in.component";

export function initializeApp(appInitService: AppInitService) {
return (): Promise<any> => appInitService.Init();
Expand Down Expand Up @@ -146,7 +147,8 @@ export function initializeApp(appInitService: AppInitService) {
CommentsPipe,
BibliographyPipe,
SourcePipe,
LexiasPipe
LexiasPipe,
FillInComponent
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
<!-- <button type="button" (click)="selectCompany()">Select company</button>-->
</td>
<td class="min">
<mat-icon matSuffix (click)="getHelpText('performedCompany')">help</mat-icon>
Expand Down
56 changes: 41 additions & 15 deletions src/app/search/advanced-search/advanced-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {CustomValidators} from "../../customValidators";
import {ResultsComponent} from "../results/results.component";
import {ListService} from "../../services/list.service";
import {TreeTableService} from "../../services/tree-table.service";
import {FillInComponent} from "../dialog/fill-in/fill-in.component";

@Component({
selector: "app-advanced-search",
Expand Down Expand Up @@ -355,6 +356,7 @@ export class AdvancedSearchComponent implements OnInit {
}

ngOnInit() {
console.log(this.listService.getList("genre"));
const genresNode = this.listService.getList("genre").nodes;
this.genres = genresNode.reduce((acc, list) => this.treeTableService.flattenTree(acc, list), []);

Expand Down Expand Up @@ -400,6 +402,26 @@ export class AdvancedSearchComponent implements OnInit {
}

search() {
if ((!this.form.get("text").value
&& !this.form.get("author").value
&& !this.form.get("gender").value
&& !this.form.get("bookTitle").value
&& !this.form.get("lexia").value
&& !this.form.get("language").value
&& !this.form.get("function").value
&& !this.form.get("marking").value
&& !this.form.get("createdDate").value)
&& (!this.form.get("plays").value && !this.form.get("genre").value)) {
console.log("empty");
const dialogConfig = new MatDialogConfig();
dialogConfig.width = "650px";
dialogConfig.data = {
title: "Please note",
text: this.stringService.getString("text_not_filled")
};
this.helpDialog.open(FillInComponent, dialogConfig);
return;
}
this.prepareStructure();
this.resultBox.search(this.myPassage, this.priority);
}
Expand Down Expand Up @@ -485,7 +507,7 @@ export class AdvancedSearchComponent implements OnInit {

if (this.form.get("plays").value) {
// Only plays means if genre is "Drama (Theatre)"
this.genreRef.searchVal1 = this.listService.searchNodeByName("Drama (Theatre)");
this.genreRef.searchVal1 = this.listService.searchNodeByName("ALL DRAMA");
} else {
if (this.form.get("genre").value) {
this.genreRef.searchVal1 = this.form.get("genre").value;
Expand All @@ -500,51 +522,51 @@ export class AdvancedSearchComponent implements OnInit {
getHelpText(formControlName: string) {
switch (formControlName) {
case ("text"): {
this.openHelpDialog(this.stringService.getString("text_help"), "Text");
this.openHelpDialog(this.stringService.getString("text_help"), this.stringService.getString("default_title"));
break;
}
case ("author"): {
this.openHelpDialog(this.stringService.getString("author_help"), "Author");
this.openHelpDialog(this.stringService.getString("author_help"), this.stringService.getString("default_title"));
break;
}
case ("bookTitle"): {
this.openHelpDialog(this.stringService.getString("title_help"), "Title");
this.openHelpDialog(this.stringService.getString("title_help"), this.stringService.getString("default_title"));
break;
}
case ("lexia"): {
this.openHelpDialog(this.stringService.getString("lexia_help"), "Lexia");
this.openHelpDialog(this.stringService.getString("lexia_help"), "What is quoted?");
break;
}
case ("createdDate"): {
this.openHelpDialog(this.stringService.getString("date_help"), "Date");
this.openHelpDialog(this.stringService.getString("date_help"), this.stringService.getString("default_title"));
break;
}
case ("marking"): {
this.openHelpDialog(this.stringService.getString("marking_help"), "Marking");
this.openHelpDialog(this.stringService.getString("marking_help"), "\"Marking\"");
break;
}
case ("function"): {
this.openHelpDialog(this.stringService.getString("function_help"), "Function");
this.openHelpDialog(this.stringService.getString("function_help"), this.stringService.getString("default_title"));
break;
}
case ("performedCompany"): {
this.openHelpDialog(this.stringService.getString("per_company_help"), "First performance: company");
this.openHelpDialog(this.stringService.getString("per_company_help"), this.stringService.getString("default_title"));
break;
}
case ("performedActor"): {
this.openHelpDialog(this.stringService.getString("per_actor_help"), "First performance: actor");
this.openHelpDialog(this.stringService.getString("per_actor_help"), this.stringService.getString("default_title"));
break;
}
case ("language"): {
this.openHelpDialog(this.stringService.getString("language_help"), "Language");
this.openHelpDialog(this.stringService.getString("language_help"), this.stringService.getString("default_title"));
break;
}
case ("genre"): {
this.openHelpDialog(this.stringService.getString("genre_help"), "Genre");
this.openHelpDialog(this.stringService.getString("genre_help"), this.stringService.getString("default_title"));
break;
}
case ("plays"): {
this.openHelpDialog(this.stringService.getString("plays_help"), "Only Plays");
this.openHelpDialog(this.stringService.getString("plays_help"), this.stringService.getString("default_title"));
break;
}
}
Expand All @@ -558,13 +580,17 @@ export class AdvancedSearchComponent implements OnInit {
toggled ? this.form.get("genre").disable() : this.form.get("genre").enable();
}

openHelpDialog(text: string, name: string) {
openHelpDialog(text: string, title: string) {
const dialogConfig = new MatDialogConfig();
dialogConfig.width = "650px";
dialogConfig.data = {
text,
name
title
};
this.helpDialog.open(HelpComponent, dialogConfig);
}

selectCompany() {
console.log("select company");
}
}
8 changes: 8 additions & 0 deletions src/app/search/dialog/fill-in/fill-in.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<mat-dialog-content>
<h3>{{title}}</h3>
<div [innerHTML]="text"></div>
</mat-dialog-content>

<mat-dialog-actions>
<button type="button" mat-button (click)="close()">Close</button>
</mat-dialog-actions>
3 changes: 3 additions & 0 deletions src/app/search/dialog/fill-in/fill-in.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mat-dialog-actions {
justify-content: flex-end;
}
25 changes: 25 additions & 0 deletions src/app/search/dialog/fill-in/fill-in.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';

import {FillInComponent} from './fill-in.component';

describe('FillInComponent', () => {
let component: FillInComponent;
let fixture: ComponentFixture<FillInComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [FillInComponent]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FillInComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
27 changes: 27 additions & 0 deletions src/app/search/dialog/fill-in/fill-in.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Component, Inject, OnInit} from "@angular/core";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";

@Component({
selector: "app-fill-in",
templateUrl: "./fill-in.component.html",
styleUrls: ["./fill-in.component.scss"]
})
export class FillInComponent implements OnInit {
title: string;
text: string;

constructor(private dialogRef: MatDialogRef<FillInComponent>,
@Inject(MAT_DIALOG_DATA) data) {
console.log(data);
this.title = data.title;
this.text = data.text;
}

ngOnInit(): void {
}

close() {
this.dialogRef.close();
}

}
2 changes: 1 addition & 1 deletion src/app/search/dialog/help/help.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<mat-dialog-content>
<h3>Help for "{{name}}"</h3>
<h3>{{title}}</h3>
<div [innerHTML]="text"></div>
</mat-dialog-content>

Expand Down
5 changes: 2 additions & 3 deletions src/app/search/dialog/help/help.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
styleUrls: ["./help.component.scss"]
})
export class HelpComponent implements OnInit {
title: string;
text: string;
name: string;

constructor(private dialogRef: MatDialogRef<HelpComponent>,
@Inject(MAT_DIALOG_DATA) data) {
console.log(data.text);
this.title = data.title;
this.text = data.text;
this.name = data.name;
}

ngOnInit() {
Expand Down
41 changes: 30 additions & 11 deletions src/app/search/simple-search/simple-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {ListService} from "../../services/list.service";
import {NgxSpinnerService} from "ngx-spinner";
import {ResultsComponent} from "../results/results.component";
import {CustomValidators} from "../../customValidators";
import {FillInComponent} from "../dialog/fill-in/fill-in.component";

@Component({
selector: "app-simple-search",
Expand Down Expand Up @@ -323,7 +324,8 @@ export class SimpleSearchComponent implements OnInit {
private stringService: StringService,
private knoraService: KnoraService,
private spinner: NgxSpinnerService,
private helpDialog: MatDialog) {
private helpDialog: MatDialog,
private fillInDialog: MatDialog) {
}

ngOnInit() {
Expand All @@ -345,6 +347,23 @@ export class SimpleSearchComponent implements OnInit {
}

search() {
if ((!this.form.get("text").value
&& !this.form.get("author").value
&& !this.form.get("bookTitle").value
&& !this.form.get("lexia").value
&& !this.form.get("date").value)
&& !this.form.get("plays").value) {
console.log("empty");
const dialogConfig = new MatDialogConfig();
dialogConfig.width = "650px";
dialogConfig.data = {
title: "Please note",
text: this.stringService.getString("text_not_filled")
};
this.helpDialog.open(FillInComponent, dialogConfig);
return;
}

if (this.form.get("text").value) {
this.textRef.searchVal1 = this.form.get("text").value;
} else {
Expand Down Expand Up @@ -387,7 +406,7 @@ export class SimpleSearchComponent implements OnInit {

if (this.form.get("plays").value) {
// Only plays means if genre is "Drama (Theatre)"
this.genreRef.searchVal1 = this.listService.searchNodeByName("Drama (Theatre)");
this.genreRef.searchVal1 = this.listService.searchNodeByName("ALL DRAMA");
} else {
this.genreRef.searchVal1 = null;
}
Expand All @@ -398,27 +417,27 @@ export class SimpleSearchComponent implements OnInit {
getHelpText(property: string) {
switch (property) {
case ("text"): {
this.openHelpDialog(this.stringService.getString("text_help"), "Text");
this.openHelpDialog(this.stringService.getString("text_help"), this.stringService.getString("default_title"));
break;
}
case ("author"): {
this.openHelpDialog(this.stringService.getString("author_help"), "Author");
this.openHelpDialog(this.stringService.getString("author_help"), this.stringService.getString("default_title"));
break;
}
case ("title"): {
this.openHelpDialog(this.stringService.getString("title_help"), "Title");
this.openHelpDialog(this.stringService.getString("title_help"), this.stringService.getString("default_title"));
break;
}
case ("lexia"): {
this.openHelpDialog(this.stringService.getString("lexia_help"), "Lexia");
this.openHelpDialog(this.stringService.getString("lexia_help"), "What is quoted?");
break;
}
case ("date"): {
this.openHelpDialog(this.stringService.getString("date_help"), "Date");
this.openHelpDialog(this.stringService.getString("date_help"), this.stringService.getString("default_title"));
break;
}
case ("plays"): {
this.openHelpDialog(this.stringService.getString("plays_help"), "Only Plays");
this.openHelpDialog(this.stringService.getString("plays_help"), this.stringService.getString("default_title"));
break;
}
}
Expand All @@ -428,12 +447,12 @@ export class SimpleSearchComponent implements OnInit {
this.form.get(formControlName).reset("");
}

openHelpDialog(text: string, name: string) {
openHelpDialog(text: string, title: string) {
const dialogConfig = new MatDialogConfig();
dialogConfig.width = "650px";
dialogConfig.data = {
text,
name
title,
text
};
this.helpDialog.open(HelpComponent, dialogConfig);
}
Expand Down
18 changes: 10 additions & 8 deletions src/app/services/string.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ import {Injectable} from "@angular/core";
})
export class StringService {
readonly strings = {
default_title: "Please note",
text_not_filled: "Fill in at least one text field to start the search.",
text_help: "All texts are given in normalized spelling, taken from modern-spelling editions or normalized by hand from scholarly " +
"or historical editions. The button \"Show historical spelling\" in your search results indicates that a passage is also " +
"available in original spelling. Shakespeare's works are quoted from shakespeare.folger.edu in British spelling. Past tense " +
"available in original spelling. <br>Shakespeare's works are quoted from shakespeare.folger.edu in British spelling. Past tense " +
"forms such as \"whipp'd\" are silently normalized in all texts.",
author_help: "As in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i> (where applicable). We include \"assigned\" " +
author_help: "Authors are given as in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i>, where applicable. We include \"assigned\" " +
"authors and, in a few cases, authors which Wiggins does not recognize.",
title_help: "As in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i>, except for Shakespeare's plays. " +
title_help: "Titles of Shakespeare plays are given as in <a href='http://shakespeare.folger.edu'><i>The Folger Shakespeare</i></a> Other play titles are given as in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i>, where applicable.<br>" +
"Multi-part plays are listed as <i>Tamburlaine Part 1</i> rather than <i>The First Part of Tamburlaine</i>.",
lexia_help: "Type in any word or name to find passages that reference each other or use the same phrase.",
date_help: "As in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i> (where applicable). Wiggins' " +
"\"Best guess\" is used where there is no certain information. For technical reasons, all Classical texts (Latin & Ancient Greek) are " +
date_help: "Date are given as in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i>, where applicable. Wiggins' " +
"\"Best guess\" is used where there is no certain information. <br>For technical reasons, all Classical texts (Latin and Greek) are " +
"currently coded for the year 1000 rather than for the correct date.",
plays_help: "We focus on plays but include some passages from nondramatic works that were written or referenced by Renaissance " +
"dramatists. Use this switch to include or exclude poems, treatises, letters, the Bible etc. from your searches.",
marking_help: "How did Renaissance authors signal that they used somebody else's words? Marking for quotation can include " +
"names, typographical features and expressions like \"as the play says\".",
function_help: "Use \"Body of text\" and its subcategories to limit your search to passages in dialogue or a particular " +
function_help: "The \"Function\" helps you to find out in which part of the text quotation is located. Is it a title, an epigraph or a name?<br>Use \"Body of text\" and its subcategories to limit your search to passages in dialogue or a particular " +
"narrative voice, or explore references in stage directions, play titles etc.",
per_company_help: "Limit your searches to plays that were premiered by a certain troupe like The King's Men or The " +
"Children of Paul's.",
per_actor_help: "Limit your searches to plays whose premiere involved a certain actor.",
language_help: "Limit your search to English material or explore a selection of passages from European " +
"literature and the Classics.",
genre_help: "As in Martin Wiggins' <i>Catalogue</i> (where applicable). Some plays are assigned more than one genre; " +
"<i>Richard III</i>, for example, can be found both under \"Tragedy\" and \"History\"."
genre_help: "Genres are given as in <i>Martin Wiggins' British Drama 1533-1642: A Catalogue</i>, where applicable. Some plays are assigned more than one genre; Shakespeare's " +
"<i>Richard III</i>, for example, can be found both under \"Tragedy\" and \"History play\"."
};

constructor() {
Expand Down

0 comments on commit 012a01b

Please sign in to comment.