-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DS-4514 start a new submission via file #724
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
59564eb
[CST-3091] add comp collection-selector, fix issue
ddinuzzo e6b0c20
Merge branch 'CST-3090-collection-dropdown' into CST-3091
ddinuzzo 573968a
Merge branch 'CST-3090-collection-dropdown' into CST-3091
ddinuzzo 0ca1798
[CST-3091] fix tests and add new labels
ddinuzzo 8df505b
Merge branch 'master' into CST-3091
ddinuzzo 8068436
[CST-3091] fix close dialog and test
ddinuzzo 99a6bf5
Merge branch 'master' into CST-3091
ddinuzzo 6ef3f68
Fixed issue with search requests that weren't fetched again after ent…
atarix83 e46ee57
reverted i18n files to master version
atarix83 73b5a37
Merge branch 'main' into CST-3091
ddinuzzo 6422288
added TypeDocs on collection selectior component
ddinuzzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/app/+my-dspace-page/collection-selector/collection-selector.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div> | ||
<div class="modal-header">{{'dso-selector.create.submission.head' | translate}} | ||
<button type="button" class="close" (click)="close()" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
<ds-collection-dropdown (selectionChange)="selectObject($event.collection)"> | ||
</ds-collection-dropdown> | ||
</div> | ||
</div> |
Empty file.
164 changes: 164 additions & 0 deletions
164
src/app/+my-dspace-page/collection-selector/collection-selector.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; | ||
|
||
import { CollectionSelectorComponent } from './collection-selector.component'; | ||
import { CollectionDropdownComponent } from 'src/app/shared/collection-dropdown/collection-dropdown.component'; | ||
import { Collection } from 'src/app/core/shared/collection.model'; | ||
import { of, Observable } from 'rxjs'; | ||
import { RemoteData } from 'src/app/core/data/remote-data'; | ||
import { Community } from 'src/app/core/shared/community.model'; | ||
import { FindListOptions } from 'src/app/core/data/request.models'; | ||
import { FollowLinkConfig } from 'src/app/shared/utils/follow-link-config.model'; | ||
import { PaginatedList } from 'src/app/core/data/paginated-list'; | ||
import { createSuccessfulRemoteDataObject } from 'src/app/shared/remote-data.utils'; | ||
import { PageInfo } from 'src/app/core/shared/page-info.model'; | ||
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; | ||
import { TranslateLoaderMock } from 'src/app/shared/mocks/translate-loader.mock'; | ||
import { CollectionDataService } from 'src/app/core/data/collection-data.service'; | ||
import { ChangeDetectorRef, ElementRef, NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { hot } from 'jasmine-marbles'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
describe('CollectionSelectorComponent', () => { | ||
let component: CollectionSelectorComponent; | ||
let fixture: ComponentFixture<CollectionSelectorComponent>; | ||
const modal = jasmine.createSpyObj('modal', ['close', 'dismiss']); | ||
|
||
const community: Community = Object.assign(new Community(), { | ||
id: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', | ||
uuid: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', | ||
name: 'Community 1' | ||
}); | ||
|
||
const collections: Collection[] = [ | ||
Object.assign(new Collection(), { | ||
id: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', | ||
name: 'Collection 1', | ||
metadata: [ | ||
{ | ||
key: 'dc.title', | ||
language: 'en_US', | ||
value: 'Community 1-Collection 1' | ||
}], | ||
parentCommunity: of( | ||
new RemoteData(false, false, true, undefined, community, 200) | ||
) | ||
}), | ||
Object.assign(new Collection(), { | ||
id: '59ee713b-ee53-4220-8c3f-9860dc84fe33', | ||
name: 'Collection 2', | ||
metadata: [ | ||
{ | ||
key: 'dc.title', | ||
language: 'en_US', | ||
value: 'Community 1-Collection 2' | ||
}], | ||
parentCommunity: of( | ||
new RemoteData(false, false, true, undefined, community, 200) | ||
) | ||
}), | ||
Object.assign(new Collection(), { | ||
id: 'e9dbf393-7127-415f-8919-55be34a6e9ed', | ||
name: 'Collection 3', | ||
metadata: [ | ||
{ | ||
key: 'dc.title', | ||
language: 'en_US', | ||
value: 'Community 1-Collection 3' | ||
}], | ||
parentCommunity: of( | ||
new RemoteData(false, false, true, undefined, community, 200) | ||
) | ||
}), | ||
Object.assign(new Collection(), { | ||
id: '59da2ff0-9bf4-45bf-88be-e35abd33f304', | ||
name: 'Collection 4', | ||
metadata: [ | ||
{ | ||
key: 'dc.title', | ||
language: 'en_US', | ||
value: 'Community 1-Collection 4' | ||
}], | ||
parentCommunity: of( | ||
new RemoteData(false, false, true, undefined, community, 200) | ||
) | ||
}), | ||
Object.assign(new Collection(), { | ||
id: 'a5159760-f362-4659-9e81-e3253ad91ede', | ||
name: 'Collection 5', | ||
metadata: [ | ||
{ | ||
key: 'dc.title', | ||
language: 'en_US', | ||
value: 'Community 1-Collection 5' | ||
}], | ||
parentCommunity: of( | ||
new RemoteData(false, false, true, undefined, community, 200) | ||
) | ||
}) | ||
]; | ||
|
||
// tslint:disable-next-line: max-classes-per-file | ||
const collectionDataServiceMock = { | ||
getAuthorizedCollection(query: string, options: FindListOptions = {}, ...linksToFollow: Array<FollowLinkConfig<Collection>>): Observable<RemoteData<PaginatedList<Collection>>> { | ||
return hot( 'a|', { | ||
a: createSuccessfulRemoteDataObject( | ||
new PaginatedList(new PageInfo(), collections) | ||
) | ||
}); | ||
} | ||
}; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
TranslateModule.forRoot({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useClass: TranslateLoaderMock | ||
} | ||
}) | ||
], | ||
declarations: [ CollectionSelectorComponent, CollectionDropdownComponent ], | ||
providers: [ | ||
{provide: CollectionDataService, useValue: collectionDataServiceMock}, | ||
{provide: ChangeDetectorRef, useValue: {}}, | ||
{provide: ElementRef, userValue: {}}, | ||
{provide: NgbActiveModal, useValue: modal}, | ||
{provide: ActivatedRoute, useValue: {}} | ||
], | ||
schemas: [NO_ERRORS_SCHEMA] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CollectionSelectorComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should call selectObject', fakeAsync(() => { | ||
spyOn(component, 'selectObject'); | ||
fixture.detectChanges(); | ||
tick(); | ||
fixture.whenStable().then(() => { | ||
const collectionItem = fixture.debugElement.query(By.css('.collection-item:nth-child(2)')); | ||
collectionItem.triggerEventHandler('click', { | ||
preventDefault: () => {/**/ | ||
} | ||
}); | ||
expect(component.selectObject).toHaveBeenCalled(); | ||
}); | ||
})); | ||
|
||
it('should close the dialog', () => { | ||
component.close(); | ||
expect((component as any).activeModal.close).toHaveBeenCalled(); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
src/app/+my-dspace-page/collection-selector/collection-selector.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Component } from '@angular/core'; | ||
import { DSpaceObject } from '../../core/shared/dspace-object.model'; | ||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
@Component({ | ||
selector: 'ds-collection-selector', | ||
templateUrl: './collection-selector.component.html', | ||
styleUrls: ['./collection-selector.component.scss'] | ||
}) | ||
export class CollectionSelectorComponent { | ||
|
||
constructor(protected activeModal: NgbActiveModal) {} | ||
|
||
/** | ||
* Method called when an element has been selected from collection list. | ||
* Its close the active modal and send selected value to the component container | ||
* @param dso The selected DSpaceObject | ||
*/ | ||
selectObject(dso: DSpaceObject) { | ||
this.activeModal.close(dso); | ||
} | ||
|
||
/** | ||
* Close the modal | ||
*/ | ||
close() { | ||
this.activeModal.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a TypeDocs description to this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done