From 4cbd3b0c0a8f86adcf731cae4e4e8fe44a9ab1f6 Mon Sep 17 00:00:00 2001 From: Lukas Rosenthaler Date: Sat, 20 Nov 2021 19:17:50 +0100 Subject: [PATCH 1/3] Bugfixes --- src/app/edit/edit-book/edit-book.component.ts | 32 +++++------------ .../edit-company/edit-company.component.ts | 18 ++-------- .../edit-passage/edit-passage.component.ts | 35 +++++++------------ .../edit/edit-person/edit-person.component.ts | 17 ++------- .../edit/edit-venue/edit-venue.component.ts | 8 +---- 5 files changed, 26 insertions(+), 84 deletions(-) diff --git a/src/app/edit/edit-book/edit-book.component.ts b/src/app/edit/edit-book/edit-book.component.ts index 04cc0e77..65d2ab9b 100644 --- a/src/app/edit/edit-book/edit-book.component.ts +++ b/src/app/edit/edit-book/edit-book.component.ts @@ -850,7 +850,7 @@ export class EditBookComponent implements OnInit { addGenre(genre?: { id: string; iri: string }): void { const genres = this.getGenres(); - if (genre?.iri === undefined) { + if (genre === undefined) { genres.push(this.fb.group({genreIri: this.genreTypes[0].iri})); this.data.genres.push({genreIri: this.genreTypes[0].iri}); this.valIds.genres.push({id: undefined, changed: false, toBeDeleted: false}); @@ -902,7 +902,7 @@ export class EditBookComponent implements OnInit { addSubject(subject?: { id: string; iri: string }): void { const subjects = this.getSubjects(); - if (subject?.iri === undefined) { + if (subject === undefined) { subjects.push(this.fb.group({subjectIri: this.subjectTypes[0].iri})); this.data.subjects.push({subjectIri: this.subjectTypes[0].iri}); this.valIds.subjects.push({id: undefined, changed: false, toBeDeleted: false}); @@ -1139,49 +1139,34 @@ export class EditBookComponent implements OnInit { case 'writtenBy': this.form.value.writtenBy[index].writtenByName = res[0].label; this.form.value.writtenBy[index].writtenByIri = res[0].id; + this.value.writtenBy = this.form.value.writtenBy; break; case 'lexias': this.form.value.lexias[index].lexiaName = res[0].label; this.form.value.lexias[index].lexiaIri = res[0].id; + this.value.lexias = this.form.value.lexias; break; case 'performedBy': this.form.value.performedBy[index].performedByName = res[0].label; this.form.value.performedBy[index].performedByIri = res[0].id; + this.value.performedBy = this.form.value.performedBy; break; case 'performedByActor': this.form.value.performedByActor[index].performedByActorName = res[0].label; this.form.value.performedByActor[index].performedByActorIri = res[0].id; + this.value.performedByActor = this.form.value.performedByActor; break; case 'performedIn': this.form.value.performedIn[index].performedInName = res[0].label; this.form.value.performedIn[index].performedInIri = res[0].id; + this.value.performedIn = this.form.value.performedIn; break; } - this.value = new BookData( - this.form.value.label, - this.form.value.internalId, - this.form.value.title, - this.form.value.creationDate, - this.form.value.edition, - this.form.value.genres, - this.form.value.language, - this.form.value.writtenBy, - this.form.value.comment, - this.form.value.extraInfo, - this.form.value.editionHist, - this.form.value.firstPerformance, - this.form.value.prefixTitle, - this.form.value.pubdate, - this.form.value.subjects, - this.form.value.lexias, - this.form.value.performedBy, - this.form.value.performedByActor, - this.form.value.performedIn - ); this.options = []; } _handleInput(what: string, index?: number): void { + console.log('_handleInput', what, index); this.onChange(this.form.value); switch (what) { case 'label': @@ -1450,6 +1435,7 @@ export class EditBookComponent implements OnInit { ); } else { const obs: Array> = []; + console.log('this.valIds:', this.valIds); if (this.valIds.label.changed) { const gaga: Observable = this.knoraService.updateLabel( diff --git a/src/app/edit/edit-company/edit-company.component.ts b/src/app/edit/edit-company/edit-company.component.ts index dabbae8f..1220d540 100644 --- a/src/app/edit/edit-company/edit-company.component.ts +++ b/src/app/edit/edit-company/edit-company.component.ts @@ -434,26 +434,12 @@ export class EditCompanyComponent implements OnInit { case 'members': this.form.value.members[index].memberName = res[0].label; this.form.value.members[index].memberIri = res[0].id; - this.value = new CompanyData( - this.form.value.label, - this.form.value.title, - this.form.value.internalId, - this.form.value.extraInfo, - this.form.value.members, - this.form.value.lexias, - ); + this.value.members = this.form.value.members; break; case 'lexias': this.form.value.lexias[index].lexiaName = res[0].label; this.form.value.lexias[index].lexiaIri = res[0].id; - this.value = new CompanyData( - this.form.value.label, - this.form.value.title, - this.form.value.internalId, - this.form.value.extraInfo, - this.form.value.members, - this.form.value.lexias, - ); + this.value.lexias = this.form.value.lexias; break; } this.options = []; diff --git a/src/app/edit/edit-passage/edit-passage.component.ts b/src/app/edit/edit-passage/edit-passage.component.ts index 256c4ed9..09460daa 100644 --- a/src/app/edit/edit-passage/edit-passage.component.ts +++ b/src/app/edit/edit-passage/edit-passage.component.ts @@ -797,7 +797,7 @@ export class EditPassageComponent implements OnInit { addFunctionVoice(functionVoice?: {id: string; iri: string }): void { const functionVoices = this.getFunctionVoices(); - if (functionVoice.iri === undefined) { + if (functionVoice === undefined) { functionVoices.push(this.fb.group({functionVoiceIri: this.functionVoiceTypes[0].iri})); this.data.functionVoices.push({functionVoiceIri: this.functionVoiceTypes[0].iri}); this.valIds.functionVoices.push({id: undefined, changed: false, toBeDeleted: false}); @@ -823,7 +823,7 @@ export class EditPassageComponent implements OnInit { addMarking(marking?: {id: string; iri: string }): void { const markings = this.getMarkings(); - if (marking.iri === undefined) { + if (marking === undefined) { markings.push(this.fb.group({markingIri: this.markingTypes[0].iri})); this.data.markings.push({markingIri: this.markingTypes[0].iri}); this.valIds.markings.push({id: undefined, changed: false, toBeDeleted: false}); @@ -973,41 +973,30 @@ export class EditPassageComponent implements OnInit { case 'occursIn': this.form.value.occursInName = res[0].label; this.form.value.occursInIri = res[0].id; + this.value.occursIn = { + occursInName: this.form.value.occursInName, + occursInIri: this.form.value.occursInIri + }; break; case 'contributedBy': this.form.value.contributedByName = res[0].label; this.form.value.contributedByIri = res[0].id; + this.value.contributedBy = { + contributedByName: this.form.value.contributedByName, + contributedByIri: this.form.value.contributedByIri + }; break; case 'contains': this.form.value.contains[index].containsName = res[0].label; this.form.value.contains[index].containsIri = res[0].id; + this.value.contains = this.form.value.contains; break; case 'mentionedIn': this.form.value.mentionedIn[index].mentionedInName = res[0].label; this.form.value.mentionedIn[index].mentionedInIri = res[0].id; + this.value.mentionedIn = this.form.value.mentionedIn; break; } - this.value = new PassageData( - this.form.value.label, - this.form.value.internalId, - this.form.value.displayedTitle, - this.form.value.functionVoices, - this.form.value.markings, - this.form.value.researchField, - this.form.value.status, - this.form.value.text, - {occursInName: this.form.value.occursInName, occursInIri: this.form.value.occursInIri}, - {contributedByName: this.form.value.contributedByName, contributedByIri: this.form.value.contributedByIri}, - this.form.value.contains, - this.form.value.internalComment, - this.form.value.page, - this.form.value.pageHist, - this.form.value.comment, - this.form.value.extraInfo, - this.form.value.prefixTitle, - this.form.value.textHist, - this.form.value.mentionedIn - ); this.options = []; } diff --git a/src/app/edit/edit-person/edit-person.component.ts b/src/app/edit/edit-person/edit-person.component.ts index b5ee7aa5..7e281108 100644 --- a/src/app/edit/edit-person/edit-person.component.ts +++ b/src/app/edit/edit-person/edit-person.component.ts @@ -109,7 +109,7 @@ class PersonIds { @@ -456,20 +456,7 @@ export class EditPersonComponent implements OnInit { case 'lexias': this.form.value.lexias[index].lexiaName = res[0].label; this.form.value.lexias[index].lexiaIri = res[0].id; - this.value = new PersonData( - this.form.value.label, - this.form.value.internalId, - this.form.value.firstName, - this.form.value.lastName, - this.form.value.gender, - this.form.value.description, - this.form.value.birthDate, - //this.form.value.birthDateEnd, - this.form.value.deathDate, - //this.form.value.deathDateEnd, - this.form.value.extraInfo, - this.form.value.lexias, - ); + this.value.lexias = this.form.value.lexias; break; } this.options = []; diff --git a/src/app/edit/edit-venue/edit-venue.component.ts b/src/app/edit/edit-venue/edit-venue.component.ts index 0f81dbe5..baf1a615 100644 --- a/src/app/edit/edit-venue/edit-venue.component.ts +++ b/src/app/edit/edit-venue/edit-venue.component.ts @@ -350,15 +350,9 @@ export class EditVenueComponent implements OnInit { case 'lexias': this.form.value.lexias[index].lexiaName = res[0].label; this.form.value.lexias[index].lexiaIri = res[0].id; + this.value.lexias = this.form.value.lexias; break; } - this.value = new VenueData( - this.form.value.label, - this.form.value.title, - this.form.value.place, - this.form.value.extraInfo, - this.form.value.lexias - ); } _handleInput(what: string, index?: number): void { From dfa899b0ade2617f13558323cf42a047edae2897 Mon Sep 17 00:00:00 2001 From: Lukas Rosenthaler Date: Sat, 20 Nov 2021 23:33:23 +0100 Subject: [PATCH 2/3] ... --- src/app/edit/edit.component.ts | 322 +++++++++++++++++---------------- 1 file changed, 168 insertions(+), 154 deletions(-) diff --git a/src/app/edit/edit.component.ts b/src/app/edit/edit.component.ts index 1c295b85..eb360fa3 100644 --- a/src/app/edit/edit.component.ts +++ b/src/app/edit/edit.component.ts @@ -15,170 +15,184 @@ import {Router} from "@angular/router"; selector: 'app-edit', template: `
- - Company {{knoraService.loggedin}} - -

- - - - - - {{ option.label }} - - - - -
-
- - - Person - -

- - - - New +

+ + + + - - {{ option.label }} - - - - -
-
+ + {{ option.label }} + + + + + + + + + Book + + +

+ + + + + + {{ option.label }} + + + + +
+
- - Lexia - -

- - - - New +

+ + + + - - {{ option.label }} - - - - -
-
+ + {{ option.label }} + + + + + + - - Passage - -

- - - - New +

+ + + + - - {{ option.label }} - - - - -
-
+ + {{ option.label }} + + + + + + - - Book - -

- - - - - - {{ option.label }} - - - - -
-
+ + Company {{knoraService.loggedin}} + + +

+ + + + + + {{ option.label }} + + + + +
+
- - Venue - -

- - - - New +

+ + + + - - {{ option.label }} - - - - -
-
+ + {{ option.label }} + + + + + +
- No access! + + No access! +
`, styles: [ From af72d2ca1e2ce3026443ffb9fafbb3d5eb0a0fd7 Mon Sep 17 00:00:00 2001 From: Lukas Rosenthaler Date: Sun, 21 Nov 2021 23:34:14 +0100 Subject: [PATCH 3/3] Bugfixes --- package.json | 2 +- src/app/app.component.html | 2 +- src/app/edit/edit-book/edit-book.component.ts | 35 +++++++++-------- .../edit-company/edit-company.component.ts | 38 ++++++++++++------- .../edit/edit-lexia/edit-lexia.component.ts | 34 ++++++++++------- .../edit-passage/edit-passage.component.ts | 34 ++++++++++------- .../edit/edit-person/edit-person.component.ts | 36 ++++++++++-------- .../edit/edit-venue/edit-venue.component.ts | 34 ++++++++++------- 8 files changed, 126 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index afbae1e6..b3c8718c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "0826-wordweb-app", - "version": "2.10.15", + "version": "2.10.16", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/src/app/app.component.html b/src/app/app.component.html index ea11dc60..65b8028c 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -44,7 +44,7 @@
- © 2019-2021 WordWeb | Made by WordWeb at DHLab | {{version}} + © 2019-2021 WordWeb | Made by WordWeb at DHLab (VT/LR) | v{{version}}
diff --git a/src/app/edit/edit-book/edit-book.component.ts b/src/app/edit/edit-book/edit-book.component.ts index 65d2ab9b..6c1c5161 100644 --- a/src/app/edit/edit-book/edit-book.component.ts +++ b/src/app/edit/edit-book/edit-book.component.ts @@ -1420,23 +1420,28 @@ export class EditBookComponent implements OnInit { this.working = true; console.log('this.value:', this.value); if (this.inData.bookIri === undefined) { - this.knoraService.createBook(this.value).subscribe( - res => { - console.log('CREATE_RESULT:', res); - this.working = false; - this.location.back(); - }, - error => { - this.snackBar.open('Error storing the passage object!', 'OK'); - console.log('EditCompany.save(): ERROR', error); - this.working = false; - this.location.back(); - } - ); + if (this.form.valid) { + this.knoraService.createBook(this.value).subscribe( + res => { + console.log('CREATE_RESULT:', res); + this.working = false; + this.location.back(); + }, + error => { + this.snackBar.open('Error storing the passage object!', 'OK'); + console.log('EditCompany.save(): ERROR', error); + this.working = false; + this.location.back(); + } + ); + } else { + this.snackBar.open('Invalid/incomplete data in form – Please check!', + 'OK', + {duration: 10000}); + this.working = false; + } } else { const obs: Array> = []; - console.log('this.valIds:', this.valIds); - if (this.valIds.label.changed) { const gaga: Observable = this.knoraService.updateLabel( this.resId, diff --git a/src/app/edit/edit-company/edit-company.component.ts b/src/app/edit/edit-company/edit-company.component.ts index 1220d540..50221abd 100644 --- a/src/app/edit/edit-company/edit-company.component.ts +++ b/src/app/edit/edit-company/edit-company.component.ts @@ -389,6 +389,10 @@ export class EditCompanyComponent implements OnInit { onTouched = () => {}; + onSubmit() { + + } + _handleLinkInput(what: string, index?: number): void { switch(what) { case 'members': @@ -536,21 +540,27 @@ export class EditCompanyComponent implements OnInit { save(): void { this.working = true; - console.log('this.value:', this.value); if (this.inData.companyIri === undefined) { - this.knoraService.createCompany(this.value).subscribe( - res => { - console.log('CREATE_RESULT:', res); - this.working = false; - this.location.back(); - }, - error => { - this.snackBar.open('Error storing the company object!', 'OK'); - console.log('EditCompany.save(): ERROR', error); - this.working = false; - this.location.back(); - } - ); + if (this.form.valid) { + this.knoraService.createCompany(this.value).subscribe( + res => { + console.log('CREATE_RESULT:', res); + this.working = false; + this.location.back(); + }, + error => { + this.snackBar.open('Error storing the company object!', 'OK'); + console.log('EditCompany.save(): ERROR', error); + this.working = false; + this.location.back(); + } + ); + } else { + this.snackBar.open('Invalid/incomplete data in form – Please check!', + 'OK', + {duration: 10000}); + this.working = false; + } } else { const obs: Array> = []; diff --git a/src/app/edit/edit-lexia/edit-lexia.component.ts b/src/app/edit/edit-lexia/edit-lexia.component.ts index 1d3b262b..ea70d40b 100644 --- a/src/app/edit/edit-lexia/edit-lexia.component.ts +++ b/src/app/edit/edit-lexia/edit-lexia.component.ts @@ -525,21 +525,27 @@ export class EditLexiaComponent implements OnInit { save(): void { this.working = true; - console.log('this.value:', this.value); if (this.inData.lexiaIri === undefined) { - this.knoraService.createLexia(this.value).subscribe( - res => { - console.log('CREATE_RESULT:', res); - this.working = false; - this.location.back(); - }, - error => { - this.snackBar.open('Error storing the lexia object!', 'OK'); - console.log('EditLexia.save(): ERROR', error); - this.working = false; - this.location.back(); - } - ); + if (this.form.valid) { + this.knoraService.createLexia(this.value).subscribe( + res => { + console.log('CREATE_RESULT:', res); + this.working = false; + this.location.back(); + }, + error => { + this.snackBar.open('Error storing the lexia object!', 'OK'); + console.log('EditLexia.save(): ERROR', error); + this.working = false; + this.location.back(); + } + ); + } else { + this.snackBar.open('Invalid/incomplete data in form – Please check!', + 'OK', + {duration: 10000}); + this.working = false; + } } else { const obs: Array> = []; diff --git a/src/app/edit/edit-passage/edit-passage.component.ts b/src/app/edit/edit-passage/edit-passage.component.ts index 09460daa..3f3423d8 100644 --- a/src/app/edit/edit-passage/edit-passage.component.ts +++ b/src/app/edit/edit-passage/edit-passage.component.ts @@ -1224,21 +1224,27 @@ export class EditPassageComponent implements OnInit { save(): void { this.working = true; - console.log('this.value:', this.value); if (this.inData.passageIri === undefined) { - this.knoraService.createPassage(this.value).subscribe( - res => { - console.log('CREATE_RESULT:', res); - this.working = false; - this.location.back(); - }, - error => { - this.snackBar.open('Error storing the passage object!', 'OK'); - console.log('EditCompany.save(): ERROR', error); - this.working = false; - this.location.back(); - } - ); + if (this.form.valid) { + this.knoraService.createPassage(this.value).subscribe( + res => { + console.log('CREATE_RESULT:', res); + this.working = false; + this.location.back(); + }, + error => { + this.snackBar.open('Error storing the passage object!', 'OK'); + console.log('EditCompany.save(): ERROR', error); + this.working = false; + this.location.back(); + } + ); + } else { + this.snackBar.open('Invalid/incomplete data in form – Please check!', + 'OK', + {duration: 10000}); + this.working = false; + } } else { const obs: Array> = []; diff --git a/src/app/edit/edit-person/edit-person.component.ts b/src/app/edit/edit-person/edit-person.component.ts index 7e281108..7e508fa0 100644 --- a/src/app/edit/edit-person/edit-person.component.ts +++ b/src/app/edit/edit-person/edit-person.component.ts @@ -581,24 +581,28 @@ export class EditPersonComponent implements OnInit { save(): void { this.working = true; - console.log('this.value:', this.value); if (this.inData.personIri === undefined) { - this.knoraService.createPerson(this.value).subscribe( - res => { - console.log('CREATE_RESULT:', res); - this.working = false; - this.location.back(); - }, - error => { - this.snackBar.open('Error storing the person object!', 'OK'); - console.log('EditPerson.save(): ERROR', error); - this.working = false; - this.location.back(); - } - ); + if (this.form.valid) { + this.knoraService.createPerson(this.value).subscribe( + res => { + console.log('CREATE_RESULT:', res); + this.working = false; + this.location.back(); + }, + error => { + this.snackBar.open('Error storing the person object!', 'OK'); + console.log('EditPerson.save(): ERROR', error); + this.working = false; + this.location.back(); + } + ); + } else { + this.snackBar.open('Invalid/incomplete data in form – Please check!', + 'OK', + {duration: 10000}); + this.working = false; + } } else { - console.log('this.valIds:', this.valIds); - const obs: Array> = []; if (this.valIds.label.changed) { diff --git a/src/app/edit/edit-venue/edit-venue.component.ts b/src/app/edit/edit-venue/edit-venue.component.ts index baf1a615..92e75e82 100644 --- a/src/app/edit/edit-venue/edit-venue.component.ts +++ b/src/app/edit/edit-venue/edit-venue.component.ts @@ -424,21 +424,27 @@ export class EditVenueComponent implements OnInit { save(): void { this.working = true; - console.log('this.value:', this.value); if (this.inData.venueIri === undefined) { - this.knoraService.createVenue(this.value).subscribe( - res => { - console.log('CREATE_RESULT:', res); - this.working = false; - this.location.back(); - }, - error => { - this.snackBar.open('Error storing the venue object!', 'OK'); - console.log('EditVenue.save(): ERROR', error); - this.working = false; - this.location.back(); - } - ); + if (this.form.valid) { + this.knoraService.createVenue(this.value).subscribe( + res => { + console.log('CREATE_RESULT:', res); + this.working = false; + this.location.back(); + }, + error => { + this.snackBar.open('Error storing the venue object!', 'OK'); + console.log('EditVenue.save(): ERROR', error); + this.working = false; + this.location.back(); + } + ); + } else { + this.snackBar.open('Invalid/incomplete data in form – Please check!', + 'OK', + {duration: 10000}); + this.working = false; + } } else { const obs: Array> = [];