diff --git a/.rubocop.yml b/.rubocop.yml index ff5b5c4dc..4265d3ab1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,10 +51,10 @@ Metrics/AbcSize: - spec/**/* Metrics/ModuleLength: - Max: 500 + Max: 1000 Metrics/ClassLength: - Max: 500 + Max: 1000 RSpec/NestedGroups: Max: 6 diff --git a/app/controllers/webhook_secret_controller.rb b/app/controllers/webhook_secret_controller.rb index 27f35b260..b9b8a3f24 100644 --- a/app/controllers/webhook_secret_controller.rb +++ b/app/controllers/webhook_secret_controller.rb @@ -10,7 +10,8 @@ def update webhook_secret_params[:key] => webhook_secret_params[:value] }.compact_blank) - redirect_back(fallback_location: settings_webhooks_path, notice: I18n.t('webhook_secret_has_been_saved')) + redirect_back(fallback_location: settings_webhook_path(@webhook_url), + notice: I18n.t('webhook_secret_has_been_saved')) end private diff --git a/app/controllers/webhook_settings_controller.rb b/app/controllers/webhook_settings_controller.rb index 2c6362af3..5f023ad13 100644 --- a/app/controllers/webhook_settings_controller.rb +++ b/app/controllers/webhook_settings_controller.rb @@ -1,22 +1,47 @@ # frozen_string_literal: true class WebhookSettingsController < ApplicationController - before_action :load_webhook_url - authorize_resource :webhook_url, parent: false + load_and_authorize_resource :webhook_url, parent: false, only: %i[index show new create update destroy] + load_and_authorize_resource :webhook_url, only: %i[resend], id_param: :webhook_id + + def index + @webhook_urls = @webhook_urls.order(id: :desc) + @webhook_url = @webhook_urls.first_or_initialize + + render @webhook_urls.size > 1 ? 'index' : 'show' + end def show; end - def create - @webhook_url.assign_attributes(webhook_params) + def new; end - @webhook_url.url.present? ? @webhook_url.save! : @webhook_url.delete + def create + @webhook_url.save! - redirect_back(fallback_location: settings_webhooks_path, notice: I18n.t('webhook_url_has_been_saved')) + redirect_to settings_webhooks_path, notice: I18n.t('webhook_url_has_been_saved') end def update + @webhook_url.update!(update_params) + + redirect_back(fallback_location: settings_webhook_path(@webhook_url), + notice: I18n.t('webhook_url_has_been_updated')) + end + + def destroy + @webhook_url.destroy! + + redirect_to settings_webhooks_path, notice: I18n.t('webhook_url_has_been_deleted') + end + + def resend submitter = current_account.submitters.where.not(completed_at: nil).order(:id).last + if submitter.blank? || @webhook_url.blank? + return redirect_back(fallback_location: settings_webhooks_path, + alert: I18n.t('unable_to_resend_webhook_request')) + end + SendFormCompletedWebhookRequestJob.perform_async('submitter_id' => submitter.id, 'webhook_url_id' => @webhook_url.id) @@ -25,11 +50,11 @@ def update private - def load_webhook_url - @webhook_url = current_account.webhook_urls.first_or_initialize + def create_params + params.require(:webhook_url).permit(:url, events: []).reverse_merge(events: []) end - def webhook_params + def update_params params.require(:webhook_url).permit(:url) end end diff --git a/app/javascript/draw.js b/app/javascript/draw.js index 81ceccf52..c42c3c72a 100644 --- a/app/javascript/draw.js +++ b/app/javascript/draw.js @@ -12,6 +12,10 @@ window.customElements.define('draw-signature', class extends HTMLElement { this.pad = new SignaturePad(this.canvas) + if (this.dataset.color) { + this.pad.penColor = this.dataset.color + } + this.pad.addEventListener('endStroke', () => { this.updateSubmitButtonVisibility() }) diff --git a/app/javascript/submission_form/area.vue b/app/javascript/submission_form/area.vue index c77222e6a..750228fa8 100644 --- a/app/javascript/submission_form/area.vue +++ b/app/javascript/submission_form/area.vue @@ -39,7 +39,6 @@
+ + + + + +