[CORD-2810] Prevent the user from inserting values in read_only fields
Change-Id: I00460544dd7d36f8482b04ea89912005a108f6b8
diff --git a/src/app/core/services/helpers/config.helpers.spec.ts b/src/app/core/services/helpers/config.helpers.spec.ts
index db1c840..9e7318e 100644
--- a/src/app/core/services/helpers/config.helpers.spec.ts
+++ b/src/app/core/services/helpers/config.helpers.spec.ts
@@ -36,7 +36,8 @@
{
type: 'number',
name: 'id',
- validators: []
+ validators: [],
+ read_only: false
},
{
type: 'string',
@@ -46,7 +47,8 @@
bool_value: true,
name: 'required'
}
- ]
+ ],
+ read_only: false
},
{
type: 'string',
@@ -56,7 +58,8 @@
int_value: 30,
name: 'maxlength'
}
- ]
+ ],
+ read_only: false
},
{
type: 'number',
@@ -70,12 +73,14 @@
int_value: 40,
name: 'max'
}
- ]
+ ],
+ read_only: false
},
{
type: 'date',
name: 'updated',
- validators: []
+ validators: [],
+ read_only: false
},
],
description: '',
@@ -255,13 +260,15 @@
type: 'boolean',
name: 'active',
default: '"True"',
- validators: []
+ validators: [],
+ read_only: false
},
{
type: 'boolean',
name: 'disabled',
default: '"False"',
- validators: []
+ validators: [],
+ read_only: false
},
];
const form_fields = service.modelFieldToInputCfg(fields);
@@ -312,7 +319,8 @@
relation: {
model: 'Test',
type: 'many_to_one'
- }
+ },
+ read_only: false
};
describe('the populateRelated method', () => {
@@ -332,7 +340,8 @@
name: 'test',
label: 'Test',
type: 'select',
- validators: {}
+ validators: {},
+ read_only: false
};
it('should add the available choice to the select', () => {
@@ -358,7 +367,8 @@
{
type: 'number',
name: 'foo',
- validators: []
+ validators: [],
+ read_only: false
},
{
type: 'string',
@@ -368,7 +378,8 @@
bool_value: true,
name: 'required'
}
- ]
+ ],
+ read_only: false
}
],
description: '',
diff --git a/src/app/core/services/helpers/config.helpers.ts b/src/app/core/services/helpers/config.helpers.ts
index 4baf9c5..443b6c2 100644
--- a/src/app/core/services/helpers/config.helpers.ts
+++ b/src/app/core/services/helpers/config.helpers.ts
@@ -34,6 +34,7 @@
export interface IXosModelDefsField {
name: string;
type: string;
+ read_only: boolean;
validators?: IXosModelDefsFieldValidators[];
hint?: string;
relation?: {
@@ -271,7 +272,8 @@
type: f.type,
validators: this.formatValidators(f.validators),
hint: f.hint,
- default: this.formatDefaultValues(f.default)
+ default: this.formatDefaultValues(f.default),
+ read_only: f.read_only
};
// NOTE populate drop-downs based on relation