mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-23 00:01:16 +00:00
Redirect when cancelling instead of submitting a form
This commit is contained in:
parent
044c6835d4
commit
244447c57a
@ -10,12 +10,11 @@ interface InitialFormData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CounterConfig {
|
interface CounterConfig {
|
||||||
csrfToken: string;
|
|
||||||
clickApiUrl: string;
|
|
||||||
customerBalance: number;
|
customerBalance: number;
|
||||||
customerId: number;
|
customerId: number;
|
||||||
products: Record<string, Product>;
|
products: Record<string, Product>;
|
||||||
formInitial: InitialFormData[];
|
formInitial: InitialFormData[];
|
||||||
|
cancelUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Product {
|
interface Product {
|
||||||
@ -132,11 +131,7 @@ exportToHtml("loadCounter", (config: CounterConfig) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.basket = new Object({});
|
location.href = config.cancelUrl;
|
||||||
// We need to wait for the templated form to be removed before sending
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.finish();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCode() {
|
handleCode() {
|
||||||
|
@ -199,11 +199,10 @@
|
|||||||
];
|
];
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
loadCounter({
|
loadCounter({
|
||||||
csrfToken: "{{ csrf_token }}",
|
|
||||||
clickApiUrl: "{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}", customerBalance: {{ customer.amount }},
|
|
||||||
products: products,
|
products: products,
|
||||||
customerId: {{ customer.pk }},
|
customerId: {{ customer.pk }},
|
||||||
formInitial: formInitial,
|
formInitial: formInitial,
|
||||||
|
cancelUrl: "{{ cancel_url }}",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -260,6 +260,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, SingleObjectMixin, FormView):
|
|||||||
product
|
product
|
||||||
)
|
)
|
||||||
kwargs["customer"] = self.customer
|
kwargs["customer"] = self.customer
|
||||||
|
kwargs["cancel_url"] = self.get_success_url()
|
||||||
|
|
||||||
# To get all forms errors to the javascript, we create a list of error list
|
# To get all forms errors to the javascript, we create a list of error list
|
||||||
kwargs["form_errors"] = []
|
kwargs["form_errors"] = []
|
||||||
|
Loading…
Reference in New Issue
Block a user