mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fix linting issues
This commit is contained in:
@@ -95,4 +95,4 @@ export const paginatedRelationsToItems = (thisId: string) =>
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@@ -49,9 +49,6 @@ export class RelatedEntitiesSearchComponent implements OnInit {
|
|||||||
fixedFilter: string;
|
fixedFilter: string;
|
||||||
configuration$: Observable<string>;
|
configuration$: Observable<string>;
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (isNotEmpty(this.relationType) && isNotEmpty(this.item)) {
|
if (isNotEmpty(this.relationType) && isNotEmpty(this.item)) {
|
||||||
this.fixedFilter = getFilterByRelation(this.relationType, this.item.id);
|
this.fixedFilter = getFilterByRelation(this.relationType, this.item.id);
|
||||||
|
@@ -8,7 +8,6 @@ import { ConfigurationSearchPageGuard } from './configuration-search-page.guard'
|
|||||||
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
||||||
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
||||||
|
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
SearchPageComponent,
|
SearchPageComponent,
|
||||||
FilteredSearchPageComponent,
|
FilteredSearchPageComponent,
|
||||||
|
@@ -12,7 +12,7 @@ import { ItemType } from '../shared/item-relationships/item-type.model';
|
|||||||
|
|
||||||
describe('RelationshipTypeService', () => {
|
describe('RelationshipTypeService', () => {
|
||||||
let service: RelationshipTypeService;
|
let service: RelationshipTypeService;
|
||||||
let requestService : RequestService;
|
let requestService: RequestService;
|
||||||
let restEndpointURL;
|
let restEndpointURL;
|
||||||
let halService: any;
|
let halService: any;
|
||||||
let publicationTypeString;
|
let publicationTypeString;
|
||||||
@@ -23,8 +23,6 @@ describe('RelationshipTypeService', () => {
|
|||||||
let orgUnitType;
|
let orgUnitType;
|
||||||
|
|
||||||
let relationshipType1;
|
let relationshipType1;
|
||||||
|
|
||||||
|
|
||||||
let relationshipType2;
|
let relationshipType2;
|
||||||
|
|
||||||
let buildList;
|
let buildList;
|
||||||
@@ -49,7 +47,6 @@ describe('RelationshipTypeService', () => {
|
|||||||
rightType: createSuccessfulRemoteDataObject$(personType)
|
rightType: createSuccessfulRemoteDataObject$(personType)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
relationshipType2 = Object.assign(new RelationshipType(), {
|
relationshipType2 = Object.assign(new RelationshipType(), {
|
||||||
id: '2',
|
id: '2',
|
||||||
uuid: '2',
|
uuid: '2',
|
||||||
|
@@ -56,9 +56,13 @@ export class RelationshipTypeService {
|
|||||||
/* Flatten the page so we can treat it like an observable */
|
/* Flatten the page so we can treat it like an observable */
|
||||||
switchMap((typeListRD: RemoteData<PaginatedList<RelationshipType>>) => typeListRD.payload.page),
|
switchMap((typeListRD: RemoteData<PaginatedList<RelationshipType>>) => typeListRD.payload.page),
|
||||||
switchMap((type: RelationshipType) => {
|
switchMap((type: RelationshipType) => {
|
||||||
if (type.leftwardType === label) return this.checkType(type, firstType, secondType);
|
if (type.leftwardType === label) {
|
||||||
else if (type.rightwardType === label) return this.checkType(type, secondType, firstType);
|
return this.checkType(type, firstType, secondType);
|
||||||
else return [];
|
} else if (type.rightwardType === label) {
|
||||||
|
return this.checkType(type, secondType, firstType);
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -74,4 +78,4 @@ export class RelationshipTypeService {
|
|||||||
map(() => type)
|
map(() => type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,6 @@ import { AppState, keySelector } from '../../app.reducer';
|
|||||||
import { NameVariantListState } from '../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/name-variant.reducer';
|
import { NameVariantListState } from '../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/name-variant.reducer';
|
||||||
import { RemoveNameVariantAction, SetNameVariantAction } from '../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/name-variant.actions';
|
import { RemoveNameVariantAction, SetNameVariantAction } from '../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/name-variant.actions';
|
||||||
|
|
||||||
|
|
||||||
const relationshipListsStateSelector = (state: AppState) => state.relationshipLists;
|
const relationshipListsStateSelector = (state: AppState) => state.relationshipLists;
|
||||||
|
|
||||||
const relationshipListStateSelector = (listID: string): MemoizedSelector<AppState, NameVariantListState> => {
|
const relationshipListStateSelector = (listID: string): MemoizedSelector<AppState, NameVariantListState> => {
|
||||||
@@ -313,7 +312,7 @@ export class RelationshipService extends DataService<Relationship> {
|
|||||||
relation.relationshipType.pipe(
|
relation.relationshipType.pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
getRemoteDataPayload(),
|
getRemoteDataPayload(),
|
||||||
map(type => {
|
map((type) => {
|
||||||
return { relation, type }
|
return { relation, type }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@@ -34,4 +34,3 @@ export class NormalizedGroup extends NormalizedDSpaceObject<Group> implements Ca
|
|||||||
@autoserialize
|
@autoserialize
|
||||||
public permanent: boolean;
|
public permanent: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { Action } from '@ngrx/store';
|
import { Action } from '@ngrx/store';
|
||||||
import { type } from '../../shared/ngrx/type';
|
import { type } from '../../shared/ngrx/type';
|
||||||
import { Params } from '@angular/router';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of HrefIndexAction type definitions
|
* The list of HrefIndexAction type definitions
|
||||||
@@ -18,12 +17,6 @@ export const RouterActionTypes = {
|
|||||||
*/
|
*/
|
||||||
export class RouteUpdateAction implements Action {
|
export class RouteUpdateAction implements Action {
|
||||||
type = RouterActionTypes.ROUTE_UPDATE;
|
type = RouterActionTypes.ROUTE_UPDATE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new RouteUpdateAction
|
|
||||||
*/
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tslint:enable:max-classes-per-file */
|
/* tslint:enable:max-classes-per-file */
|
||||||
|
@@ -19,7 +19,7 @@ export class RouterEffects {
|
|||||||
map((actions: RouterNavigationAction[]) =>
|
map((actions: RouterNavigationAction[]) =>
|
||||||
actions.map((navigateAction) => {
|
actions.map((navigateAction) => {
|
||||||
const urlTree = this.router.parseUrl(navigateAction.payload.routerState.url);
|
const urlTree = this.router.parseUrl(navigateAction.payload.routerState.url);
|
||||||
return urlTree.root.children['primary'].segments.map(it => it.path).join('/');
|
return urlTree.root.children.primary.segments.map((it) => it.path).join('/');
|
||||||
})),
|
})),
|
||||||
filter((actions: string[]) => actions[0] !== actions[1]),
|
filter((actions: string[]) => actions[0] !== actions[1]),
|
||||||
map(() => new RouteUpdateAction())
|
map(() => new RouteUpdateAction())
|
||||||
|
@@ -94,4 +94,4 @@ function setParameter(state: RouteState, action: SetParameterAction | SetQueryPa
|
|||||||
const subState = state[paramType];
|
const subState = state[paramType];
|
||||||
const newSubstate = Object.assign({}, subState, { [action.payload.key]: action.payload.value });
|
const newSubstate = Object.assign({}, subState, { [action.payload.key]: action.payload.value });
|
||||||
return Object.assign({}, state, { [paramType]: newSubstate });
|
return Object.assign({}, state, { [paramType]: newSubstate });
|
||||||
}
|
}
|
||||||
|
@@ -126,9 +126,8 @@ export const getFirstOccurrence = () =>
|
|||||||
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
|
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
export const obsLog = (logString?: string) =>
|
export const obsLog = (logString?: string) =>
|
||||||
<T>(source: Observable<T>): Observable<T> =>
|
<T>(source: Observable<T>): Observable<T> =>
|
||||||
source.pipe(
|
source.pipe(
|
||||||
tap((t) => console.log(logString || '', t))
|
tap((t) => console.log(logString || '', t))
|
||||||
);
|
);
|
||||||
|
@@ -5,21 +5,6 @@ import { hasValue } from '../../shared/empty.util';
|
|||||||
* Represents the state of a paginated response
|
* Represents the state of a paginated response
|
||||||
*/
|
*/
|
||||||
export class PageInfo {
|
export class PageInfo {
|
||||||
constructor(
|
|
||||||
options?: {
|
|
||||||
elementsPerPage: number,
|
|
||||||
totalElements: number,
|
|
||||||
totalPages: number,
|
|
||||||
currentPage: number
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
if (hasValue(options)) {
|
|
||||||
this.elementsPerPage = options.elementsPerPage;
|
|
||||||
this.totalElements = options.totalElements;
|
|
||||||
this.totalPages = options.totalPages;
|
|
||||||
this.currentPage = options.currentPage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of elements on a page
|
* The number of elements on a page
|
||||||
@@ -59,4 +44,20 @@ export class PageInfo {
|
|||||||
|
|
||||||
@autoserialize
|
@autoserialize
|
||||||
self: string;
|
self: string;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
options?: {
|
||||||
|
elementsPerPage: number,
|
||||||
|
totalElements: number,
|
||||||
|
totalPages: number,
|
||||||
|
currentPage: number
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
if (hasValue(options)) {
|
||||||
|
this.elementsPerPage = options.elementsPerPage;
|
||||||
|
this.totalElements = options.totalElements;
|
||||||
|
this.totalPages = options.totalPages;
|
||||||
|
this.currentPage = options.currentPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ export function excludeFromEquals(object: any, propertyName: string): any {
|
|||||||
excludedFromEquals.set(object.constructor, [...list, propertyName]);
|
excludedFromEquals.set(object.constructor, [...list, propertyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line:ban-types
|
||||||
export function getExcludedFromEqualsFor(constructor: Function): string[] {
|
export function getExcludedFromEqualsFor(constructor: Function): string[] {
|
||||||
return excludedFromEquals.get(constructor) || [];
|
return excludedFromEquals.get(constructor) || [];
|
||||||
}
|
}
|
||||||
@@ -50,8 +51,8 @@ export function fieldsForEquals(...fields: string[]): any {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line:ban-types
|
||||||
export function getFieldsForEquals(constructor: Function, field: string): string[] {
|
export function getFieldsForEquals(constructor: Function, field: string): string[] {
|
||||||
const fieldMap = fieldsForEqualsMap.get(constructor) || new Map();
|
const fieldMap = fieldsForEqualsMap.get(constructor) || new Map();
|
||||||
return fieldMap.get(field);
|
return fieldMap.get(field);
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@ class Dog extends EquatableObject<Dog> {
|
|||||||
public favouriteToy: { name: string, colour: string };
|
public favouriteToy: { name: string, colour: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line:max-classes-per-file
|
||||||
class Owner extends EquatableObject<Owner> {
|
class Owner extends EquatableObject<Owner> {
|
||||||
@excludeFromEquals
|
@excludeFromEquals
|
||||||
favouriteFood: string;
|
favouriteFood: string;
|
||||||
@@ -110,4 +111,3 @@ describe('equatable', () => {
|
|||||||
expect(isEqual).toBe(false);
|
expect(isEqual).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -39,4 +39,4 @@ export abstract class EquatableObject<T> {
|
|||||||
const keys = Object.keys(this).filter((key) => !excludedKeys.includes(key));
|
const keys = Object.keys(this).filter((key) => !excludedKeys.includes(key));
|
||||||
return equalsByFields(this, other, keys);
|
return equalsByFields(this, other, keys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ let mockItemWithoutMetadata: ItemSearchResult;
|
|||||||
let nameVariant;
|
let nameVariant;
|
||||||
let mockRelationshipService;
|
let mockRelationshipService;
|
||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
mockItemWithMetadata = Object.assign(
|
mockItemWithMetadata = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -65,7 +64,7 @@ function init() {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
nameVariant = "Doe J.";
|
nameVariant = 'Doe J.';
|
||||||
mockRelationshipService = {
|
mockRelationshipService = {
|
||||||
getNameVariant: () => observableOf(nameVariant)
|
getNameVariant: () => observableOf(nameVariant)
|
||||||
};
|
};
|
||||||
|
@@ -26,7 +26,6 @@ let mockItemWithoutMetadata: ItemSearchResult;
|
|||||||
let nameVariant;
|
let nameVariant;
|
||||||
let mockRelationshipService;
|
let mockRelationshipService;
|
||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
mockItemWithMetadata = Object.assign(
|
mockItemWithMetadata = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -65,7 +64,7 @@ function init() {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
nameVariant = "Doe J.";
|
nameVariant = 'Doe J.';
|
||||||
mockRelationshipService = {
|
mockRelationshipService = {
|
||||||
getNameVariant: () => observableOf(nameVariant)
|
getNameVariant: () => observableOf(nameVariant)
|
||||||
};
|
};
|
||||||
|
@@ -1,19 +1,14 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'name-variant-modal',
|
selector: 'ds-name-variant-modal',
|
||||||
templateUrl: './name-variant-modal.component.html',
|
templateUrl: './name-variant-modal.component.html',
|
||||||
styleUrls: ['./name-variant-modal.component.scss']
|
styleUrls: ['./name-variant-modal.component.scss']
|
||||||
})
|
})
|
||||||
export class NameVariantModalComponent implements OnInit {
|
export class NameVariantModalComponent {
|
||||||
@Input() value: string;
|
@Input() value: string;
|
||||||
|
|
||||||
constructor(public modal: NgbActiveModal) {
|
constructor(public modal: NgbActiveModal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -190,6 +190,7 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
|
|||||||
|
|
||||||
const ngZone = TestBed.get(NgZone);
|
const ngZone = TestBed.get(NgZone);
|
||||||
|
|
||||||
|
// tslint:disable-next-line:ban-types
|
||||||
spyOn(ngZone, 'runOutsideAngular').and.callFake((fn: Function) => fn());
|
spyOn(ngZone, 'runOutsideAngular').and.callFake((fn: Function) => fn());
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
debugElement = fixture.debugElement;
|
debugElement = fixture.debugElement;
|
||||||
|
@@ -178,7 +178,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
@Input() hasErrorMessaging = false;
|
@Input() hasErrorMessaging = false;
|
||||||
@Input() layout = null as DynamicFormLayout;
|
@Input() layout = null as DynamicFormLayout;
|
||||||
@Input() model: any;
|
@Input() model: any;
|
||||||
relationships$: Observable<SearchResult<Item>[]>;
|
relationships$: Observable<Array<SearchResult<Item>>>;
|
||||||
hasRelationLookup: boolean;
|
hasRelationLookup: boolean;
|
||||||
modalRef: NgbModalRef;
|
modalRef: NgbModalRef;
|
||||||
item$: Observable<Item>;
|
item$: Observable<Item>;
|
||||||
@@ -231,14 +231,14 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
take(1),
|
take(1),
|
||||||
switchMap((item: Item) => this.relationService.getRelatedItemsByLabel(item, this.model.relationship.relationshipType)),
|
switchMap((item: Item) => this.relationService.getRelatedItemsByLabel(item, this.model.relationship.relationshipType)),
|
||||||
map((items: RemoteData<PaginatedList<Item>>) => items.payload.page.map((item) => Object.assign(new ItemSearchResult(), { indexableObject: item }))),
|
map((items: RemoteData<PaginatedList<Item>>) => items.payload.page.map((item) => Object.assign(new ItemSearchResult(), { indexableObject: item }))),
|
||||||
).subscribe((relatedItems: SearchResult<Item>[]) => this.selectableListService.select(this.listId, relatedItems));
|
).subscribe((relatedItems: Array<SearchResult<Item>>) => this.selectableListService.select(this.listId, relatedItems));
|
||||||
|
|
||||||
this.relationships$ = this.selectableListService.getSelectableList(this.listId).pipe(
|
this.relationships$ = this.selectableListService.getSelectableList(this.listId).pipe(
|
||||||
map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []),
|
map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []),
|
||||||
) as Observable<SearchResult<Item>[]>;
|
) as Observable<Array<SearchResult<Item>>>;
|
||||||
this.modelValueMDRepresentation =
|
this.modelValueMDRepresentation =
|
||||||
observableCombineLatest(this.item$, this.relationships$).pipe(
|
observableCombineLatest(this.item$, this.relationships$).pipe(
|
||||||
map(([item, relatedItems]: [Item, SearchResult<DSpaceObject>[]]) =>
|
map(([item, relatedItems]: [Item, Array<SearchResult<DSpaceObject>>]) =>
|
||||||
relatedItems
|
relatedItems
|
||||||
.map((element: SearchResult<DSpaceObject>) => {
|
.map((element: SearchResult<DSpaceObject>) => {
|
||||||
const relationMD: MetadataValue = item.firstMetadata(this.model.relationship.metadataField, { value: element.indexableObject.uuid });
|
const relationMD: MetadataValue = item.firstMetadata(this.model.relationship.metadataField, { value: element.indexableObject.uuid });
|
||||||
@@ -294,7 +294,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public hasResultsSelected(): Observable<boolean> {
|
public hasResultsSelected(): Observable<boolean> {
|
||||||
return this.model.value.pipe(map((list: SearchResult<DSpaceObject>[]) => isNotEmpty(list)));
|
return this.model.value.pipe(map((list: Array<SearchResult<DSpaceObject>>) => isNotEmpty(list)));
|
||||||
}
|
}
|
||||||
|
|
||||||
openLookup() {
|
openLookup() {
|
||||||
|
@@ -58,8 +58,8 @@ describe('DsDynamicLookupRelationModalComponent', () => {
|
|||||||
{ provide: RelationshipTypeService, useValue: {} },
|
{ provide: RelationshipTypeService, useValue: {} },
|
||||||
{
|
{
|
||||||
provide: Store, useValue: {
|
provide: Store, useValue: {
|
||||||
dispatch: () => {
|
// tslint:disable-next-line:no-empty
|
||||||
}
|
dispatch: () => {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ provide: NgZone, useValue: new NgZone({}) },
|
{ provide: NgZone, useValue: new NgZone({}) },
|
||||||
|
@@ -74,7 +74,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
this.modal.close();
|
this.modal.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
select(...selectableObjects: SearchResult<Item>[]) {
|
select(...selectableObjects: Array<SearchResult<Item>>) {
|
||||||
this.zone.runOutsideAngular(
|
this.zone.runOutsideAngular(
|
||||||
() => {
|
() => {
|
||||||
const obs: Observable<any[]> = combineLatest(...selectableObjects.map((sri: SearchResult<Item>) => {
|
const obs: Observable<any[]> = combineLatest(...selectableObjects.map((sri: SearchResult<Item>) => {
|
||||||
@@ -92,8 +92,8 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
obs
|
obs
|
||||||
.subscribe((obs: any[]) => {
|
.subscribe((arr: any[]) => {
|
||||||
return obs.forEach((object: any) => {
|
return arr.forEach((object: any) => {
|
||||||
this.store.dispatch(new AddRelationshipAction(this.item, object.item, this.relationshipOptions.relationshipType, object.nameVariant));
|
this.store.dispatch(new AddRelationshipAction(this.item, object.item, this.relationshipOptions.relationshipType, object.nameVariant));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -108,7 +108,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
).subscribe((nameVariant: string) => this.store.dispatch(new UpdateRelationshipAction(this.item, sri.indexableObject, this.relationshipOptions.relationshipType, nameVariant)))
|
).subscribe((nameVariant: string) => this.store.dispatch(new UpdateRelationshipAction(this.item, sri.indexableObject, this.relationshipOptions.relationshipType, nameVariant)))
|
||||||
}
|
}
|
||||||
|
|
||||||
deselect(...selectableObjects: SearchResult<Item>[]) {
|
deselect(...selectableObjects: Array<SearchResult<Item>>) {
|
||||||
this.zone.runOutsideAngular(
|
this.zone.runOutsideAngular(
|
||||||
() => selectableObjects.forEach((object) => {
|
() => selectableObjects.forEach((object) => {
|
||||||
this.subMap[object.indexableObject.uuid].unsubscribe();
|
this.subMap[object.indexableObject.uuid].unsubscribe();
|
||||||
@@ -120,7 +120,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
private setExistingNameVariants() {
|
private setExistingNameVariants() {
|
||||||
const virtualMDs: MetadataValue[] = this.item.allMetadata(this.metadataFields).filter((mdValue) => mdValue.isVirtual);
|
const virtualMDs: MetadataValue[] = this.item.allMetadata(this.metadataFields).filter((mdValue) => mdValue.isVirtual);
|
||||||
|
|
||||||
const relatedItemPairs$: Observable<[Item, Item][]> =
|
const relatedItemPairs$: Observable<Array<[Item, Item]>> =
|
||||||
combineLatest(virtualMDs.map((md: MetadataValue) => this.relationshipService.findById(md.virtualValue).pipe(getSucceededRemoteData(), getRemoteDataPayload())))
|
combineLatest(virtualMDs.map((md: MetadataValue) => this.relationshipService.findById(md.virtualValue).pipe(getSucceededRemoteData(), getRemoteDataPayload())))
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((relationships: Relationship[]) => combineLatest(relationships.map((relationship: Relationship) =>
|
switchMap((relationships: Relationship[]) => combineLatest(relationships.map((relationship: Relationship) =>
|
||||||
@@ -133,11 +133,11 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
);
|
);
|
||||||
|
|
||||||
const relatedItems$: Observable<Item[]> = relatedItemPairs$.pipe(
|
const relatedItems$: Observable<Item[]> = relatedItemPairs$.pipe(
|
||||||
map(([relatedItemPairs,]: [[Item, Item][]]) => relatedItemPairs.map(([left, right]: [Item, Item]) => left.uuid === this.item.uuid ? left : right))
|
map(([relatedItemPairs,]: [Array<[Item, Item]>]) => relatedItemPairs.map(([left, right]: [Item, Item]) => left.uuid === this.item.uuid ? left : right))
|
||||||
);
|
);
|
||||||
|
|
||||||
relatedItems$.pipe(take(1)).subscribe((relatedItems) => {
|
relatedItems$.pipe(take(1)).subscribe((relatedItems) => {
|
||||||
let index: number = 0;
|
let index = 0;
|
||||||
virtualMDs.forEach(
|
virtualMDs.forEach(
|
||||||
(md: MetadataValue) => {
|
(md: MetadataValue) => {
|
||||||
this.relationshipService.setNameVariant(this.listId, relatedItems[index].uuid, md.value);
|
this.relationshipService.setNameVariant(this.listId, relatedItems[index].uuid, md.value);
|
||||||
@@ -151,4 +151,4 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
Object.values(this.subMap).forEach((subscription) => subscription.unsubscribe());
|
Object.values(this.subMap).forEach((subscription) => subscription.unsubscribe());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,6 @@ function init() {
|
|||||||
variantList1Item2 = 'Test Name Variant 2';
|
variantList1Item2 = 'Test Name Variant 2';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe('nameVariantReducer', () => {
|
describe('nameVariantReducer', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
init();
|
init();
|
||||||
|
@@ -5,14 +5,14 @@
|
|||||||
import { NameVariantAction, NameVariantActionTypes, SetNameVariantAction } from './name-variant.actions';
|
import { NameVariantAction, NameVariantActionTypes, SetNameVariantAction } from './name-variant.actions';
|
||||||
import { hasValue } from '../../../../empty.util';
|
import { hasValue } from '../../../../empty.util';
|
||||||
|
|
||||||
export type NameVariantListsState = {
|
export interface NameVariantListsState {
|
||||||
[listID: string]: NameVariantListState;
|
[listID: string]: NameVariantListState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of a single list containing nameVariants in the store
|
* Represents the state of a single list containing nameVariants in the store
|
||||||
*/
|
*/
|
||||||
export type NameVariantListState = {
|
export interface NameVariantListState {
|
||||||
[itemID: string]: string;
|
[itemID: string]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +35,8 @@ export function nameVariantReducer(state: NameVariantListsState = {}, action: Na
|
|||||||
if (hasValue(listState) && hasValue(listState[action.payload.itemID])) {
|
if (hasValue(listState) && hasValue(listState[action.payload.itemID])) {
|
||||||
const newListState = setNameVariant(listState, action.payload.itemID, undefined);
|
const newListState = setNameVariant(listState, action.payload.itemID, undefined);
|
||||||
return Object.assign({}, state, { [action.payload.listID]: newListState });
|
return Object.assign({}, state, { [action.payload.listID]: newListState });
|
||||||
|
} else {
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@@ -40,7 +40,6 @@ describe('RelationshipEffects', () => {
|
|||||||
let mockRelationshipService;
|
let mockRelationshipService;
|
||||||
let mockRelationshipTypeService;
|
let mockRelationshipTypeService;
|
||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
testUUID1 = '20e24c2f-a00a-467c-bdee-c929e79bf08d';
|
testUUID1 = '20e24c2f-a00a-467c-bdee-c929e79bf08d';
|
||||||
testUUID2 = '7f66a4d0-8557-4e77-8b1e-19930895f10a';
|
testUUID2 = '7f66a4d0-8557-4e77-8b1e-19930895f10a';
|
||||||
@@ -125,7 +124,7 @@ describe('RelationshipEffects', () => {
|
|||||||
|
|
||||||
describe('When it\'s not the first time for this identifier', () => {
|
describe('When it\'s not the first time for this identifier', () => {
|
||||||
let action;
|
let action;
|
||||||
let testActionType = "TEST_TYPE";
|
const testActionType = 'TEST_TYPE';
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(relationEffects as any).initialActionMap[identifier] = testActionType;
|
(relationEffects as any).initialActionMap[identifier] = testActionType;
|
||||||
(relationEffects as any).debounceMap[identifier] = new BehaviorSubject<string>(testActionType);
|
(relationEffects as any).debounceMap[identifier] = new BehaviorSubject<string>(testActionType);
|
||||||
@@ -197,7 +196,7 @@ describe('RelationshipEffects', () => {
|
|||||||
|
|
||||||
describe('When it\'s not the first time for this identifier', () => {
|
describe('When it\'s not the first time for this identifier', () => {
|
||||||
let action;
|
let action;
|
||||||
let testActionType = "TEST_TYPE";
|
const testActionType = 'TEST_TYPE';
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(relationEffects as any).initialActionMap[identifier] = testActionType;
|
(relationEffects as any).initialActionMap[identifier] = testActionType;
|
||||||
(relationEffects as any).debounceMap[identifier] = new BehaviorSubject<string>(testActionType);
|
(relationEffects as any).debounceMap[identifier] = new BehaviorSubject<string>(testActionType);
|
||||||
|
@@ -28,12 +28,10 @@ export class RelationshipEffects {
|
|||||||
[identifier: string]: string
|
[identifier: string]: string
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
|
|
||||||
private initialActionMap: {
|
private initialActionMap: {
|
||||||
[identifier: string]: string
|
[identifier: string]: string
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effect that makes sure all last fired RelationshipActions' types are stored in the map of this service, with the object uuid as their key
|
* Effect that makes sure all last fired RelationshipActions' types are stored in the map of this service, with the object uuid as their key
|
||||||
*/
|
*/
|
||||||
@@ -92,19 +90,16 @@ export class RelationshipEffects {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
constructor(private actions$: Actions,
|
constructor(private actions$: Actions,
|
||||||
private relationshipService: RelationshipService,
|
private relationshipService: RelationshipService,
|
||||||
private relationshipTypeService: RelationshipTypeService,
|
private relationshipTypeService: RelationshipTypeService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private createIdentifier(item1: Item, item2: Item, relationshipType: string): string {
|
private createIdentifier(item1: Item, item2: Item, relationshipType: string): string {
|
||||||
return `${item1.uuid}-${item2.uuid}-${relationshipType}`;
|
return `${item1.uuid}-${item2.uuid}-${relationshipType}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private addRelationship(item1: Item, item2: Item, relationshipType: string, nameVariant?: string) {
|
private addRelationship(item1: Item, item2: Item, relationshipType: string, nameVariant?: string) {
|
||||||
const type1: string = item1.firstMetadataValue('relationship.type');
|
const type1: string = item1.firstMetadataValue('relationship.type');
|
||||||
const type2: string = item2.firstMetadataValue('relationship.type');
|
const type2: string = item2.firstMetadataValue('relationship.type');
|
||||||
|
@@ -96,21 +96,21 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
selectPage(page: SearchResult<Item>[]) {
|
selectPage(page: Array<SearchResult<Item>>) {
|
||||||
this.selection$
|
this.selection$
|
||||||
.pipe(take(1))
|
.pipe(take(1))
|
||||||
.subscribe((selection: SearchResult<Item>[]) => {
|
.subscribe((selection: Array<SearchResult<Item>>) => {
|
||||||
const filteredPage = page.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) < 0);
|
const filteredPage = page.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) < 0);
|
||||||
this.selectObject.emit(...filteredPage);
|
this.selectObject.emit(...filteredPage);
|
||||||
});
|
});
|
||||||
this.selectableListService.select(this.listId, page);
|
this.selectableListService.select(this.listId, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
deselectPage(page: SearchResult<Item>[]) {
|
deselectPage(page: Array<SearchResult<Item>>) {
|
||||||
this.allSelected = false;
|
this.allSelected = false;
|
||||||
this.selection$
|
this.selection$
|
||||||
.pipe(take(1))
|
.pipe(take(1))
|
||||||
.subscribe((selection: SearchResult<Item>[]) => {
|
.subscribe((selection: Array<SearchResult<Item>>) => {
|
||||||
const filteredPage = page.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) >= 0);
|
const filteredPage = page.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) >= 0);
|
||||||
this.deselectObject.emit(...filteredPage);
|
this.deselectObject.emit(...filteredPage);
|
||||||
});
|
});
|
||||||
@@ -133,7 +133,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
|
|||||||
).subscribe((results) => {
|
).subscribe((results) => {
|
||||||
this.selection$
|
this.selection$
|
||||||
.pipe(take(1))
|
.pipe(take(1))
|
||||||
.subscribe((selection: SearchResult<Item>[]) => {
|
.subscribe((selection: Array<SearchResult<Item>>) => {
|
||||||
const filteredResults = results.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) < 0);
|
const filteredResults = results.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) < 0);
|
||||||
this.selectObject.emit(...filteredResults);
|
this.selectObject.emit(...filteredResults);
|
||||||
});
|
});
|
||||||
|
@@ -75,4 +75,4 @@ export class DsDynamicLookupRelationSelectionTabComponent {
|
|||||||
queryParams: Object.assign({}, { page: 1, pageSize: this.initialPagination.pageSize }),
|
queryParams: Object.assign({}, { page: 1, pageSize: this.initialPagination.pageSize }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
const RELATION_METADATA_PREFIX = "relation."
|
const RELATION_METADATA_PREFIX = 'relation.'
|
||||||
|
|
||||||
export class RelationshipOptions {
|
export class RelationshipOptions {
|
||||||
relationshipType: string;
|
relationshipType: string;
|
||||||
|
@@ -18,7 +18,6 @@ export class SelectableListItemControlComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() object: ListableObject;
|
@Input() object: ListableObject;
|
||||||
|
|
||||||
|
|
||||||
@Input() selectionConfig: { repeatable: boolean, listId: string };
|
@Input() selectionConfig: { repeatable: boolean, listId: string };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +29,6 @@ export class SelectableListItemControlComponent implements OnInit {
|
|||||||
|
|
||||||
@Output() selectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();
|
@Output() selectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();
|
||||||
|
|
||||||
|
|
||||||
selected$: Observable<boolean>;
|
selected$: Observable<boolean>;
|
||||||
|
|
||||||
constructor(public selectionService: SelectableListService) {
|
constructor(public selectionService: SelectableListService) {
|
||||||
|
@@ -179,6 +179,4 @@ export class ObjectListComponent {
|
|||||||
onPaginationChange(event) {
|
onPaginationChange(event) {
|
||||||
this.paginationChange.emit(event);
|
this.paginationChange.emit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ export const SelectableListActionTypes = {
|
|||||||
|
|
||||||
/* tslint:disable:max-classes-per-file */
|
/* tslint:disable:max-classes-per-file */
|
||||||
export abstract class SelectableListAction implements Action {
|
export abstract class SelectableListAction implements Action {
|
||||||
|
// tslint:disable-next-line:no-shadowed-variable
|
||||||
constructor(public type, public id: string) {
|
constructor(public type, public id: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,12 +76,9 @@ export class SelectableListSetSelectionAction extends SelectableListAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class SelectableListDeselectAllAction extends SelectableListAction {
|
export class SelectableListDeselectAllAction extends SelectableListAction {
|
||||||
constructor(id: string) {
|
constructor(id: string) {
|
||||||
super(SelectableListActionTypes.DESELECT_ALL, id);
|
super(SelectableListActionTypes.DESELECT_ALL, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* tslint:enable:max-classes-per-file */
|
||||||
|
|
||||||
/* tslint:enable:max-classes-per-file */
|
|
||||||
|
@@ -12,7 +12,7 @@ import { hasNoValue } from '../../empty.util';
|
|||||||
/**
|
/**
|
||||||
* Represents the state of all selectable lists in the store
|
* Represents the state of all selectable lists in the store
|
||||||
*/
|
*/
|
||||||
export type SelectableListsState = {
|
export interface SelectableListsState {
|
||||||
[id: string]: SelectableListState;
|
[id: string]: SelectableListState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,6 @@ function clearSelection(id: string) {
|
|||||||
return { id: id, selection: [] };
|
return { id: id, selection: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isObjectInSelection(selection: ListableObject[], object: ListableObject) {
|
function isObjectInSelection(selection: ListableObject[], object: ListableObject) {
|
||||||
return selection.findIndex((selected) => selected.equals(object)) >= 0
|
return selection.findIndex((selected) => selected.equals(object)) >= 0
|
||||||
}
|
}
|
||||||
|
@@ -15,4 +15,4 @@ export function getQueryByRelations(relationType: string, itemUUID: string): str
|
|||||||
*/
|
*/
|
||||||
export function getFilterByRelation(relationType: string, itemUUID: string): string {
|
export function getFilterByRelation(relationType: string, itemUUID: string): string {
|
||||||
return `f.${relationType}=${itemUUID}`;
|
return `f.${relationType}=${itemUUID}`;
|
||||||
}
|
}
|
||||||
|
@@ -2,5 +2,5 @@ import { Router } from '@angular/router';
|
|||||||
|
|
||||||
export function currentPath(router: Router) {
|
export function currentPath(router: Router) {
|
||||||
const urlTree = router.parseUrl(router.url);
|
const urlTree = router.parseUrl(router.url);
|
||||||
return '/' + urlTree.root.children['primary'].segments.map(it => it.path).join('/')
|
return '/' + urlTree.root.children.primary.segments.map((it) => it.path).join('/')
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user