forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
119915: Changed the dspace.entity.type textarea with a select to prev…
…ent incorrect values
- Loading branch information
1 parent
2ba3f0b
commit 77b66a5
Showing
8 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...-value-field/dso-edit-metadata-entity-field/dso-edit-metadata-entity-field.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,5 @@ | ||
<select class="form-control" [(ngModel)]="mdValue?.newValue.value" (ngModelChange)="confirm.emit(false)"> | ||
<option *ngFor="let entity of (entities$ | async)" [value]="entity.label === 'none' ? undefined : entity.label"> | ||
{{ entity.label }} | ||
</option> | ||
</select> |
Empty file.
32 changes: 32 additions & 0 deletions
32
...lue-field/dso-edit-metadata-entity-field/dso-edit-metadata-entity-field.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,32 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { DsoEditMetadataEntityFieldComponent } from './dso-edit-metadata-entity-field.component'; | ||
import { EntityTypeDataServiceStub } from '../../../../shared/testing/entity-type-data.service.stub'; | ||
import { EntityTypeDataService } from '../../../../core/data/entity-type-data.service'; | ||
|
||
describe('DsoEditMetadataEntityFieldComponent', () => { | ||
let component: DsoEditMetadataEntityFieldComponent; | ||
let fixture: ComponentFixture<DsoEditMetadataEntityFieldComponent>; | ||
|
||
let entityTypeService: EntityTypeDataServiceStub; | ||
|
||
beforeEach(async () => { | ||
entityTypeService = new EntityTypeDataServiceStub(); | ||
|
||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
DsoEditMetadataEntityFieldComponent, | ||
], | ||
providers: [ | ||
{ provide: EntityTypeDataService, useValue: entityTypeService }, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DsoEditMetadataEntityFieldComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
...ta-value-field/dso-edit-metadata-entity-field/dso-edit-metadata-entity-field.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,38 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { editMetadataValueFieldComponent } from '../dso-edit-metadata-value-field-loader/dso-edit-metadata-value-field.decorator'; | ||
import { EditMetadataValueFieldType } from '../dso-edit-metadata-field-type.enum'; | ||
import { EntityTypeDataService } from '../../../../core/data/entity-type-data.service'; | ||
import { Observable } from 'rxjs'; | ||
import { getFirstSucceededRemoteListPayload } from '../../../../core/shared/operators'; | ||
import { ItemType } from '../../../../core/shared/item-relationships/item-type.model'; | ||
import { AbstractDsoEditMetadataValueFieldComponent } from '../abstract-dso-edit-metadata-value-field.component'; | ||
|
||
/** | ||
* The component used to gather input for entity-type metadata fields | ||
*/ | ||
@Component({ | ||
selector: 'ds-dso-edit-metadata-entity-field', | ||
templateUrl: './dso-edit-metadata-entity-field.component.html', | ||
styleUrls: ['./dso-edit-metadata-entity-field.component.scss'], | ||
}) | ||
@editMetadataValueFieldComponent(EditMetadataValueFieldType.ENTITY_TYPE) | ||
export class DsoEditMetadataEntityFieldComponent extends AbstractDsoEditMetadataValueFieldComponent implements OnInit { | ||
|
||
/** | ||
* List of all the existing entity types | ||
*/ | ||
entities$: Observable<ItemType[]>; | ||
|
||
constructor( | ||
protected entityTypeService: EntityTypeDataService, | ||
) { | ||
super(); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.entities$ = this.entityTypeService.findAll({ elementsPerPage: 100, currentPage: 1 }).pipe( | ||
getFirstSucceededRemoteListPayload(), | ||
); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
*/ | ||
export enum EditMetadataValueFieldType { | ||
PLAIN_TEXT = 'PLAIN_TEXT', | ||
ENTITY_TYPE = 'ENTITY_TYPE', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { FindListOptions } from '../../core/data/find-list-options.model'; | ||
import { FollowLinkConfig } from '../utils/follow-link-config.model'; | ||
import { ItemType } from '../../core/shared/item-relationships/item-type.model'; | ||
import { Observable } from 'rxjs'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
import { PaginatedList } from '../../core/data/paginated-list.model'; | ||
import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils'; | ||
import { createPaginatedList } from './utils.test'; | ||
|
||
/** | ||
* Stub class {@link EntityTypeDataService} | ||
*/ | ||
export class EntityTypeDataServiceStub { | ||
|
||
public findAll(_options?: FindListOptions, _useCachedVersionIfAvailable?: boolean, _reRequestOnStale?: boolean, ..._linksToFollow: FollowLinkConfig<ItemType>[]): Observable<RemoteData<PaginatedList<ItemType>>> { | ||
return createSuccessfulRemoteDataObject$(createPaginatedList()); | ||
} | ||
|
||
} |