mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
bug fixing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ExternalSourceService } from './external-source.service';
|
||||
import { SearchService } from '../shared/search/search.service';
|
||||
import { concat, map, multicast, startWith, take, takeWhile } from 'rxjs/operators';
|
||||
import { concat, map, multicast, startWith, take, takeWhile, tap } from 'rxjs/operators';
|
||||
import { PaginatedSearchOptions } from '../../shared/search/paginated-search-options.model';
|
||||
import { ReplaySubject } from 'rxjs/internal/ReplaySubject';
|
||||
import { RemoteData } from './remote-data';
|
||||
@@ -51,6 +51,7 @@ export class LookupRelationService {
|
||||
if (setSearchConfig) {
|
||||
this.searchConfig = newConfig;
|
||||
}
|
||||
console.log(newConfig);
|
||||
return this.searchService.search(newConfig).pipe(
|
||||
/* Make sure to only listen to the first x results, until loading is finished */
|
||||
/* TODO: in Rxjs 6.4.0 and up, we can replace this with takeWhile(predicate, true) - see https://stackoverflow.com/a/44644237 */
|
||||
@@ -61,6 +62,7 @@ export class LookupRelationService {
|
||||
concat(subject.pipe(take(1)))
|
||||
)
|
||||
) as any
|
||||
,
|
||||
) as Observable<RemoteData<PaginatedList<SearchResult<Item>>>>;
|
||||
}
|
||||
|
||||
|
@@ -418,15 +418,4 @@ export class RelationshipService extends DataService<Relationship> {
|
||||
return update$;
|
||||
}
|
||||
|
||||
public toVirtualMetadata(relationship: Relationship, useLeft: boolean): MetadataValue {
|
||||
const metadataValue = new MetadataValue();
|
||||
metadataValue.authority = VIRTUAL_METADATA_PREFIX + relationship.id;
|
||||
// What if there's no name variant?
|
||||
if (useLeft) {
|
||||
metadataValue.value = relationship.leftwardValue
|
||||
} else {
|
||||
metadataValue.value = relationship.rightwardValue
|
||||
}
|
||||
return metadataValue;
|
||||
}
|
||||
}
|
||||
|
@@ -315,9 +315,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
size: 'lg'
|
||||
});
|
||||
const modalComp = this.modalRef.componentInstance;
|
||||
|
||||
modalComp.query = this.model.value ? this.model.value.value : '';
|
||||
if (hasValue(this.model.value)) {
|
||||
modalComp.query = this.model.value.value;
|
||||
modalComp.selectEvent.pipe(take(1)).subscribe(() => this.model.setValue(undefined))
|
||||
modalComp.selectEvent.pipe(take(1)).subscribe(() => this.model.value = '');
|
||||
}
|
||||
modalComp.repeatable = this.model.repeatable;
|
||||
modalComp.listId = this.listId;
|
||||
@@ -325,7 +326,6 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
modalComp.metadataFields = this.model.metadataFields;
|
||||
modalComp.item = this.item;
|
||||
modalComp.submissionId = this.model.submissionId;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -8,5 +8,5 @@
|
||||
[ngClass]="[getClass(model, 'element', 'host'), getClass(model, 'grid', 'host')]"
|
||||
[templates]="templates"
|
||||
(dfBlur)="onEvent($event, 'blur')"
|
||||
(dfChange)="onEvent($event, 'change'); log('test')"
|
||||
(dfChange)="onEvent($event, 'change')"
|
||||
(dfFocus)="onEvent($event, 'focus')"></ds-dynamic-form-control-container>
|
||||
|
@@ -37,8 +37,4 @@ export class DsDynamicFormComponent extends DynamicFormComponent {
|
||||
constructor(protected formService: FormBuilderService, protected layoutService: DynamicFormLayoutService) {
|
||||
super(formService, layoutService);
|
||||
}
|
||||
|
||||
log(t: string) {
|
||||
console.log(t);
|
||||
}
|
||||
}
|
||||
|
@@ -77,9 +77,13 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
|
||||
|
||||
if (values[0].value) {
|
||||
(this.get(0) as DsDynamicInputModel).valueUpdates.next(values[0]);
|
||||
} else {
|
||||
(this.get(0) as DsDynamicInputModel).valueUpdates.next(undefined);
|
||||
}
|
||||
if (values[1].value) {
|
||||
(this.get(1) as DsDynamicInputModel).valueUpdates.next(values[1]);
|
||||
} else {
|
||||
(this.get(1) as DsDynamicInputModel).valueUpdates.next(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ import { RemoteData } from '../../../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { ExternalSource } from '../../../../../core/shared/external-source.model';
|
||||
import { ExternalSourceService } from '../../../../../core/data/external-source.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dynamic-lookup-relation-modal',
|
||||
@@ -113,8 +114,10 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
||||
private lookupRelationService: LookupRelationService,
|
||||
private searchConfigService: SearchConfigurationService,
|
||||
private zone: NgZone,
|
||||
private store: Store<AppState>
|
||||
private store: Store<AppState>,
|
||||
private router: Router,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -193,43 +196,6 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set existing name variants for items by the item's virtual metadata
|
||||
*/
|
||||
private setExistingNameVariants() {
|
||||
const virtualMDs: MetadataValue[] = this.item.allMetadata(this.metadataFields).filter((mdValue) => mdValue.isVirtual);
|
||||
|
||||
const relatedItemPairs$: Observable<Array<[Item, Item]>> =
|
||||
combineLatest(virtualMDs.map((md: MetadataValue) => this.relationshipService.findById(md.virtualValue).pipe(getSucceededRemoteData(), getRemoteDataPayload())))
|
||||
.pipe(
|
||||
switchMap((relationships: Relationship[]) => combineLatest(relationships.map((relationship: Relationship) =>
|
||||
combineLatest(
|
||||
relationship.leftItem.pipe(getSucceededRemoteData(), getRemoteDataPayload()),
|
||||
relationship.rightItem.pipe(getSucceededRemoteData(), getRemoteDataPayload())
|
||||
))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
const relatedItems$: Observable<Item[]> = relatedItemPairs$.pipe(
|
||||
map((relatedItemPairs: Array<[Item, Item]>) => {
|
||||
return relatedItemPairs
|
||||
.map(([left, right]: [Item, Item]) => left.uuid === this.item.uuid ? left : right)
|
||||
})
|
||||
);
|
||||
|
||||
relatedItems$.pipe(take(1)).subscribe((relatedItems) => {
|
||||
let index = 0;
|
||||
virtualMDs.forEach(
|
||||
(md: MetadataValue) => {
|
||||
this.relationshipService.setNameVariant(this.listId, relatedItems[index].uuid, md.value);
|
||||
index++;
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate and set the total entries available for each tab
|
||||
*/
|
||||
@@ -253,6 +219,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.router.navigate([], {});
|
||||
Object.values(this.subMap).forEach((subscription) => subscription.unsubscribe());
|
||||
}
|
||||
}
|
||||
|
@@ -141,26 +141,4 @@ export class RelationshipEffects {
|
||||
switchMap(() => this.submissionObjectService.findById(submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()))
|
||||
).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject])));
|
||||
}
|
||||
|
||||
// private addAsMetadataInStore(submissionID: string, sectionID: string, metadataField: string, relationship: Relationship, repeatable: boolean, relationshipType: string) {
|
||||
// const sectionData$: Observable<WorkspaceitemSectionDataType> = this.sectionsService.getSectionData(submissionID, sectionID);
|
||||
// observableCombineLatest(
|
||||
// sectionData$.pipe(take(1)),
|
||||
// relationship.relationshipType.pipe(getSucceededRemoteData(), getRemoteDataPayload())
|
||||
// ).subscribe(
|
||||
// ([sectionData, relType]: [WorkspaceitemSectionDataType, RelationshipType]) => {
|
||||
// const useLeft = relType.rightwardType === relationshipType;
|
||||
// const value = this.relationshipService.toVirtualMetadata(relationship, useLeft);
|
||||
// let values;
|
||||
// if (repeatable) {
|
||||
// const existingValues: FormFieldMetadataValueObject[] = sectionData[metadataField];
|
||||
// values = [...existingValues, value];
|
||||
// } else {
|
||||
// values = [value];
|
||||
// }
|
||||
// sectionData[metadataField] = values;
|
||||
// this.sectionsService.updateSectionData(submissionID, sectionID, sectionData);
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
[resultCount]="(resultsRD$ | async)?.payload?.totalElements"
|
||||
[inPlaceSearch]="true" [showViewModes]="false"></ds-search-sidebar>
|
||||
<div class="col-8">
|
||||
<ds-search-form [inPlaceSearch]="true" [query]="query"></ds-search-form>
|
||||
<ds-search-form [query]="(searchConfigService.paginatedSearchOptions | async)?.query" [inPlaceSearch]="true"></ds-search-form>
|
||||
|
||||
<ds-search-labels [inPlaceSearch]="true"></ds-search-labels>
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{(resultsRD$ | async)?.state}}
|
||||
<ds-search-results [searchResults]="(resultsRD$ | async)"
|
||||
[sortConfig]="this.lookupRelationService.searchConfig?.sort"
|
||||
[searchConfig]="this.lookupRelationService.searchConfig"
|
||||
|
@@ -2,20 +2,18 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspace-page.component';
|
||||
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
||||
import { Item } from '../../../../../../core/shared/item.model';
|
||||
import { PaginatedSearchOptions } from '../../../../../search/paginated-search-options.model';
|
||||
import { SearchResult } from '../../../../../search/search-result.model';
|
||||
import { PaginatedList } from '../../../../../../core/data/paginated-list';
|
||||
import { RemoteData } from '../../../../../../core/data/remote-data';
|
||||
import { Observable, ReplaySubject } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RelationshipOptions } from '../../../models/relationship-options.model';
|
||||
import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model';
|
||||
import { ListableObject } from '../../../../../object-collection/shared/listable-object.model';
|
||||
import { SearchService } from '../../../../../../core/shared/search/search.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
|
||||
import { hasValue, isNotEmpty } from '../../../../../empty.util';
|
||||
import { concat, map, multicast, switchMap, take, takeWhile, tap } from 'rxjs/operators';
|
||||
import { DSpaceObject } from '../../../../../../core/shared/dspace-object.model';
|
||||
import { hasValue } from '../../../../../empty.util';
|
||||
import { map, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { getSucceededRemoteData } from '../../../../../../core/shared/operators';
|
||||
import { RouteService } from '../../../../../../core/services/route.service';
|
||||
import { CollectionElementLinkType } from '../../../../../object-collection/collection-element-link.type';
|
||||
@@ -102,10 +100,10 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
|
||||
/**
|
||||
* The initial pagination to use
|
||||
*/
|
||||
initialPagination = Object.assign(new PaginationComponentOptions(), {
|
||||
id: 'submission-relation-list',
|
||||
initialPagination = {
|
||||
page: 1,
|
||||
pageSize: 5
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The type of links to display
|
||||
@@ -140,7 +138,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
|
||||
*/
|
||||
resetRoute() {
|
||||
this.router.navigate([], {
|
||||
queryParams: Object.assign({}, { pageSize: this.initialPagination.pageSize }, this.route.snapshot.queryParams, { page: 1 })
|
||||
queryParams: Object.assign({ query: this.query }, this.route.snapshot.queryParams, this.initialPagination),
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,6 @@ describe('DisabledFieldParser test suite', () => {
|
||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
||||
|
||||
const fieldModel = parser.parse();
|
||||
console.log(fieldModel);
|
||||
expect(fieldModel.value).toEqual(expectedValue);
|
||||
});
|
||||
|
||||
|
@@ -86,7 +86,6 @@ export abstract class FieldParser {
|
||||
if (model.hasLanguages || isNotEmpty(model.relationship)) {
|
||||
setLayout(model, 'grid', 'control', 'col');
|
||||
}
|
||||
console.log(model);
|
||||
return [model];
|
||||
}
|
||||
} as DynamicRowArrayModelConfig;
|
||||
|
@@ -20,11 +20,6 @@
|
||||
(click)="insertItem($event, group.context, group.index + 1)">
|
||||
<i class="fas fa-plus" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary"
|
||||
(click)="removeItem($event, context, index)"
|
||||
[disabled]="group.context.groups.length === 1 || isItemReadOnly(context, index)">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -293,6 +293,7 @@ export class FormComponent implements OnDestroy, OnInit {
|
||||
}
|
||||
|
||||
removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
|
||||
console.log(arrayContext, index);
|
||||
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
|
||||
this.removeArrayItem.emit(this.getEvent($event, arrayContext, index, 'remove'));
|
||||
this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext);
|
||||
|
Reference in New Issue
Block a user