¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -1,16 +1,16 @@
import FlashSaleProduct from './FlashSaleProduct';
import FlashSaleProduct from "./FlashSaleProduct";
export default class {
constructor() {
this.productCount = 0;
this.addFlashSaleProducts(FleetCart.data['flash_sale.products']);
this.addFlashSaleProducts(FleetCart.data["flash_sale.products"]);
if (this.productCount === 0) {
this.addProduct();
}
this.addFlashSaleProductsError(FleetCart.errors['flash_sale.products']);
this.addFlashSaleProductsError(FleetCart.errors["flash_sale.products"]);
this.attachEventListeners();
this.makeProductPanelsSortable();
@@ -23,9 +23,12 @@ export default class {
}
addProduct(attributes = {}) {
let productTemplate = new FlashSaleProduct({ productPanelNumber: this.productCount++, product: attributes });
let productTemplate = new FlashSaleProduct({
productPanelNumber: this.productCount++,
product: attributes,
});
$('#products-wrapper').append(productTemplate.render());
$("#products-wrapper").append(productTemplate.render());
window.admin.selectize();
}
@@ -34,31 +37,31 @@ export default class {
for (let key in errors) {
let parent = this.getInputFieldForKey(key).parent();
parent.addClass('has-error');
parent.addClass("has-error");
parent.append(`<span class="help-block">${errors[key][0]}</span>`);
}
}
getInputFieldForKey(key) {
let keyParts = key.split('.');
let keyParts = key.split(".");
// Replace all "_" to "-".
keyParts = keyParts.map(k => {
return k.split('_').join('-');
keyParts = keyParts.map((k) => {
return k.split("_").join("-");
});
return $(`#${keyParts.join('-')}`);
return $(`#${keyParts.join("-")}`);
}
attachEventListeners() {
$('.add-product').on('click', () => {
$(".add-product").on("click", () => {
this.addProduct();
});
}
makeProductPanelsSortable() {
Sortable.create(document.getElementById('products-wrapper'), {
handle: '.drag-icon',
Sortable.create(document.getElementById("products-wrapper"), {
handle: ".drag-handle",
animation: 150,
});
}

View File

@@ -7,7 +7,7 @@ return [
'quantity' => 'Quantity',
'campaign_name' => 'Campaign Name',
// validation
# validation
'products.*.product_id' => 'Product',
'products.*.end_date' => 'End Date',
'products.*.price' => 'Price',

View File

@@ -16,3 +16,9 @@
@endsection
@include('flashsale::admin.flash_sales.partials.shortcuts')
@push('globals')
@vite([
'Modules/FlashSale/Resources/assets/admin/js/main.js',
])
@endpush

View File

@@ -18,3 +18,9 @@
@endsection
@include('flashsale::admin.flash_sales.partials.shortcuts')
@push('globals')
@vite([
'Modules/FlashSale/Resources/assets/admin/js/main.js',
])
@endpush

View File

@@ -25,7 +25,7 @@
@endcomponent
@push('scripts')
<script>
<script type="module">
new DataTable('#flash_sales-table .table', {
columns: [
{ data: 'checkbox', orderable: false, searchable: false, width: '3%' },

View File

@@ -6,7 +6,7 @@
@endpush
@push('scripts')
<script>
<script type="module">
keypressAction([
{ key: 'b', route: "{{ route('admin.flash_sales.index') }}" }
]);

View File

@@ -1,7 +1,7 @@
<script type="text/html" id="flash-sale-product-template">
<div class="panel">
<div class="panel-header clearfix">
<span class="drag-icon pull-left">
<span class="drag-handle pull-left">
<i class="fa">&#xf142;</i>
<i class="fa">&#xf142;</i>
</span>
@@ -48,8 +48,10 @@
{{ trans('flashsale::attributes.end_date') }}<span class="m-l-5 text-red">*</span>
</label>
<input type="text"
<input
type="text"
name="products[<%- productPanelNumber %>][end_date]"
data-time
class="form-control datetime-picker"
id="products-<%- productPanelNumber %>-campaign-end"
value="<%- product.pivot.end_date %>"