Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import { RemoteData } from '@dspace/core/data/remote-data';
import { RequestService } from '@dspace/core/data/request.service';
import { NotificationsService } from '@dspace/core/notification-system/notifications.service';
import { Collection } from '@dspace/core/shared/collection.model';
import { Item } from '@dspace/core/shared/item.model';
import { NoContent } from '@dspace/core/shared/NoContent.model';
import {
getFirstCompletedRemoteData,
getFirstSucceededRemoteDataPayload,
} from '@dspace/core/shared/operators';
import { TemplateItem } from '@dspace/core/shared/template-item.model';
import { hasValue } from '@dspace/shared/utils/empty.util';
import {
TranslateModule,
Expand Down Expand Up @@ -63,7 +63,7 @@ export class CollectionMetadataComponent extends ComcolMetadataComponent<Collect
/**
* The collection's item template
*/
itemTemplateRD$: Observable<RemoteData<Item>>;
itemTemplateRD$: Observable<RemoteData<TemplateItem>>;

public constructor(
protected collectionDataService: CollectionDataService,
Expand Down Expand Up @@ -114,7 +114,7 @@ export class CollectionMetadataComponent extends ComcolMetadataComponent<Collect
getFirstSucceededRemoteDataPayload(),
);
const template$ = collection$.pipe(
switchMap((collection: Collection) => this.itemTemplateService.createByCollectionID(new Item(), collection.uuid).pipe(
switchMap((collection: Collection) => this.itemTemplateService.createByCollectionID(new TemplateItem(), collection.uuid).pipe(
getFirstSucceededRemoteDataPayload(),
)),
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/data/item-template-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { RestResponse } from '../cache/response.models';
import { CoreState } from '../core-state.model';
import { NotificationsService } from '../notification-system/notifications.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { Item } from '../shared/item.model';
import { testCreateDataImplementation } from './base/create-data.spec';
import { testDeleteDataImplementation } from './base/delete-data.spec';
import { testPatchDataImplementation } from './base/patch-data.spec';
Expand All @@ -22,12 +21,13 @@ import { RequestService } from './request.service';
import { RequestEntry } from './request-entry.model';
import { RestRequest } from './rest-request.model';
import createSpyObj = jasmine.createSpyObj;
import { TemplateItem } from '../shared/template-item.model';

describe('ItemTemplateDataService', () => {
let service: ItemTemplateDataService;
let byCollection: any;

const item = new Item();
const item = new TemplateItem();
const collectionEndpoint = 'https://rest.api/core/collections/4af28e99-6a9c-4036-a199-e1b587046d39';
const itemEndpoint = `${collectionEndpoint}/itemtemplate`;
const scopeID = '4af28e99-6a9c-4036-a199-e1b587046d39';
Expand Down
16 changes: 8 additions & 8 deletions src/app/core/data/item-template-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ObjectCacheService } from '../cache/object-cache.service';
import { NotificationsService } from '../notification-system/notifications.service';
import { FollowLinkConfig } from '../shared/follow-link-config.model';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { Item } from '../shared/item.model';
import { TemplateItem } from '../shared/template-item.model';
import { CreateDataImpl } from './base/create-data';
import { IdentifiableDataService } from './base/identifiable-data.service';
import { BundleDataService } from './bundle-data.service';
Expand All @@ -22,8 +22,8 @@ import { RequestService } from './request.service';
/**
* Data service for interacting with Item templates via their Collection
*/
class CollectionItemTemplateDataService extends IdentifiableDataService<Item> {
private createData: CreateDataImpl<Item>;
class CollectionItemTemplateDataService extends IdentifiableDataService<TemplateItem> {
private createData: CreateDataImpl<TemplateItem>;

constructor(
protected requestService: RequestService,
Expand All @@ -36,7 +36,7 @@ class CollectionItemTemplateDataService extends IdentifiableDataService<Item> {
super('itemtemplates', requestService, rdbService, objectCache, halService, undefined);

// We only intend to use createOnEndpoint, so this inner data service feature doesn't need an endpoint at all
this.createData = new CreateDataImpl<Item>(undefined, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
this.createData = new CreateDataImpl<TemplateItem>(undefined, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
}

/**
Expand All @@ -56,7 +56,7 @@ class CollectionItemTemplateDataService extends IdentifiableDataService<Item> {
* @param item
* @param collectionID
*/
public createTemplate(item: Item, collectionID: string): Observable<RemoteData<Item>> {
public createTemplate(item: TemplateItem, collectionID: string): Observable<RemoteData<TemplateItem>> {
return this.createData.createOnEndpoint(item, this.getIDHrefObs(collectionID));
}
}
Expand All @@ -74,7 +74,7 @@ export class ItemTemplateDataService extends BaseItemDataService {
protected objectCache: ObjectCacheService,
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected comparator: DSOChangeAnalyzer<Item>,
protected comparator: DSOChangeAnalyzer<TemplateItem>,
protected browseService: BrowseService,
protected bundleService: BundleDataService,
protected collectionService: CollectionDataService,
Expand All @@ -94,7 +94,7 @@ export class ItemTemplateDataService extends BaseItemDataService {
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
*/
findByCollectionID(collectionID: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Item>[]): Observable<RemoteData<Item>> {
findByCollectionID(collectionID: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<TemplateItem>[]): Observable<RemoteData<TemplateItem>> {
return this.byCollection.findById(collectionID, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}

Expand All @@ -103,7 +103,7 @@ export class ItemTemplateDataService extends BaseItemDataService {
* @param item
* @param collectionID
*/
createByCollectionID(item: Item, collectionID: string): Observable<RemoteData<Item>> {
createByCollectionID(item: TemplateItem, collectionID: string): Observable<RemoteData<TemplateItem>> {
return this.byCollection.createTemplate(item, collectionID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<div class="d-flex flex-row">
<div class="flex-grow-1 ds-flex-cell ds-value-cell"><b class="dont-break-out preserve-line-breaks">{{ dsoType + '.edit.metadata.headers.value' | translate }}</b></div>
<div class="ds-flex-cell ds-lang-cell"><b>{{ dsoType + '.edit.metadata.headers.language' | translate }}</b></div>
<div class="ds-flex-cell ds-authority-cell"><b>{{ dsoType + '.edit.metadata.headers.authority' | translate }}</b></div>
<div class="ds-flex-cell ds-security-cell"><b>{{'item.edit.metadata.headers.security'| translate}}</b></div>
<div class="text-center ds-flex-cell ds-edit-cell"><b>{{ dsoType + '.edit.metadata.headers.edit' | translate }}</b></div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('DsoEditMetadataHeadersComponent', () => {
fixture.detectChanges();
});

it('should display five headers', () => {
expect(fixture.debugElement.queryAll(By.css('.ds-flex-cell')).length).toEqual(5);
it('should display four headers', () => {
expect(fixture.debugElement.queryAll(By.css('.ds-flex-cell')).length).toEqual(4);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
max-width: var(--ds-dso-edit-lang-width);
}

.ds-authority-cell {
min-width: var(--ds-dso-edit-authority-width);
max-width: var(--ds-dso-edit-authority-width);
}

.ds-security-cell {
min-width: var(--ds-dso-edit-security-width);
max-width: var(--ds-dso-edit-security-width);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
</button>
}
@if ((isAuthorityControlled$ | async) && (isSuggesterVocabulary$ | async)) {
<div class="mt-2">
<div class="btn-group w-75">
<i dsAuthorityConfidenceState
class="fas fa-fw p-0 me-1 mt-auto mb-auto"
aria-hidden="true"
[authorityValue]="mdValue.newValue.confidence"
[iconMode]="true"
></i>
<div class="d-flex w-75 mt-2">
<i dsAuthorityConfidenceState
class="fas fa-fw p-0 me-1 mt-auto mb-auto"
aria-hidden="true"
[authorityValue]="mdValue.newValue.confidence"
[iconMode]="true"
></i>
<div class="input-group">
<input class="form-control form-outline" data-test="authority-input" [(ngModel)]="mdValue.newValue.authority"
[disabled]="!editingAuthority"
[attr.aria-label]="(dsoType + '.edit.metadata.edit.authority.key') | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Collection } from '@dspace/core/shared/collection.model';
import { ConfidenceType } from '@dspace/core/shared/confidence-type';
import { DSpaceObject } from '@dspace/core/shared/dspace-object.model';
import { Item } from '@dspace/core/shared/item.model';
import { ITEM } from '@dspace/core/shared/item.resource-type';
import { MetadataValue } from '@dspace/core/shared/metadata.models';
import { Vocabulary } from '@dspace/core/submission/vocabularies/models/vocabulary.model';
import { VocabularyService } from '@dspace/core/submission/vocabularies/vocabulary.service';
Expand Down Expand Up @@ -53,6 +54,7 @@ describe('DsoEditMetadataAuthorityFieldComponent', () => {
},
id: 'item',
uuid: 'item',
type: ITEM.value,
owningCollection: createSuccessfulRemoteDataObject$(collection),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { Collection } from '@dspace/core/shared/collection.model';
import { DSpaceObject } from '@dspace/core/shared/dspace-object.model';
import { followLink } from '@dspace/core/shared/follow-link-config.model';
import { Item } from '@dspace/core/shared/item.model';
import { ITEM } from '@dspace/core/shared/item.resource-type';
import { getFirstSucceededRemoteDataPayload } from '@dspace/core/shared/operators';
import { TemplateItem } from '@dspace/core/shared/template-item.model';
import { Vocabulary } from '@dspace/core/submission/vocabularies/models/vocabulary.model';
import { VocabularyService } from '@dspace/core/submission/vocabularies/vocabulary.service';
import { isNotEmpty } from '@dspace/shared/utils/empty.util';
Expand Down Expand Up @@ -37,9 +39,9 @@ export class DsoEditMetadataFieldService {
*/
findDsoFieldVocabulary(dso: DSpaceObject, mdField: string): Observable<Vocabulary> {
if (isNotEmpty(mdField)) {
const owningCollection$: Observable<Collection> = this.itemService.findByHref(dso._links.self.href, true, true, followLink('owningCollection')).pipe(
const owningCollection$: Observable<Collection> = this.itemService.findByHref(dso._links.self.href, true, true, followLink('owningCollection', { isOptional: true }), followLink('templateItemOf', { isOptional: true })).pipe(
getFirstSucceededRemoteDataPayload(),
switchMap((item: Item) => item.owningCollection),
switchMap((item: Item | TemplateItem) => item.type as unknown === ITEM.value ? item.owningCollection : (item as TemplateItem).templateItemOf),
getFirstSucceededRemoteDataPayload(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@
<div class="dont-break-out preserve-line-breaks">{{ mdValue.newValue.language }}</div>
}
</div>
<div class="ds-flex-cell ds-authority-cell" role="cell">
@if (!mdValue.editing) {
<div class="dont-break-out preserve-line-breaks">{{ mdValue.newValue.authority }}</div>
}
@if(mdValue.editing) {
<textarea class="form-control" rows="5" [(ngModel)]="mdValue.newValue.authority"
[attr.aria-label]="(dsoType + '.edit.metadata.edit.authority') | translate"
[dsDebounce]="300" (onDebounce)="confirm.emit(false)"></textarea>
}
</div>
<div class="flex-grow-1 ds-flex-cell ds-security-cell d-flex justify-content-center" role="cell">
<div class="btn-group edit-field">
@if (canShowMetadataSecurity$ | async) {
Expand Down Expand Up @@ -111,7 +101,7 @@
[class.disabled]="isOnlyValue || saving" [dsBtnDisabled]="isOnlyValue || saving"
[title]="dsoType + '.edit.metadata.edit.buttons.drag' | translate"
ngbTooltip="{{ dsoType + '.edit.metadata.edit.buttons.drag' | translate }}">
<i class="drag-icon"></i>
<i class="drag-icon d-flex m-auto"></i>
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
cursor: grab;
}

.drag-icon {
height: #{$font-size-base};
width: #{$font-size-base};
}

::ng-deep .edit-field>ngb-tooltip-window .tooltip-inner {
min-width: var(--ds-dso-edit-virtual-tooltip-min-width);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
import {
CUSTOM_ELEMENTS_SCHEMA,
DebugElement,
NO_ERRORS_SCHEMA,
} from '@angular/core';
import {
ComponentFixture,
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { RouterModule } from '@angular/router';
import { DSONameService } from '@dspace/core/breadcrumbs/dso-name.service';
import { RelationshipDataService } from '@dspace/core/data/relationship-data.service';
import { MetadataField } from '@dspace/core/metadata/metadata-field.model';
import { MetadataSchema } from '@dspace/core/metadata/metadata-schema.model';
import { NotificationsService } from '@dspace/core/notification-system/notifications.service';
import { Collection } from '@dspace/core/shared/collection.model';
import { DSpaceObject } from '@dspace/core/shared/dspace-object.model';
import { Item } from '@dspace/core/shared/item.model';
import {
MetadataValue,
VIRTUAL_METADATA_PREFIX,
} from '@dspace/core/shared/metadata.models';
import { ItemMetadataRepresentation } from '@dspace/core/shared/metadata-representation/item/item-metadata-representation.model';
import { DsoEditMetadataFieldServiceStub } from '@dspace/core/testing/dso-edit-metadata-field.service.stub';
import { createPaginatedList } from '@dspace/core/testing/utils.test';
import { createSuccessfulRemoteDataObject$ } from '@dspace/core/utilities/remote-data.utils';
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { RegistryService } from 'src/app/admin/admin-registries/registry/registry.service';
import { mockSecurityConfig } from 'src/app/submission/utils/submission.mock';

import { BtnDisabledDirective } from '../../../shared/btn-disabled.directive';
import { ThemedTypeBadgeComponent } from '../../../shared/object-collection/shared/badges/type-badge/themed-type-badge.component';
import { VarDirective } from '../../../shared/utils/var.directive';
import {
DsoEditMetadataChangeType,
DsoEditMetadataValue,
Expand All @@ -54,28 +45,10 @@ describe('DsoEditMetadataValueComponent', () => {
let relationshipService: RelationshipDataService;
let dsoNameService: DSONameService;
let dsoEditMetadataFieldService: DsoEditMetadataFieldServiceStub;
let registryService: RegistryService;
let notificationsService: NotificationsService;
let editMetadataValue: DsoEditMetadataValue;
let metadataValue: MetadataValue;
let dso: DSpaceObject;

const collection = Object.assign(new Collection(), {
uuid: 'fake-uuid',
});

const item = Object.assign(new Item(), {
_links: {
self: { href: 'fake-item-url/item' },
},
id: 'item',
uuid: 'item',
owningCollection: createSuccessfulRemoteDataObject$(collection),
});

let metadataSchema: MetadataSchema;
let metadataFields: MetadataField[];

function initServices(): void {
relationshipService = jasmine.createSpyObj('relationshipService', {
resolveMetadataRepresentation: of(
Expand All @@ -86,10 +59,6 @@ describe('DsoEditMetadataValueComponent', () => {
getName: 'Related Name',
});
dsoEditMetadataFieldService = new DsoEditMetadataFieldServiceStub();
registryService = jasmine.createSpyObj('registryService', {
queryMetadataFields: createSuccessfulRemoteDataObject$(createPaginatedList(metadataFields)),
});
notificationsService = jasmine.createSpyObj('notificationsService', ['error', 'success']);
}

beforeEach(waitForAsync(async () => {
Expand All @@ -111,29 +80,26 @@ describe('DsoEditMetadataValueComponent', () => {
await TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
RouterTestingModule.withRoutes([]),
RouterModule.forRoot([]),
DsoEditMetadataValueComponent,
VarDirective,
BtnDisabledDirective,
],
providers: [
{ provide: RelationshipDataService, useValue: relationshipService },
{ provide: DSONameService, useValue: dsoNameService },
{ provide: DsoEditMetadataFieldService, useValue: dsoEditMetadataFieldService },
{ provide: RegistryService, useValue: registryService },
{ provide: NotificationsService, useValue: notificationsService },
],
schemas: [NO_ERRORS_SCHEMA],
})
.overrideComponent(DsoEditMetadataValueComponent, {
remove: {
imports: [
ThemedTypeBadgeComponent,
DsoEditMetadataValueFieldLoaderComponent,
],
},
})
.compileComponents();
}).overrideComponent(DsoEditMetadataValueComponent, {
add: {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
},
remove: {
imports: [
ThemedTypeBadgeComponent,
DsoEditMetadataValueFieldLoaderComponent,
],
},
}).compileComponents();
}));

beforeEach(() => {
Expand Down
Loading
Loading