-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [#483] Add tests to the CRUD layout * [#483] Fix the check for slim and erb layout files * [#493] Add slim view templates for new, form, and edit * [#493] Fix view error --------- Co-authored-by: Xavier MALPARTY <[email protected]>
- Loading branch information
1 parent
688614e
commit a63ef25
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
.template/addons/crud/lib/templates/slim/scaffold/_form.html.slim.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
= form_with(model: <%= model_resource_name %>) do |form| | ||
- if <%= singular_table_name %>.errors.any? | ||
div style="color: red" | ||
h2 = "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:" | ||
ul | ||
- <%= singular_table_name %>.errors.each do |error| | ||
li = error.full_message | ||
|
||
<% attributes.each do |attribute| -%> | ||
.mb-3 | ||
<% if attribute.password_digest? -%> | ||
= form.label :password, class: 'form-label' | ||
= form.password_field :password, class: 'form-control' | ||
|
||
.mb-3 | ||
= form.label :password_confirmation, class: 'form-label' | ||
= form.password_field :password_confirmation, class: 'form-control' | ||
<% elsif attribute.attachments? -%> | ||
= form.label :<%= attribute.column_name %>, class: 'form-label' | ||
= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: 'form-control' | ||
<% else -%> | ||
= form.label :<%= attribute.column_name %>, class: 'form-label' | ||
= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: 'form-control' | ||
<% end -%> | ||
|
||
<% end -%> | ||
div | ||
= form.submit 'Submit', class: 'btn btn-primary' |
8 changes: 8 additions & 0 deletions
8
.template/addons/crud/lib/templates/slim/scaffold/edit.html.slim.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
h1 Editing <%= human_name.downcase %> | ||
|
||
== render "form", <%= singular_table_name %>: @<%= singular_table_name %> | ||
|
||
br | ||
|
||
div | ||
=< link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>, class: 'btn btn-secondary' |
10 changes: 10 additions & 0 deletions
10
.template/addons/crud/lib/templates/slim/scaffold/new.html.slim.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
content_for :title, "New <%= human_name.downcase %>" | ||
|
||
h1 New <%= human_name.downcase %> | ||
|
||
== render 'form', <%= singular_table_name %>: @<%= singular_table_name %> | ||
|
||
br | ||
|
||
div | ||
= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> |