From 2f72cee2400a325e7d5afda9eb3e0912d82370b8 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Tue, 2 Dec 2025 10:44:22 -0600 Subject: [PATCH 1/3] Initial pass at supporting selectableAnswer field --- services/application/src/mongodb/schema/field/select.js | 8 ++++++++ services/graphql/src/graphql/definitions/field.js | 6 ++++++ services/manage/app/components/custom-field/options.js | 1 + services/manage/app/components/custom-select-field.js | 4 ++++ .../manage/orgs/view/apps/view/fields/edit/select.js | 3 +++ .../view/apps/view/users/edit/custom-select-fields.js | 1 + .../manage/orgs/view/apps/view/fields/edit/select.js | 3 +++ .../view/apps/view/users/edit/custom-select-fields.js | 1 + .../app/templates/components/custom-field/option.hbs | 7 +++++++ 9 files changed, 34 insertions(+) diff --git a/services/application/src/mongodb/schema/field/select.js b/services/application/src/mongodb/schema/field/select.js index aab1a1ef..28d27f17 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 + */ + selectableAnswer: { + 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..808fef0f 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" + selectableAnswer: 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" + selectableAnswer: 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" + selectableAnswer: 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..a40c434d 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'), + selectableAnswer: 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..91a3aaa8 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; }), + selectableAnswer: computed('selected.{options.selectableAnswer}', function() { + return this.get('selected.option.selectableAnswer') || 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..9c8395b3 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 + selectableAnswer } ... on SelectFieldOptionGroup { options { @@ -106,6 +107,7 @@ export default Controller.extend(ActionMixin, AppQueryMixin, { label: option.label, externalIdentifier: option.externalIdentifier, canWriteIn: option.canWriteIn, + selectableAnswer: option.selectableAnswer, })), groups: groups.map((group) => ({ id: group.id, @@ -114,6 +116,7 @@ export default Controller.extend(ActionMixin, AppQueryMixin, { optionIds: group.options.map(option => option.id), })), }; + console.log(options); if (!Object.keys(input.externalId).length) delete input.externalId; const variables = { input }; await this.mutate({ mutation, variables }, 'updateSelectField'); 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..e85643a5 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 + selectableAnswer } 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..493aa64b 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 + selectableAnswer } ... on SelectFieldOptionGroup { options { @@ -31,6 +32,7 @@ const query = gql` label index externalIdentifier + selectableAnswer canWriteIn } } @@ -39,6 +41,7 @@ const query = gql` id label externalIdentifier + selectableAnswer 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..c0a6709f 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 + selectableAnswer } ... 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..da364c3d 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 @@ ↕ +
+ +
+
Date: Tue, 2 Dec 2025 10:55:04 -0600 Subject: [PATCH 2/3] Remove console.log --- .../controllers/manage/orgs/view/apps/view/fields/edit/select.js | 1 - 1 file changed, 1 deletion(-) 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 9c8395b3..abc4026a 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 @@ -116,7 +116,6 @@ export default Controller.extend(ActionMixin, AppQueryMixin, { optionIds: group.options.map(option => option.id), })), }; - console.log(options); if (!Object.keys(input.externalId).length) delete input.externalId; const variables = { input }; await this.mutate({ mutation, variables }, 'updateSelectField'); From c76d5d3ed88343baec9bf19323313f2b77682be8 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Tue, 2 Dec 2025 11:34:46 -0600 Subject: [PATCH 3/3] Rename to canSelect --- services/application/src/mongodb/schema/field/select.js | 2 +- services/graphql/src/graphql/definitions/field.js | 6 +++--- services/manage/app/components/custom-field/options.js | 2 +- services/manage/app/components/custom-select-field.js | 4 ++-- .../manage/orgs/view/apps/view/fields/edit/select.js | 4 ++-- .../orgs/view/apps/view/users/edit/custom-select-fields.js | 2 +- .../routes/manage/orgs/view/apps/view/fields/edit/select.js | 6 +++--- .../orgs/view/apps/view/users/edit/custom-select-fields.js | 2 +- .../manage/app/templates/components/custom-field/option.hbs | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/services/application/src/mongodb/schema/field/select.js b/services/application/src/mongodb/schema/field/select.js index 28d27f17..8ab6e830 100644 --- a/services/application/src/mongodb/schema/field/select.js +++ b/services/application/src/mongodb/schema/field/select.js @@ -38,7 +38,7 @@ const optionSchema = new Schema({ /** * Whether or not the option is allowed to be selected */ - selectableAnswer: { + canSelect: { type: Boolean, default: true, }, diff --git a/services/graphql/src/graphql/definitions/field.js b/services/graphql/src/graphql/definitions/field.js index 808fef0f..1a9f5279 100644 --- a/services/graphql/src/graphql/definitions/field.js +++ b/services/graphql/src/graphql/definitions/field.js @@ -175,7 +175,7 @@ type SelectFieldOption implements SelectFieldOptionChoice { "Whether free-form, write-in values are supported." canWriteIn: Boolean "Whether or not the option is allowed to be selected" - selectableAnswer: Boolean + canSelect: Boolean "The order of the option. When rendered, options and groups will be sorted using this value." index: Int! } @@ -251,7 +251,7 @@ input CreateSelectFieldOptionInput { "Whether free-form, write-in values are supported." canWriteIn: Boolean = false "Whether or not the option is allowed to be selected" - selectableAnswer: Boolean = true + canSelect: Boolean = true } input CreateTextFieldMutationInput { @@ -381,7 +381,7 @@ input UpdateSelectFieldOptionInput { "Whether free-form, write-in values are supported." canWriteIn: Boolean "Whether or not the option is allowed to be selected" - selectableAnswer: Boolean + 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 a40c434d..9b1a95ce 100644 --- a/services/manage/app/components/custom-field/options.js +++ b/services/manage/app/components/custom-field/options.js @@ -36,7 +36,7 @@ export default Component.extend({ this.choices.pushObject({ label: '', index: this.get('index'), - selectableAnswer: true, + 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 91a3aaa8..34d1a945 100644 --- a/services/manage/app/components/custom-select-field.js +++ b/services/manage/app/components/custom-select-field.js @@ -23,8 +23,8 @@ export default Component.extend({ return this.get('selected.canWriteIn') || this.get('selected.option.canWriteIn') || false; }), - selectableAnswer: computed('selected.{options.selectableAnswer}', function() { - return this.get('selected.option.selectableAnswer') || true; + canSelect: computed('selected.{options.canSelect}', function() { + return this.get('selected.option.canSelect') || true; }), /** 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 abc4026a..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,7 +25,7 @@ const mutation = gql` ... on SelectFieldOption { externalIdentifier canWriteIn - selectableAnswer + canSelect } ... on SelectFieldOptionGroup { options { @@ -107,7 +107,7 @@ export default Controller.extend(ActionMixin, AppQueryMixin, { label: option.label, externalIdentifier: option.externalIdentifier, canWriteIn: option.canWriteIn, - selectableAnswer: option.selectableAnswer, + 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 e85643a5..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,7 +15,7 @@ const mutation = gql` label option { canWriteIn - selectableAnswer + 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 493aa64b..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,7 +24,7 @@ const query = gql` ... on SelectFieldOption { externalIdentifier canWriteIn - selectableAnswer + canSelect } ... on SelectFieldOptionGroup { options { @@ -32,7 +32,7 @@ const query = gql` label index externalIdentifier - selectableAnswer + canSelect canWriteIn } } @@ -41,7 +41,7 @@ const query = gql` id label externalIdentifier - selectableAnswer + 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 c0a6709f..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,7 +20,7 @@ const query = gql` label ... on SelectFieldOption { canWriteIn - selectableAnswer + 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 da364c3d..88a9aecd 100644 --- a/services/manage/app/templates/components/custom-field/option.hbs +++ b/services/manage/app/templates/components/custom-field/option.hbs @@ -35,7 +35,7 @@ class="d-flex border border-secondary border-left-0 border-right-0" title="Allow answer to be selected" > - +