From 2bf2ad9a9d354012d68b74dc57b67af18e7e2276 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 23 Feb 2024 15:39:59 +0100 Subject: [PATCH] insert error tag below edit of row if form is invalid --- app/views/skills/_row.html.haml | 21 +++++++++++++++++++++ app/views/skills/edit.html.haml | 22 +--------------------- app/views/skills/edit.turbo_stream.erb | 12 ++++++++++++ 3 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 app/views/skills/_row.html.haml create mode 100644 app/views/skills/edit.turbo_stream.erb diff --git a/app/views/skills/_row.html.haml b/app/views/skills/_row.html.haml new file mode 100644 index 000000000..550f7b722 --- /dev/null +++ b/app/views/skills/_row.html.haml @@ -0,0 +1,21 @@ += form_with(model: @skill) do |f| + .row.border.border-top.table-light.table-hover.table-row{"data-controller" => "table"} + .col-2.d-flex.align-items-center + = f.text_field :title, class: "form-control", value: @skill.title + .col-1.bg-light.d-flex.align-items-center + =@skill.people.count + .col-3.d-flex.align-items-center + = f.collection_select :category_id, Category.all_parents { |category| category.title}, :id, :title, {:selected => @skill.category.parent.id}, class: "form-select w-100", data: {action: "change->table#adjustChildren", table_target: "parentSelect"} + .col-2.bg-light.d-flex.align-items-center + = f.collection_select :category_id, @skill.category.parent.children, :id, :title, {:selected => @skill.category.id}, class: "form-select w-100", data: {table_target: "childSelect"} + .col-1.d-flex.align-items-center + =f.check_box :default_set, class: "form-check-input", checked: @skill.default_set + .col-1.bg-light.d-flex.align-items-center + = f.select :radar, Settings.radar, {:selected => @skill.radar}, class: "form-select radar-select" + .col-1.d-flex.align-items-center + = f.select :portfolio, Settings.portfolio, {:selected => @skill.portfolio}, class: "form-select portfolio-select" + .col-1 + %div.h-100.d-flex.justify-content-center.align-items-center + = image_submit_tag("/assets/floppy2-fill.svg") + = link_to skills_path, class: "ms-3" do + %img.pointer.save-button{:src=> "/assets/x.svg",:height=>"16"} \ No newline at end of file diff --git a/app/views/skills/edit.html.haml b/app/views/skills/edit.html.haml index 919093f7e..21b209d33 100644 --- a/app/views/skills/edit.html.haml +++ b/app/views/skills/edit.html.haml @@ -1,24 +1,4 @@ %div %h1.font-bold.text-2xl.mb-3 Editing Skill %turbo-frame{id: "#{dom_id @skill}"} - = form_with(model: @skill) do |f| - .row.border.border-top.table-light.table-hover.table-row{"data-controller" => "table"} - .col-2.d-flex.align-items-center - = f.text_field :title, class: "form-control", value: @skill.title - .col-1.bg-light.d-flex.align-items-center - =@skill.people.count - .col-3.d-flex.align-items-center - = f.collection_select :category_id, Category.all_parents { |category| category.title}, :id, :title, {:selected => @skill.category.parent.id}, class: "form-select w-100", data: {action: "change->table#adjustChildren", table_target: "parentSelect"} - .col-2.bg-light.d-flex.align-items-center - = f.collection_select :category_id, @skill.category.parent.children, :id, :title, {:selected => @skill.category.id}, class: "form-select w-100", data: {table_target: "childSelect"} - .col-1.d-flex.align-items-center - =f.check_box :default_set, class: "form-check-input", checked: @skill.default_set - .col-1.bg-light.d-flex.align-items-center - = f.select :radar, Settings.radar, {:selected => @skill.radar}, class: "form-select radar-select" - .col-1.d-flex.align-items-center - = f.select :portfolio, Settings.portfolio, {:selected => @skill.portfolio}, class: "form-select portfolio-select" - .col-1 - %div.h-100.d-flex.justify-content-center.align-items-center - = image_submit_tag("/assets/floppy2-fill.svg") - = link_to skills_path, class: "ms-3" do - %img.pointer.save-button{:src=> "/assets/x.svg",:height=>"16"} \ No newline at end of file + = render "skills/row", skill: @skill \ No newline at end of file diff --git a/app/views/skills/edit.turbo_stream.erb b/app/views/skills/edit.turbo_stream.erb new file mode 100644 index 000000000..d995cb233 --- /dev/null +++ b/app/views/skills/edit.turbo_stream.erb @@ -0,0 +1,12 @@ +<%= turbo_stream.update "#{dom_id @skill}" do %> + <%= render "row", skill: @skill %> + <% if @skill.errors.any? %> +
+ +
+ <% end %> +<% end %> \ No newline at end of file