From 81bb27131833b190fb43bb5a22f4954615625088 Mon Sep 17 00:00:00 2001 From: Austin Jacob Date: Mon, 21 Oct 2024 13:48:23 +0530 Subject: [PATCH 1/5] Added a field called :is_satisfaction_rating_optional --- app/controllers/admin/consultations_controller.rb | 2 +- app/controllers/organisation/consultations_controller.rb | 2 +- app/graphql/types/objects/consultation/base.rb | 5 +++++ app/views/admin/consultations/_form.html.slim | 2 ++ app/views/admin/consultations/show.html.slim | 7 +++++++ app/views/organisation/consultations/show.html.slim | 7 +++++++ ...dd_is_satisfaction_rating_enabled_to_consultations.rb | 9 +++++++++ db/schema.rb | 3 ++- 8 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20241021070453_add_is_satisfaction_rating_enabled_to_consultations.rb diff --git a/app/controllers/admin/consultations_controller.rb b/app/controllers/admin/consultations_controller.rb index 792d825d..63fe5879 100644 --- a/app/controllers/admin/consultations_controller.rb +++ b/app/controllers/admin/consultations_controller.rb @@ -194,7 +194,7 @@ def import_responses private def secure_params - params.require(:consultation).permit(:title, :title_hindi, :title_odia, :url, :ministry_id, :response_deadline, :summary, :consultation_feedback_email, :review_type, :visibility, :response_submission_message, :private_response, :officer_name, :officer_designation) + params.require(:consultation).permit(:title, :title_hindi, :title_odia, :url, :ministry_id, :response_deadline, :summary, :consultation_feedback_email, :review_type, :visibility, :response_submission_message, :private_response, :officer_name, :officer_designation, :is_satisfaction_rating_optional) end def set_consultation diff --git a/app/controllers/organisation/consultations_controller.rb b/app/controllers/organisation/consultations_controller.rb index 1b1802c4..92bb2c58 100644 --- a/app/controllers/organisation/consultations_controller.rb +++ b/app/controllers/organisation/consultations_controller.rb @@ -144,7 +144,7 @@ def import_responses private def secure_params - params.require(:consultation).permit(:title, :title_hindi, :title_odia, :url, :ministry_id, :response_deadline, :summary, :consultation_feedback_email, :review_type, :visibility, :private_response, :organisation_id) + params.require(:consultation).permit(:title, :title_hindi, :title_odia, :url, :ministry_id, :response_deadline, :summary, :consultation_feedback_email, :review_type, :visibility, :private_response, :organisation_id, :is_satisfaction_rating_optional) end def set_consultation diff --git a/app/graphql/types/objects/consultation/base.rb b/app/graphql/types/objects/consultation/base.rb index 4752903a..85b218ed 100644 --- a/app/graphql/types/objects/consultation/base.rb +++ b/app/graphql/types/objects/consultation/base.rb @@ -26,6 +26,7 @@ def visible?(context) end field :response_submission_message, String, nil, null: true field :review_type, Types::Enums::ConsultationReviewType, nil, null: false + field :is_consultation_rating_optional, Boolean, nil, null: false field :satisfaction_rating_distribution, GraphQL::Types::JSON, nil, null: true field :shared_responses, Types::Connections::ConsultationResponse, nil, null: true do argument :sort, Types::Enums::ConsultationResponseSorts, required: false, default_value: nil @@ -72,6 +73,10 @@ def odia_title object.title_odia end + def is_consultation_rating_optional + object.is_satisfaction_rating_optional + end + def english_summary return unless object.english_summary.to_s.present? diff --git a/app/views/admin/consultations/_form.html.slim b/app/views/admin/consultations/_form.html.slim index 402e3381..8b64ae44 100644 --- a/app/views/admin/consultations/_form.html.slim +++ b/app/views/admin/consultations/_form.html.slim @@ -10,6 +10,8 @@ = f.input :visibility, as: :boolean, checked_value: "private_consultation", unchecked_value: "public_consultation", label: "Private Consultation" .private-consultation = f.input :private_response, as: :boolean, checked_value: 1, unchecked_value: 0, label: "Enforce Private Response" + .satisfaction_rating_optional + = f.input :is_satisfaction_rating_optional, as: :boolean, checked_value: true, unchecked_value: false, label: "Is Satisfaction Rating Optional" = f.input :consultation_feedback_email, placeholder: "Consultation feedback email address", required: false, autofocus: true, wrapper: :form_input_group, input_html: { id: "consultation_feedback_email" } = f.input :officer_name, placeholder: "Officer name", required: false, autofocus: true, wrapper: :form_input_group, input_html: { id: "officer_name" } = f.input :officer_designation, placeholder: "Officer designation", required: false, autofocus: true, wrapper: :form_input_group, input_html: { id: "officer_designation" } diff --git a/app/views/admin/consultations/show.html.slim b/app/views/admin/consultations/show.html.slim index d316676e..9da9932e 100644 --- a/app/views/admin/consultations/show.html.slim +++ b/app/views/admin/consultations/show.html.slim @@ -166,6 +166,13 @@ .admin-list-bg.mt-4 .consultation-feedback-flex .width-50 class="#{@consultation.private_consultation? ? '' : 'width-75'}" + .p-4 + .question-parent + .question-header-text + | Is Satisfaction Rating optional? + .question-text + .padding-right-40 + = @consultation.is_satisfaction_rating_optional ? "Yes" : "No" - if (@consultation.private_consultation? && @response_rounds.size > 1) ul.questions-rounds-tab.nav.nav-tabs.mt-2.pb-3.questions-box-shadow-top role="tablist" - @response_rounds.each_with_index do |response_round, index| diff --git a/app/views/organisation/consultations/show.html.slim b/app/views/organisation/consultations/show.html.slim index 717a6fcf..c45eef7c 100644 --- a/app/views/organisation/consultations/show.html.slim +++ b/app/views/organisation/consultations/show.html.slim @@ -122,6 +122,13 @@ .admin-list-bg.mt-4 .consultation-feedback-flex .width-50 + .p-4 + .question-parent + .question-header-text + | Is Satisfaction Rating optional? + .question-text + .padding-right-40 + = @consultation.is_satisfaction_rating_optional ? "Yes" : "No" - if @response_rounds.size > 1 ul.questions-rounds-tab.nav.nav-tabs.mt-2.pb-3.questions-box-shadow-top role="tablist" - @response_rounds.each_with_index do |response_round, index| diff --git a/db/migrate/20241021070453_add_is_satisfaction_rating_enabled_to_consultations.rb b/db/migrate/20241021070453_add_is_satisfaction_rating_enabled_to_consultations.rb new file mode 100644 index 00000000..343d10b3 --- /dev/null +++ b/db/migrate/20241021070453_add_is_satisfaction_rating_enabled_to_consultations.rb @@ -0,0 +1,9 @@ +class AddIsSatisfactionRatingEnabledToConsultations < ActiveRecord::Migration[7.1] + def up + add_column :consultations, :is_satisfaction_rating_optional, :boolean, default: false, null: false + end + + def down + remove_column :consultations, :is_satisfaction_rating_optional + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 0fbb1c5a..679a1553 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_09_02_200244) do +ActiveRecord::Schema[7.1].define(version: 2024_10_21_070453) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "uuid-ossp" @@ -193,6 +193,7 @@ t.string "officer_designation" t.string "title_hindi" t.string "title_odia" + t.boolean "is_satisfaction_rating_optional", default: false, null: false t.index ["deleted_at"], name: "index_consultations_on_deleted_at" t.index ["ministry_id"], name: "index_consultations_on_ministry_id" end From fc61aa792c64021710b90c6bafd9868892831d0f Mon Sep 17 00:00:00 2001 From: Austin Jacob Date: Mon, 21 Oct 2024 13:50:41 +0530 Subject: [PATCH 2/5] Updated satisfaction_rating as optional --- app/graphql/types/inputs/consultation_response/create.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/graphql/types/inputs/consultation_response/create.rb b/app/graphql/types/inputs/consultation_response/create.rb index 740d1cd3..d4cc7e17 100644 --- a/app/graphql/types/inputs/consultation_response/create.rb +++ b/app/graphql/types/inputs/consultation_response/create.rb @@ -7,7 +7,7 @@ class Create < Types::BaseInputObject argument :consultation_id, Int, nil, required: true argument :response_text, String, nil, required: false argument :response_status, Int, nil, required: true - argument :satisfaction_rating, Types::Enums::ConsultationResponseSatisfactionRatings, nil, required: true + argument :satisfaction_rating, Types::Enums::ConsultationResponseSatisfactionRatings, nil, required: false argument :template_id, Int, "ID of the response you are using as a template", required: false, default_value: nil argument :visibility, Types::Enums::ConsultationResponseVisibilities, nil, required: true end From bcb0c3cd3f72f304d9f4e6cd6b258abf31268722 Mon Sep 17 00:00:00 2001 From: Austin Jacob Date: Mon, 21 Oct 2024 13:52:41 +0530 Subject: [PATCH 3/5] Small changes in names --- app/graphql/types/objects/consultation/base.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/graphql/types/objects/consultation/base.rb b/app/graphql/types/objects/consultation/base.rb index 85b218ed..ecb60e9d 100644 --- a/app/graphql/types/objects/consultation/base.rb +++ b/app/graphql/types/objects/consultation/base.rb @@ -26,7 +26,7 @@ def visible?(context) end field :response_submission_message, String, nil, null: true field :review_type, Types::Enums::ConsultationReviewType, nil, null: false - field :is_consultation_rating_optional, Boolean, nil, null: false + field :is_satisfaction_rating_optional, Boolean, nil, null: false field :satisfaction_rating_distribution, GraphQL::Types::JSON, nil, null: true field :shared_responses, Types::Connections::ConsultationResponse, nil, null: true do argument :sort, Types::Enums::ConsultationResponseSorts, required: false, default_value: nil @@ -73,11 +73,6 @@ def odia_title object.title_odia end - def is_consultation_rating_optional - object.is_satisfaction_rating_optional - end - - def english_summary return unless object.english_summary.to_s.present? From 4cc86f12bec66a48dac7dd38ccb192a3dc5b5358 Mon Sep 17 00:00:00 2001 From: Austin Jacob Date: Mon, 21 Oct 2024 15:38:19 +0530 Subject: [PATCH 4/5] Updated code for is_satisfaction_rating_optional --- app/views/admin/consultations/_form.html.slim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/consultations/_form.html.slim b/app/views/admin/consultations/_form.html.slim index 8b64ae44..c64fecfd 100644 --- a/app/views/admin/consultations/_form.html.slim +++ b/app/views/admin/consultations/_form.html.slim @@ -10,8 +10,8 @@ = f.input :visibility, as: :boolean, checked_value: "private_consultation", unchecked_value: "public_consultation", label: "Private Consultation" .private-consultation = f.input :private_response, as: :boolean, checked_value: 1, unchecked_value: 0, label: "Enforce Private Response" - .satisfaction_rating_optional - = f.input :is_satisfaction_rating_optional, as: :boolean, checked_value: true, unchecked_value: false, label: "Is Satisfaction Rating Optional" + .private-consultation + = f.input :is_satisfaction_rating_optional, as: :boolean, label: "Is Satisfaction Rating Optional", include_hidden: true = f.input :consultation_feedback_email, placeholder: "Consultation feedback email address", required: false, autofocus: true, wrapper: :form_input_group, input_html: { id: "consultation_feedback_email" } = f.input :officer_name, placeholder: "Officer name", required: false, autofocus: true, wrapper: :form_input_group, input_html: { id: "officer_name" } = f.input :officer_designation, placeholder: "Officer designation", required: false, autofocus: true, wrapper: :form_input_group, input_html: { id: "officer_designation" } From 2d1cde993f5bb15be3e1b5632d9ec5322d29af9c Mon Sep 17 00:00:00 2001 From: Austin Jacob Date: Mon, 21 Oct 2024 19:09:40 +0530 Subject: [PATCH 5/5] consultation Satisfaction Rating Issue Fix --- app/graphql/types/objects/consultation_response/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/graphql/types/objects/consultation_response/base.rb b/app/graphql/types/objects/consultation_response/base.rb index c35daab2..d09732f2 100644 --- a/app/graphql/types/objects/consultation_response/base.rb +++ b/app/graphql/types/objects/consultation_response/base.rb @@ -14,7 +14,7 @@ class Base < BaseObject field :response_text, String, nil, null: true field :response_status, Integer, nil, null: false field :round_number, Integer, nil, null: true - field :satisfaction_rating, Types::Enums::ConsultationResponseSatisfactionRatings, nil, null: false + field :satisfaction_rating, Types::Enums::ConsultationResponseSatisfactionRatings, nil, null: true field :satisfaction_rating_distribution, GraphQL::Types::JSON, nil, null: true field :templates_count, Integer, "Count of responses that used this response as a template", null: false field :up_vote_count, Integer, "Count of users that up-voted this response", null: false