new controller: scaffolding nested resources needs improvement
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 175
- PR merge metrics
- No merged PRs in 30d
Description
The following command doesn't work yet:
bud new controller posts/comments index new
The problems are the following:
-
Currently the generated
view/posts/comments/index.sveltecontains a missingcommentvariable:<script> export let comments = [] </script> <h1>Comment Index</h1> <table border="1" cellpadding="10"> {#if comments.length > 0} <thead> {#each Object.keys(comments[0]) as key} <th>{key}</th> {/each} </thead> {/if} {#each comments as comment} <tr> {#each Object.keys(comment) as key} {#if key.toLowerCase() === "id"} <td><a href={`/posts/${comment.post_id || 0}/comments/${comment.id || 0}`}>{comment[key]}</a></td> {:else} <td>{comment[key]}</td> {/if} {/each} </tr> {/each} </table> <br /> <a href={`/posts/${comment.post_id || 0}/comments/new`}>New Comment</a> <style> table { border-collapse: collapse; } </style>Right now it's not clear how we should pass this through. Also open to other ideas like using the URL path instead.
-
posts/comments/new.sveltehas a similar problem. It generates a file that is missingcommentvariable. This variable isn't needed when the scaffolding is unnested.<h1>New Comment</h1> <form method="post" action={`/posts/${comment.post_id || 0}/comments`}> <!-- Add input fields here --> <input type="submit" value="Create Comment" /> </form> <br /> <a href={`/posts/${comment.post_id || 0}/comments`}>Back</a>In this case, just a bit more work needs to be done to conditionally introduce a script tag.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running bud new controller posts/comments index new and inspect the generated view/posts/comments/index.svelte and posts/comments/new.svelte. Compare nested output with unnested scaffolding, then make the generated links and form work without undefined variables and verify that the conditional script handling is correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100