Skip to content

Commit

Permalink
Merge pull request #925 from civis-vote/make-safisfaction-optional-main
Browse files Browse the repository at this point in the history
Feat:Made Satisfaction Rating Optional
  • Loading branch information
austinjb32 authored Oct 22, 2024
2 parents e825785 + 2d1cde9 commit 88ffb40
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/consultations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/organisation/consultations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/inputs/consultation_response/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/objects/consultation/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_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
Expand Down Expand Up @@ -72,7 +73,6 @@ def odia_title
object.title_odia
end


def english_summary
return unless object.english_summary.to_s.present?

Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/objects/consultation_response/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/views/admin/consultations/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
.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" }
Expand Down
7 changes: 7 additions & 0 deletions app/views/admin/consultations/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
7 changes: 7 additions & 0 deletions app/views/organisation/consultations/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 88ffb40

Please sign in to comment.