From b4cdb5140d516e4fff5f54a1cb4e08dfe780c4ad Mon Sep 17 00:00:00 2001 From: Florian Eisenmenger Date: Fri, 25 Mar 2022 15:35:59 +0100 Subject: [PATCH] check --- .../js/zenit-platform-atmos-set1.js | 47 +++++++++++++++---- .../app/storefront/src/scss/overrides.scss | 5 ++ .../plugins/Deliverydate/date_panel.html.twig | 33 +++++++++++++ .../js/zenit-platform-atmos-set2.js | 47 +++++++++++++++---- .../app/storefront/src/scss/overrides.scss | 5 ++ .../page/product-detail/_product-detail.scss | 1 + .../plugins/Deliverydate/date_panel.html.twig | 33 +++++++++++++ 7 files changed, 153 insertions(+), 18 deletions(-) create mode 100644 zenitPlatformAtmosSet1/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig create mode 100644 zenitPlatformAtmosSet2/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig diff --git a/zenitPlatformAtmosSet1/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set1.js b/zenitPlatformAtmosSet1/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set1.js index efaf23c..3693ab8 100644 --- a/zenitPlatformAtmosSet1/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set1.js +++ b/zenitPlatformAtmosSet1/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set1.js @@ -35,6 +35,10 @@ $(document).ready(function() { $("[name='shippingMethodId']").on('change', () => { changeDelivery(fp); }); + + /* Set first selectable day selected */ + setDateSelected(); + changeDelivery(fp); } @@ -63,7 +67,7 @@ $(document).ready(function() { var hash = this.hash; var sTop = parseInt($(hash).offset().top - $(".header-inner").outerHeight() - 12); - scrollTo(sTop, 800); + scrollToPos(sTop, 800); window.location.hash = hash; } // End if }); @@ -72,7 +76,7 @@ $(document).ready(function() { // c = element or pixel position // e = duration // d = (optative) ease function. Default easeOutCuaic -function scrollTo(c,e,d){d||(d=easeOutCuaic);var a=document.documentElement;if(0===a.scrollTop){var b=a.scrollTop;++a.scrollTop;a=b+1===a.scrollTop--?a:document.body}b=a.scrollTop;0>=e||("object"===typeof b&&(b=b.offsetTop),"object"===typeof c&&(c=c.offsetTop),function(a,b,c,f,d,e,h){function g(){0>f||1=d?a.scrollTop=c:(a.scrollTop=b-(b-c)*h(f),f+=d*e,setTimeout(g,e))}g()}(a,b,c,0,1/e,20,d))}; +function scrollToPos(c,e,d){d||(d=easeOutCuaic);var a=document.documentElement;if(0===a.scrollTop){var b=a.scrollTop;++a.scrollTop;a=b+1===a.scrollTop--?a:document.body}b=a.scrollTop;0>=e||("object"===typeof b&&(b=b.offsetTop),"object"===typeof c&&(c=c.offsetTop),function(a,b,c,f,d,e,h){function g(){0>f||1=d?a.scrollTop=c:(a.scrollTop=b-(b-c)*h(f),f+=d*e,setTimeout(g,e))}g()}(a,b,c,0,1/e,20,d))}; function easeOutCuaic(t){ t--; return t*t*t+1; @@ -86,7 +90,32 @@ function manipulateDateInputValue() { } } +function setDateSelected() { + let spwnFirstSelectableDay = $(".flatpickr-day:not(.flatpickr-disabled)").first().text(); + let spwnFPdate = new Date(); + + let spwnDay = spwnFPdate.getDate(); + let spwnMonth = spwnFPdate.getMonth(); + let spwnMonthTemp = 0; + spwnMonth = spwnMonth + 1; + if((String(spwnMonth)).length === 1) { + spwnMonthTemp = spwnMonth; + spwnMonth = '0' + spwnMonth; + } + if (spwnFirstSelectableDay < spwnDay) { + spwnMonth = spwnMonthTemp + 1; + if((String(spwnMonth)).length === 1) { + spwnMonth = '0' + spwnMonth; + } + } + let spwnFrmattedDate = spwnFPdate.getFullYear() + '/' + spwnMonth + '/' + spwnFirstSelectableDay; + + fp.setDate(new Date(spwnFrmattedDate)); + spawnDateInputValue = spwnFirstSelectableDay + '.' + spwnMonth + '.' + spwnFPdate.getFullYear(); +} + function changeDelivery(fp) { + $("body").on("click", "#spwn-delivery .spwn-delivery--time span", function() { $("#spwn-delivery .spwn-delivery--time span").removeClass("active"); $(this).addClass("active"); @@ -115,16 +144,18 @@ function changeDelivery(fp) { } setIncludedDays("evening", fp, daysToAdd); $("#spwn-delivery p").text("Abendzustellung gewählt. Bitte wählen Sie nun eine Wunsch-Zeit:"); - $("#spwn-delivery .spwn-delivery--time").append("18 - 21 Uhr20 - 23 Uhr"); + $("#spwn-delivery .spwn-delivery--time").append("18 - 20 Uhr19 - 21 Uhr20 - 22 Uhr"); // If not date from DPD days + if (!$(".flatpickr-day").hasClass("selected")) { + setDateSelected(); + } if ($(".flatpickr-day").hasClass("selected")) { if (spawnDateInputValue === "" || spawnDateInputValue.indexOf("Uhr") === -1) { manipulateDateInputValue(); } // If DPD date is not in Abendzustellung range } else { - $(".confirm-delivery-date #dtgs-datepicker-inputfield").val(""); - spawnDateInputValue = ""; + setDateSelected(); } } else { // DPD @@ -142,8 +173,7 @@ function changeDelivery(fp) { $("#spwn-delivery p").text("DPD gewählt. Die Zustellung erfolgt zwischen 7 und 13 Uhr."); if (!$(".flatpickr-day").hasClass("selected")) { // If Abendzustellung date is not in DPD range - $(".confirm-delivery-date #dtgs-datepicker-inputfield").val(""); - spawnDateInputValue = ""; + setDateSelected(); } } } else { @@ -157,8 +187,7 @@ function changeDelivery(fp) { $("#spwn-delivery p").text("DPD gewählt. Die Zustellung erfolgt zwischen 7 und 18 Uhr."); if (!$(".flatpickr-day").hasClass("selected")) { // If Abendzustellung or DPD DE date is not in DPD AT range - $(".confirm-delivery-date #dtgs-datepicker-inputfield").val(""); - spawnDateInputValue = ""; + setDateSelected(); } } } diff --git a/zenitPlatformAtmosSet1/src/Resources/app/storefront/src/scss/overrides.scss b/zenitPlatformAtmosSet1/src/Resources/app/storefront/src/scss/overrides.scss index 465dcbf..de194a1 100644 --- a/zenitPlatformAtmosSet1/src/Resources/app/storefront/src/scss/overrides.scss +++ b/zenitPlatformAtmosSet1/src/Resources/app/storefront/src/scss/overrides.scss @@ -177,3 +177,8 @@ input.custom-number[type=number] { } } } + +.confirm-delivery-date.do-not-show, +#spwn-delivery { + display: none !important; +} diff --git a/zenitPlatformAtmosSet1/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig b/zenitPlatformAtmosSet1/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig new file mode 100644 index 0000000..6358c59 --- /dev/null +++ b/zenitPlatformAtmosSet1/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig @@ -0,0 +1,33 @@ +{% set totalWeight = 0 %} +{% for lineItem in page.cart.lineItems %} + {% if lineItem.deliveryInformation.weight != null %} + {% set totalWeight = totalWeight + (lineItem.quantity * lineItem.deliveryInformation.weight) %} + {% endif %} +{% endfor %} +{% block page_checkout_confirm_delivery_date %} + {% if page.extensions.DeliveryDateConfig.data.deliveryDateActive %} +
+
+
+
+
+
+ {{ "dtgs-delivery-date.confirmDatePanelHeader"|trans }} +
+

+ {{ "dtgs-delivery-date.confirmDatePanelText"|trans }} +

+ +
+
+
+
+
+ {% endif %} +{% endblock %} diff --git a/zenitPlatformAtmosSet2/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set2.js b/zenitPlatformAtmosSet2/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set2.js index b961c00..dfee5c2 100644 --- a/zenitPlatformAtmosSet2/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set2.js +++ b/zenitPlatformAtmosSet2/src/Resources/app/storefront/dist/storefront/js/zenit-platform-atmos-set2.js @@ -35,6 +35,10 @@ $(document).ready(function() { $("[name='shippingMethodId']").on('change', () => { changeDelivery(fp); }); + + /* Set first selectable day selected */ + setDateSelected(); + changeDelivery(fp); } @@ -63,7 +67,7 @@ $(document).ready(function() { var hash = this.hash; var sTop = parseInt($(hash).offset().top - $(".header-inner").outerHeight() - 12); - scrollTo(sTop, 800); + scrollToPos(sTop, 800); window.location.hash = hash; } // End if }); @@ -72,7 +76,7 @@ $(document).ready(function() { // c = element or pixel position // e = duration // d = (optative) ease function. Default easeOutCuaic -function scrollTo(c,e,d){d||(d=easeOutCuaic);var a=document.documentElement;if(0===a.scrollTop){var b=a.scrollTop;++a.scrollTop;a=b+1===a.scrollTop--?a:document.body}b=a.scrollTop;0>=e||("object"===typeof b&&(b=b.offsetTop),"object"===typeof c&&(c=c.offsetTop),function(a,b,c,f,d,e,h){function g(){0>f||1=d?a.scrollTop=c:(a.scrollTop=b-(b-c)*h(f),f+=d*e,setTimeout(g,e))}g()}(a,b,c,0,1/e,20,d))}; +function scrollToPos(c,e,d){d||(d=easeOutCuaic);var a=document.documentElement;if(0===a.scrollTop){var b=a.scrollTop;++a.scrollTop;a=b+1===a.scrollTop--?a:document.body}b=a.scrollTop;0>=e||("object"===typeof b&&(b=b.offsetTop),"object"===typeof c&&(c=c.offsetTop),function(a,b,c,f,d,e,h){function g(){0>f||1=d?a.scrollTop=c:(a.scrollTop=b-(b-c)*h(f),f+=d*e,setTimeout(g,e))}g()}(a,b,c,0,1/e,20,d))}; function easeOutCuaic(t){ t--; return t*t*t+1; @@ -86,7 +90,32 @@ function manipulateDateInputValue() { } } +function setDateSelected() { + let spwnFirstSelectableDay = $(".flatpickr-day:not(.flatpickr-disabled)").first().text(); + let spwnFPdate = new Date(); + + let spwnDay = spwnFPdate.getDate(); + let spwnMonth = spwnFPdate.getMonth(); + let spwnMonthTemp = 0; + spwnMonth = spwnMonth + 1; + if((String(spwnMonth)).length === 1) { + spwnMonthTemp = spwnMonth; + spwnMonth = '0' + spwnMonth; + } + if (spwnFirstSelectableDay < spwnDay) { + spwnMonth = spwnMonthTemp + 1; + if((String(spwnMonth)).length === 1) { + spwnMonth = '0' + spwnMonth; + } + } + let spwnFrmattedDate = spwnFPdate.getFullYear() + '/' + spwnMonth + '/' + spwnFirstSelectableDay; + + fp.setDate(new Date(spwnFrmattedDate)); + spawnDateInputValue = spwnFirstSelectableDay + '.' + spwnMonth + '.' + spwnFPdate.getFullYear(); +} + function changeDelivery(fp) { + $("body").on("click", "#spwn-delivery .spwn-delivery--time span", function() { $("#spwn-delivery .spwn-delivery--time span").removeClass("active"); $(this).addClass("active"); @@ -115,16 +144,18 @@ function changeDelivery(fp) { } setIncludedDays("evening", fp, daysToAdd); $("#spwn-delivery p").text("Abendzustellung gewählt. Bitte wählen Sie nun eine Wunsch-Zeit:"); - $("#spwn-delivery .spwn-delivery--time").append("18 - 21 Uhr20 - 23 Uhr"); + $("#spwn-delivery .spwn-delivery--time").append("18 - 20 Uhr19 - 21 Uhr20 - 22 Uhr"); // If not date from DPD days + if (!$(".flatpickr-day").hasClass("selected")) { + setDateSelected(); + } if ($(".flatpickr-day").hasClass("selected")) { if (spawnDateInputValue === "" || spawnDateInputValue.indexOf("Uhr") === -1) { manipulateDateInputValue(); } // If DPD date is not in Abendzustellung range } else { - $(".confirm-delivery-date #dtgs-datepicker-inputfield").val(""); - spawnDateInputValue = ""; + setDateSelected(); } } else { // DPD @@ -142,8 +173,7 @@ function changeDelivery(fp) { $("#spwn-delivery p").text("DPD gewählt. Die Zustellung erfolgt zwischen 7 und 13 Uhr."); if (!$(".flatpickr-day").hasClass("selected")) { // If Abendzustellung date is not in DPD range - $(".confirm-delivery-date #dtgs-datepicker-inputfield").val(""); - spawnDateInputValue = ""; + setDateSelected(); } } } else { @@ -157,8 +187,7 @@ function changeDelivery(fp) { $("#spwn-delivery p").text("DPD gewählt. Die Zustellung erfolgt zwischen 7 und 18 Uhr."); if (!$(".flatpickr-day").hasClass("selected")) { // If Abendzustellung or DPD DE date is not in DPD AT range - $(".confirm-delivery-date #dtgs-datepicker-inputfield").val(""); - spawnDateInputValue = ""; + setDateSelected(); } } } diff --git a/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/overrides.scss b/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/overrides.scss index ca03277..c10aa18 100644 --- a/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/overrides.scss +++ b/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/overrides.scss @@ -165,3 +165,8 @@ input.custom-number[type=number] { } } } + +.confirm-delivery-date.do-not-show, +#spwn-delivery { + display: none !important; +} diff --git a/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/page/product-detail/_product-detail.scss b/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/page/product-detail/_product-detail.scss index 73b553c..5406d18 100644 --- a/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/page/product-detail/_product-detail.scss +++ b/zenitPlatformAtmosSet2/src/Resources/app/storefront/src/scss/page/product-detail/_product-detail.scss @@ -79,6 +79,7 @@ border-bottom: 1px solid #86b04b; } .product-detail-name { + font-weight: bold; color: $sw-color-brand-secondary; line-height: 40px !important; } diff --git a/zenitPlatformAtmosSet2/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig b/zenitPlatformAtmosSet2/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig new file mode 100644 index 0000000..29bd24f --- /dev/null +++ b/zenitPlatformAtmosSet2/src/Resources/views/storefront/plugins/Deliverydate/date_panel.html.twig @@ -0,0 +1,33 @@ +{% set totalWeight = 0 %} +{% for lineItem in page.cart.lineItems %} + {% if lineItem.deliveryInformation.weight != null %} + {% set totalWeight = totalWeight + (lineItem.quantity * lineItem.deliveryInformation.weight) %} + {% endif %} +{% endfor %} +{% block page_checkout_confirm_delivery_date %} + {% if page.extensions.DeliveryDateConfig.data.deliveryDateActive %} +
+
+
+
+
+
+ {{ "dtgs-delivery-date.confirmDatePanelHeader"|trans }} +
+

+ {{ "dtgs-delivery-date.confirmDatePanelText"|trans }} +

+ +
+
+
+
+
+ {% endif %} +{% endblock %}