diff --git a/projects/laji/src/app/+observation/annotations/annotation-item/annotation-item.component.ts b/projects/laji/src/app/+observation/annotations/annotation-item/annotation-item.component.ts index f1b9a6a9b..797bca89e 100644 --- a/projects/laji/src/app/+observation/annotations/annotation-item/annotation-item.component.ts +++ b/projects/laji/src/app/+observation/annotations/annotation-item/annotation-item.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Input } from '@angular/core'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-annotation-item', diff --git a/projects/laji/src/app/+observation/annotations/annotations-list/annotations-list.component.ts b/projects/laji/src/app/+observation/annotations/annotations-list/annotations-list.component.ts index 6bf7398c8..40016c857 100644 --- a/projects/laji/src/app/+observation/annotations/annotations-list/annotations-list.component.ts +++ b/projects/laji/src/app/+observation/annotations/annotations-list/annotations-list.component.ts @@ -2,8 +2,9 @@ import { Component, Input, OnInit } from '@angular/core'; import { PagedResult } from '../../../shared/model/PagedResult'; import {TranslateService} from '@ngx-translate/core'; import { DocumentViewerFacade } from '../../../shared-modules/document-viewer/document-viewer.facade'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-annotations-list', diff --git a/projects/laji/src/app/+observation/annotations/annotations.component.ts b/projects/laji/src/app/+observation/annotations/annotations.component.ts index 7663ecaf8..73c1b1a15 100644 --- a/projects/laji/src/app/+observation/annotations/annotations.component.ts +++ b/projects/laji/src/app/+observation/annotations/annotations.component.ts @@ -6,8 +6,10 @@ import { TranslateService } from '@ngx-translate/core'; import { WarehouseApi } from '../../shared/api/WarehouseApi'; import { PagedResult } from '../../shared/model/PagedResult'; import { AnnotationService } from '../../shared-modules/document-viewer/service/annotation.service'; -import { AnnotationTag } from '../../shared/model/AnnotationTag'; import { DeleteOwnDocumentService } from '../../shared/service/delete-own-document.service'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-annotations', @@ -51,13 +53,12 @@ export class AnnotationsComponent implements OnInit, OnChanges, OnDestroy { private translations: TranslateService, private cd: ChangeDetectorRef, private annotationService: AnnotationService, - private translate: TranslateService, private deleteOwnDocument: DeleteOwnDocumentService ) { } ngOnInit() { this.lang = this.translations.currentLang; - this.annotationTags$ = this.annotationService.getAllTags(this.lang); + this.annotationTags$ = this.annotationService.getAllTags(); this.subscriptionDeleteOwnDocument = this.deleteOwnDocument.childEventListner().subscribe(info => { this.childEvent = info; diff --git a/projects/laji/src/app/+project-form/form/document-form/document-form.facade.ts b/projects/laji/src/app/+project-form/form/document-form/document-form.facade.ts index 7b3aad165..da22483c6 100644 --- a/projects/laji/src/app/+project-form/form/document-form/document-form.facade.ts +++ b/projects/laji/src/app/+project-form/form/document-form/document-form.facade.ts @@ -19,13 +19,14 @@ import * as moment from 'moment'; import { LocalStorage } from 'ngx-webstorage'; import { Global } from 'projects/laji/src/environments/global'; import { Person } from '../../../shared/model/Person'; -import { Annotation } from '../../../shared/model/Annotation'; -import { LajiApi, LajiApiService } from '../../../shared/service/laji-api.service'; import { Logger } from '../../../shared/logger'; import { LajiFormUtil } from 'projects/laji/src/app/+project-form/form/laji-form/laji-form-util.service'; import equals from 'deep-equal'; import { ProjectFormService } from '../../../shared/service/project-form.service'; import { LajiApiClientBService } from 'projects/laji-api-client-b/src/laji-api-client-b.service'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type Annotation = components['schemas']['annotation']; export enum FormError { notFoundForm = 'notFoundForm', @@ -100,7 +101,6 @@ export class DocumentFormFacade { private formPermissionService: FormPermissionService, private namedPlacesService: NamedPlacesService, private documentStorage: DocumentStorage, - private lajiApi: LajiApiService, private logger: Logger, private projectFormService: ProjectFormService, private api: LajiApiClientBService @@ -508,7 +508,7 @@ export class DocumentFormFacade { return this.getAnnotations(documentID).pipe( shareReplay(), map((annotations) => (annotations || []).reduce((cumulative, current) => { - if ((current.byRole || [] as any[]).includes('MMAN.formAdmin')) { + if (current.byRole?.includes('MMAN.formAdmin')) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion cumulative[current.targetID!] = [current]; } @@ -526,10 +526,7 @@ export class DocumentFormFacade { this.annotationCache[cacheKey] = (!documentID || FormService.isTmpId(documentID)) ? of([]) - : this.lajiApi.getList( - LajiApi.Endpoints.annotations, - {personToken: this.userService.getToken(), rootID: documentID, pageSize: 100, page} - ).pipe( + : this.api.get('/annotations', { query: { rootID: documentID, pageSize: 100, page } }).pipe( mergeMap(result => (result.currentPage < result.lastPage) ? this.getAnnotations(documentID, result.currentPage + 1, [...results, ...result.results]) : of([...results, ...result.results])), diff --git a/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.html b/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.html index 431563573..814277e42 100644 --- a/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.html +++ b/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.html @@ -12,7 +12,7 @@
{{(expert ? 'annotation.addIdentificationExpert' : 'annotation.addIdentifica class="form-control input-sm taxon-input" name="opinion" [disabled]="unIdentifyable" - [required]="expert && (personRoleAnnotation===annotationRole.expert || personRoleAnnotation === 'MMAN.ictAdmin' ) && (annotation.addedTags.length > 0)" + [required]="expert && (personRoleAnnotation=== 'MMAN.expert' || personRoleAnnotation === 'MMAN.ictAdmin' ) && (annotation.addedTags.length > 0)" [(ngModel)]="annotation.identification.taxon" [luTypeahead]="taxonAutocomplete" [luTypeaheadOptionsLimit]="20" @@ -48,33 +48,34 @@
{{(expert ? 'annotation.addIdentificationExpert' : 'annotation.addIdentifica
-
+
-
{{ item.id | toQName | label }}
+
{{ item.id | toQName | label }}
-
+
-
{{ item.id | toQName | label }}
+
{{ item.id | toQName | label }}
-
+
-
{{ item.id | toQName | label }}
+
{{ item.id | toQName | label }}
-
+
-
{{ item.id | toQName | label }}
+
{{ item.id | toQName | label }}
@@ -84,9 +85,9 @@
{{(expert ? 'annotation.addIdentificationExpert' : 'annotation.addIdentifica
-
+
-
{{ item.id | toQName | label }}
+
{{ item.id | toQName | label }}
@@ -98,86 +99,19 @@
{{(expert ? 'annotation.addIdentificationExpert' : 'annotation.addIdentifica
-
{{ item.id | toQName | label }}
+
{{ item.id | toQName | label }}
-
In this type of annotation, you need to add at lest 1 check tag or a taxon
-
+
{{ 'annotation.taxonSpecifier' | translate }} {{ 'annotation.taxonSpecifierInfo' | translate }}
{{ 'annotation.taxonSpecifier' | translate }} {{ 'annotation.taxo (focus)="onFocus($event)" (blur)="onBlur($event)">
-
+
{{ 'MAN.atlasCode' | label }}
{{ 'MAN.notes' | label }}
-
diff --git a/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.ts b/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.ts index e334c80a1..075601a2f 100644 --- a/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.ts +++ b/projects/laji/src/app/shared-modules/annotations/annotation-form-new/annotation-form-new.component.ts @@ -1,14 +1,12 @@ import {map, mergeMap, switchMap } from 'rxjs/operators'; -import { Component, EventEmitter, Input, OnChanges, OnInit, +import { Component, EventEmitter, Input, OnInit, Output, ChangeDetectorRef, ElementRef, ViewChild, HostListener, ChangeDetectionStrategy, AfterContentChecked } from '@angular/core'; import { animate, style, transition, trigger } from '@angular/animations'; -import { Annotation } from '../../../shared/model/Annotation'; import { AnnotationService } from '../../document-viewer/service/annotation.service'; import { Observable, Subscription } from 'rxjs'; import { Logger } from '../../../shared/logger/logger.service'; import { TranslateService } from '@ngx-translate/core'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; import { Global } from '../../../../environments/global'; import { IdService } from '../../../shared/service/id.service'; import { LabelPipe } from '../../../shared/pipe/label.pipe'; @@ -20,13 +18,13 @@ import { TypeaheadMatch } from '../../../../../../laji-ui/src/lib/typeahead/type import { DialogService } from '../../../shared/service/dialog.service'; import { SelectStyle } from '../../select/metadata-select/metadata-select.component'; import { LajiApiClientBService } from 'projects/laji-api-client-b/src/laji-api-client-b.service'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +import { WithNonNullableKeys } from '../../../shared/service/util.service'; -export interface AnnotationFormAnnotation extends Annotation { - identification: Annotation.Identification; - addedTags: string[]; - removedTags: string[]; - atlasCode?: string; -} +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; + +export type AnnotationFormAnnotation = WithNonNullableKeys; interface AnnotationTaxonomy { id: string|null; @@ -37,7 +35,6 @@ interface AnnotationTaxonomy { scientificNameAuthorship: string|null; } - @Component({ selector: 'laji-annotation-form-new', templateUrl: './annotation-form-new.component.html', @@ -57,12 +54,12 @@ interface AnnotationTaxonomy { changeDetection: ChangeDetectionStrategy.OnPush }) -export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterContentChecked { +export class AnnotationFormNewComponent implements OnInit, AfterContentChecked { static readonly lang = ['en', 'fi', 'sv']; @Input() isEditor?: boolean; @Input() personID?: string; - @Input() personRoleAnnotation?: Annotation.AnnotationRoleEnum; + @Input() personRoleAnnotation?: Annotation['byRole']; @Input() annotations?: Annotation[]; @Input({ required: true }) annotation!: AnnotationFormAnnotation; @Input() identifying?: boolean; @@ -80,15 +77,13 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont error: any; unIdentifyable = false; sending = false; - needsAck?: boolean; - annotationAddadableTags$!: Observable; + annotationAddableTags$!: Observable; annotationRemovableTags$!: Observable; annotationSub?: Subscription; alertNotSpamVerified?: boolean; typeaheadLoading = false; - types = Annotation.TypeEnum; selectedOptions: string[] = []; - tmpTags?: Annotation[]; + tmpTags?: AnnotationTag[]; isFocusedTaxonComment: any; inputType: any; inputName: any; @@ -103,8 +98,6 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont currentTaxonName = ''; selectStyleBasic = SelectStyle.basic; annotationTagsObservation: Record = Global.annotationTags; - annotationRole = Annotation.AnnotationRoleEnum; - constructor( private annotationService: AnnotationService, @@ -162,10 +155,6 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont }); } - ngOnChanges() { - this.initAnnotation(); - } - select(event: TypeaheadMatch) { this.annotation.identification.taxonID = event.item.key; this.annotation.identification.taxon = event.item.autocompleteSelectedName; @@ -239,7 +228,7 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont verifyCurrentTaxon() { this.copyCurrentTaxon(); if (!this.annotation.addedTags.includes('MMAN.5')) { - this.addToAddTags({id: 'MMAN.5', quality: 'MMAN.typePositiveQuality'}); + this.addToAddTags({id: 'MMAN.5', type: 'MMAN.typePositiveQuality'}); } } @@ -292,30 +281,24 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont } initAnnotationTags() { - this.annotationAddadableTags$ = this.annotationService.getAllAddableTags(this.translate.currentLang).pipe( + this.annotationAddableTags$ = this.annotationService.getAllAddableTags().pipe( map(data => data.map(element => { if (element['id'] === 'MMAN.3') { - return { id: element['id'], quality: element['type'] as any, position: 1 }; + return { ...element, position: 1 }; } else { - return { id: element['id'], quality: element['type'] as any, position: 0 }; + return { ...element, position: 0 }; } })) ); - this.annotationRemovableTags$ = this.annotationService.getAllRemovableTags(this.translate.currentLang).pipe( + this.annotationRemovableTags$ = this.annotationService.getAllRemovableTags().pipe( map( data => data.filter( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - tag => this.labelPipe.transform((this.unit.interpretations.effectiveTags || []), 'warehouse').indexOf(tag['name']!) !== -1 ) + tag => this.labelPipe.transform((this.unit.interpretations.effectiveTags || []), 'warehouse').indexOf(tag['name']) !== -1 ) ) ); } - - initAnnotation() { - this.needsAck = this.annotations && this.annotations[0] && this.annotations[0].type !== Annotation.TypeEnum.TypeAcknowledged; - } - filterBasicForm() { this.annotation.removedTags = []; this.annotation.identification.taxonSpecifier = ''; @@ -347,7 +330,7 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont } this.sending = true; if (this.unIdentifyable) { - this.annotation.type = Annotation.TypeEnum.TypeUnidentifiable; + this.annotation.type = 'MAN.typeUnidentifiable'; } if (!this.expert) { @@ -378,8 +361,8 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont } - addToAddTags(value: { id: string; quality: string }) { - if ( value.quality === 'MMAN.typePositiveQuality' || value.quality === 'MMAN.typeNegativeQuality' || value.id === 'MMAN.3') { + addToAddTags(value: Pick) { + if ( value.type === 'MMAN.typePositiveQuality' || value.type === 'MMAN.typeNegativeQuality' || value.id === 'MMAN.3') { const index = this.annotation.addedTags.indexOf( this.findFirstTagNegativePositive(this.annotation.addedTags) ); @@ -413,7 +396,7 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont this.annotation.addedTags = [...this.annotation.addedTags]; } - checkInsideRemovableTags(value: { id: string; quality: string }) { + checkInsideRemovableTags(value: Pick) { this.annotationRemovableTags$.subscribe(data => { this.tmpTags = data; if (this.annotation.addedTags.indexOf('MMAN.5') === -1 && this.annotation.addedTags.indexOf('MMAN.8') === -1 @@ -478,7 +461,7 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont removeAllTagsByCategory(array: string[], category: string) { let index = array.length - 1; while (index >= 0) { - if (this.annotationTagsObservation[this.annotation.addedTags[index]].quality === category) { + if (this.annotationTagsObservation[this.annotation.addedTags[index]].type === category) { array.splice(index, 1); } @@ -512,9 +495,9 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont ( (this.annotation.identification.taxon === '' || this.annotation.identification.taxon === undefined) && (this.annotation.addedTags.indexOf('MMAN.5') !== -1 || this.annotation.addedTags.indexOf('MMAN.8') !== -1 || this.annotation.addedTags.indexOf('MMAN.9') !== -1) && - (this.personRoleAnnotation === this.annotationRole.expert) && this.expert && !this.isEditor) + (this.personRoleAnnotation === 'MMAN.expert') && this.expert && !this.isEditor) || - ((((this.personRoleAnnotation === this.annotationRole.expert) && !this.expert) || (this.personRoleAnnotation === this.annotationRole.basic && this.expert)) && + ((((this.personRoleAnnotation === 'MMAN.expert') && !this.expert) || (this.personRoleAnnotation === 'MMAN.basic' && this.expert)) && ((this.annotation.addedTags.length === 0 || (this.annotation.addedTags.length === 1 && (this.annotation.addedTags.indexOf('MMAN.5') !== -1 || this.annotation.addedTags.indexOf('MMAN.8') !== -1 || this.annotation.addedTags.indexOf('MMAN.9') !== -1) || (!checkTypeTagPasses)) || (this.annotation.addedTags.length > 1 && !checkTypeTagPasses)) && @@ -580,11 +563,11 @@ export class AnnotationFormNewComponent implements OnInit , OnChanges, AfterCont } if (this.expert && e.keyCode === 49 && e.altKey) { // alt + 1 --> add convincing - this.addToAddTags({id: 'MMAN.5', quality: 'MMAN.typePositiveQuality'}); + this.addToAddTags({id: 'MMAN.5', type: 'MMAN.typePositiveQuality'}); } if (this.expert && e.keyCode === 48 && e.altKey) { // alt + 0 --> add erroneus - this.addToAddTags({id: 'MMAN.8', quality: 'MMAN.typeNegativeQuality'}); + this.addToAddTags({id: 'MMAN.8', type: 'MMAN.typeNegativeQuality'}); } if (e.keyCode === 82 && e.altKey) { // alt + r --> delete all added tags diff --git a/projects/laji/src/app/shared-modules/annotations/annotation-list/annotation-list.component.ts b/projects/laji/src/app/shared-modules/annotations/annotation-list/annotation-list.component.ts index 179f4169e..949aef8e6 100644 --- a/projects/laji/src/app/shared-modules/annotations/annotation-list/annotation-list.component.ts +++ b/projects/laji/src/app/shared-modules/annotations/annotation-list/annotation-list.component.ts @@ -8,10 +8,11 @@ import { OnInit, Output } from '@angular/core'; -import { Annotation } from '../../../shared/model/Annotation'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; import { WarehousePipe } from '../../../shared/pipe/warehouse.pipe'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +type AnnotationTag = components['schemas']['tag']; +type AnnotationDW = components['schemas']['DwQuery_Annotation']; @Component({ selector: 'laji-annotation-list', @@ -22,15 +23,14 @@ import { WarehousePipe } from '../../../shared/pipe/warehouse.pipe'; }) export class AnnotationListComponent implements OnInit, OnDestroy, OnChanges { - @Input({ required: true }) annotations!: Annotation[]; + @Input({ required: true }) annotations!: AnnotationDW[]; @Input() personID?: string; @Input() showLinks = true; @Input() lastAnnotationAddedId?: string; - @Input() effectiveTags?: Annotation[]; + @Input() effectiveTags?: AnnotationTag[]; @Input() annotationTags?: AnnotationTag[] | null; - @Output() remove = new EventEmitter(); + @Output() remove = new EventEmitter(); - types = Annotation.TypeEnum; lastFalse?: number; hasNextTrue?: boolean; open?: boolean[] = undefined; @@ -69,7 +69,7 @@ export class AnnotationListComponent implements OnInit, OnDestroy, OnChanges { this.populateArrayShowItem(this.annotations); } - populateArrayShowItem(array: Annotation[]) { + populateArrayShowItem(array: AnnotationDW[]) { const showItem: boolean[] = []; array.forEach(element => { if (element['deleted'] || !element['valid']) { @@ -81,7 +81,7 @@ export class AnnotationListComponent implements OnInit, OnDestroy, OnChanges { this.showItem = showItem; } - findLastIndex(annotation: Annotation[], field: keyof Annotation, value: any) { + findLastIndex(annotation: AnnotationDW[], field: keyof AnnotationDW, value: any) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion annotation.sort((a, b) => (a.created! > b.created!) ? 1 : -1); const index = annotation.slice().reverse().findIndex(x => (x[field] === value && x['deleted'] === false)); diff --git a/projects/laji/src/app/shared-modules/annotations/annotations.component.html b/projects/laji/src/app/shared-modules/annotations/annotations.component.html index 06804cc46..2a37da35c 100644 --- a/projects/laji/src/app/shared-modules/annotations/annotations.component.html +++ b/projects/laji/src/app/shared-modules/annotations/annotations.component.html @@ -12,7 +12,7 @@
- +
{{ 'vihko.home.form.trip.1' | translate}} diff --git a/projects/laji/src/app/shared-modules/annotations/annotations.component.ts b/projects/laji/src/app/shared-modules/annotations/annotations.component.ts index 55f79c869..d6d74ab04 100644 --- a/projects/laji/src/app/shared-modules/annotations/annotations.component.ts +++ b/projects/laji/src/app/shared-modules/annotations/annotations.component.ts @@ -1,7 +1,6 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ChangeDetectionStrategy, ChangeDetectorRef, OnDestroy } from '@angular/core'; import { AnnotationService } from '../document-viewer/service/annotation.service'; -import { Annotation } from '../../shared/model/Annotation'; import { IdService } from '../../shared/service/id.service'; import { DocumentViewerFacade } from '../document-viewer/document-viewer.facade'; import { @@ -16,8 +15,12 @@ import { WarehouseApi } from '../../shared/api/WarehouseApi'; import { TaxonTagEffectiveService } from '../document-viewer/taxon-tag-effective.service'; import { LoadingElementsService } from '../document-viewer/loading-elements.service'; import { PlatformService } from '../../root/platform.service'; -import { AnnotationTag } from '../../shared/model/AnnotationTag'; import { TranslateService } from '@ngx-translate/core'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +import { Unsaved } from '../../shared/service/util.service'; + +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-annotations', @@ -32,7 +35,7 @@ export class AnnotationsComponent implements OnInit, OnDestroy { @Input() documentID?: string; @Input() isEditor?: boolean; @Input() personID?: string; - @Input() personRoleAnnotation?: Annotation.AnnotationRoleEnum; + @Input() personRoleAnnotation?: Annotation['byRole']; @Input() identifying? = false; @Input() unit: any; @Input() gathering: any; @@ -49,9 +52,8 @@ export class AnnotationsComponent implements OnInit, OnDestroy { error = false; adding = false; expert = true; - type?: Annotation.TypeEnum; - annotation!: AnnotationFormAnnotation; - annotationRole = Annotation.AnnotationRoleEnum; + type?: Annotation['type']; + annotation!: Unsaved; loading = false; lastAnnotationAddedId?: string; result: PagedResult = { @@ -128,7 +130,7 @@ export class AnnotationsComponent implements OnInit, OnDestroy { addedTags: [], removedTags: [], deleted: false, - type: Annotation.TypeEnum.TypeOpinion, + type: 'MAN.typeOpinion', occurrenceAtTimeOfAnnotation: { countryVerbatim: this.gathering && this.gathering.country ? this.gathering.country : '', dateBegin: this.gathering && this.gathering.eventDate && this.gathering.eventDate.begin ? this.gathering.eventDate.begin : '', @@ -180,10 +182,10 @@ export class AnnotationsComponent implements OnInit, OnDestroy { this.loadingElements.emitChildEvent(true); this.annotationService.delete(annotation) .subscribe( - (data: Annotation) => { - const foundIndex = this.annotations.findIndex(x => IdService.getId(x.id) === IdService.getId(data.id)); - this.annotations[foundIndex] = data; - this.saveDone(data); + (updatedAnnotation) => { + const foundIndex = this.annotations.findIndex(x => IdService.getId(x.id) === IdService.getId(updatedAnnotation.id)); + this.annotations[foundIndex] = updatedAnnotation; + this.saveDone(updatedAnnotation); }, (e) => { this.loading = false; diff --git a/projects/laji/src/app/shared-modules/document-viewer/document-annotation/document-annotation.component.ts b/projects/laji/src/app/shared-modules/document-viewer/document-annotation/document-annotation.component.ts index 9a30cf011..993add586 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/document-annotation/document-annotation.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/document-annotation/document-annotation.component.ts @@ -22,8 +22,6 @@ import { SessionStorage } from 'ngx-webstorage'; import { IdService } from '../../../shared/service/id.service'; import { isIctAdmin, UserService } from '../../../shared/service/user.service'; import { Global } from '../../../../environments/global'; -import { Annotation } from '../../../shared/model/Annotation'; -import { Person } from '../../../shared/model/Person'; import { DocumentViewerChildComunicationService } from '../document-viewer-child-comunication.service'; import { TaxonTagEffectiveService } from '../taxon-tag-effective.service'; import { LoadingElementsService } from '../loading-elements.service'; @@ -31,12 +29,13 @@ import { CheckFocusService } from '../check-focus.service'; import { TranslateService } from '@ngx-translate/core'; import { AnnotationService } from '../service/annotation.service'; import { DocumentToolsService } from '../document-tools.service'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; import { TemplateForm } from '../../own-submissions/models/template-form'; -import { Router } from '@angular/router'; -import { LocalizeRouterService } from '../../../locale/localize-router.service'; import { DeleteOwnDocumentService } from '../../../shared/service/delete-own-document.service'; import { DocumentPermissionService } from '../service/document-permission.service'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-document-annotation', @@ -76,7 +75,7 @@ export class DocumentAnnotationComponent implements AfterViewInit, OnChanges, On documentID?: string; personID?: string; isEditor = false; - personRoleAnnotation?: Annotation.AnnotationRoleEnum; + personRoleAnnotation?: Annotation['byRole']; activeGathering: any; mapData: any = []; hasMapData = false; @@ -123,18 +122,16 @@ export class DocumentAnnotationComponent implements AfterViewInit, OnChanges, On private translate: TranslateService, private documentToolsService: DocumentToolsService, private annotationService: AnnotationService, - private router: Router, - private localizeRouterService: LocalizeRouterService, private deleteDocumentService: DeleteOwnDocumentService, private documentPermissionService: DocumentPermissionService ) { } ngOnInit() { - this.annotationTags$ = this.annotationService.getAllTags(this.translate.currentLang); + this.annotationTags$ = this.annotationService.getAllTags(); this.currentLang = this.translate.currentLang; this.metaFetch = this.userService.user$.subscribe(person => { if (!person) { - this.personRoleAnnotation = Annotation.AnnotationRoleEnum.basic; + this.personRoleAnnotation = 'MMAN.basic'; this.cd.markForCheck(); return; } @@ -142,12 +139,12 @@ export class DocumentAnnotationComponent implements AfterViewInit, OnChanges, On this.personID = person.id; if (isIctAdmin(person)) { - this.personRoleAnnotation = Annotation.AnnotationRoleEnum.expert; + this.personRoleAnnotation = 'MMAN.expert'; } else { if (person.roleAnnotation) { this.personRoleAnnotation = person.roleAnnotation; } else { - this.personRoleAnnotation = Annotation.AnnotationRoleEnum.basic; + this.personRoleAnnotation = 'MMAN.basic'; } } @@ -395,10 +392,6 @@ export class DocumentAnnotationComponent implements AfterViewInit, OnChanges, On this.deleteDocumentService.emitChildEvent(e); this.closeDocument(); this.deleteDocumentService.emitChildEvent(null); - - /*this.router.navigate( - this.localizeRouterService.translateRoute(['/vihko/ownSubmissions/']) - );*/ } } diff --git a/projects/laji/src/app/shared-modules/document-viewer/document/document.component.ts b/projects/laji/src/app/shared-modules/document-viewer/document/document.component.ts index 0ad1e2692..5d725731a 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/document/document.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/document/document.component.ts @@ -21,12 +21,10 @@ import { SessionStorage } from 'ngx-webstorage'; import { IdService } from '../../../shared/service/id.service'; import { UserService } from '../../../shared/service/user.service'; import { Global } from '../../../../environments/global'; -import { TranslateService } from '@ngx-translate/core'; import { DocumentViewerChildComunicationService } from '../document-viewer-child-comunication.service'; import { TaxonTagEffectiveService } from '../taxon-tag-effective.service'; import { DocumentToolsService } from '../document-tools.service'; import { AnnotationService } from '../service/annotation.service'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; import { TemplateForm } from '../../own-submissions/models/template-form'; import { Router } from '@angular/router'; import { LocalizeRouterService } from '../../../locale/localize-router.service'; @@ -35,6 +33,9 @@ import { HistoryService } from '../../../shared/service/history.service'; import { DocumentPermissionService } from '../service/document-permission.service'; import { FormService } from '../../../shared/service/form.service'; import { Form } from '../../../shared/model/Form'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-document', @@ -96,7 +97,6 @@ export class DocumentComponent implements AfterViewInit, OnChanges, OnInit, OnDe private taxonTagEffective: TaxonTagEffectiveService, private annotationService: AnnotationService, private documentToolsService: DocumentToolsService, - private translate: TranslateService, private router: Router, private localizeRouterService: LocalizeRouterService, private deleteDocumentService: DeleteOwnDocumentService, @@ -106,7 +106,7 @@ export class DocumentComponent implements AfterViewInit, OnChanges, OnInit, OnDe ) { } ngOnInit() { - this.annotationTags$ = this.annotationService.getAllTags(this.translate.currentLang); + this.annotationTags$ = this.annotationService.getAllTags(); this.childComunicationsubscription = this.childComunication.childEventListner().subscribe(info => { this.childEvent = info; diff --git a/projects/laji/src/app/shared-modules/document-viewer/gathering-annotation/gathering-annotation.component.ts b/projects/laji/src/app/shared-modules/document-viewer/gathering-annotation/gathering-annotation.component.ts index 041fd8e47..bf27c89a5 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/gathering-annotation/gathering-annotation.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/gathering-annotation/gathering-annotation.component.ts @@ -1,12 +1,13 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, OnDestroy} from '@angular/core'; import { animate, style, transition, trigger } from '@angular/animations'; -import { Annotation } from '../../../shared/model/Annotation'; -import { Subject, Subscription } from 'rxjs'; +import { Subject } from 'rxjs'; import { LoadingElementsService } from '../loading-elements.service'; import { TaxonTagEffectiveService } from '../taxon-tag-effective.service'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-gathering-annotation', @@ -26,7 +27,7 @@ export class GatheringAnnotationComponent implements OnDestroy { @Input() isEditor?: boolean; @Input() personID?: string; - @Input() personRoleAnnotation?: Annotation.AnnotationRoleEnum; + @Input() personRoleAnnotation?: Annotation['byRole']; @Input({ required: true }) documentID!: string; @Input() createdDate: any; @Input() loadDate?: string; diff --git a/projects/laji/src/app/shared-modules/document-viewer/gathering/gathering.component.ts b/projects/laji/src/app/shared-modules/document-viewer/gathering/gathering.component.ts index e3c44e3dc..5cac6d425 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/gathering/gathering.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/gathering/gathering.component.ts @@ -1,7 +1,9 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, OnInit, OnDestroy} from '@angular/core'; import { TaxonTagEffectiveService } from '../taxon-tag-effective.service'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-gathering', diff --git a/projects/laji/src/app/shared-modules/document-viewer/observation-effective-tags-taxon/observation-effective-tags-taxon.component.ts b/projects/laji/src/app/shared-modules/document-viewer/observation-effective-tags-taxon/observation-effective-tags-taxon.component.ts index 2b9b1612f..e27d45628 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/observation-effective-tags-taxon/observation-effective-tags-taxon.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/observation-effective-tags-taxon/observation-effective-tags-taxon.component.ts @@ -3,11 +3,12 @@ import { Subject, Subscription, of, from, Observable } from 'rxjs'; import { LoadingElementsService } from '../loading-elements.service'; import { ToQNamePipe } from '../../../shared/pipe/to-qname.pipe'; import { AnnotationService } from '../service/annotation.service'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; import { WarehousePipe } from '../../../shared/pipe/warehouse.pipe'; import { WarehouseValueMappingService } from '../../../shared/service/warehouse-value-mapping.service'; -import { TranslateService } from '@ngx-translate/core'; import { switchMap, toArray, concatMap } from 'rxjs/operators'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-observation-effective-tags-taxon', @@ -37,7 +38,6 @@ export class ObservationEffectiveTagsTaxonComponent implements OnInit, OnDestroy private toQname: ToQNamePipe, private loadingElements: LoadingElementsService, private annotationService: AnnotationService, - private translate: TranslateService, private warehouseValueMappingService: WarehouseValueMappingService ) { } @@ -48,7 +48,7 @@ export class ObservationEffectiveTagsTaxonComponent implements OnInit, OnDestroy switchMap(keys => this.annotationTags ? of(this.annotationTags.filter(item => keys.includes(item.id))) : from(keys).pipe( - concatMap(key => this.annotationService.getTag(key, this.translate.currentLang)), + concatMap(key => this.annotationService.getTag(key)), toArray() ) ) diff --git a/projects/laji/src/app/shared-modules/document-viewer/service/annotation.service.ts b/projects/laji/src/app/shared-modules/document-viewer/service/annotation.service.ts index 5bbbe7971..e7ce8a9c1 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/service/annotation.service.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/service/annotation.service.ts @@ -1,76 +1,69 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { Annotation } from '../../../shared/model/Annotation'; import { isIctAdmin, UserService } from '../../../shared/service/user.service'; -import { IdService } from '../../../shared/service/id.service'; -import { LajiApi, LajiApiService } from '../../../shared/service/laji-api.service'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; import { AbstractCachedHttpService } from '../../../shared/service/abstract-cached-http.service'; import { map, switchMap, take } from 'rxjs/operators'; -import { MultiLangService } from '../../lang/service/multi-lang.service'; +import { LajiApiClientBService } from 'projects/laji-api-client-b/src/laji-api-client-b.service'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; +import { IdService } from '../../../shared/service/id.service'; + +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; @Injectable({providedIn: 'root'}) export class AnnotationService extends AbstractCachedHttpService { constructor( - private lajiApi: LajiApiService, - private userService: UserService + private userService: UserService, + private api: LajiApiClientBService ) { super(); } - delete(annotation: Annotation): Observable { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return this.lajiApi.remove(LajiApi.Endpoints.annotations, IdService.getId(annotation.id!), {personToken: this.userService.getToken()}); + delete(annotation: Annotation) { + return this.api.delete('/annotations/{id}', { path: { id: IdService.getId(annotation.id)! } }); } save(annotation: Annotation): Observable { - return this.lajiApi.post(LajiApi.Endpoints.annotations, annotation, {personToken: this.userService.getToken()}); + return this.api.post('/annotations', undefined, annotation); } - getTag(id: string, lang: string): Observable { - return this.getAllTags(lang).pipe( + getTag(id: string): Observable { + return this.getAllTags().pipe( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion map(tags => tags.find(t => t.id === id)!) ); } - getAllTags(lang: string): Observable { - return this.fetchList(this.lajiApi.getList(LajiApi.Endpoints.annotationsTags, {lang: 'multi'}), 'multi').pipe( - map(tags => tags.map(t => ({ - ...t, - name: MultiLangService.getValue(t.name as any, lang), - description: MultiLangService.getValue(t.description as any, lang) - }))) - ); + getAllTags(): Observable { + return this.api.get('/annotations/tags').pipe(map(({results}) => Object.values(results))); } - getAllAddableTags(lang: string, own = false): Observable { - return this.annotatorsTags('requiredRolesAdd', lang, own); + getAllAddableTags(own = false): Observable { + return this.annotatorsTags('requiredRolesAdd', own); } - getAllRemovableTags(lang: string, own = false): Observable { - return this.annotatorsTags('requiredRolesRemove', lang, own); + getAllRemovableTags(own = false): Observable { + return this.annotatorsTags('requiredRolesRemove', own); } private annotatorsTags( type: keyof Pick, - lang: string, own: boolean ): Observable { return this.userService.user$.pipe( take(1), map(user => { if (own) { - return [Annotation.AnnotationRoleEnum.owner]; + return ['MMAN.owner']; } - const roles = [((user && user.roleAnnotation) || Annotation.AnnotationRoleEnum.basic)]; + const roles = [((user && user.roleAnnotation) || 'MMAN.basic')]; if (isIctAdmin(user)) { - roles.push(Annotation.AnnotationRoleEnum.ictAdmin); + roles.push('MMAN.ictAdmin'); } return roles; }), - switchMap(annotatorsRole => this.getAllTags(lang).pipe( + switchMap(annotatorsRole => this.getAllTags().pipe( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion map(tags => tags.filter(tag => tag[type] && tag[type]!.some(r => annotatorsRole.includes(r)))) )) diff --git a/projects/laji/src/app/shared-modules/document-viewer/unit-annotation-list/unit-annotation-list.component.ts b/projects/laji/src/app/shared-modules/document-viewer/unit-annotation-list/unit-annotation-list.component.ts index 525e74d7d..45a8be819 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/unit-annotation-list/unit-annotation-list.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/unit-annotation-list/unit-annotation-list.component.ts @@ -2,8 +2,10 @@ import { Component, Input, OnInit, Output, EventEmitter, OnDestroy, ChangeDetectionStrategy} from '@angular/core'; import { ToQNamePipe } from '../../../shared/pipe/to-qname.pipe'; import { IdService } from '../../../shared/service/id.service'; -import { Annotation } from '../../../shared/model/Annotation'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-unit-annotation-list', @@ -14,7 +16,7 @@ import { AnnotationTag } from '../../../shared/model/AnnotationTag'; export class UnitAnnotationListComponent implements OnInit, OnDestroy { @Input() isEditor?: boolean; @Input() personID?: string; - @Input() personRoleAnnotation?: Annotation.AnnotationRoleEnum; + @Input() personRoleAnnotation?: Annotation['byRole']; @Input({ required: true }) documentID!: string; @Input() unit: any; @Input() gathering: any; diff --git a/projects/laji/src/app/shared-modules/document-viewer/unit/unit.component.ts b/projects/laji/src/app/shared-modules/document-viewer/unit/unit.component.ts index e3bc0b5ef..b3a5b1760 100644 --- a/projects/laji/src/app/shared-modules/document-viewer/unit/unit.component.ts +++ b/projects/laji/src/app/shared-modules/document-viewer/unit/unit.component.ts @@ -4,7 +4,9 @@ import { ToQNamePipe } from '../../../shared/pipe/to-qname.pipe'; import { IdService } from '../../../shared/service/id.service'; import { Annotation } from '../../../shared/model/Annotation'; import { DocumentViewerFacade } from '../document-viewer.facade'; -import { AnnotationTag } from '../../../shared/model/AnnotationTag'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type AnnotationTag = components['schemas']['tag']; @Component({ selector: 'laji-unit', diff --git a/projects/laji/src/app/shared-modules/select/metadata-select/metadata-select.component.ts b/projects/laji/src/app/shared-modules/select/metadata-select/metadata-select.component.ts index 2896d6507..db38e7d7e 100644 --- a/projects/laji/src/app/shared-modules/select/metadata-select/metadata-select.component.ts +++ b/projects/laji/src/app/shared-modules/select/metadata-select/metadata-select.component.ts @@ -229,9 +229,9 @@ export class MetadataSelectComponent implements OnChanges, OnDestroy, ControlVal this._shouldSort = true; switch (this.field) { case 'MMAN.tag': - return this.annotationService.getAllTags('multi').pipe( + return this.annotationService.getAllTags().pipe( map(tags => tags.filter(t => !t.requiredRolesAdd || !t.requiredRolesAdd.includes(Annotation.AnnotationRoleEnum.formAdmin))), - map(tags => tags.map(t => ({id: t.id, value: MultiLangService.getValue(t.name as any, this.lang)}))) + map(tags => tags.map(t => ({ id: t.id, value: t.name }))) ); case 'MY.collectionID': return this.collectionService.getAll$(this.lang, true); diff --git a/projects/laji/src/app/shared/model/Form.ts b/projects/laji/src/app/shared/model/Form.ts index 9e3b0c86b..640d7f19b 100644 --- a/projects/laji/src/app/shared/model/Form.ts +++ b/projects/laji/src/app/shared/model/Form.ts @@ -2,8 +2,10 @@ * Form interface */ import { Document } from './Document'; -import { Annotation } from './Annotation'; import { MultiLanguage } from './MultiLanguage'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type Annotation = components['schemas']['annotation']; export namespace Form { export enum PrintType { diff --git a/projects/laji/src/app/shared/pipe/unique.pipe.ts b/projects/laji/src/app/shared/pipe/unique.pipe.ts index fa261763c..8047e31f4 100644 --- a/projects/laji/src/app/shared/pipe/unique.pipe.ts +++ b/projects/laji/src/app/shared/pipe/unique.pipe.ts @@ -1,8 +1,11 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { Annotation } from '../model/Annotation'; -import { AnnotationTag } from '../model/AnnotationTag'; import { IdService } from '../service/id.service'; +import { components } from 'projects/laji-api-client-b/generated/api.d'; + +type Annotation = components['schemas']['annotation']; +type AnnotationTag = components['schemas']['tag']; + @Pipe({ name: 'activeTags', pure: false diff --git a/projects/laji/src/app/shared/service/laji-api.service.ts b/projects/laji/src/app/shared/service/laji-api.service.ts index 98e4c64d4..6e78c8843 100644 --- a/projects/laji/src/app/shared/service/laji-api.service.ts +++ b/projects/laji/src/app/shared/service/laji-api.service.ts @@ -9,14 +9,12 @@ import { Checklist } from '../model/Checklist'; import { PagedResult } from '../model/PagedResult'; import { Source } from '../model/Source'; import { Form } from '../model/Form'; -import { Annotation } from '../model/Annotation'; import { Notification } from '../model/Notification'; import { Information } from '../model/Information'; import { Publication } from '../model/Publication'; import { Feedback } from '../model/Feedback'; import { News } from '../model/News'; import { Image } from '../model/Image'; -import { AnnotationTag } from '../model/AnnotationTag'; import { Collection } from '../model/Collection'; import { Util } from './util.service'; import { components } from 'projects/laji-api-client-b/generated/api.d'; @@ -26,8 +24,6 @@ type Taxon = components['schemas']['Taxon']; export namespace LajiApi { export enum Endpoints { - annotationsTags = 'annotations/tags', - annotations = 'annotations', areas = 'areas', documentStats = 'documents/stats', checklists = 'checklists', @@ -72,13 +68,6 @@ export namespace LajiApi { langFallback?: boolean; } - export type AnnotationQuery = PersonToken; - - export interface AnnotationListQuery extends Paged, PersonToken { - rootID: string; - } - - export type AnnotationTagsQuery = LangWithFallback; export interface AreaQuery extends Lang, Paged { type?: LajiApi.AreaType; @@ -158,10 +147,6 @@ export namespace LajiApi { base64pdf: string; } - export type AnnotationTagListResponse = Array; - - export type AnnotationListResponse = PagedResult; - export type AreaListResponse = PagedResult; export type ChecklistListResponse = PagedResult; @@ -188,8 +173,6 @@ export class LajiApiService { constructor(private httpClient: HttpClient) { } - getList(endpoint: LajiApi.Endpoints.annotationsTags, query: LajiApi.Query.AnnotationTagsQuery): Observable; - getList(endpoint: LajiApi.Endpoints.annotations, query: LajiApi.Query.AnnotationListQuery): Observable; getList(endpoint: LajiApi.Endpoints.areas, query: LajiApi.Query.AreaQuery): Observable; getList(endpoint: LajiApi.Endpoints.checklists, query: LajiApi.Query.ChecklistQuery): Observable; getList(endpoint: LajiApi.Endpoints.collections, query: LajiApi.Query.CollectionQuery): Observable; @@ -218,7 +201,6 @@ export class LajiApiService { return this.httpClient.get(url, options); } - post(endpoint: LajiApi.Endpoints.annotations, data: Annotation, query: LajiApi.Query.AnnotationQuery): Observable; post(endpoint: LajiApi.Endpoints.feedback, data: Feedback, query: LajiApi.Query.FeedbackQuery): Observable; post(endpoint: LajiApi.Endpoints.htmlToPdf, data: any): Observable; post(endpoint: LajiApi.Endpoints, data: any, query: any = {}): Observable { @@ -227,9 +209,6 @@ export class LajiApiService { if (endpoint === LajiApi.Endpoints.htmlToPdf) { options['responseType'] = 'blob'; } - if (endpoint === LajiApi.Endpoints.annotations) { - options['headers'] = 'x-beta'; - } return this.httpClient.post( url, data, @@ -249,7 +228,6 @@ export class LajiApiService { } - remove(endpoint: LajiApi.Endpoints.annotations, id: string, query: LajiApi.Query.AnnotationQuery): Observable; remove(endpoint: LajiApi.Endpoints.notifications, id: string, query: LajiApi.Query.NotificationQuery): Observable; remove(endpoint: LajiApi.Endpoints, id: string, query: any = {}): Observable { const url = `${environment.apiBase}/${endpoint}/${id}`; diff --git a/projects/laji/src/app/shared/service/triplestore-label.service.ts b/projects/laji/src/app/shared/service/triplestore-label.service.ts index 9f8b8d07f..14022e8c3 100644 --- a/projects/laji/src/app/shared/service/triplestore-label.service.ts +++ b/projects/laji/src/app/shared/service/triplestore-label.service.ts @@ -120,10 +120,9 @@ export class TriplestoreLabelService { return this.sourceService.getName(key, lang); case 'MMAN': if (!TriplestoreLabelService.requestCache[key]) { - TriplestoreLabelService.requestCache[key] = this.annotationService.getTag(key, 'multi').pipe( + TriplestoreLabelService.requestCache[key] = this.annotationService.getTag(key).pipe( map(tag => tag.name), tap(name => TriplestoreLabelService.cache[key] = name), - map(name => MultiLangService.getValue((name as any), lang)), share() ); } diff --git a/projects/laji/src/app/shared/service/util.service.ts b/projects/laji/src/app/shared/service/util.service.ts index 0626aba81..56eb3e837 100644 --- a/projects/laji/src/app/shared/service/util.service.ts +++ b/projects/laji/src/app/shared/service/util.service.ts @@ -7,6 +7,19 @@ export type WithNonNullableKeys = T & { [P in K]-?: NonNullable; }; +type DeepOptionalKeys = + T extends Array + ? DeepOptionalKeys[] + : T extends object + ? { + [K in keyof T]?: K extends OptionalKeys + ? T[K] + : DeepOptionalKeys; + } + : T; + +export type Unsaved = DeepOptionalKeys; + export class Util { /** * Clones the object using JSON stringify