Skip to content

Commit c903df8

Browse files
authored
Merge pull request DSpace#2297 from 4Science/DURACOM-152
Fixed read-only visibility for submission form fields
2 parents 5c8828f + 42026b3 commit c903df8

16 files changed

Lines changed: 107 additions & 20 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum SubmissionFieldScopeType {
2+
WorkspaceItem = 'SUBMISSION',
3+
WorkflowItem = 'WORKFLOW',
4+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export enum SubmissionScopeType {
22
WorkspaceItem = 'WORKSPACE',
3-
WorkflowItem = 'WORKFLOW'
3+
WorkflowItem = 'WORKFLOW',
44
}

src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-concat.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
4646
@serializable() submissionId: string;
4747
@serializable() hasSelectableMetadata: boolean;
4848
@serializable() metadataValue: MetadataValue;
49+
@serializable() readOnly?: boolean;
4950

5051
isCustomGroup = true;
5152
valueUpdates: Subject<string>;
@@ -65,6 +66,7 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
6566
this.valueUpdates = new Subject<string>();
6667
this.valueUpdates.subscribe((value: string) => this.value = value);
6768
this.typeBindRelations = config.typeBindRelations ? config.typeBindRelations : [];
69+
this.readOnly = config.disabled;
6870
}
6971

7072
get value() {

src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-input.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class DsDynamicInputModel extends DynamicInputModel {
5555
this.metadataFields = config.metadataFields;
5656
this.hint = config.hint;
5757
this.readOnly = config.readOnly;
58+
this.disabled = config.readOnly;
5859
this.value = config.value;
5960
this.relationship = config.relationship;
6061
this.submissionId = config.submissionId;

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
[ngbTypeahead]="search"
4040
[placeholder]="model.placeholder"
4141
[readonly]="model.readOnly"
42+
[disabled]="model.readOnly"
4243
[resultTemplate]="rt"
4344
[type]="model.inputType"
4445
[(ngModel)]="currentValue"
@@ -63,6 +64,7 @@
6364
[name]="model.name"
6465
[placeholder]="model.placeholder"
6566
[readonly]="true"
67+
[disabled]="model.readOnly"
6668
[type]="model.inputType"
6769
[value]="currentValue?.display"
6870
(focus)="onFocus($event)"

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
216216
* @param event The click event fired
217217
*/
218218
openTree(event) {
219+
if (this.model.readOnly) {
220+
return;
221+
}
219222
event.preventDefault();
220223
event.stopImmediatePropagation();
221224
this.subs.push(this.vocabulary$.pipe(

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
role="combobox"
44
[attr.aria-label]="model.label"
55
[attr.aria-owns]="'combobox_' + id + '_listbox'">
6-
<i ngbDropdownToggle class="position-absolute scrollable-dropdown-toggle"
7-
aria-hidden="true"></i>
6+
<i *ngIf="!model.readOnly" ngbDropdownToggle class="position-absolute scrollable-dropdown-toggle"
7+
aria-hidden="true"></i>
8+
<i *ngIf="model.readOnly" class="dropdown-toggle position-absolute toggle-icon"
9+
aria-hidden="true"></i>
810
<input class="form-control"
911
[attr.aria-controls]="'combobox_' + id + '_listbox'"
1012
[attr.aria-activedescendant]="'combobox_' + id + '_selected'"
@@ -15,6 +17,7 @@
1517
[id]="id"
1618
[name]="model.name"
1719
[readonly]="true"
20+
[disabled]="model.readOnly"
1821
[type]="model.inputType"
1922
[value]="(currentValue | async)"
2023
(blur)="onBlur($event)"

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@
3232
.scrollable-dropdown-input[readonly]{
3333
background-color: #fff;
3434
}
35+
36+
.toggle-icon {
37+
padding: 0.7rem 0.7rem 0 0.7rem;
38+
}

src/app/shared/form/builder/models/form-field.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SectionVisibility } from './../../../../submission/objects/section-visibility.model';
12
import { autoserialize } from 'cerialize';
23

34
import { LanguageCode } from './form-field-language-value.model';
@@ -124,4 +125,7 @@ export class FormFieldModel {
124125
*/
125126
@autoserialize
126127
value: any;
128+
129+
@autoserialize
130+
visibility: SectionVisibility;
127131
}

src/app/shared/form/builder/parsers/concat-field-parser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export class ConcatFieldParser extends FieldParser {
8383
input1ModelConfig.required = true;
8484
}
8585

86+
concatGroup.disabled = input1ModelConfig.readOnly;
87+
8688
if (isNotEmpty(this.firstPlaceholder)) {
8789
input1ModelConfig.placeholder = this.firstPlaceholder;
8890
}

0 commit comments

Comments
 (0)