Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read_only as visible property #2147

Merged
merged 3 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions jsapp/xlform/src/model.base.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 12 additions & 9 deletions jsapp/xlform/src/model.configs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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->
Expand Down Expand Up @@ -280,6 +281,8 @@ module.exports = do ->
required:
value: false
_hideUnlessChanged: true
read_only:
value: false
relevant:
value: ""
_hideUnlessChanged: true
Expand Down
7 changes: 7 additions & 0 deletions jsapp/xlform/src/view.rowDetail.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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")
jnm marked this conversation as resolved.
Show resolved Hide resolved
afterRender: ->
@listenForCheckboxChange()

viewRowDetail.DetailViewMixins.appearance =
getTypes: () ->
types =
Expand Down
3 changes: 2 additions & 1 deletion test/xlform/survey.tests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ do ->
'select_from_list_name': 'yesno',
'name': 'yn',
'label': 'YesNo',
'required': 'false'
'required': 'false',
'read_only': 'false'
}
],
'choices': {
Expand Down