2020-07-09 09:08:47 +00:00
|
|
|
<StateChart @src={{chart}} as |State Guard Action dispatch state|>
|
|
|
|
|
|
|
|
<Ref @target={{this}} @name="dispatch" @value={{dispatch}} />
|
|
|
|
|
|
|
|
{{#let (hash
|
|
|
|
data=data
|
|
|
|
error=error
|
|
|
|
persist=(action "persist")
|
|
|
|
delete=(queue (action (mut data)) (action dispatch "REMOVE"))
|
|
|
|
inflight=(state-matches state (array "persisting" "removing"))
|
|
|
|
) as |api|}}
|
|
|
|
|
|
|
|
{{yield api}}
|
|
|
|
|
|
|
|
<State @matches="removing">
|
|
|
|
<DataSink
|
|
|
|
@sink={{sink}}
|
|
|
|
@item={{data}}
|
|
|
|
@data={{null}}
|
|
|
|
@onchange={{action dispatch "SUCCESS"}}
|
|
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")}}
|
|
|
|
/>
|
|
|
|
</State>
|
|
|
|
|
|
|
|
<State @matches="persisting">
|
|
|
|
<DataSink
|
|
|
|
@sink={{sink}}
|
|
|
|
@item={{data}}
|
|
|
|
@onchange={{action dispatch "SUCCESS"}}
|
|
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")}}
|
|
|
|
/>
|
|
|
|
</State>
|
|
|
|
|
|
|
|
<State @matches="removed">
|
2020-07-17 13:42:45 +00:00
|
|
|
{{#yield-slot name="removed" params=(block-params (component 'notification' after=(queue (action dispatch "RESET") (action ondelete))))}}
|
|
|
|
{{yield api}}
|
|
|
|
{{else}}
|
|
|
|
<Notification @after={{queue (action dispatch "RESET") (action ondelete)}}>
|
2020-07-09 09:08:47 +00:00
|
|
|
<p data-notification role="alert" class="success notification-delete">
|
|
|
|
<strong>Success!</strong>
|
2020-07-20 17:04:43 +00:00
|
|
|
Your {{or label type}} has been deleted.
|
2020-07-09 09:08:47 +00:00
|
|
|
</p>
|
2020-07-17 13:42:45 +00:00
|
|
|
</Notification>
|
|
|
|
{{/yield-slot}}
|
2020-07-09 09:08:47 +00:00
|
|
|
</State>
|
|
|
|
|
|
|
|
<State @matches="persisted">
|
|
|
|
<Notification @after={{action onchange}}>
|
|
|
|
{{#yield-slot name="persisted"}}
|
|
|
|
{{yield api}}
|
|
|
|
{{else}}
|
|
|
|
<p data-notification role="alert" class="success notification-update">
|
|
|
|
<strong>Success!</strong>
|
2020-07-20 17:04:43 +00:00
|
|
|
Your {{or label type}} has been saved.
|
2020-07-09 09:08:47 +00:00
|
|
|
</p>
|
|
|
|
{{/yield-slot}}
|
|
|
|
</Notification>
|
|
|
|
</State>
|
|
|
|
|
|
|
|
<State @matches="error">
|
|
|
|
{{#yield-slot name="error" params=(block-params (component 'notification' after=(action dispatch "RESET")))}}
|
|
|
|
{{yield api}}
|
|
|
|
{{else}}
|
|
|
|
<Notification @after={{action dispatch "RESET"}}>
|
|
|
|
<p data-notification role="alert" class="error notification-update">
|
|
|
|
<strong>Error!</strong>
|
2020-07-20 17:04:43 +00:00
|
|
|
There was an error saving your {{or label type}}.
|
2020-07-09 09:08:47 +00:00
|
|
|
{{#if (and api.error.status api.error.detail)}}
|
|
|
|
<br />{{api.error.status}}: {{api.error.detail}}
|
|
|
|
{{/if}}
|
|
|
|
</p>
|
|
|
|
</Notification>
|
|
|
|
{{/yield-slot}}
|
|
|
|
</State>
|
|
|
|
<YieldSlot @name="content">
|
|
|
|
{{yield api}}
|
|
|
|
</YieldSlot>
|
|
|
|
|
|
|
|
{{/let}}
|
|
|
|
</StateChart>
|