diff --git a/jsapp/xlform/src/model.base.coffee b/jsapp/xlform/src/model.base.coffee index 37cc5638d6..2c9f2cd2bf 100644 --- a/jsapp/xlform/src/model.base.coffee +++ b/jsapp/xlform/src/model.base.coffee @@ -161,9 +161,20 @@ module.exports = do -> # @_parent.trigger "change", @key, val, ctxt # when attributes change, register changes with parent survey - if @key in ["name", "label", "hint", "guidance_hint", "required", - "calculation", "default", "appearance", - "constraint_message", "tags"] or @key.match(/^.+::.+/) + observedAttrs = [ + 'name', + 'label', + 'hint', + 'guidance_hint', + 'required', + 'read_only' + 'calculation', + 'default', + 'appearance', + 'constraint_message', + 'tags' + ] + if @key in observedAttrs or @key.match(/^.+::.+/) @on "change", (changes)=> @getSurvey().trigger "change", changes diff --git a/jsapp/xlform/src/model.configs.coffee b/jsapp/xlform/src/model.configs.coffee index b5c5e9c7f6..caa04a765a 100644 --- a/jsapp/xlform/src/model.configs.coffee +++ b/jsapp/xlform/src/model.configs.coffee @@ -202,15 +202,16 @@ module.exports = do -> } configs.columns = [ - "type", - "name", - "label", - "hint", - "guidance_hint", - "required", - "relevant", - "default", - "constraint" + 'type', + 'name', + 'label', + 'hint', + 'guidance_hint', + 'required', + 'read_only', + 'relevant', + 'default', + 'constraint' ] configs.lookupRowType = do-> @@ -280,6 +281,8 @@ module.exports = do -> required: value: false _hideUnlessChanged: true + read_only: + value: false relevant: value: "" _hideUnlessChanged: true diff --git a/jsapp/xlform/src/view.rowDetail.coffee b/jsapp/xlform/src/view.rowDetail.coffee index 3c1162e5c5..87b7c9d0b2 100644 --- a/jsapp/xlform/src/view.rowDetail.coffee +++ b/jsapp/xlform/src/view.rowDetail.coffee @@ -377,6 +377,13 @@ module.exports = do -> afterRender: -> @listenForCheckboxChange() + viewRowDetail.DetailViewMixins.read_only = + html: -> + @$el.addClass("card__settings__fields--active") + viewRowDetail.Templates.checkbox @cid, @model.key, _t("Read only") + afterRender: -> + @listenForCheckboxChange() + viewRowDetail.DetailViewMixins.appearance = getTypes: () -> types = diff --git a/test/xlform/survey.tests.coffee b/test/xlform/survey.tests.coffee index 5ab1929c0f..34b67c2464 100644 --- a/test/xlform/survey.tests.coffee +++ b/test/xlform/survey.tests.coffee @@ -122,7 +122,8 @@ do -> 'select_from_list_name': 'yesno', 'name': 'yn', 'label': 'YesNo', - 'required': 'false' + 'required': 'false', + 'read_only': 'false' } ], 'choices': {