created new tab for lookup

This commit is contained in:
lotte
2019-09-03 15:42:42 +02:00
parent 4ace067265
commit 3018845d0a
13 changed files with 58 additions and 12 deletions

View File

@@ -56,8 +56,8 @@ export class RelationshipTypeService {
/* Flatten the page so we can treat it like an observable */
switchMap((typeListRD: RemoteData<PaginatedList<RelationshipType>>) => typeListRD.payload.page),
switchMap((type: RelationshipType) => {
if (type.rightLabel === label) return this.checkType(type, firstType, secondType);
else if (type.leftLabel === label) return this.checkType(type, secondType, firstType);
if (type.leftLabel === label) return this.checkType(type, firstType, secondType);
else if (type.rightLabel === label) return this.checkType(type, secondType, firstType);
else return [];
}),
);

View File

@@ -247,6 +247,8 @@ export class RelationshipService extends DataService<Relationship> {
getRelationshipByItemsAndLabel(item1: Item, item2: Item, label: string): Observable<Relationship> {
return this.getItemRelationshipsByLabel(item1, label)
.pipe(
getSucceededRemoteData(),
map((relationshipListRD: RemoteData<PaginatedList<Relationship>>) => relationshipListRD.payload.page),
mergeMap((relationships: Relationship[]) => {
return observableCombineLatest(...relationships.map((relationship: Relationship) => {
return observableCombineLatest(

View File

@@ -15,7 +15,8 @@
[selection$]="selection$"
[listId]="listId"
[relationship]="relationship"
[repeatable]="repeatable">
[repeatable]="repeatable"
class="d-block pt-3">
</ds-dynamic-lookup-relation-search-tab>
</ng-template>
</ngb-tab>

View File

@@ -9,7 +9,6 @@ import { hasNoValue, hasValueOperator } from '../../../../empty.util';
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
import { RelationshipType } from '../../../../../core/shared/item-relationships/relationship-type.model';
import { RelationshipTypeService } from '../../../../../core/data/relationship-type.service';
import { cloneDeep } from 'lodash';
const DEBOUNCE_TIME = 5000;
@@ -74,13 +73,13 @@ export class RelationshipEffects {
private addRelationship(item1: Item, item2: Item, relationshipType: string) {
// const type1: string = item1.firstMetadataValue('relationship.type');
const type1: string = 'JournalVolume';
const type1: string = item1.firstMetadataValue('relationship.type');
// const type1: string = 'JournalVolume';
const type2: string = item2.firstMetadataValue('relationship.type');
return this.relationshipTypeService.getRelationshipTypeByLabelAndTypes(relationshipType, type1, type2)
.pipe(
mergeMap((type: RelationshipType) => {
const isSwitched = type.leftLabel === relationshipType;
const isSwitched = type.rightLabel === relationshipType;
if (isSwitched) {
return this.relationshipService.addRelationship(type.id, item2, item1);
} else {

View File

@@ -1,7 +1,7 @@
<div class="row" *ngVar="(resultsRD$ | async) as resultsRD">
<ds-search-sidebar class="col-4" id="search-sidebar"
[resultCount]="(resultsRD$ | async)?.payload?.totalElements"
[inPlaceSearch]="true"></ds-search-sidebar>
[inPlaceSearch]="true" [showViewModes]="false"></ds-search-sidebar>
<div class="col-8">
<form class="input-group mb-3" #queryForm="ngForm"
(ngSubmit)="search(queryForm.value.query)">

View File

@@ -44,7 +44,6 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
@Input() itemRD$;
@Input() repeatable: boolean;
@Input() selection$: Observable<ListableObject[]>;
resultsRD$: Observable<RemoteData<PaginatedList<SearchResult<Item>>>>;
searchConfig: PaginatedSearchOptions;
searchQuery;

View File

@@ -0,0 +1,4 @@
<ds-search-results [searchResults]="selection$ | async"
[selectable]="true"
[selectionConfig]="{ repeatable: repeatable, listId: listId }"
></ds-search-results>

View File

@@ -0,0 +1,33 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspace-page.component';
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
import { Observable } from 'rxjs';
import { RelationshipOptions } from '../../../models/relationship-options.model';
import { ListableObject } from '../../../../../object-collection/shared/listable-object.model';
@Component({
selector: 'ds-dynamic-lookup-relation-selection-tab',
styleUrls: ['./dynamic-lookup-relation-selection-tab.component.scss'],
templateUrl: './dynamic-lookup-relation-selection-tab.component.html',
providers: [
{
provide: SEARCH_CONFIG_SERVICE,
useClass: SearchConfigurationService
}
]
})
export class DsDynamicLookupRelationSelectionTabComponent {
@Input() label: string;
@Input() relationship: RelationshipOptions;
@Input() listId: string;
@Input() itemRD$;
@Input() repeatable: boolean;
@Input() selection$: Observable<ListableObject[]>;
constructor(
) {
}
}

View File

@@ -77,7 +77,8 @@ const rowArrayQualdropConfig = {
notRepeatable: true,
groupFactory: () => {
return [MockQualdropModel];
}
},
required: false
} as DynamicRowArrayModelConfig;
export const MockRowArrayQualdropModel: DynamicRowArrayModel = new DynamicRowArrayModel(rowArrayQualdropConfig);

View File

@@ -8,7 +8,7 @@
</button>
</div>
<div id="search-sidebar-content">
<ds-view-mode-switch [viewModeList]="viewModeList" class="d-none d-md-block"></ds-view-mode-switch>
<ds-view-mode-switch *ngIf="showViewModes" [viewModeList]="viewModeList" class="d-none d-md-block"></ds-view-mode-switch>
<div class="sidebar-content">
<ds-search-switch-configuration [inPlaceSearch]="inPlaceSearch" *ngIf="configurationList" [configurationList]="configurationList"></ds-search-switch-configuration>
<ds-search-filters [inPlaceSearch]="inPlaceSearch"></ds-search-filters>

View File

@@ -34,6 +34,11 @@ export class SearchSidebarComponent {
*/
@Input() viewModeList;
/**
* Whether to show the view mode switch
*/
@Input() showViewModes = true;
/**
* True when the search component should show results on the current page
*/

View File

@@ -161,6 +161,7 @@ import { SearchSwitchConfigurationComponent } from './search/search-switch-confi
import { SearchAuthorityFilterComponent } from './search/search-filters/search-filter/search-authority-filter/search-authority-filter.component';
import { DsDynamicDisabledComponent } from './form/builder/ds-dynamic-form-ui/models/disabled/dynamic-disabled.component';
import { DsDynamicLookupRelationSearchTabComponent } from './form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component';
import { DsDynamicLookupRelationSelectionTabComponent } from './form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component';
const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -362,7 +363,8 @@ const ENTRY_COMPONENTS = [
SearchFacetSelectedOptionComponent,
SearchFacetRangeOptionComponent,
SearchAuthorityFilterComponent,
DsDynamicLookupRelationSearchTabComponent
DsDynamicLookupRelationSearchTabComponent,
DsDynamicLookupRelationSelectionTabComponent
];
const SHARED_ITEM_PAGE_COMPONENTS = [