Skip to content

v0.6.11 - Typeahead with nested features for scoping results, more flags

Latest
Compare
Choose a tag to compare
@jasonfb jasonfb released this 28 Jan 19:13
· 1 commit to main since this release
20db385

• Typeahead now can use --auth, --auth-identifier, --namespace, and --nested
• Works similar to how same flags work on scaffold generator. (Notice that the typeahead generator is a completely separate generator).
• When using nested, your results are scoped the parent objects in the nest chain (which is the last one)

e.g.
bin/rails generate hot_glue:scaffold Member --namespace=account_dashboard --nested=account/room --auth='current_user' --auth-identifier='user' --modify='user_id{typeahead}[account]'

here the user_id field on members will use a typeahead under 1 parent: account (even though this scaffold is under two parents: account/room, the typeahead is built only with --nested=account as shown below)

The scaffold expects the typeahead to be in the same namespace (in this case account_dashboard).

The current_user object is the auth root, so the account in the nest chain must belong to the current_user. As well, account must have many rooms and the rooms must have many members (the room must belong to the account and the member will automatically belong to the parent room)

This would be used in conjunction with a typeahead built within the same namespace:

bin/rails generate hot_glue:typeahead User --namespace='account_dashboard' --nested='account' --auth-identifier='user' --auth='current_user'

Notice that the scaffold controller for Member operates two levels deep in the nest chain (account/room) but the Typeahead controller operates only 1 level deep in the same nest chain and also the same namespace (account). The typeahead must be in the same namespace, but it is not required that the typeahead exist in the same nested structure. Indeed, the Users are loaded from accounts because that's what we need to scope them in the typeahead (we only want to return users belonging to this account), but to join a User to a Room, we are building a separate join table (members). The typeahead controller within the same namespace may be used by more than one typeahead field — for example, if you have separate scaffolds with references to Users and want the typeahead to work for both.

(See 'typeahead' section for details)

--include-object-names

When you are "Editing X" we specify that X is a ___ (author, book, room, etc)

e.g. "Editing author Edgar Allan Poe" vs "Editing Edgar Allan Poe"

Can also be specified globally in config/hot_glue.yml

--new-button-position (above, below; default: above)
Show the new button above or below the list.

--downnest-shows-headings (default: false)
Show headings above downnested portals.