diff --git a/config/environment.default.js b/config/environment.default.js index b493d0473a..b8eae1ccff 100644 --- a/config/environment.default.js +++ b/config/environment.default.js @@ -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: { diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 208e5415a8..38d90e67ea 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -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" + } + } } } diff --git a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts index 8b71bca423..e429b57bae 100644 --- a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts +++ b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts @@ -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, }, diff --git a/src/app/+search-page/search-page.module.ts b/src/app/+search-page/search-page.module.ts index 5fa1fadfae..4cd0c9428b 100644 --- a/src/app/+search-page/search-page.module.ts +++ b/src/app/+search-page/search-page.module.ts @@ -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, diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.html b/src/app/shared/dso-selector/dso-selector/dso-selector.component.html index ceaefc2ac9..bc520bfe3b 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.html +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.html @@ -6,20 +6,14 @@ [formControl]="input"> -
- -
\ No newline at end of file diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts new file mode 100644 index 0000000000..38067f3dc0 --- /dev/null +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts @@ -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; + 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); + }); + +}); diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 6eb5716489..f3164a37e2 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -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 = 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; + + /** + * List with search results of DSpace objects for the current query + */ + listEntries$: Observable>>>; + + /** + * List of element references to all elements + */ @ViewChildren('listEntryElement') listElements: QueryList; 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>>) => { - return searchResultsRD.payload.page.map( - (searchResult: SearchResult) => { - 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; - } } diff --git a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html deleted file mode 100644 index 16fd37928f..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts index c4bff22c7b..631480c04d 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts @@ -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>; - 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); } } diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html index a50f1a57c6..e6a0db3b62 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html @@ -1,19 +1,19 @@
- \ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts index 017f933d1f..c3d112a455 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts @@ -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>; - 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); } } diff --git a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.html deleted file mode 100644 index 1009867056..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts index 44a8d67d04..dac79dddcb 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts @@ -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>; - 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(); - } } diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html new file mode 100644 index 0000000000..88f4a6f917 --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html @@ -0,0 +1,10 @@ +
+ + +
\ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts new file mode 100644 index 0000000000..3d053e9dcb --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts @@ -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>; + 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(); + } +} diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component.html deleted file mode 100644 index 9d050ef2fc..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component.ts deleted file mode 100644 index 11e1c47f55..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component.ts +++ /dev/null @@ -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>; - 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(); - } -} diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-selector.component.ts new file mode 100644 index 0000000000..edf3f37f6e --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-selector.component.ts @@ -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)]); + } +} diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component.html deleted file mode 100644 index b75a760f8e..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component.ts deleted file mode 100644 index 8932be26ca..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component.ts +++ /dev/null @@ -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>; - 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(); - } -} diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-selector.component.ts new file mode 100644 index 0000000000..9af974782a --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-selector.component.ts @@ -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)]); + } +} diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component.html deleted file mode 100644 index a9c508e381..0000000000 --- a/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-selector.component.ts similarity index 57% rename from src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component.ts rename to src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-selector.component.ts index f71e61a1fa..ff6ab35bf3 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-selector.component.ts @@ -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>; - 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(); - } } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 3ee20d435d..5d87148a73 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -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 = [ diff --git a/src/app/shared/testing/search-service-stub.ts b/src/app/shared/testing/search-service-stub.ts index cbc0611a47..2a46e42ef5 100644 --- a/src/app/shared/testing/search-service-stub.ts +++ b/src/app/shared/testing/search-service-stub.ts @@ -40,4 +40,8 @@ export class SearchServiceStub { getFilterLabels() { return observableOf([]); } + + search() { + return observableOf({}); + } }