Skip to content

Commit

Permalink
Merge pull request #3937 from kobotoolbox/formbuilder-handle-deprecat…
Browse files Browse the repository at this point in the history
…ed-metadata

Allow form builder to open forms using deprecated metadata, but then force those metadata to be disabled
  • Loading branch information
jnm authored Jul 14, 2022
2 parents b94aace + 5350fc6 commit 8760848
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jsapp/js/components/metadataEditor.es6
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ export default class MetadataEditor extends React.Component {
META_QUESTION_TYPES.start,
META_QUESTION_TYPES.end,
META_QUESTION_TYPES.today,
META_QUESTION_TYPES.deviceid,
META_QUESTION_TYPES.audit,
];
const rightColumn = [
META_QUESTION_TYPES.username,
META_QUESTION_TYPES.phonenumber,
META_QUESTION_TYPES.deviceid,
];

let backgroundAudioProp = this.getMetaProperty(
Expand Down
2 changes: 2 additions & 0 deletions jsapp/xlform/src/model.aliases.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ module.exports = do ->
['start'],
['end'],
['today'],
['simserial'],
['subscriberid'],
['phonenumber', 'phone_number'],
['audit'],
]
Expand Down
14 changes: 14 additions & 0 deletions jsapp/xlform/src/model.configs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ module.exports = do ->
label: "username"
description: "includes interviewer's username"
default: false
simserial:
name: "simserial"
label: "sim serial"
description: "records the serial number of the network sim card"
default: false
deprecated: true
subscriberid:
name: "subscriberid"
label: "subscriber id"
description: "records the subscriber id of the sim card"
default: false
deprecated: true
deviceid:
name: "deviceid"
label: "device id"
Expand Down Expand Up @@ -63,6 +75,8 @@ module.exports = do ->
name: @get("name")
label: @get("label")
description: @get("description")
default: @get("default")
deprecated: @get("deprecated")

class configs.SurveyDetailSchema extends Backbone.Collection
model: SurveyDetailSchemaItem
Expand Down
7 changes: 6 additions & 1 deletion jsapp/xlform/src/model.surveyDetail.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ module.exports = do ->
if (dtobj = @get(detail.type))
if detail.parameters
dtobj.set("parameters", detail.parameters)
dtobj.set("value", true)
if dtobj.get("deprecated")
# …unless the detail (aka metadata) is deprecated, in which case its
# value is forced to the default
dtobj.set("value", dtobj.get("default"))
else
dtobj.set("value", true)
else
throw new Error("SurveyDetail `#{key}` not loaded from schema. [Aliases have not been implemented]")
return
Expand Down

0 comments on commit 8760848

Please sign in to comment.