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 @@ diff --git a/src/app/edit/edit-book/edit-book.component.ts b/src/app/edit/edit-book/edit-book.component.ts index 04cc0e77..6c1c5161 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': @@ -1435,22 +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> = []; - 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 dabbae8f..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': @@ -434,26 +438,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 = []; @@ -550,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 256c4ed9..3f3423d8 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 = []; } @@ -1235,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 b5ee7aa5..7e508fa0 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 = []; @@ -594,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 0f81dbe5..92e75e82 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 { @@ -430,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> = []; 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: [