From 3b60c62c7933dac1834fae26dd98f5feb493f986 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 4 May 2022 10:25:53 +0200 Subject: [PATCH] Refactor modal loading [SCI-6780] --- .../step_orderable_elements_controller.rb | 2 +- .../vue/protocol/mixins/components/delete.js | 14 ++++++++----- app/javascript/vue/protocol/modals.vue | 1 - .../vue/protocol/modals/delete_component.vue | 21 +++++++++++++++---- app/javascript/vue/protocol/step.vue | 4 ++-- .../protocol/step_components/checklist.vue | 4 ++++ .../vue/protocol/step_components/table.vue | 4 ++++ .../vue/protocol/step_components/text.vue | 4 ++++ app/serializers/checklist_serializer.rb | 2 +- app/serializers/step_table_serializer.rb | 4 +++- app/serializers/step_text_serializer.rb | 2 +- config/locales/en.yml | 1 + 12 files changed, 47 insertions(+), 16 deletions(-) diff --git a/app/controllers/step_orderable_elements_controller.rb b/app/controllers/step_orderable_elements_controller.rb index eae9ee97e..d6ad48c41 100644 --- a/app/controllers/step_orderable_elements_controller.rb +++ b/app/controllers/step_orderable_elements_controller.rb @@ -2,7 +2,7 @@ class StepOrderableElementsController < ApplicationController before_action :load_vars_nested - before_action :load_vars + before_action :load_vars, only: :destroy before_action :check_manage_permissions, only: %i(create destroy) def create diff --git a/app/javascript/vue/protocol/mixins/components/delete.js b/app/javascript/vue/protocol/mixins/components/delete.js index 554277ffd..735a0eeae 100644 --- a/app/javascript/vue/protocol/mixins/components/delete.js +++ b/app/javascript/vue/protocol/mixins/components/delete.js @@ -1,11 +1,15 @@ export default { + data() { + return { + confirmingDelete: false + }; + }, methods: { showDeleteModal() { - $('#modalDestroyProtocolContent').modal('show'); - $('#modalDestroyProtocolContent .delete-step').off().one('click', () => { - this.deleteComponent(); - $('#modalDestroyProtocolContent').modal('hide'); - }); + this.confirmingDelete = true; + }, + closeDeleteModal() { + this.confirmingDelete = false; }, deleteComponent() { $.ajax({ diff --git a/app/javascript/vue/protocol/modals.vue b/app/javascript/vue/protocol/modals.vue index 14b237a53..0d5339491 100644 --- a/app/javascript/vue/protocol/modals.vue +++ b/app/javascript/vue/protocol/modals.vue @@ -1,6 +1,5 @@ diff --git a/app/javascript/vue/protocol/step.vue b/app/javascript/vue/protocol/step.vue index b211489b5..a09071b91 100644 --- a/app/javascript/vue/protocol/step.vue +++ b/app/javascript/vue/protocol/step.vue @@ -109,10 +109,10 @@ }, changeState() { this.step.attributes.completed = !this.step.attributes.completed; - this.$emit('step:update', this.step) + this.$emit('step:update', this.step.attributes) $.post(this.step.attributes.urls.state_url, {completed: this.step.attributes.completed}).error(() => { this.step.attributes.completed = !this.step.attributes.completed; - this.$emit('step:update', this.step) + this.$emit('step:update', this.step.attributes) HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger'); }) }, diff --git a/app/javascript/vue/protocol/step_components/checklist.vue b/app/javascript/vue/protocol/step_components/checklist.vue index 4f5591d4e..6ba347d92 100644 --- a/app/javascript/vue/protocol/step_components/checklist.vue +++ b/app/javascript/vue/protocol/step_components/checklist.vue @@ -4,13 +4,17 @@ +