Skip to content

Commit 43d9e3f

Browse files
93746: Feedback 2022-12-14 - missing types & tooltip width
1 parent 50f7211 commit 43d9e3f

6 files changed

Lines changed: 46 additions & 34 deletions

File tree

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-form.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class DsoEditMetadataForm {
187187
Object.entries(metadata).forEach(([mdField, values]: [string, MetadataValue[]]) => {
188188
this.originalFieldKeys.push(mdField);
189189
this.fieldKeys.push(mdField);
190-
this.fields[mdField] = values.map((value) => new DsoEditMetadataValue(value));
190+
this.fields[mdField] = values.map((value: MetadataValue) => new DsoEditMetadataValue(value));
191191
});
192192
}
193193

@@ -205,7 +205,7 @@ export class DsoEditMetadataForm {
205205
* Clear the temporary value afterwards
206206
* @param mdField
207207
*/
208-
setMetadataField(mdField: string) {
208+
setMetadataField(mdField: string): void {
209209
this.newValue.editing = false;
210210
this.addValueToField(this.newValue, mdField);
211211
this.newValue = undefined;
@@ -217,7 +217,7 @@ export class DsoEditMetadataForm {
217217
* @param mdField
218218
* @private
219219
*/
220-
private addValueToField(value: DsoEditMetadataValue, mdField: string) {
220+
private addValueToField(value: DsoEditMetadataValue, mdField: string): void {
221221
if (isEmpty(this.fields[mdField])) {
222222
this.fieldKeys.push(mdField);
223223
this.fields[mdField] = [];
@@ -230,7 +230,7 @@ export class DsoEditMetadataForm {
230230
* @param mdField
231231
* @param index
232232
*/
233-
remove(mdField: string, index: number) {
233+
remove(mdField: string, index: number): void {
234234
if (isNotEmpty(this.fields[mdField])) {
235235
this.fields[mdField].splice(index, 1);
236236
if (this.fields[mdField].length === 0) {
@@ -244,7 +244,7 @@ export class DsoEditMetadataForm {
244244
* Returns if at least one value within the form contains a change
245245
*/
246246
hasChanges(): boolean {
247-
return Object.values(this.fields).some((values) => values.some((value) => value.hasChanges()));
247+
return Object.values(this.fields).some((values: DsoEditMetadataValue[]) => values.some((value: DsoEditMetadataValue) => value.hasChanges()));
248248
}
249249

250250
/**
@@ -253,9 +253,9 @@ export class DsoEditMetadataForm {
253253
*/
254254
discard(): void {
255255
this.resetReinstatable();
256-
Object.entries(this.fields).forEach(([field, values]) => {
256+
Object.entries(this.fields).forEach(([field, values]: [string, DsoEditMetadataValue[]]) => {
257257
let removeFromIndex = -1;
258-
values.forEach((value, index) => {
258+
values.forEach((value: DsoEditMetadataValue, index: number) => {
259259
if (value.change === DsoEditMetadataChangeType.ADD) {
260260
if (isEmpty(this.reinstatableNewValues[field])) {
261261
this.reinstatableNewValues[field] = [];
@@ -272,7 +272,7 @@ export class DsoEditMetadataForm {
272272
this.fields[field].splice(removeFromIndex, this.fields[field].length - removeFromIndex);
273273
}
274274
});
275-
this.fieldKeys.forEach((field) => {
275+
this.fieldKeys.forEach((field: string) => {
276276
if (this.originalFieldKeys.indexOf(field) < 0) {
277277
delete this.fields[field];
278278
}
@@ -281,13 +281,13 @@ export class DsoEditMetadataForm {
281281
}
282282

283283
reinstate(): void {
284-
Object.values(this.fields).forEach((values) => {
285-
values.forEach((value) => {
284+
Object.values(this.fields).forEach((values: DsoEditMetadataValue[]) => {
285+
values.forEach((value: DsoEditMetadataValue) => {
286286
value.reinstate();
287287
});
288288
});
289-
Object.entries(this.reinstatableNewValues).forEach(([field, values]) => {
290-
values.forEach((value) => {
289+
Object.entries(this.reinstatableNewValues).forEach(([field, values]: [string, DsoEditMetadataValue[]]) => {
290+
values.forEach((value: DsoEditMetadataValue) => {
291291
this.addValueToField(value, field);
292292
});
293293
});
@@ -300,17 +300,17 @@ export class DsoEditMetadataForm {
300300
isReinstatable(): boolean {
301301
return isNotEmpty(this.reinstatableNewValues) ||
302302
Object.values(this.fields)
303-
.some((values) => values
304-
.some((value) => value.isReinstatable()));
303+
.some((values: DsoEditMetadataValue[]) => values
304+
.some((value: DsoEditMetadataValue) => value.isReinstatable()));
305305
}
306306

307307
/**
308308
* Reset the state of the re-instatable properties and values
309309
*/
310-
resetReinstatable() {
310+
resetReinstatable(): void {
311311
this.reinstatableNewValues = {};
312-
Object.values(this.fields).forEach((values) => {
313-
values.forEach((value) => {
312+
Object.values(this.fields).forEach((values: DsoEditMetadataValue[]) => {
313+
values.forEach((value: DsoEditMetadataValue) => {
314314
value.resetReinstatable();
315315
});
316316
});
@@ -321,8 +321,8 @@ export class DsoEditMetadataForm {
321321
*/
322322
getOperations(): Operation[] {
323323
const operations: Operation[] = [];
324-
Object.entries(this.fields).forEach(([field, values]) => {
325-
values.forEach((value, place) => {
324+
Object.entries(this.fields).forEach(([field, values]: [string, DsoEditMetadataValue[]]) => {
325+
values.forEach((value: DsoEditMetadataValue, place: number) => {
326326
if (value.hasChanges()) {
327327
let operation: MetadataPatchOperation;
328328
if (value.change === DsoEditMetadataChangeType.UPDATE) {

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-value/dso-edit-metadata-value.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
.ds-drag-handle:not(.disabled) {
77
cursor: grab;
88
}
9+
10+
::ng-deep .tooltip-inner {
11+
min-width: var(--ds-dso-edit-virtual-tooltip-min-width);
12+
}

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-value/dso-edit-metadata-value.component.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
22
import { DsoEditMetadataChangeType, DsoEditMetadataValue } from '../dso-edit-metadata-form';
33
import { Observable } from 'rxjs/internal/Observable';
4-
import { MetadataRepresentationType } from '../../../core/shared/metadata-representation/metadata-representation.model';
4+
import {
5+
MetadataRepresentation,
6+
MetadataRepresentationType
7+
} from '../../../core/shared/metadata-representation/metadata-representation.model';
58
import { RelationshipService } from '../../../core/data/relationship.service';
69
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
7-
import { of } from 'rxjs/internal/observable/of';
810
import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model';
911
import { map } from 'rxjs/operators';
1012
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
1113
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
14+
import { EMPTY } from 'rxjs/internal/observable/empty';
1215

1316
@Component({
1417
selector: 'ds-dso-edit-metadata-value',
@@ -100,15 +103,19 @@ export class DsoEditMetadataValueComponent implements OnInit {
100103
/**
101104
* Initialise potential properties of a virtual metadata value
102105
*/
103-
initVirtualProperties() {
106+
initVirtualProperties(): void {
104107
this.mdRepresentation$ = this.mdValue.newValue.isVirtual ?
105108
this.relationshipService.resolveMetadataRepresentation(this.mdValue.newValue, this.dso, 'Item')
106-
.pipe(map((mdRepresentation) => mdRepresentation.representationType === MetadataRepresentationType.Item ? mdRepresentation : null)) : of(null);
109+
.pipe(
110+
map((mdRepresentation: MetadataRepresentation) =>
111+
mdRepresentation.representationType === MetadataRepresentationType.Item ? mdRepresentation as ItemMetadataRepresentation : null
112+
)
113+
) : EMPTY;
107114
this.mdRepresentationItemRoute$ = this.mdRepresentation$.pipe(
108-
map((mdRepresentation) => mdRepresentation ? getItemPageRoute(mdRepresentation) : null),
115+
map((mdRepresentation: ItemMetadataRepresentation) => mdRepresentation ? getItemPageRoute(mdRepresentation) : null),
109116
);
110117
this.mdRepresentationName$ = this.mdRepresentation$.pipe(
111-
map((mdRepresentation) => mdRepresentation ? this.dsoNameService.getName(mdRepresentation) : null),
118+
map((mdRepresentation: ItemMetadataRepresentation) => mdRepresentation ? this.dsoNameService.getName(mdRepresentation) : null),
112119
);
113120
}
114121
}

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class DsoEditMetadataComponent implements OnInit, OnDestroy {
120120
this.initForm();
121121
}
122122
this.savingOrLoadingFieldValidation$ = observableCombineLatest([this.saving$, this.loadingFieldValidation$]).pipe(
123-
map(([saving, loading]) => saving || loading),
123+
map(([saving, loading]: [boolean, boolean]) => saving || loading),
124124
);
125125
}
126126

@@ -188,7 +188,7 @@ export class DsoEditMetadataComponent implements OnInit, OnDestroy {
188188
* Confirm the newly added value
189189
* @param saved Whether or not the value was manually saved (only then, add the value to its metadata field)
190190
*/
191-
confirmNewValue(saved: boolean) {
191+
confirmNewValue(saved: boolean): void {
192192
if (saved) {
193193
this.setMetadataField();
194194
}
@@ -199,10 +199,10 @@ export class DsoEditMetadataComponent implements OnInit, OnDestroy {
199199
* This will move the new value to its respective parent metadata field
200200
* Validate the metadata field first
201201
*/
202-
setMetadataField() {
202+
setMetadataField(): void {
203203
this.form.resetReinstatable();
204204
this.loadingFieldValidation$.next(true);
205-
this.metadataFieldSelectorComponent.validate().subscribe((valid) => {
205+
this.metadataFieldSelectorComponent.validate().subscribe((valid: boolean) => {
206206
this.loadingFieldValidation$.next(false);
207207
if (valid) {
208208
this.form.setMetadataField(this.newMdField);
@@ -238,7 +238,7 @@ export class DsoEditMetadataComponent implements OnInit, OnDestroy {
238238
/**
239239
* Unsubscribe from any open subscriptions
240240
*/
241-
ngOnDestroy() {
241+
ngOnDestroy(): void {
242242
if (hasValue(this.dsoUpdateSubscription)) {
243243
this.dsoUpdateSubscription.unsubscribe();
244244
}

src/app/dso-shared/dso-edit-metadata/metadata-field-selector/metadata-field-selector.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
119119
);
120120
this.mdFieldOptions$ = this.query$.pipe(
121121
distinctUntilChanged(),
122-
switchMap((query) => {
122+
switchMap((query: string) => {
123123
this.showInvalid = false;
124124
if (query !== null) {
125125
return this.registryService.queryMetadataFields(query, null, true, false, followLink('schema')).pipe(
@@ -152,15 +152,15 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
152152
metadataFieldsToString(),
153153
take(1),
154154
map((fields: string[]) => fields.indexOf(this.mdField) > -1),
155-
tap((exists) => this.showInvalid = !exists),
155+
tap((exists: boolean) => this.showInvalid = !exists),
156156
);
157157
}
158158

159159
/**
160160
* Select a metadata field from the dropdown optipons
161161
* @param mdFieldOption
162162
*/
163-
select(mdFieldOption: string) {
163+
select(mdFieldOption: string): void {
164164
this.selectedValueLoading = true;
165165
this.input.setValue(mdFieldOption);
166166
}
@@ -169,6 +169,6 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
169169
* Unsubscribe from any open subscriptions
170170
*/
171171
ngOnDestroy(): void {
172-
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
172+
this.subs.filter((sub: Subscription) => hasValue(sub)).forEach((sub: Subscription) => sub.unsubscribe());
173173
}
174174
}

src/styles/_custom_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@
8989
--ds-dso-edit-field-width: 210px;
9090
--ds-dso-edit-lang-width: 90px;
9191
--ds-dso-edit-actions-width: 173px;
92+
--ds-dso-edit-virtual-tooltip-min-width: 300px;
9293
}

0 commit comments

Comments
 (0)