generated from Setono/SyliusPluginSkeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
window.addEventListener('DOMContentLoaded', (event) => { | ||
document.querySelectorAll('button.delete-order-item').forEach((button) => { | ||
button.addEventListener('click', (event) => { | ||
const orderLineId = event.currentTarget.closest('tr').remove(); | ||
}); | ||
document.querySelectorAll('button.delete-order-item').forEach((button) => { | ||
button.addEventListener('click', (event) => { | ||
var row = event.currentTarget.parentElement.parentElement; | ||
row.nextElementSibling.remove(); | ||
row.remove(); | ||
}); | ||
}); | ||
|
||
document.querySelector('button.add-order-item').addEventListener('click', (event) => { | ||
const orderItemTable = event.currentTarget.closest('table'); | ||
|
||
document.querySelector('button.add-order-item').addEventListener('click', (event) => { | ||
const orderItemTable = event.currentTarget.closest('table'); | ||
const html = orderItemTable | ||
.dataset | ||
.prototype | ||
.replace( | ||
/__name__/g, | ||
orderItemTable.dataset.index | ||
) | ||
; | ||
|
||
const html = orderItemTable | ||
.dataset | ||
.prototype | ||
.replace( | ||
/__name__/g, | ||
orderItemTable.dataset.index | ||
) | ||
; | ||
orderItemTable.querySelector('tbody').insertAdjacentHTML('beforeend', html) | ||
|
||
orderItemTable.querySelector('tbody').insertAdjacentHTML('beforeend', html) | ||
orderItemTable.dataset.index++; | ||
|
||
orderItemTable.dataset.index++; | ||
var rows = orderItemTable.querySelectorAll('form[name="sylius_order"] tbody tr'); | ||
var lastItemRowDeleteButton = rows[rows.length - 2].querySelector('button.delete-order-item'); | ||
lastItemRowDeleteButton.addEventListener('click', (event) => { | ||
var row = event.currentTarget.parentElement.parentElement; | ||
row.nextElementSibling.remove(); | ||
row.remove(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
{% extends '@SyliusAdmin/Form/theme.html.twig' %} | ||
|
||
{% block _sylius_order_items_entry_widget %} | ||
<tr> | ||
<tr class="item"> | ||
<td>{{ form_widget(form.quantity) }}</td> | ||
<td>{{ form_widget(form.variant) }}</td> | ||
<td colspan="3"> </td> | ||
<td colspan="4" class="right aligned"> | ||
<button class="ui red labeled icon button delete-order-item" type="button"> | ||
<i class="icon trash"></i> {{ 'sylius.ui.delete'|trans }} | ||
</button> | ||
</td> | ||
</tr> | ||
<tr class="item-discounts"> | ||
{# TODO: enable disounts for new order item as well #} | ||
{# <td colspan="6">{{ form_widget(form.discounts) }}</td>#} | ||
</tr> | ||
{% endblock %} |