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

TAN-3586 Add matrix field #10095

Conversation

sebastienhoorens
Copy link
Contributor

Changelog

Added

  • [TAN-3501] Added matrix (linear scale) custom field type

Copy link

@cl-dev-bot
Copy link
Collaborator

cl-dev-bot commented Jan 17, 2025

Messages
📖 Changelog provided 🎉
📖 Notion issue: TAN-3586
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 42f3099

Base automatically changed from TAN-3501-add-ranking-field to ranking-survey-question-feature January 23, 2025 14:59
@amanda-anderson amanda-anderson changed the base branch from ranking-survey-question-feature to master January 28, 2025 10:31
@amanda-anderson amanda-anderson changed the base branch from master to matrix-question-feature-branch January 28, 2025 10:32
@amanda-anderson
Copy link
Contributor

FYI Sebi I merged master into your branch so I can merge it into my FE ones as well :) There were no merge conflicts.

Copy link
Contributor

@jamesspeake jamesspeake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it all looks generally good. Assume we cannot currently support logic on these questions although they are much like linear scale.

@@ -89,6 +90,7 @@ class CustomField < ApplicationRecord
validates :minimum_select_count, comparison: { greater_than_or_equal_to: 0 }, if: :multiselect?, allow_nil: true
validates :page_layout, presence: true, inclusion: { in: PAGE_LAYOUTS }, if: :page?
validates :page_layout, absence: true, unless: :page?
# validates :matrix_statements, presence: true, if: :supports_matrix_statements?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ideally this would be enabled. But the update_all endpoint currently doesn't allow this (first the field is created, then the statements and options are added). It seemed too complicated to tackle the update_all endpoint for this, so I'll instead just remove this line.

Comment on lines +50 to +52
has_many :matrix_statements, record_type: :custom_field_matrix_statement, serializer: ::WebApi::V1::CustomFieldMatrixStatementSerializer, if: proc { |field|
field.supports_matrix_statements?
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we including this in all the controller queries too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesspeake Yes, they're included in idea_custom_fields_controller.rb:97. I didn't spot other endpoints where we might want to include them as well?

back/app/services/custom_field_service.rb Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this controller used on the FE?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is it just for completeness for the FE given that they are returned as relationships elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Amanda expressed the need to have an explicit endpoint for the statements, even though they are included in the custom field responses.

Comment on lines +227 to +233
linear_scale_label1: 'Strongly disagree',
linear_scale_label2: '',
linear_scale_label3: '',
linear_scale_label4: '',
linear_scale_label5: 'Strongly agree',
linear_scale_label6: '',
linear_scale_label7: ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mentioned it to Edwin the other day when he add up to 11 for linear scale, but think a good future refactor would be to just have one linear_scale_labels column on custom fields with all the labels in there as one json blob

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it would be an improvement. Either a JSON blob or even a separate table/relationship.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to revert this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting!

@sebastienhoorens
Copy link
Contributor Author

This was merged through this PR #10203 so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants