From: Vincent Vanwaelscappel Date: Tue, 25 Oct 2022 16:43:22 +0000 (+0200) Subject: wait #5534 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=79e646288b90fd87f380d60f87331333ea287823;p=fluidbook-html5.git wait #5534 --- diff --git a/js/libs/fluidbook/cart/fluidbook.cart.puma.js b/js/libs/fluidbook/cart/fluidbook.cart.puma.js index 923e3384..26216aa7 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.puma.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.puma.js @@ -3,6 +3,7 @@ function FluidbookCartPuma(cart) { this.cart = cart; this.fluidbook = this.cart.fluidbook; this.data = this.fluidbook.settings.basketReferences; + this.exportFileName = ''; this.init(); } @@ -11,13 +12,17 @@ FluidbookCartPuma.prototype = { var $this = this; this.items = this.fluidbook.cache.get('cart', []); $(document).on(this.fluidbook.input.clickEvent, '.exportCartPDF', function () { - $this.exportPDF(); + $this.chooseFileName(function () { + $this.exportPDF(); + }); return false; }); $(document).on(this.fluidbook.input.clickEvent, '.exportCartXLS', function () { try { - $this.exportXLS(); + $this.chooseFileName(function () { + $this.exportXLS(); + }); } catch (err) { console.log(err); } @@ -25,7 +30,9 @@ FluidbookCartPuma.prototype = { }); $(document).on(this.fluidbook.input.clickEvent, '.exportEANXLS', function () { try { - $this.exportEANXLS(); + $this.chooseFileName(function () { + $this.exportEANXLS(); + }); } catch (err) { console.log(err); } @@ -224,12 +231,12 @@ FluidbookCartPuma.prototype = { }, 2000); }, - getExportFileName: function (label) { - if (label === undefined) { - label = 'Cart'; + getExportFileName: function () { + if (this.exportFileName !== '') { + return this.exportFileName; } var date = new Date(); - return this.fluidbook.settings.title + ' - ' + label + ' - ' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate(); + return this.fluidbook.settings.title + ' - ' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate(); }, exportEANXLS: function () { @@ -280,12 +287,47 @@ FluidbookCartPuma.prototype = { const url = window.URL.createObjectURL(blob); const anchor = document.createElement('a'); anchor.href = url; - anchor.download = $this.getExportFileName('EAN') + '.xlsx'; + anchor.download = $this.getExportFileName() + '.xlsx'; anchor.click(); window.URL.revokeObjectURL(url); }); }, + chooseFileName: function (callback) { + var $this = this; + $.confirm({ + title: 'Name your file', + content: '' + + '
' + + '
' + + '' + + '
' + + '
', + buttons: { + formSubmit: { + text: 'Submit', + btnClass: 'btn-ok', + action: function () { + $this.exportFileName = this.$content.find('.name').val(); + callback(); + } + }, + cancel: function () { + //close + }, + }, + onContentReady: function () { + // bind to events + var jc = this; + this.$content.find('form').on('submit', function (e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); + } + }); + }, + exportXLS: function () { var $this = this; const workbook = new ExcelJS.Workbook();