From 4dea38633a544c5d1426938f27481abf66d9e49f Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 26 Dec 2023 09:30:51 -0500 Subject: [PATCH] Fix page saveing for next page logic --- app/javascript/surveys/edit-survey-page.vue | 7 ++++++- app/serializers/survey/page_serializer.rb | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/javascript/surveys/edit-survey-page.vue b/app/javascript/surveys/edit-survey-page.vue index 0fe7ecd99..c8acd9d49 100644 --- a/app/javascript/surveys/edit-survey-page.vue +++ b/app/javascript/surveys/edit-survey-page.vue @@ -24,7 +24,7 @@
After page {{i + 1}} - +

{{SURVEY_CONFIRM_DELETE_PAGE_1}}

@@ -97,6 +97,11 @@ export default { } }, methods: { + updatePage(arg) { + this.page.next_page_action = arg != -1 ? 'next_page' : 'submit' + this.page.next_page_id = arg + this.savePage(this.page) + }, mergePageUp() { this.mergePage(this.page, this.getPreviousPage(this.page.id)) }, diff --git a/app/serializers/survey/page_serializer.rb b/app/serializers/survey/page_serializer.rb index ec4902d8b..89b87c580 100644 --- a/app/serializers/survey/page_serializer.rb +++ b/app/serializers/survey/page_serializer.rb @@ -1,9 +1,13 @@ class Survey::PageSerializer include JSONAPI::Serializer - attributes :id, :title, :next_page_id, :next_page_action, + attributes :id, :title, :next_page_action, :sort_order, :created_at, :updated_at, :survey_id + # Because the DB can not set -1 for a UUID we fake it for the front end + attribute :next_page_id do |object| + object.next_page_action == 'submit' ? -1 : object.next_page_id + end has_many :questions, serializer: Survey::QuestionSerializer, links: {