diff --git a/services/application/src/mongodb/schema/field/select.js b/services/application/src/mongodb/schema/field/select.js index aab1a1ef..8ab6e830 100644 --- a/services/application/src/mongodb/schema/field/select.js +++ b/services/application/src/mongodb/schema/field/select.js @@ -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({ diff --git a/services/graphql/src/graphql/definitions/field.js b/services/graphql/src/graphql/definitions/field.js index 5edff7db..1a9f5279 100644 --- a/services/graphql/src/graphql/definitions/field.js +++ b/services/graphql/src/graphql/definitions/field.js @@ -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! } @@ -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 { @@ -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 } diff --git a/services/manage/app/components/custom-field/options.js b/services/manage/app/components/custom-field/options.js index fe36e23d..9b1a95ce 100644 --- a/services/manage/app/components/custom-field/options.js +++ b/services/manage/app/components/custom-field/options.js @@ -36,6 +36,7 @@ export default Component.extend({ this.choices.pushObject({ label: '', index: this.get('index'), + canSelect: true, __typename: 'SelectFieldOption', }); }, diff --git a/services/manage/app/components/custom-select-field.js b/services/manage/app/components/custom-select-field.js index 565e6718..34d1a945 100644 --- a/services/manage/app/components/custom-select-field.js +++ b/services/manage/app/components/custom-select-field.js @@ -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. diff --git a/services/manage/app/controllers/manage/orgs/view/apps/view/fields/edit/select.js b/services/manage/app/controllers/manage/orgs/view/apps/view/fields/edit/select.js index 861c298f..15282cb9 100644 --- a/services/manage/app/controllers/manage/orgs/view/apps/view/fields/edit/select.js +++ b/services/manage/app/controllers/manage/orgs/view/apps/view/fields/edit/select.js @@ -25,6 +25,7 @@ const mutation = gql` ... on SelectFieldOption { externalIdentifier canWriteIn + canSelect } ... on SelectFieldOptionGroup { options { @@ -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, diff --git a/services/manage/app/controllers/manage/orgs/view/apps/view/users/edit/custom-select-fields.js b/services/manage/app/controllers/manage/orgs/view/apps/view/users/edit/custom-select-fields.js index b5b523d9..fbcbbf70 100644 --- a/services/manage/app/controllers/manage/orgs/view/apps/view/users/edit/custom-select-fields.js +++ b/services/manage/app/controllers/manage/orgs/view/apps/view/users/edit/custom-select-fields.js @@ -15,6 +15,7 @@ const mutation = gql` label option { canWriteIn + canSelect } writeInValue } diff --git a/services/manage/app/routes/manage/orgs/view/apps/view/fields/edit/select.js b/services/manage/app/routes/manage/orgs/view/apps/view/fields/edit/select.js index 939ba255..2408ea5e 100644 --- a/services/manage/app/routes/manage/orgs/view/apps/view/fields/edit/select.js +++ b/services/manage/app/routes/manage/orgs/view/apps/view/fields/edit/select.js @@ -24,6 +24,7 @@ const query = gql` ... on SelectFieldOption { externalIdentifier canWriteIn + canSelect } ... on SelectFieldOptionGroup { options { @@ -31,6 +32,7 @@ const query = gql` label index externalIdentifier + canSelect canWriteIn } } @@ -39,6 +41,7 @@ const query = gql` id label externalIdentifier + canSelect canWriteIn index } diff --git a/services/manage/app/routes/manage/orgs/view/apps/view/users/edit/custom-select-fields.js b/services/manage/app/routes/manage/orgs/view/apps/view/users/edit/custom-select-fields.js index 791c9244..42775bd8 100644 --- a/services/manage/app/routes/manage/orgs/view/apps/view/users/edit/custom-select-fields.js +++ b/services/manage/app/routes/manage/orgs/view/apps/view/users/edit/custom-select-fields.js @@ -20,6 +20,7 @@ const query = gql` label ... on SelectFieldOption { canWriteIn + canSelect } ... on SelectFieldOptionGroup { options { diff --git a/services/manage/app/templates/components/custom-field/option.hbs b/services/manage/app/templates/components/custom-field/option.hbs index 330d77fa..88a9aecd 100644 --- a/services/manage/app/templates/components/custom-field/option.hbs +++ b/services/manage/app/templates/components/custom-field/option.hbs @@ -31,6 +31,13 @@ ↕ +
+ +
+