adjust dashboard templates style

This commit is contained in:
Alex Turchyn
2023-06-28 00:22:34 +03:00
parent 897df83633
commit 9c9c1ad6f0
14 changed files with 166 additions and 150 deletions
+14 -13
View File
@@ -1,13 +1,12 @@
# frozen_string_literal: true
class TemplatesController < ApplicationController
layout 'plain'
before_action :load_base_template, only: %i[new create]
def show
@template = current_account.templates.preload(documents_attachments: { preview_images_attachments: :blob })
.find(params[:id])
@template = current_account.templates.find(params[:id])
@pagy, @submissions = pagy(@template.submissions.active)
end
def new
@@ -15,20 +14,22 @@ class TemplatesController < ApplicationController
@template.name = "#{@base_template.name} (Clone)" if @base_template
end
def create
@template =
if @base_template
current_account.templates.new(**@base_template.slice(:fields, :schema, :submitters), **template_params)
else
current_account.templates.new(template_params)
end
def edit
@template = current_account.templates.preload(documents_attachments: { preview_images_attachments: :blob })
.find(params[:id])
render :edit, layout: 'plain'
end
def create
@template = current_account.templates.new(template_params)
@template.author = current_user
@template.assign_attributes(@base_template.slice(:fields, :schema, :submitters)) if @base_template
if @template.save
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
redirect_to template_path(@template)
redirect_to edit_template_path(@template)
else
render turbo_stream: turbo_stream.replace(:modal, template: 'templates/new'), status: :unprocessable_entity
end
@@ -38,7 +39,7 @@ class TemplatesController < ApplicationController
@template = current_account.templates.find(params[:id])
@template.update!(deleted_at: Time.current)
redirect_to settings_users_path, notice: 'template has been archived.'
redirect_back(fallback_location: root_path, notice: 'Template has been archived.')
end
private