Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- run:
name: Install-cf-cli
command: |
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.11&source=github-rel'
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
# collect reports
Expand All @@ -93,7 +93,7 @@ jobs:
- run:
name: Install-cf-cli
command: |
curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
- run:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.2.4-slim
FROM ruby:3.3.4-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
Expand Down
42 changes: 21 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ GEM
aes_key_wrap (1.1.0)
ast (2.4.2)
aws-eventstream (1.3.0)
aws-partitions (1.1018.0)
aws-partitions (1.1006.0)
aws-record (2.13.2)
aws-sdk-dynamodb (~> 1, >= 1.85.0)
aws-sdk-core (3.214.0)
aws-sdk-core (3.212.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-dynamodb (1.126.0)
aws-sdk-dynamodb (1.129.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-kms (1.96.0)
aws-sdk-kms (1.95.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-rails (4.1.0)
Expand All @@ -128,20 +128,20 @@ GEM
aws-sessionstore-dynamodb (~> 2)
concurrent-ruby (~> 1.3, >= 1.3.1)
railties (>= 7.0.0)
aws-sdk-s3 (1.169.0)
aws-sdk-s3 (1.170.1)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sdk-ses (1.76.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-sesv2 (1.65.0)
aws-sdk-sesv2 (1.66.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-sns (1.89.0)
aws-sdk-sns (1.90.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-sqs (1.87.0)
aws-sdk-sqs (1.88.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sessionstore-dynamodb (2.2.0)
Expand Down Expand Up @@ -189,7 +189,7 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
carrierwave (3.0.7)
carrierwave (3.1.0)
activemodel (>= 6.0.0)
activesupport (>= 6.0.0)
addressable (~> 2.6)
Expand Down Expand Up @@ -222,17 +222,17 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.5.1)
docile (1.4.1)
dotenv (3.1.4)
dotenv (3.1.7)
drb (2.2.1)
dumb_delegator (1.0.0)
erubi (1.13.0)
erubi (1.13.1)
excon (1.2.2)
factory_bot (6.5.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
faraday (2.12.1)
faraday (2.12.2)
faraday-net_http (>= 2.0, < 3.5)
json
logger
Expand All @@ -250,7 +250,7 @@ GEM
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
fog-aws (3.29.0)
fog-aws (3.30.0)
base64 (~> 0.2.0)
fog-core (~> 2.6)
fog-json (~> 1.1)
Expand Down Expand Up @@ -292,7 +292,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.9.0)
json (2.9.1)
json-jwt (1.16.7)
activesupport (>= 4.2)
aes_key_wrap
Expand Down Expand Up @@ -347,7 +347,7 @@ GEM
bigdecimal (~> 3.1)
net-http (0.6.0)
uri
net-imap (0.5.2)
net-imap (0.5.4)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -392,7 +392,7 @@ GEM
omniauth (~> 2.0)
orm_adapter (0.5.0)
ostruct (0.6.1)
paper_trail (15.2.0)
paper_trail (16.0.0)
activerecord (>= 6.1)
request_store (~> 1.4)
parallel (1.26.3)
Expand Down Expand Up @@ -472,7 +472,7 @@ GEM
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
redis-client (0.23.0)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
Expand All @@ -484,7 +484,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.9)
rexml (3.4.0)
rolify (6.0.1)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
Expand Down Expand Up @@ -515,7 +515,7 @@ GEM
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.36.2)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-rails (2.27.0)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -548,7 +548,7 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sidekiq (7.3.6)
sidekiq (7.3.7)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
Expand All @@ -575,7 +575,7 @@ GEM
stringio (3.1.2)
thor (1.3.2)
thread_safe (0.3.6)
tilt (2.4.0)
tilt (2.5.0)
timeout (0.4.3)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
Expand Down
13 changes: 0 additions & 13 deletions app/assets/javascripts/chartjs-3.9.1.js

This file was deleted.

1 change: 1 addition & 0 deletions app/controllers/admin/forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ def form_admin_options_params
:omb_approval_number,
:expiration_date,
:service_id,
:enforce_new_submission_validations,
)
end

Expand Down
52 changes: 30 additions & 22 deletions app/controllers/admin/question_options_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,57 +37,65 @@ def update_title
def create
text_array = question_option_params[:text].split("\n")
position = @question.question_options.size + 1
@question_options = []
@new_question_options = []
@errors = []
result = false

if text_array.length.positive?
if text_array.length.positive? # multiple options
text_array.each do |txt|
if ["radio_buttons", "checkbox", "dropdown"].include?(@question.question_type)
if ["radio_buttons", "checkbox"].include?(@question.question_type)
if txt.upcase == 'OTHER' || txt.upcase == 'OTRO'
@errors << "Use add #{txt} button"
next
end
end
question_option = QuestionOption.where(question_id: params[:question_id], text: txt).first
if question_option
@question_option = QuestionOption.where(question_id: params[:question_id], text: txt).first
if @question_option
@errors << "Question option already exists for text #{txt}"
next
end
question_option = QuestionOption.new(question_id: params[:question_id], text: txt, value: txt, position:)
if question_option.save
@question_options << question_option
@question_option = QuestionOption.new(question_id: params[:question_id], text: txt, value: txt, position:)
if @question_option.save
@new_question_options << @question_option
position += 1
else
@errors << question_option.errors.full_messages
@errors << @question_option.errors.full_messages
end
end
else
question_option = QuestionOption.where(question_id: params[:question_id], text: params[:text]).first
@question_option = QuestionOption.where(question_id: params[:question_id], text: params[:text]).first
if question_option
@errors << "Question option already exists for text #{params[:text]}"
else
question_option = QuestionOption.new(question_option_params)
question_option.position = position
if question_option.save
@question_options << question_option
@question_option = QuestionOption.new(question_option_params)
@question_option.position = position
if @question_option.save
@new_question_options << @question_option
# ok
else
@errors << question_option.errors.full_messages
@errors << @question_option.errors.full_messages
end
end
end

render :create, format: :js
end

def create_other
@new_question_options = []
@errors = []
question_option = QuestionOption.new
question_option.position = @question.question_options.size + 1
question_option.question_id = @question.id
question_option.text = 'Other'
question_option.value = 'OTHER'
question_option.save!
@question_options = [question_option]

if @question.question_options.detect { |option| option.other_option }
@errors << "An Other option already exists"
else
@question_option = @question.question_options.new(other_option: true)
@question_option.position = @question.question_options.size + 1
@question_option.text = 'Other'
@question_option.value = 'OTHER'
@question_option.save!
@new_question_options << @question_option
end

render :create, format: :js
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def add_tag
tag = tag_params[:tag]

if !tag.strip.empty? && !@submission.tags.include?(tag)
@submission.tags << tag.strip.downcase
@submission.save!
unique_tags = (@submission.tags.clone << tag.strip.downcase).uniq
@submission.update(tags: unique_tags)
@submission.form.update_submission_tags!(@submission.tags)
end
end
Expand Down
15 changes: 12 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ def cx_collections_filter_message(quarter, year, status)
"for " + parts.join(" ")
end

def form_edit_component_path(question_type)
case question_type
when "radio_buttons", "combobox"
"components/forms/edit/question_types/radio_button_option"
when "dropdown"
"components/forms/edit/question_types/dropdown_option"
when "checkbox"
"components/forms/edit/question_types/checkbox_option"
end
end

# Returns javascript to capture form input for one Form Question
def question_type_javascript_params(question)
if question.question_type == 'text_field'
Expand All @@ -133,15 +144,13 @@ def question_type_javascript_params(question)
elsif question.question_type == 'text_email_field'
"form.querySelector(\"##{question.ui_selector}\") && form.querySelector(\"##{question.ui_selector}\").value"
elsif question.question_type == 'text_phone_field'
"form.querySelector(\"##{question.ui_selector}\") && form.querySelector(\"##{question.ui_selector}\").value"
"form.querySelector(\"##{question.ui_selector}\") && form.querySelector(\"##{question.ui_selector}\").dataset.rawValue"
elsif question.question_type == 'textarea'
"form.querySelector(\"##{question.ui_selector}\") && form.querySelector(\"##{question.ui_selector}\").value"
elsif question.question_type == 'radio_buttons'
"form.querySelector(\"input[name=#{question.ui_selector}]:checked\") && form.querySelector(\"input[name=#{question.ui_selector}]:checked\").value"
elsif question.question_type == 'star_radio_buttons'
"form.querySelector(\"input[name=#{question.ui_selector}]:checked\") && form.querySelector(\"input[name=#{question.ui_selector}]:checked\").value"
elsif question.question_type == 'thumbs_up_down_buttons'
"form.querySelector(\"input[name=#{question.ui_selector}]:checked\") && form.querySelector(\"input[name=#{question.ui_selector}]:checked\").value"
elsif question.question_type == 'big_thumbs_up_down_buttons'
"form.querySelector(\"input[name=#{question.ui_selector}]:checked\") && form.querySelector(\"input[name=#{question.ui_selector}]:checked\").value"
elsif question.question_type == 'yes_no_buttons'
Expand Down
3 changes: 2 additions & 1 deletion app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ def form_feedback(form_id:, email:)

def submission_notification(submission_id:, emails: [])
set_logo
emails_to_notify = User.where(email: emails).select { |user| !user.inactive }.collect(&:email)
@submission = Submission.find(submission_id)
@form = @submission.form
mail subject: "New Submission to #{@form.name}",
to: emails
to: emails_to_notify
end

def form_status_changed(form:, action:, event:)
Expand Down
1 change: 1 addition & 0 deletions app/models/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def duplicate!(new_user:)
new_form.notification_emails = nil
new_form.organization = new_user.organization
new_form.template = false
new_form.enforce_new_submission_validations = true
new_form.save!

# Manually remove the Form Section created with create_first_form_section
Expand Down
12 changes: 9 additions & 3 deletions app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Question < ApplicationRecord
'custom_text_display',
'states_dropdown',
'star_radio_buttons',
'thumbs_up_down_buttons',
'big_thumbs_up_down_buttons',
'yes_no_buttons',
'hidden_field',
Expand All @@ -40,7 +39,6 @@ class Question < ApplicationRecord
'combobox',
'custom_text_display',
'star_radio_buttons',
'thumbs_up_down_buttons',
'big_thumbs_up_down_buttons',
'yes_no_buttons',
].freeze
Expand All @@ -49,7 +47,7 @@ class Question < ApplicationRecord
validates :character_limit, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: MAX_CHARACTERS, allow_nil: true }

after_commit do |question|
FormCache.invalidate(question.form.short_uuid) if question.persisted?
FormCache.invalidate(question.form.short_uuid) if question.persisted? || question.destroyed?
end

def max_length
Expand All @@ -60,9 +58,17 @@ def validate_question_types
errors.add(:question_type, "Invalid question type '#{question_type}'. Valid types include: #{QUESTION_TYPES.to_sentence}.") unless QUESTION_TYPES.include?(question_type)
end

def has_other_question_option?
question_options.where(other_option: true).exists?
end

# used to generate a (application-wide) unique id for each question
# (such that the questions on 2 different Touchpoints have unique DOM string)
def ui_selector
"question_#{id}_#{answer_field}" # question_123_answer_02
end

def submission_answers
form.submissions.collect { |s| s.send(answer_field) }
end
end
Loading
Loading