Skip to content

Commit

Permalink
Update form_props dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jho406 committed Dec 1, 2024
1 parent 8020ccc commit 8b437c2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import { usePage } from '@thoughtbot/superglue'

export default function <%= js_plural_table_name(:upper) %>Edit() {
const {
form,
<%= js_singular_table_name %>Form,
<%= js_singular_table_name %>Path,
<%= js_plural_table_name %>Path,
} = usePage().data

const { inputs, props, extras } = form
const { inputs, form, extras } = <%= js_singular_table_name %>Form
const validationErrors = useSelector((state) => state.flash["<%= js_singular_table_name%>FormErrors"])

return (
<Layout>
<Form {...props} extras={extras} validationErrors={validationErrors} data-sg-visit>
<Form {...form} extras={extras} validationErrors={validationErrors} data-sg-visit>
<%- attributes.each do |attr| -%>
<<%= js_component(attr)%> {...inputs.<%= attr.column_name.camelize(:lower)%>} label="<%= attr.column_name.humanize %>" errorKey="<%= attr.column_name %>" />
<%- end -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function <%= js_plural_table_name(:upper) %>Index() {
} = usePage().data
const <%= js_singular_table_name %>Items = <%= js_plural_table_name %>.map((<%= js_singular_table_name %>, key) => {
const { deleteForm } = <%=js_singular_table_name%>;
const { inputs, props, extras } = deleteForm;
const { inputs, form, extras } = deleteForm;

return (
<tr key={<%= js_singular_table_name %>.id}>
Expand All @@ -19,7 +19,7 @@ export default function <%= js_plural_table_name(:upper) %>Index() {
<td><a href={ <%=js_singular_table_name%>.<%=js_singular_table_name%>Path } data-sg-visit>Show</a></td>
<td><a href={ <%=js_singular_table_name%>.edit<%=js_singular_table_name(:upper)%>Path } data-sg-visit>Edit</a></td>
<td>
<Form {...props} extras={extras} data-sg-visit>
<Form {...form} extras={extras} data-sg-visit>
<button type="submit">Delete</button>
</Form>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import { usePage } from '@thoughtbot/superglue'

export default function <%= js_plural_table_name(:upper) %>New() {
const {
form,
<%= js_singular_table_name %>Form,
<%= js_plural_table_name %>Path
} = usePage().data

const { inputs, props, extras } = form
const { inputs, form, extras } = <%= js_singular_table_name %>Form
const validationErrors = useSelector((state) => state.flash["<%= js_singular_table_name%>FormErrors"])

return (
<Layout>
<Form {...props} extras={extras} validationErrors={validationErrors} data-sg-visit>
<Form {...form} extras={extras} validationErrors={validationErrors} data-sg-visit>
<%- attributes.each do |attr| -%>
<<%= js_component(attr)%> {...inputs.<%= attr.column_name.camelize(:lower)%>} label="<%= attr.column_name.humanize %>" errorKey="<%= attr.column_name %>" />
<%- end -%>
<button {...form.inputs.submit} type="submit"> {...form.inputs.submit.text} </button>
<button {...inputs.submit} type="submit"> {...inputs.submit.text} </button>
</Form>

<a href={<%= js_plural_table_name %>Path} data-sg-visit>Back</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if @<%= singular_table_name %>.errors.any?
flash.now["<%= js_singular_table_name%>Errors"] = @<%= singular_table_name %>.errors.to_h
end

json.form(partial: 'form') do
json.<%= js_singular_table_name %>Form(partial: 'form') do
end

json.<%= js_singular_table_name%>Path <%= singular_table_name%>_path(@<%=singular_table_name%>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if @<%= singular_table_name %>.errors.any?
flash.now["<%= js_singular_table_name%>Errors"] = @<%= singular_table_name %>.errors.to_h
end

json.form(partial: 'form') do
json.<%= js_singular_table_name %>Form(partial: 'form') do
end

json.<%= js_plural_table_name %>Path <%= plural_table_name %>_path
Expand Down
2 changes: 1 addition & 1 deletion superglue_rails/superglue.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Gem::Specification.new do |s|

s.add_dependency "actionpack", ">= 7.0.0"
s.add_dependency "props_template", ">= 0.32.0"
s.add_dependency "form_props", ">= 0.0.5"
s.add_dependency "form_props", ">= 0.1.0"
end

0 comments on commit 8b437c2

Please sign in to comment.