first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
export default class {
constructor(download) {
this.downloadHtml = this.getDownloadHtml(download);
}
getDownloadHtml(download) {
let template = _.template($('#product-download-template').html());
return $(template(download));
}
render() {
this.attachEventListeners();
return this.downloadHtml;
}
attachEventListeners() {
this.downloadHtml.find('.delete-row').on('click', () => {
this.downloadHtml.remove();
});
this.downloadHtml.find('.btn-choose-file').on('click', () => {
let picker = new MediaPicker();
picker.on('select', (file) => {
this.downloadHtml.find('.download-name').val(file.filename);
this.downloadHtml.find('.download-file').val(file.id);
});
});
}
}

View File

@@ -0,0 +1,44 @@
import Download from './Download';
export default class {
constructor() {
this.downloadsCount = 0;
this.addDownloads(FleetCart.data['product.downloads']);
if (this.downloadsCount === 0) {
this.addDownload();
}
this.attachEventListeners();
this.makeDownloadsSortable();
}
addDownloads(downloads) {
for (let attributes of downloads) {
this.addDownload(attributes);
}
}
addDownload(attributes = {}) {
let download = new Download({ download: attributes });
$('#downloads-wrapper').append(download.render());
this.downloadsCount++;
window.admin.tooltip();
}
attachEventListeners() {
$('#add-new-file').on('click', () => {
this.addDownload();
});
}
makeDownloadsSortable() {
Sortable.create(document.getElementById('downloads-wrapper'), {
handle: '.drag-icon',
animation: 150,
});
}
}

View File

@@ -0,0 +1,34 @@
export default class {
constructor() {
this.managerStock();
window.admin.removeSubmitButtonOffsetOn([
'#images', '#downloads', '#attributes', '#options',
'#related_products', '#up_sells', '#cross_sells', '#reviews',
]);
$('#product-create-form, #product-edit-form').on('submit', this.submit);
}
managerStock() {
$('#manage_stock').on('change', (e) => {
if (e.currentTarget.value === '1') {
$('#qty-field').removeClass('hide');
} else {
$('#qty-field').addClass('hide');
}
});
}
submit(e) {
e.preventDefault();
DataTable.removeLengthFields();
window.form.appendHiddenInputs('#product-create-form, #product-edit-form', 'up_sells', DataTable.getSelectedIds('#up_sells .table'));
window.form.appendHiddenInputs('#product-create-form, #product-edit-form', 'cross_sells', DataTable.getSelectedIds('#cross_sells .table'));
window.form.appendHiddenInputs('#product-create-form, #product-edit-form', 'related_products', DataTable.getSelectedIds('#related_products .table'));
e.currentTarget.submit();
}
}

View File

@@ -0,0 +1,5 @@
import Downloads from './Downloads';
import ProductForm from './ProductForm';
new ProductForm();
new Downloads();

View File

@@ -0,0 +1,22 @@
#images, #attachments {
margin-bottom: 15px;
}
.attachment-wrapper {
tr {
td {
&:nth-child(2),
&:nth-child(3) {
min-width: 200px;
}
&:nth-child(4) {
width: 59px;
}
}
}
.choose-file {
padding: 10px 15px;
}
}