Skip to content

Commit

Permalink
Added missing types and fixed issues that were hidden because of this
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Apr 29, 2024
1 parent da76367 commit 6cf25f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ItemType } from '../../../../core/shared/item-relationships/item-type.m
import { DsDynamicLookupRelationModalComponent } from '../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component';
import { RelationshipOptions } from '../../../../shared/form/builder/models/relationship-options.model';
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
import { SearchResult } from '../../../../shared/search/models/search-result.model';
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { PaginatedList } from '../../../../core/data/paginated-list.model';
import { RemoteData } from '../../../../core/data/remote-data';
Expand Down Expand Up @@ -236,11 +236,11 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
modalComp.collection = collection;
});

modalComp.select = (...selectableObjects: SearchResult<Item>[]) => {
modalComp.select = (...selectableObjects: ItemSearchResult[]) => {
selectableObjects.forEach((searchResult) => {
const relatedItem: Item = searchResult.indexableObject;

const foundIndex = modalComp.toRemove.findIndex( el => el.uuid === relatedItem.uuid);
const foundIndex = modalComp.toRemove.findIndex((itemSearchResult: ItemSearchResult) => itemSearchResult.indexableObject.uuid === relatedItem.uuid);

if (foundIndex !== -1) {
modalComp.toRemove.splice(foundIndex,1);
Expand All @@ -264,7 +264,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
}
});
};
modalComp.deselect = (...selectableObjects: SearchResult<Item>[]) => {
modalComp.deselect = (...selectableObjects: ItemSearchResult[]) => {
selectableObjects.forEach((searchResult) => {
const relatedItem: Item = searchResult.indexableObject;

Expand All @@ -281,10 +281,9 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {


modalComp.submitEv = () => {
const subscriptions: Observable<RelationshipIdentifiable>[] = [];

const subscriptions = [];

modalComp.toAdd.forEach((searchResult: SearchResult<Item>) => {
modalComp.toAdd.forEach((searchResult: ItemSearchResult) => {
const relatedItem = searchResult.indexableObject;
subscriptions.push(this.relationshipService.getNameVariant(this.listId, relatedItem.uuid).pipe(
map((nameVariant) => {
Expand All @@ -301,7 +300,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
});

modalComp.toRemove.forEach( (searchResult) => {
subscriptions.push(this.relationshipService.getNameVariant(this.listId, searchResult.indexableObjectuuid).pipe(
subscriptions.push(this.relationshipService.getNameVariant(this.listId, searchResult.indexableObject.uuid).pipe(
switchMap((nameVariant) => {
return this.getRelationFromId(searchResult.indexableObject).pipe(
map( (relationship: Relationship) => {
Expand Down Expand Up @@ -358,11 +357,11 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
this.selectableListService.deselectAll(this.listId);
}

getRelationFromId(relatedItem) {
getRelationFromId(relatedItem: Item): Observable<Relationship> {
return this.currentItemIsLeftItem$.pipe(
take(1),
switchMap( isLeft => {
let apiCall;
switchMap((isLeft: boolean) => {
let apiCall: Observable<PaginatedList<Relationship>>;
if (isLeft) {
apiCall = this.relationshipService.searchByItemsAndType( this.relationshipType.id, this.item.uuid, this.relationshipType.leftwardType ,[relatedItem.id] ).pipe(
getFirstSucceededRemoteData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { RemoteDataBuildService } from '../../../../../core/cache/builders/remot
import { getAllSucceededRemoteDataPayload } from '../../../../../core/shared/operators';
import { followLink } from '../../../../utils/follow-link-config.model';
import { RelationshipType } from '../../../../../core/shared/item-relationships/relationship-type.model';
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';

@Component({
selector: 'ds-dynamic-lookup-relation-modal',
Expand Down Expand Up @@ -141,12 +142,12 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
/**
* Maintain the list of the related items to be added
*/
toAdd = [];
toAdd: ItemSearchResult[] = [];

/**
* Maintain the list of the related items to be removed
*/
toRemove = [];
toRemove: ItemSearchResult[] = [];

/**
* Disable buttons while the submit button is pressed
Expand Down

0 comments on commit 6cf25f3

Please sign in to comment.