Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new/create/edit/update/delete controller verbs #75

Closed

Conversation

fergloragain
Copy link

No description provided.

@matthewmueller
Copy link
Contributor

matthewmueller commented May 21, 2022

Thanks for giving this a go @fergloragain!

The code you wrote looks good, but I'd like to add the views as well. Would you be interested in contributing the svelte views as well?

Maybe something like the following? (untested)

{{$.Controller.Route}}/new.svelte

<h1>New {{$.Name.Singular}}</h1>

<form method="post" action="{{ $.Route }}">
  <!-- Add input fields here -->
  <input type="submit" value="Create {{ $.Name }}" />
</form>

<a href="..">Back</a>

{{$.Controller.Route}}/edit.svelte

<script>
  export let {{$.Variable}} = {}
</script>

<h1>Edit {{$.Name.Singular}}</h1>

<form method="post" action="{{ $.Route }}">
  <!-- Add input fields here -->
  <input type="hidden" value="{{$.Variable.Primary}}" />
  <input type="submit" value="Create {{ $.Name }}" />
</form>

<a href="..">Back</a>

After looking at your PR, I realized that we can't really infer too much about the new and edit views, so I may eventually simplify this command to just be controllers and replace the current command with something like: bud new resource story:/ title:string url:string body:text. What do you think?

Either way, let's align this command with the index and show actions.

@TechplexEngineer
Copy link
Contributor

TechplexEngineer commented May 22, 2022

This is exciting! Have you considered a way for users to add their own templates at a project scope level?

That was a killer feature of ASP.Net MVC eons ago, we wrote some pretty complex templates and generated 95% of our application.
(Sorry if this is OT)

@matthewmueller
Copy link
Contributor

matthewmueller commented May 22, 2022

@TechplexEngineer Yep! I'm still working on exposing this, but you'll be able to create your own commands soon, so you could create a bud new auth by defining a commands in the project's ./command/new package:

Something like this:

package new

type Controller struct {
  *scaffold.Template // some scaffolding helper library could be nice
}

func (c *Controller) Auth() error {
  c.Template.Files["controller/admin/admin.go"] = `... some template ...`
  return c.Write()
}

Largely inspired by Laravel's custom command support. Anything you can point me to in the ASP.Net MVC world I could have a look at?

I'll try and get an RFC up soon.

@matthewmueller
Copy link
Contributor

What do you think about wrapping this one up @fergloragain? Otherwise, just let us know :)

@matthewmueller
Copy link
Contributor

@fergloragain re-opening since we definitely want to incorporate these changes! I'll pull this change in and add the views.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants