Skip to content

Commit

Permalink
Refine CRUD templates (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed May 3, 2024
1 parent 45188b0 commit bc2ad7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class <%= pluralized_name %>::EditPage < MainLayout
quick_def page_title, "Edit <%= resource %> with id: #{<%= underscored_resource %>.id}"

def content
link "Back to all <%= pluralized_name %>", <%= pluralized_name %>::Index
link "Back to all <%= pluralized_name %>", to: <%= pluralized_name %>::Index
h1 "Edit <%= resource %> with id: #{<%= underscored_resource %>.id}"
render_<%= underscored_resource %>_form(operation)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class <%= pluralized_name %>::IndexPage < MainLayout
ul do
<%= pluralized_name.underscore %>.each do |<%= underscored_resource %>|
li do
link <%= underscored_resource %>.<%= columns.first.name %>, <%= pluralized_name %>::Show.with(<%= underscored_resource %>)
link <%= underscored_resource %>.<%= columns.first.name %>, to: <%= pluralized_name %>::Show.with(<%= underscored_resource %>)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/lucky/tasks/gen/templates/resource/pages/show_page.cr.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ class <%= pluralized_name %>::ShowPage < MainLayout
quick_def page_title, "<%= resource %> with id: #{<%= underscored_resource %>.id}"

def content
link "Back to all <%= pluralized_name %>", <%= pluralized_name %>::Index
link "Back to all <%= pluralized_name %>", to: <%= pluralized_name %>::Index
h1 "<%= resource %> with id: #{<%= underscored_resource %>.id}"
render_actions
render_<%= underscored_resource %>_fields
end

def render_actions
section do
link "Edit", <%= pluralized_name %>::Edit.with(<%= underscored_resource %>.id)
link "Edit", to: <%= pluralized_name %>::Edit.with(<%= underscored_resource %>.id)
text " | "
link "Delete",
<%= pluralized_name %>::Delete.with(<%= underscored_resource %>.id),
to: <%= pluralized_name %>::Delete.with(<%= underscored_resource %>.id),
data_confirm: "Are you sure?"
end
end
Expand Down

0 comments on commit bc2ad7b

Please sign in to comment.