Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions services/application/src/mongodb/schema/field/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const optionSchema = new Schema({
type: Boolean,
default: false,
},

/**
* Whether or not the option is allowed to be selected
*/
canSelect: {
type: Boolean,
default: true,
},
});

const groupSchema = new Schema({
Expand Down
6 changes: 6 additions & 0 deletions services/graphql/src/graphql/definitions/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ type SelectFieldOption implements SelectFieldOptionChoice {
externalIdentifier: String
"Whether free-form, write-in values are supported."
canWriteIn: Boolean
"Whether or not the option is allowed to be selected"
canSelect: Boolean
"The order of the option. When rendered, options and groups will be sorted using this value."
index: Int!
}
Expand Down Expand Up @@ -248,6 +250,8 @@ input CreateSelectFieldOptionInput {
externalIdentifier: String
"Whether free-form, write-in values are supported."
canWriteIn: Boolean = false
"Whether or not the option is allowed to be selected"
canSelect: Boolean = true
}

input CreateTextFieldMutationInput {
Expand Down Expand Up @@ -376,6 +380,8 @@ input UpdateSelectFieldOptionInput {
externalIdentifier: String
"Whether free-form, write-in values are supported."
canWriteIn: Boolean
"Whether or not the option is allowed to be selected"
canSelect: Boolean
"The order of the option. When rendered, options and groups will be sorted using this value."
index: Int = 0
}
Expand Down
1 change: 1 addition & 0 deletions services/manage/app/components/custom-field/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default Component.extend({
this.choices.pushObject({
label: '',
index: this.get('index'),
canSelect: true,
__typename: 'SelectFieldOption',
});
},
Expand Down
4 changes: 4 additions & 0 deletions services/manage/app/components/custom-select-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default Component.extend({
return this.get('selected.canWriteIn') || this.get('selected.option.canWriteIn') || false;
}),

canSelect: computed('selected.{options.canSelect}', function() {
return this.get('selected.option.canSelect') || true;
}),

/**
* Use the selected answer as the option (when found) to ensure
* selection highlighting is applied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mutation = gql`
... on SelectFieldOption {
externalIdentifier
canWriteIn
canSelect
}
... on SelectFieldOptionGroup {
options {
Expand Down Expand Up @@ -106,6 +107,7 @@ export default Controller.extend(ActionMixin, AppQueryMixin, {
label: option.label,
externalIdentifier: option.externalIdentifier,
canWriteIn: option.canWriteIn,
canSelect: option.canSelect,
})),
groups: groups.map((group) => ({
id: group.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const mutation = gql`
label
option {
canWriteIn
canSelect
}
writeInValue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ const query = gql`
... on SelectFieldOption {
externalIdentifier
canWriteIn
canSelect
}
... on SelectFieldOptionGroup {
options {
id
label
index
externalIdentifier
canSelect
canWriteIn
}
}
Expand All @@ -39,6 +41,7 @@ const query = gql`
id
label
externalIdentifier
canSelect
canWriteIn
index
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const query = gql`
label
... on SelectFieldOption {
canWriteIn
canSelect
}
... on SelectFieldOptionGroup {
options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
↕
</button>

<div
class="d-flex border border-secondary border-left-0 border-right-0"
title="Allow answer to be selected"
>
<FormElements::ToggleButton @value={{model.canSelect}} @size="small" />
</div>

<div
class="d-flex border border-secondary border-left-0 border-right-0"
title="Allow write-in values"
Expand Down