mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 19:13:08 +00:00
refactored, started tests
This commit is contained in:
@@ -10,9 +10,10 @@ module.exports = {
|
||||
// The REST API server settings.
|
||||
rest: {
|
||||
ssl: true,
|
||||
host: 'dspace7-internal.atmire.com',
|
||||
host: 'dspace7.4science.it',
|
||||
port: 443,
|
||||
nameSpace: '/rest/api'
|
||||
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
||||
nameSpace: '/dspace-spring-rest/api'
|
||||
},
|
||||
// Caching settings
|
||||
cache: {
|
||||
|
@@ -642,5 +642,31 @@
|
||||
},
|
||||
"chips": {
|
||||
"remove": "Remove chip"
|
||||
},
|
||||
"dso-selector": {
|
||||
"create": {
|
||||
"community": {
|
||||
"head": "New community",
|
||||
"sub-level": "Create a new community in",
|
||||
"top-level": "Create a new top-level community"
|
||||
},
|
||||
"collection": {
|
||||
"head": "New collection"
|
||||
},
|
||||
"item": {
|
||||
"head": "New item"
|
||||
}
|
||||
},
|
||||
"edit": {
|
||||
"community": {
|
||||
"head": "Edit community"
|
||||
},
|
||||
"collection": {
|
||||
"head": "Edit collection"
|
||||
},
|
||||
"item": {
|
||||
"head": "Edit item"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ import { OnClickMenuItemModel } from '../../shared/menu/menu-item/models/onclick
|
||||
import { CreateCommunityParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component';
|
||||
import { CreateItemParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';
|
||||
import { CreateCollectionParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component';
|
||||
import { EditCollectionParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component';
|
||||
import { EditItemParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component';
|
||||
import { EditCommunityParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component';
|
||||
import { EditItemSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-selector.component';
|
||||
import { EditCommunitySelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-selector.component';
|
||||
import { EditCollectionSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-selector.component';
|
||||
|
||||
/**
|
||||
* Component representing the admin sidebar
|
||||
@@ -179,7 +179,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
||||
type: MenuItemType.ONCLICK,
|
||||
text: 'menu.section.edit_community',
|
||||
function: () => {
|
||||
this.modalService.open(EditCommunityParentSelectorComponent);
|
||||
this.modalService.open(EditCommunitySelectorComponent);
|
||||
}
|
||||
} as OnClickMenuItemModel,
|
||||
},
|
||||
@@ -192,7 +192,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
||||
type: MenuItemType.ONCLICK,
|
||||
text: 'menu.section.edit_collection',
|
||||
function: () => {
|
||||
this.modalService.open(EditCollectionParentSelectorComponent);
|
||||
this.modalService.open(EditCollectionSelectorComponent);
|
||||
}
|
||||
} as OnClickMenuItemModel,
|
||||
},
|
||||
@@ -205,7 +205,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
||||
type: MenuItemType.ONCLICK,
|
||||
text: 'menu.section.edit_item',
|
||||
function: () => {
|
||||
this.modalService.open(EditItemParentSelectorComponent);
|
||||
this.modalService.open(EditItemSelectorComponent);
|
||||
}
|
||||
} as OnClickMenuItemModel,
|
||||
},
|
||||
|
@@ -11,7 +11,6 @@ import { CommunitySearchResultListElementComponent } from '../shared/object-list
|
||||
import { ItemSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component';
|
||||
import { CommunitySearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component'
|
||||
import { CollectionSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component';
|
||||
import { SearchService } from './search-service/search.service';
|
||||
import { SearchSidebarComponent } from './search-sidebar/search-sidebar.component';
|
||||
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
|
||||
import { SearchSidebarEffects } from './search-sidebar/search-sidebar.effects';
|
||||
@@ -46,13 +45,12 @@ const effects = [
|
||||
SearchResultsComponent,
|
||||
SearchSidebarComponent,
|
||||
SearchSettingsComponent,
|
||||
ItemSearchResultListElementComponent,
|
||||
CollectionSearchResultListElementComponent,
|
||||
CommunitySearchResultListElementComponent,
|
||||
// ItemSearchResultListElementComponent,
|
||||
// CollectionSearchResultListElementComponent,
|
||||
// CommunitySearchResultListElementComponent,
|
||||
ItemSearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
CommunitySearchResultListElementComponent,
|
||||
SearchFiltersComponent,
|
||||
SearchFilterComponent,
|
||||
SearchFacetFilterComponent,
|
||||
@@ -70,9 +68,9 @@ const effects = [
|
||||
SearchConfigurationService
|
||||
],
|
||||
entryComponents: [
|
||||
ItemSearchResultListElementComponent,
|
||||
CollectionSearchResultListElementComponent,
|
||||
CommunitySearchResultListElementComponent,
|
||||
// ItemSearchResultListElementComponent,
|
||||
// CollectionSearchResultListElementComponent,
|
||||
// CommunitySearchResultListElementComponent,
|
||||
ItemSearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
|
@@ -6,20 +6,14 @@
|
||||
[formControl]="input">
|
||||
</div>
|
||||
<div class="dropdown-divider"></div>
|
||||
<div class="scrollable-menu" #entryList>
|
||||
<button class="dropdown-item disabled" *ngIf="(listEntries$ | async)?.length == 0">
|
||||
<div class="scrollable-menu list-group">
|
||||
<button class="list-group-item list-group-item-action border-0 disabled" *ngIf="(listEntries$ | async)?.length == 0">
|
||||
{{'submission.sections.general.no-collection' | translate}}
|
||||
</button>
|
||||
<button *ngFor="let listEntry of (listEntries$ | async)"
|
||||
class="dropdown-item list-entry"
|
||||
title="{{ listEntry.dso.name }}"
|
||||
(click)="onSelect.emit(listEntry.dso)" #listEntryElement>
|
||||
<ul class="list-unstyled mb-0">
|
||||
<li class="list-item text-truncate text-secondary"
|
||||
*ngFor="let parent of listEntry.parents">
|
||||
{{ parent.name }} <i class="fa fa-level-down" aria-hidden="true"></i>
|
||||
</li>
|
||||
<li class="list-item text-truncate text-primary font-weight-bold">{{ listEntry.dso.name }}</li>
|
||||
</ul>
|
||||
<button *ngFor="let listEntry of (listEntries$ | async)?.payload.page"
|
||||
class="list-group-item list-group-item-action border-0 list-entry"
|
||||
title="{{ listEntry.dspaceObject.name }}"
|
||||
(click)="onSelect.emit(listEntry.dspaceObject)" #listEntryElement>
|
||||
<ds-wrapper-list-element [object]="listEntry"></ds-wrapper-list-element>
|
||||
</button>
|
||||
</div>
|
@@ -0,0 +1,65 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { DSOSelectorComponent } from './dso-selector.component';
|
||||
import { SearchService } from '../../../+search-page/search-service/search.service';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
import { PaginatedSearchOptions } from '../../../+search-page/paginated-search-options.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
|
||||
fdescribe('DSOSelectorComponent', () => {
|
||||
let component: DSOSelectorComponent;
|
||||
let fixture: ComponentFixture<DSOSelectorComponent>;
|
||||
let debugElement: DebugElement;
|
||||
|
||||
const currentDSOId = 'test-uuid-ford-sose';
|
||||
const type = DSpaceObjectType.ITEM;
|
||||
const searchResult = new ItemSearchResult();
|
||||
const item = new Item();
|
||||
item.metadata = { 'dc.title': [{ value: 'Item title', language: undefined }] };
|
||||
searchResult.dspaceObject = item;
|
||||
searchResult.hitHighlights = {};
|
||||
const searchService = jasmine.createSpyObj('searchService', {
|
||||
search: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(undefined, [searchResult])))
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
declarations: [DSOSelectorComponent],
|
||||
providers: [
|
||||
{ provide: SearchService, useValue: searchService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DSOSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement;
|
||||
component.currentDSOId = currentDSOId;
|
||||
component.type = type;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should initially call the search method on the SearchService with the given DSO uuid', () => {
|
||||
const searchOptions = new PaginatedSearchOptions({
|
||||
query: currentDSOId,
|
||||
dsoType: type,
|
||||
pagination: (component as any).defaultPagination
|
||||
});
|
||||
expect(searchService.search).toHaveBeenCalledWith(searchOptions);
|
||||
});
|
||||
|
||||
});
|
@@ -21,32 +21,60 @@ import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
|
||||
interface DSOSelectListEntry {
|
||||
parents: DSpaceObject[],
|
||||
dso: DSpaceObject
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-selector',
|
||||
// styleUrls: ['./dso-selector.component.scss'],
|
||||
templateUrl: './dso-selector.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component to render a list of DSO's of which one can be selected
|
||||
* The user can search the list by using the input field
|
||||
*/
|
||||
export class DSOSelectorComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/**
|
||||
* The initially selected DSO's uuid
|
||||
*/
|
||||
@Input() currentDSOId: string;
|
||||
|
||||
/**
|
||||
* The type of DSpace objects this components shows a list of
|
||||
*/
|
||||
@Input() type: DSpaceObjectType;
|
||||
|
||||
/**
|
||||
* Emits the selected Object when a user selects it in the list
|
||||
*/
|
||||
@Output() onSelect: EventEmitter<DSpaceObject> = new EventEmitter();
|
||||
|
||||
/**
|
||||
* Input form control to query the list
|
||||
*/
|
||||
public input: FormControl = new FormControl();
|
||||
// private subs: Subscription[] = [];
|
||||
|
||||
/**
|
||||
* Default pagination for this feature
|
||||
*/
|
||||
private defaultPagination = { id: 'dso-selector', currentPage: 1, pageSize: 5 } as any;
|
||||
listEntries$: Observable<DSOSelectListEntry[]>;
|
||||
|
||||
/**
|
||||
* List with search results of DSpace objects for the current query
|
||||
*/
|
||||
listEntries$: Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>;
|
||||
|
||||
/**
|
||||
* List of element references to all elements
|
||||
*/
|
||||
@ViewChildren('listEntryElement') listElements: QueryList<ElementRef>;
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the listEntries$ variable with search results based on the input field's current value
|
||||
* The search will always start with the initial currentDSOId value
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.listEntries$ = this.input.valueChanges
|
||||
.pipe(
|
||||
@@ -60,21 +88,13 @@ export class DSOSelectorComponent implements OnInit, AfterViewInit {
|
||||
})
|
||||
)
|
||||
}
|
||||
),
|
||||
map((searchResultsRD: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => {
|
||||
return searchResultsRD.payload.page.map(
|
||||
(searchResult: SearchResult<DSpaceObject>) => {
|
||||
let dso = searchResult.dspaceObject;
|
||||
return {
|
||||
parents: this.retrieveParentList(dso),
|
||||
dso
|
||||
} as DSOSelectListEntry
|
||||
}
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure to set focus on the first list element when the initial search (with currentDSOId) emits a single value
|
||||
*/
|
||||
ngAfterViewInit(): void {
|
||||
this.listElements.changes.pipe(
|
||||
take(1)
|
||||
@@ -84,17 +104,4 @@ export class DSOSelectorComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
retrieveParentList(dso: DSpaceObject, parents: DSpaceObject[] = []) {
|
||||
return [{ name: 'Test Community' } as any];
|
||||
// if (hasValue(dso.owner)) {
|
||||
// dso.owner.pipe(
|
||||
// first(),
|
||||
// ).subscribe((parentRD) => {
|
||||
// const newDSO: DSpaceObject = parentRD.payload;
|
||||
// parents = [...this.retrieveParentList(newDSO, parents), newDSO];
|
||||
// });
|
||||
// }
|
||||
// return parents;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
<div>
|
||||
<div class="modal-header">New Collection
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ds-dso-selector [currentDSOId]="(communityRD$ | async)?.payload.uuid" [type]="type"
|
||||
(onSelect)="createCollection($event)"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -5,39 +5,34 @@ import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { COLLECTION_PARENT_PARAMETER } from '../../../../+collection-page/collection-page-routing.module';
|
||||
import {
|
||||
COLLECTION_PARENT_PARAMETER,
|
||||
getCollectionCreatePath
|
||||
} from '../../../../+collection-page/collection-page-routing.module';
|
||||
import {
|
||||
DSOSelectorModalWrapperComponent,
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-create-collection-parent-selector',
|
||||
// styleUrls: ['./create-collection-parent-selector.component.scss'],
|
||||
templateUrl: './create-collection-parent-selector.component.html',
|
||||
templateUrl: '../dso-selector-modal-wrapper.component.html',
|
||||
})
|
||||
export class CreateCollectionParentSelectorComponent implements OnInit {
|
||||
@Input() communityRD$: Observable<RemoteData<Community>>;
|
||||
type = DSpaceObjectType.COMMUNITY;
|
||||
export class CreateCollectionParentSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||
objectType = DSpaceObjectType.COLLECTION;
|
||||
selectorType = DSpaceObjectType.COMMUNITY;
|
||||
action = SelectorActionType.CREATE;
|
||||
|
||||
private createPath = '/collections/create';
|
||||
|
||||
constructor(private activeModal: NgbActiveModal, private route: ActivatedRoute, private router: Router) {
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.communityRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data.community));
|
||||
}
|
||||
|
||||
createCollection(dso: DSpaceObject) {
|
||||
this.close();
|
||||
navigate(dso: DSpaceObject) {
|
||||
let navigationExtras: NavigationExtras = {
|
||||
queryParams: {
|
||||
[COLLECTION_PARENT_PARAMETER]: dso.uuid,
|
||||
}
|
||||
};
|
||||
this.router.navigate([this.createPath], navigationExtras);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
this.router.navigate([getCollectionCreatePath()], navigationExtras);
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,19 @@
|
||||
<div>
|
||||
<div class="modal-header">New Community
|
||||
<div class="modal-header">{{'dso-selector.'+ action + '.' + objectType.toString().toLowerCase() + '.head' | translate}}
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<button class="btn btn-outline-primary btn-lg btn-block" (click)="createCommunity()">Create a new top-level community</button>
|
||||
<button class="btn btn-outline-primary btn-lg btn-block" (click)="selectObject(undefined)">{{'dso-selector.create.community.top-level' | translate}}</button>
|
||||
<h3 class="position-relative py-1 my-3 font-weight-normal">
|
||||
<hr>
|
||||
<div id="create-community-or-separator" class="text-center position-absolute w-100">
|
||||
<span class="px-4 bg-white">or</span>
|
||||
</div>
|
||||
</h3>
|
||||
<h5 class="px-2">Create a new community in</h5>
|
||||
<ds-dso-selector [currentDSOId]="(communityRD$ | async)?.payload.uuid" [type]="type"
|
||||
(onSelect)="createCommunity($event)"></ds-dso-selector>
|
||||
|
||||
<h5 class="px-2">{{'dso-selector.create.community.sub-level' | translate}}</h5>
|
||||
<ds-dso-selector [currentDSOId]="(dsoRD$ | async)?.payload.uuid" [type]="selectorType" (onSelect)="selectObject($event)"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -8,28 +8,30 @@ import { hasValue } from '../../../empty.util';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { COMMUNITY_PARENT_PARAMETER } from '../../../../+community-page/community-page-routing.module';
|
||||
import {
|
||||
COMMUNITY_PARENT_PARAMETER,
|
||||
getCommunityCreatePath
|
||||
} from '../../../../+community-page/community-page-routing.module';
|
||||
import {
|
||||
DSOSelectorModalWrapperComponent,
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-create-community-parent-selector',
|
||||
styleUrls: ['./create-community-parent-selector.component.scss'],
|
||||
templateUrl: './create-community-parent-selector.component.html',
|
||||
})
|
||||
export class CreateCommunityParentSelectorComponent implements OnInit {
|
||||
@Input() communityRD$: Observable<RemoteData<Community>>;
|
||||
type = DSpaceObjectType.COMMUNITY;
|
||||
export class CreateCommunityParentSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||
objectType = DSpaceObjectType.COMMUNITY;
|
||||
selectorType = DSpaceObjectType.COMMUNITY;
|
||||
action = SelectorActionType.CREATE;
|
||||
|
||||
private createPath = '/communities/create';
|
||||
|
||||
constructor(private activeModal: NgbActiveModal, private route: ActivatedRoute, private router: Router) {
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.communityRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data.community));
|
||||
}
|
||||
|
||||
createCommunity(dso?: DSpaceObject) {
|
||||
this.close();
|
||||
navigate(dso: DSpaceObject) {
|
||||
let navigationExtras: NavigationExtras = {};
|
||||
if (hasValue(dso)) {
|
||||
navigationExtras = {
|
||||
@@ -38,10 +40,6 @@ export class CreateCommunityParentSelectorComponent implements OnInit {
|
||||
}
|
||||
};
|
||||
}
|
||||
this.router.navigate([this.createPath], navigationExtras);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
this.router.navigate([getCommunityCreatePath()], navigationExtras);
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<div class="modal-header">New Item
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ds-dso-selector [currentDSOId]="(collectionRD$ | async)?.payload.uuid" [type]="type"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -9,32 +9,28 @@ import { hasValue } from '../../../empty.util';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import {
|
||||
DSOSelectorModalWrapperComponent,
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-create-item-parent-selector',
|
||||
// styleUrls: ['./create-item-parent-selector.component.scss'],
|
||||
templateUrl: './create-item-parent-selector.component.html',
|
||||
templateUrl: '../dso-selector-modal-wrapper.component.html',
|
||||
})
|
||||
export class CreateItemParentSelectorComponent implements OnInit {
|
||||
@Input() collectionRD$: Observable<RemoteData<Collection>>;
|
||||
type = DSpaceObjectType.COLLECTION;
|
||||
export class CreateItemParentSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||
objectType = DSpaceObjectType.ITEM;
|
||||
selectorType = DSpaceObjectType.COLLECTION;
|
||||
action = SelectorActionType.CREATE;
|
||||
|
||||
constructor(private activeModal: NgbActiveModal, private route: ActivatedRoute) {
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.collectionRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data.collection));
|
||||
}
|
||||
|
||||
createItem(dso: DSpaceObject) {
|
||||
this.close();
|
||||
|
||||
navigate(dso: DSpaceObject) {
|
||||
let path;
|
||||
// path = this.createPath;
|
||||
// this.router.navigate([path]);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,10 @@
|
||||
<div>
|
||||
<div class="modal-header">{{'dso-selector.'+ action + '.' + objectType.toString().toLowerCase() + '.head' | translate}}
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ds-dso-selector [currentDSOId]="(dsoRD$ | async)?.payload.uuid" [type]="selectorType" (onSelect)="selectObject($event)"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,43 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
|
||||
export enum SelectorActionType {
|
||||
CREATE = 'create',
|
||||
EDIT = 'edit'
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-selector-modal-wrapper',
|
||||
templateUrl: './dso-selector-modal-wrapper.component.html',
|
||||
})
|
||||
export abstract class DSOSelectorModalWrapperComponent implements OnInit {
|
||||
@Input() dsoRD$: Observable<RemoteData<DSpaceObject>>;
|
||||
objectType: DSpaceObjectType;
|
||||
selectorType: DSpaceObjectType;
|
||||
action: SelectorActionType;
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const typeString = this.selectorType.toString().toLowerCase();
|
||||
this.dsoRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data[typeString]));
|
||||
}
|
||||
|
||||
selectObject(dso: DSpaceObject) {
|
||||
this.close();
|
||||
this.navigate(dso);
|
||||
}
|
||||
|
||||
abstract navigate(dso: DSpaceObject);
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<div class="modal-header">Edit Collection
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ds-dso-selector [currentDSOId]="(collectionRD$ | async)?.payload.uuid" [type]="type" (onSelect)="editCollection($event)"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -1,37 +0,0 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Collection } from '../../../../core/shared/collection.model';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-edit-collection-parent-selector',
|
||||
// styleUrls: ['./edit-collection-parent-selector.component.scss'],
|
||||
templateUrl: './edit-collection-parent-selector.component.html',
|
||||
})
|
||||
export class EditCollectionParentSelectorComponent implements OnInit {
|
||||
@Input() collectionRD$: Observable<RemoteData<Collection>>;
|
||||
type = DSpaceObjectType.COLLECTION;
|
||||
|
||||
constructor(private activeModal: NgbActiveModal, private route: ActivatedRoute, private router: Router) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.collectionRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data.collection));
|
||||
}
|
||||
|
||||
editCollection(dso: DSpaceObject) {
|
||||
this.close();
|
||||
this.router.navigate([getCollectionEditPath(dso.uuid)]);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
||||
import {
|
||||
DSOSelectorModalWrapperComponent,
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-edit-collection-selector',
|
||||
templateUrl: '../dso-selector-modal-wrapper.component.html',
|
||||
})
|
||||
export class EditCollectionSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||
objectType = DSpaceObjectType.COLLECTION;
|
||||
selectorType = DSpaceObjectType.COLLECTION;
|
||||
action = SelectorActionType.EDIT;
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
||||
navigate(dso: DSpaceObject) {
|
||||
this.router.navigate([getCollectionEditPath(dso.uuid)]);
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<div class="modal-header">Edit Community
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ds-dso-selector [currentDSOId]="(communityRD$ | async)?.payload.uuid" [type]="type" (onSelect)="editCommunity($event)"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -1,37 +0,0 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-edit-community-parent-selector',
|
||||
// styleUrls: ['./edit-community-parent-selector.component.scss'],
|
||||
templateUrl: './edit-community-parent-selector.component.html',
|
||||
})
|
||||
export class EditCommunityParentSelectorComponent implements OnInit {
|
||||
@Input() communityRD$: Observable<RemoteData<Community>>;
|
||||
type = DSpaceObjectType.COMMUNITY;
|
||||
|
||||
constructor(private activeModal: NgbActiveModal, private route: ActivatedRoute, private router: Router) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.communityRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data.collection));
|
||||
}
|
||||
|
||||
editCommunity(dso: DSpaceObject) {
|
||||
this.close();
|
||||
this.router.navigate([getCommunityEditPath(dso.uuid)]);
|
||||
}
|
||||
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
||||
import {
|
||||
DSOSelectorModalWrapperComponent,
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-edit-community-selector',
|
||||
templateUrl: '../dso-selector-modal-wrapper.component.html',
|
||||
})
|
||||
|
||||
export class EditCommunitySelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||
objectType = DSpaceObjectType.COMMUNITY;
|
||||
selectorType = DSpaceObjectType.COMMUNITY;
|
||||
action = SelectorActionType.EDIT;
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
||||
navigate(dso: DSpaceObject) {
|
||||
this.router.navigate([getCommunityEditPath(dso.uuid)]);
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<div class="modal-header">Edit Item
|
||||
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ds-dso-selector [currentDSOId]="(itemRD$ | async)?.payload.uuid" [type]="type" (onSelect)="editItem($event)"></ds-dso-selector>
|
||||
</div>
|
||||
</div>
|
@@ -10,29 +10,25 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { getItemEditPath } from '../../../../+item-page/item-page-routing.module';
|
||||
import {
|
||||
DSOSelectorModalWrapperComponent,
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-edit-item-parent-selector',
|
||||
// styleUrls: ['./edit-item-parent-selector.component.scss'],
|
||||
templateUrl: './edit-item-parent-selector.component.html',
|
||||
selector: 'ds-edit-item-selector',
|
||||
templateUrl: '../dso-selector-modal-wrapper.component.html',
|
||||
})
|
||||
export class EditItemParentSelectorComponent implements OnInit {
|
||||
@Input() itemRD$: Observable<RemoteData<Item>>;
|
||||
type = DSpaceObjectType.ITEM;
|
||||
export class EditItemSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||
objectType = DSpaceObjectType.ITEM;
|
||||
selectorType = DSpaceObjectType.ITEM;
|
||||
action = SelectorActionType.EDIT;
|
||||
|
||||
constructor(private activeModal: NgbActiveModal, private route: ActivatedRoute, private router: Router) {
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.itemRD$ = this.route.root.firstChild.firstChild.data.pipe(map(data => data.item));
|
||||
}
|
||||
|
||||
editItem(dso: DSpaceObject) {
|
||||
this.close();
|
||||
navigate(dso: DSpaceObject) {
|
||||
this.router.navigate([getItemEditPath(dso.uuid)]);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.activeModal.close();
|
||||
}
|
||||
}
|
@@ -99,9 +99,12 @@ import { DSOSelectorComponent } from './dso-selector/dso-selector/dso-selector.c
|
||||
import { CreateCommunityParentSelectorComponent } from './dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component';
|
||||
import { CreateItemParentSelectorComponent } from './dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';
|
||||
import { CreateCollectionParentSelectorComponent } from './dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component';
|
||||
import { EditCollectionParentSelectorComponent } from './dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component';
|
||||
import { EditItemParentSelectorComponent } from './dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component';
|
||||
import { EditCommunityParentSelectorComponent } from './dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component';
|
||||
import { CommunitySearchResultListElementComponent } from './object-list/search-result-list-element/community-search-result/community-search-result-list-element.component';
|
||||
import { CollectionSearchResultListElementComponent } from './object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component';
|
||||
import { ItemSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-search-result-list-element.component';
|
||||
import { EditItemSelectorComponent } from './dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-selector.component';
|
||||
import { EditCommunitySelectorComponent } from './dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-selector.component';
|
||||
import { EditCollectionSelectorComponent } from './dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-selector.component';
|
||||
|
||||
const MODULES = [
|
||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||
@@ -188,9 +191,12 @@ const COMPONENTS = [
|
||||
CreateCommunityParentSelectorComponent,
|
||||
CreateCollectionParentSelectorComponent,
|
||||
CreateItemParentSelectorComponent,
|
||||
EditCommunityParentSelectorComponent,
|
||||
EditCollectionParentSelectorComponent,
|
||||
EditItemParentSelectorComponent,
|
||||
EditCommunitySelectorComponent,
|
||||
EditCollectionSelectorComponent,
|
||||
EditItemSelectorComponent,
|
||||
CommunitySearchResultListElementComponent,
|
||||
CollectionSearchResultListElementComponent,
|
||||
ItemSearchResultListElementComponent,
|
||||
];
|
||||
|
||||
const ENTRY_COMPONENTS = [
|
||||
@@ -199,6 +205,9 @@ const ENTRY_COMPONENTS = [
|
||||
CollectionListElementComponent,
|
||||
CommunityListElementComponent,
|
||||
SearchResultListElementComponent,
|
||||
CommunitySearchResultListElementComponent,
|
||||
CollectionSearchResultListElementComponent,
|
||||
ItemSearchResultListElementComponent,
|
||||
ItemGridElementComponent,
|
||||
CollectionGridElementComponent,
|
||||
CommunityGridElementComponent,
|
||||
@@ -208,9 +217,9 @@ const ENTRY_COMPONENTS = [
|
||||
CreateCommunityParentSelectorComponent,
|
||||
CreateCollectionParentSelectorComponent,
|
||||
CreateItemParentSelectorComponent,
|
||||
EditCommunityParentSelectorComponent,
|
||||
EditCollectionParentSelectorComponent,
|
||||
EditItemParentSelectorComponent,
|
||||
EditCommunitySelectorComponent,
|
||||
EditCollectionSelectorComponent,
|
||||
EditItemSelectorComponent,
|
||||
];
|
||||
|
||||
const PROVIDERS = [
|
||||
|
@@ -40,4 +40,8 @@ export class SearchServiceStub {
|
||||
getFilterLabels() {
|
||||
return observableOf([]);
|
||||
}
|
||||
|
||||
search() {
|
||||
return observableOf({});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user