diff --git a/src/app/+item-page/edit-item-page/edit-item-page.component.ts b/src/app/+item-page/edit-item-page/edit-item-page.component.ts
index efde7c52fb..4ea47f08e7 100644
--- a/src/app/+item-page/edit-item-page/edit-item-page.component.ts
+++ b/src/app/+item-page/edit-item-page/edit-item-page.component.ts
@@ -50,6 +50,10 @@ export class EditItemPageComponent implements OnInit {
this.itemRD$ = this.route.data.pipe(map((data) => data.item));
}
+ /**
+ * Get the item page url
+ * @param item The item for which the url is requested
+ */
getItemPage(item: Item): string {
return getItemPageRoute(item.id)
}
diff --git a/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.spec.ts b/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.spec.ts
index 133ee19e43..565c720a75 100644
--- a/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.spec.ts
+++ b/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.spec.ts
@@ -89,7 +89,7 @@ describe('EditInPlaceFieldComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(EditInPlaceFieldComponent);
comp = fixture.componentInstance; // EditInPlaceFieldComponent test instance
- de = fixture.debugElement.query(By.css('div.d-flex'));
+ de = fixture.debugElement;
el = de.nativeElement;
comp.url = url;
@@ -109,36 +109,6 @@ describe('EditInPlaceFieldComponent', () => {
});
});
- describe('changeType is UPDATE', () => {
- beforeEach(() => {
- comp.fieldUpdate.changeType = FieldChangeType.UPDATE;
- fixture.detectChanges();
- });
- it('the div should have class table-warning', () => {
- expect(el.classList).toContain('table-warning');
- });
- });
-
- describe('changeType is ADD', () => {
- beforeEach(() => {
- comp.fieldUpdate.changeType = FieldChangeType.ADD;
- fixture.detectChanges();
- });
- it('the div should have class table-success', () => {
- expect(el.classList).toContain('table-success');
- });
- });
-
- describe('changeType is REMOVE', () => {
- beforeEach(() => {
- comp.fieldUpdate.changeType = FieldChangeType.REMOVE;
- fixture.detectChanges();
- });
- it('the div should have class table-danger', () => {
- expect(el.classList).toContain('table-danger');
- });
- });
-
describe('setEditable', () => {
const editable = false;
beforeEach(() => {
@@ -223,9 +193,9 @@ describe('EditInPlaceFieldComponent', () => {
const metadataFieldSuggestions: InputSuggestion[] =
[
- { displayValue: mdField1.toString(), value: mdField1.toString() },
- { displayValue: mdField2.toString(), value: mdField2.toString() },
- { displayValue: mdField3.toString(), value: mdField3.toString() }
+ { displayValue: mdField1.toString().split('.').join('.'), value: mdField1.toString() },
+ { displayValue: mdField2.toString().split('.').join('.'), value: mdField2.toString() },
+ { displayValue: mdField3.toString().split('.').join('.'), value: mdField3.toString() }
];
beforeEach(() => {
diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.html b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.html
index bb0c188f05..03b0e143b4 100644
--- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.html
+++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.html
@@ -30,8 +30,8 @@
{{'item.edit.metadata.headers.language' | translate}} |
{{'item.edit.metadata.headers.edit' | translate}} |
- {
{ provide: ItemDataService, useValue: itemService },
{ provide: ObjectUpdatesService, useValue: objectUpdatesService },
{ provide: Router, useValue: router },
- {
- provide: ActivatedRoute, useValue: routeStub
- },
+ { provide: ActivatedRoute, useValue: routeStub },
{ provide: NotificationsService, useValue: notificationsService },
{ provide: GLOBAL_CONFIG, useValue: { notifications: { timeOut: 10 } } as any }
], schemas: [
- CUSTOM_ELEMENTS_SCHEMA
+ NO_ERRORS_SCHEMA
]
}).compileComponents();
})
@@ -133,7 +131,7 @@ describe('ItemMetadataComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(ItemMetadataComponent);
comp = fixture.componentInstance; // EditInPlaceFieldComponent test instance
- de = fixture.debugElement.query(By.css('div.d-flex'));
+ de = fixture.debugElement;
el = de.nativeElement;
comp.url = url;
fixture.detectChanges();
@@ -205,5 +203,37 @@ describe('ItemMetadataComponent', () => {
});
});
});
-})
-;
+
+ describe('changeType is UPDATE', () => {
+ beforeEach(() => {
+ fieldUpdate1.changeType = FieldChangeType.UPDATE;
+ fixture.detectChanges();
+ });
+ it('the div should have class table-warning', () => {
+ const element = de.queryAll(By.css('tr'))[1].nativeElement;
+ expect(element.classList).toContain('table-warning');
+ });
+ });
+
+ describe('changeType is ADD', () => {
+ beforeEach(() => {
+ fieldUpdate1.changeType = FieldChangeType.ADD;
+ fixture.detectChanges();
+ });
+ it('the div should have class table-success', () => {
+ const element = de.queryAll(By.css('tr'))[1].nativeElement;
+ expect(element.classList).toContain('table-success');
+ });
+ });
+
+ describe('changeType is REMOVE', () => {
+ beforeEach(() => {
+ fieldUpdate1.changeType = FieldChangeType.REMOVE;
+ fixture.detectChanges();
+ });
+ it('the div should have class table-danger', () => {
+ const element = de.queryAll(By.css('tr'))[1].nativeElement;
+ expect(element.classList).toContain('table-danger');
+ });
+ });
+});
diff --git a/src/app/+item-page/edit-item-page/item-status/item-status.component.spec.ts b/src/app/+item-page/edit-item-page/item-status/item-status.component.spec.ts
index 9c3049c638..00ea9b9f62 100644
--- a/src/app/+item-page/edit-item-page/item-status/item-status.component.spec.ts
+++ b/src/app/+item-page/edit-item-page/item-status/item-status.component.spec.ts
@@ -6,8 +6,7 @@ import { CommonModule } from '@angular/common';
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub';
import { HostWindowService } from '../../../shared/host-window.service';
import { RouterTestingModule } from '@angular/router/testing';
-import { ActivatedRoute, Router } from '@angular/router';
-import { RouterStub } from '../../../shared/testing/router-stub';
+import { ActivatedRoute } from '@angular/router';
import { Item } from '../../../core/shared/item.model';
import { By } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@@ -24,10 +23,7 @@ describe('ItemStatusComponent', () => {
lastModified: '2018'
});
- const itemPageUrl = `fake-url/${mockItem.id}`;
- const routerStub = Object.assign(new RouterStub(), {
- url: `${itemPageUrl}/edit`
- });
+ const itemPageUrl = `items/${mockItem.id}`;
const routeStub = {
parent: {
@@ -40,7 +36,6 @@ describe('ItemStatusComponent', () => {
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
declarations: [ItemStatusComponent],
providers: [
- { provide: Router, useValue: routerStub },
{ provide: ActivatedRoute, useValue: routeStub },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
], schemas: [CUSTOM_ELEMENTS_SCHEMA]
diff --git a/src/app/+item-page/edit-item-page/item-status/item-status.component.ts b/src/app/+item-page/edit-item-page/item-status/item-status.component.ts
index b9a9e4a2f3..c7e3a023d1 100644
--- a/src/app/+item-page/edit-item-page/item-status/item-status.component.ts
+++ b/src/app/+item-page/edit-item-page/item-status/item-status.component.ts
@@ -1,7 +1,7 @@
-import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
import { Item } from '../../../core/shared/item.model';
-import { ActivatedRoute, Router } from '@angular/router';
+import { ActivatedRoute } from '@angular/router';
import { ItemOperation } from '../item-operation/itemOperation.model';
import { first, map } from 'rxjs/operators';
import { Observable } from 'rxjs';
@@ -47,7 +47,7 @@ export class ItemStatusComponent implements OnInit {
*/
actionsKeys;
- constructor(private router: Router, private route: ActivatedRoute) {
+ constructor(private route: ActivatedRoute) {
}
ngOnInit(): void {
diff --git a/src/app/core/data/object-updates/object-updates.actions.ts b/src/app/core/data/object-updates/object-updates.actions.ts
index 7381188892..6cd74b2626 100644
--- a/src/app/core/data/object-updates/object-updates.actions.ts
+++ b/src/app/core/data/object-updates/object-updates.actions.ts
@@ -122,7 +122,7 @@ export class SetValidFieldUpdateAction implements Action {
};
/**
- * Create a new SetEditableFieldUpdateAction
+ * Create a new SetValidFieldUpdateAction
*
* @param url
* the unique url of the page
@@ -206,6 +206,9 @@ export class RemoveObjectUpdatesAction implements Action {
}
}
+/**
+ * An ngrx action to remove a single field update in the ObjectUpdates state for a certain page url and field uuid
+ */
export class RemoveFieldUpdateAction implements Action {
type = ObjectUpdatesActionTypes.REMOVE_FIELD;
payload: {
diff --git a/src/app/core/data/object-updates/object-updates.reducer.ts b/src/app/core/data/object-updates/object-updates.reducer.ts
index dad394e84f..bb870dcc41 100644
--- a/src/app/core/data/object-updates/object-updates.reducer.ts
+++ b/src/app/core/data/object-updates/object-updates.reducer.ts
@@ -11,43 +11,73 @@ import {
} from './object-updates.actions';
import { hasNoValue, hasValue } from '../../../shared/empty.util';
+/**
+ * Path where discarded objects are saved
+ */
export const OBJECT_UPDATES_TRASH_PATH = '/trash';
+/**
+ * The state for a single field
+ */
export interface FieldState {
editable: boolean,
isNew: boolean,
isValid: boolean
}
+/**
+ * A list of states for all the fields for a single page, mapped by uuid
+ */
export interface FieldStates {
[uuid: string]: FieldState;
}
+/**
+ * Represents every object that has a UUID
+ */
export interface Identifiable {
uuid: string
}
+/**
+ * The state of a single field update
+ */
export interface FieldUpdate {
field: Identifiable,
changeType: FieldChangeType
}
+/**
+ * The states of all field updates available for a single page, mapped by uuid
+ */
export interface FieldUpdates {
[uuid: string]: FieldUpdate;
}
+/**
+ * The updated state of a single page
+ */
export interface ObjectUpdatesEntry {
fieldStates: FieldStates;
fieldUpdates: FieldUpdates
lastModified: Date;
- // lastUpdate: Date;
}
+/**
+ * The updated state of all pages, mapped by the page URL
+ */
export interface ObjectUpdatesState {
[url: string]: ObjectUpdatesEntry;
}
+/**
+ * Initial state for an existing initialized field
+ */
const initialFieldState = { editable: false, isNew: false, isValid: true };
+
+/**
+ * Initial state for a newly added field
+ */
const initialNewFieldState = { editable: true, isNew: true, isValid: true };
// Object.create(null) ensures the object has no default js properties (e.g. `__proto__`)
diff --git a/src/app/shared/input-suggestions/input-suggestions.component.ts b/src/app/shared/input-suggestions/input-suggestions.component.ts
index 8bdc0cf762..2984441f03 100644
--- a/src/app/shared/input-suggestions/input-suggestions.component.ts
+++ b/src/app/shared/input-suggestions/input-suggestions.component.ts
@@ -224,6 +224,7 @@ export class InputSuggestionsComponent implements ControlValueAccessor, OnChange
this.submitSuggestion.emit(data);
}
+ /* START - Method's needed to add ngModel (ControlValueAccessor) to a component */
registerOnChange(fn: any): void {
this.propagateChange = fn;
}
@@ -248,8 +249,5 @@ export class InputSuggestionsComponent implements ControlValueAccessor, OnChange
this._value = val;
this.propagateChange(this._value);
}
-
- focus() {
- this.queryInput.nativeElement.focus();
- }
+ /* END - Method's needed to add ngModel to a component */
}
diff --git a/src/app/shared/input-suggestions/input-suggestions.model.ts b/src/app/shared/input-suggestions/input-suggestions.model.ts
index 34ab769587..1ccdbbe566 100644
--- a/src/app/shared/input-suggestions/input-suggestions.model.ts
+++ b/src/app/shared/input-suggestions/input-suggestions.model.ts
@@ -1,4 +1,14 @@
+/**
+ * Interface representing a single suggestion for the input suggestions component
+ */
export interface InputSuggestion {
+ /**
+ * The displayed value of the suggestion
+ */
displayValue: string,
+
+ /**
+ * The actual value of the suggestion
+ */
value: string
}