Skip to content

Commit

Permalink
Extract a label template form
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Aug 7, 2024
1 parent dd60207 commit 6a584c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
12 changes: 12 additions & 0 deletions src/api/app/views/webui/projects/label_templates/_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.row
.col-12.col-md-10.col-lg-9
.mb-3#name
= form.label(:name, 'Name:', class: 'form-label')
= form.text_field(:name, class: classes_with_validation(label_template, :name))
- label_template.errors.where(:name).each do |error|
.error-message= error.message.capitalize
.mb-3#color
= form.label(:color, 'Color:', class: 'form-label')
= form.color_field(:color, class: classes_with_validation(label_template, :color))
- label_template.errors.where(:color).each do |error|
.error-message= error.message.capitalize
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
.row
.col-12.col-md-10.col-lg-8
= form_with(model: @label_template, url: project_label_template_path(project_name: @project, id: @label_template), method: :put) do |f|
.row
.col-12.col-md-10.col-lg-9
.mb-3#name
= f.label(:name, 'Name:')
= f.text_field(:name, class: 'form-control')
.mb-3#color
= f.label(:color, 'Color:')
= f.color_field(:color, class: 'form-control')
= render partial: 'form', locals: { form: f, label_template: @label_template }
.actions
= link_to('Cancel', project_label_templates_path(@project), title: 'Cancel', class: 'btn btn-outline-secondary px-4 me-3 mt-3 mt-sm-0')
= f.submit('Update', class: 'btn btn-primary px-4 mt-3 mt-sm-0')
13 changes: 1 addition & 12 deletions src/api/app/views/webui/projects/label_templates/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@
.row
.col-12.col-md-10.col-lg-8
= form_with(model: @label_template, url: [@project, @label_template], method: :post) do |f|
.row
.col-12.col-md-10.col-lg-9
.mb-3#name
= f.label(:name, 'Name:', class: 'form-label')
= f.text_field(:name, class: classes_with_validation(@label_template, :name))
- @label_template.errors.where(:name).each do |error|
.error-message= error.message.capitalize
.mb-3#color
= f.label(:color, 'Color:', class: 'form-label')
= f.color_field(:color, class: classes_with_validation(@label_template, :color))
- @label_template.errors.where(:color).each do |error|
.error-message= error.message.capitalize
= render partial: 'form', locals: { form: f, label_template: @label_template }
.actions
= link_to('Cancel', project_label_templates_path(@project), title: 'Cancel', class: 'btn btn-outline-secondary px-4 me-3 mt-3 mt-sm-0')
= f.submit('Create', class: 'btn btn-primary px-4 mt-3 mt-sm-0')

0 comments on commit 6a584c7

Please sign in to comment.