FleetCart/Modules/Product/Resources/assets/admin/js/Download.js

33 lines
889 B
JavaScript
Raw Normal View History

2023-06-11 12:14:03 +00:00
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);
});
});
}
}