spinner on subscription cancel

This commit is contained in:
Rimian Perkins 2019-11-14 14:07:45 +11:00
parent d9b5aa6a35
commit b3b7d88481
4 changed files with 26 additions and 4 deletions

View File

@ -15,12 +15,17 @@ export default Discourse.Route.extend({
I18n.t("yes_value"),
confirmed => {
if (confirmed) {
subscription.set("loading", true);
subscription
.destroy()
.then(result => subscription.set("status", result.status))
.catch(data =>
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
);
)
.finally(() => {
subscription.set("loading", false);
});
}
}
);

View File

@ -23,12 +23,17 @@ export default Discourse.Route.extend({
I18n.t("yes_value"),
confirmed => {
if (confirmed) {
subscription.set("loading", true);
subscription
.destroy()
.then(result => subscription.set("status", result.status))
.catch(data =>
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
);
)
.finally(() => {
subscription.set("loading", false);
});
}
}
);

View File

@ -23,7 +23,13 @@
<td>{{subscription.plan.id}}</td>
<td>{{subscription.status}}</td>
<td class="td-right">{{format-unix-date subscription.created}}</td>
<td class="td-right">{{d-button disabled=subscription.canceled label="cancel" action=(route-action "cancelSubscription" subscription) icon="times"}}</td>
<td class="td-right">
{{#if subscription.loading}}
{{loading-spinner size="small"}}
{{else}}
{{d-button disabled=subscription.canceled label="cancel" action=(route-action "cancelSubscription" subscription) icon="times"}}
{{/if}}
</td>
</tr>
{{/each}}
</table>

View File

@ -16,7 +16,13 @@
<td>{{subscription.plan.subscriptionRate}}</td>
<td>{{subscription.status}}</td>
<td>{{format-unix-date subscription.created}}</td>
<td class="td-right">{{d-button disabled=subscription.canceled label="cancel" action=(route-action "cancelSubscription" subscription) icon="times"}}</td>
<td class="td-right">
{{#if subscription.loading}}
{{loading-spinner size="small"}}
{{else}}
{{d-button disabled=subscription.canceled label="cancel" action=(route-action "cancelSubscription" subscription) icon="times"}}
{{/if}}
</td>
</tr>
{{/each}}
</table>