d1fea9ec0a
* Move notification texts to a slightly different layer (#4572) * Further Simplify/refactor the actions/notification layer (#4573) 1. Move the 'with-feedback' actions to a 'with-blocking-action' mixin which better describes what it does 2. Additional set of unit tests almost over the entire layer to prove things work/add confidence for further changes The multiple 'with-action' mixins used for every 'index/edit' combo are now reduced down to only contain the functionality related to their specific routes, i.e. where to redirect. The actual functionality to block and carry out the action and then notify are 'almost' split out so that their respective classes/objects do one thing and one thing 'well'. Mixins are chosen for the moment as the decoration approach used by mixins feels better than multiple levels of inheritence, but I would like to take this fuether in the future to a 'compositional' based approach. There is still possible further work to be done here, but I'm a lot happier now this is reduced down into separate parts.
79 lines
3.4 KiB
Handlebars
79 lines
3.4 KiB
Handlebars
{{#app-view class="kv list" loading=isLoading}}
|
|
{{#block-slot 'notification' as |status type|}}
|
|
{{partial 'dc/kv/notifications'}}
|
|
{{/block-slot}}
|
|
{{#block-slot 'breadcrumbs'}}
|
|
<ol>
|
|
{{#if (not-eq parent.Key '/') }}
|
|
<li><a href={{href-to 'dc.kv'}}>Key / Values</a></li>
|
|
{{/if}}
|
|
{{#each (slice 0 -2 (split parent.Key '/')) as |breadcrumb index|}}
|
|
<li><a href={{href-to 'dc.kv.folder' (join '/' (append (slice 0 (add index 1) (split parent.Key '/')) ''))}}>{{breadcrumb}}</a></li>
|
|
{{/each}}
|
|
</ol>
|
|
{{/block-slot}}
|
|
{{#block-slot 'header'}}
|
|
<h1>
|
|
{{#if (eq parent.Key '/') }}
|
|
Key / Value
|
|
{{else}}
|
|
{{ take 1 (drop 1 (reverse (split parent.Key '/'))) }}
|
|
{{/if}}
|
|
</h1>
|
|
{{/block-slot}}
|
|
{{#block-slot 'toolbar'}}
|
|
{{#if (gt items.length 0) }}
|
|
<form class="filter-bar">
|
|
{{freetext-filter onchange=(action 'filter') value=filter.s placeholder="Search by name"}}
|
|
</form>
|
|
{{/if}}
|
|
{{/block-slot}}
|
|
{{#block-slot 'actions'}}
|
|
{{#if (not-eq parent.Key '/') }}
|
|
<a data-test-create href="{{href-to 'dc.kv.create' parent.Key}}" class="type-create">Create</a>
|
|
{{else}}
|
|
<a data-test-create href="{{href-to 'dc.kv.root-create'}}" class="type-create">Create</a>
|
|
{{/if}}
|
|
{{/block-slot}}
|
|
{{#block-slot 'content'}}
|
|
{{#if (gt filtered.length 0)}}
|
|
{{#tabular-collection
|
|
items=(sort-by 'isFolder:desc' 'Key:asc' filtered) as |item index|
|
|
}}
|
|
{{#block-slot 'header'}}
|
|
<th>Name</th>
|
|
{{/block-slot}}
|
|
{{#block-slot 'row'}}
|
|
<td data-test-kv="{{item.Key}}" class={{if item.isFolder 'folder' 'file' }}>
|
|
<a href={{href-to (if item.isFolder 'dc.kv.folder' 'dc.kv.edit') item.Key}}>{{right-trim (left-trim item.Key parent.Key) '/'}}</a>
|
|
</td>
|
|
{{/block-slot}}
|
|
{{#block-slot 'actions' as |index change checked|}}
|
|
{{#confirmation-dialog confirming=false index=index message='Are you sure you want to delete this key?'}}
|
|
{{#block-slot 'action' as |confirm|}}
|
|
{{#action-group index=index onchange=(action change) checked=(if (eq checked index) 'checked')}}
|
|
<ul>
|
|
<li>
|
|
<a data-test-edit href={{href-to (if item.isFolder 'dc.kv.folder' 'dc.kv.edit') item.Key}}>{{if item.isFolder 'View' 'Edit'}}</a>
|
|
</li>
|
|
<li>
|
|
<a data-test-delete onclick={{action confirm 'delete' item}}>Delete</a>
|
|
</li>
|
|
</ul>
|
|
{{/action-group}}
|
|
{{/block-slot}}
|
|
{{#block-slot 'dialog' as |execute cancel message|}}
|
|
<p>
|
|
{{message}}
|
|
</p>
|
|
<button type="button" class="type-delete" {{action execute}}>Confirm Delete</button>
|
|
<button type="button" class="type-cancel" {{action cancel}}>Cancel</button>
|
|
{{/block-slot}}
|
|
{{/confirmation-dialog}}
|
|
{{/block-slot}}
|
|
{{/tabular-collection}}
|
|
{{else}}
|
|
<p>There are no Key / Value pairs.</p>
|
|
{{/if}}
|
|
{{/block-slot}}
|
|
{{/app-view}} |