From 0e0e5b31b6c09c210b6bc850fc17ea103338f45d Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Wed, 10 Jul 2019 16:47:12 +0200
Subject: [PATCH] fix: frontend shipping click events

---
 .../shippingRules/CreateRuleWindow.js         |  8 +++--
 bin/frontend/controls/order/Shipping.js       | 36 +++++++++++++++----
 locale.xml                                    |  4 +++
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/bin/backend/controls/shippingRules/CreateRuleWindow.js b/bin/backend/controls/shippingRules/CreateRuleWindow.js
index bad6f9a..cf16b34 100644
--- a/bin/backend/controls/shippingRules/CreateRuleWindow.js
+++ b/bin/backend/controls/shippingRules/CreateRuleWindow.js
@@ -32,8 +32,12 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi
             this.parent(options);
 
             this.setAttributes({
-                title: QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'),
-                icon : 'fa fa-truck'
+                title    : QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'),
+                icon     : 'fa fa-truck',
+                ok_button: {
+                    text     : QUILocale.get('quiqqer/shipping', 'window.shipping.entry.delete.rule.create'),
+                    textimage: 'fa fa-trash'
+                }
             });
 
             this.$Create = null;
diff --git a/bin/frontend/controls/order/Shipping.js b/bin/frontend/controls/order/Shipping.js
index eb41773..e8ffc7d 100644
--- a/bin/frontend/controls/order/Shipping.js
+++ b/bin/frontend/controls/order/Shipping.js
@@ -20,27 +20,49 @@ define('package/quiqqer/shipping/bin/frontend/controls/order/Shipping', [
         Extends: QUIControl,
         Type   : 'package/quiqqer/shipping/bin/frontend/controls/order/Shipping',
 
+        Binds: [
+            '$onImport',
+            '$onClick'
+        ],
+
         initialize: function (options) {
             this.parent(options);
 
+            this.$Input = null;
+
             this.addEvents({
-                onInject: this.$onInject,
                 onImport: this.$onImport
             });
         },
 
         /**
-         * event: on inject
+         * event: on import
          */
-        $onInject: function () {
-            console.log('$onInject');
+        $onImport: function () {
+            this.getElm().addEvent('click', this.$onClick);
+
+            this.$Input = this.getElm().getElement('input');
+
+            if (this.$Input.checked) {
+                this.getElm().addClass('selected');
+            }
         },
 
         /**
-         * event: on import
+         * event: on click
          */
-        $onImport: function () {
-            console.log('$onImport');
+        $onClick: function (event) {
+            if (event.target.nodeName !== 'INPUT') {
+                event.stop();
+            }
+
+            this.getElm()
+                .getParent('.quiqqer-order-step-shipping-list')
+                .getElements('.quiqqer-order-step-shipping-list-entry')
+                .removeClass('selected');
+
+            this.$Input.checked = true;
+            this.getElm().addClass('selected');
         }
     });
 });
diff --git a/locale.xml b/locale.xml
index dcf7082..1bb8f5c 100644
--- a/locale.xml
+++ b/locale.xml
@@ -331,6 +331,10 @@
             <de><![CDATA[Löschen]]></de>
             <en><![CDATA[Delete]]></en>
         </locale>
+        <locale name="window.shipping.entry.delete.rule.create">
+            <de><![CDATA[Erstellen]]></de>
+            <en><![CDATA[Create]]></en>
+        </locale>
     </groups>
 
     <groups name="quiqqer/order">
-- 
GitLab