| Attached Files |  issue 34730 source posterminal 7079.patch [^] (5,252 bytes) 2016-12-16 13:10 [Show Content] [Hide Content] # HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1481889772 -19800
#      Fri Dec 16 17:32:52 2016 +0530
# Node ID 6400190a9a120bc15c407996f1bf43ad7b73f31d
# Parent  0349abe8cc312ad8c0aa82c3d8fcfdf1b34b4028
Related to issue 34730 : Connect/Disconnect RFID when popup/modal is opened
* By default, set scanMode as true to enable RFID by default
* RFID should be disabled, when search, payment tab is showing
* Disconnect RFID when popup/modal is opened, Connect RFID when popup/modal is closed
diff -r 0349abe8cc31 -r 6400190a9a12 web/org.openbravo.retail.posterminal/js/login/model/login-model.js
--- a/web/org.openbravo.retail.posterminal/js/login/model/login-model.js	Mon Dec 12 17:03:52 2016 +0100
+++ b/web/org.openbravo.retail.posterminal/js/login/model/login-model.js	Fri Dec 16 17:32:52 2016 +0530
@@ -154,6 +154,7 @@
 
               OB.UTIL.localStorage.setItem('terminalId', data[0].terminal.id);
               terminalModel.set('useBarcode', terminalModel.get('terminal').terminalType.usebarcodescanner);
+              OB.MobileApp.view.scanMode = true;
               OB.MobileApp.view.scanningFocus(true);
               if (!terminalModel.usermodel) {
                 OB.MobileApp.model.loadingErrorsActions("The terminal.usermodel should be loaded at this point");
diff -r 0349abe8cc31 -r 6400190a9a12 web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js	Mon Dec 12 17:03:52 2016 +0100
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js	Fri Dec 16 17:32:52 2016 +0530
@@ -414,6 +414,7 @@
       colNum: 1
     });
 
+    OB.MobileApp.view.scanningFocus(true);
     if (OB.UTIL.RfidController.isRfidConfigured()) {
       OB.UTIL.RfidController.disconnectRFIDDevice();
     }
diff -r 0349abe8cc31 -r 6400190a9a12 web/org.openbravo.retail.posterminal/js/utils/preScanningFocusHook.js
--- a/web/org.openbravo.retail.posterminal/js/utils/preScanningFocusHook.js	Mon Dec 12 17:03:52 2016 +0100
+++ b/web/org.openbravo.retail.posterminal/js/utils/preScanningFocusHook.js	Fri Dec 16 17:32:52 2016 +0530
@@ -8,10 +8,12 @@
  */
 
 OB.UTIL.HookManager.registerHook('OBMOBC_PreScanningFocus', function (args, callbacks) {
-  if (args.scanMode && OB.UTIL.RfidController.isRfidConfigured() && OB.UTIL.RfidController.get('rfidWebsocket') && !OB.UTIL.RfidController.get('isRFIDEnabled') && OB.UTIL.RfidController.get('reconnectOnScanningFocus')) {
-    OB.UTIL.RfidController.connectRFIDDevice();
-  } else if (args.scanMode === false && OB.UTIL.RfidController.isRfidConfigured() && OB.UTIL.RfidController.get('rfidWebsocket') && OB.UTIL.RfidController.get('isRFIDEnabled')) {
-    OB.UTIL.RfidController.disconnectRFIDDevice();
+  if (OB.UTIL.RfidController.isRfidConfigured() && OB.UTIL.RfidController.get('rfidWebsocket')) {
+    if (args.scanMode === true && !OB.UTIL.RfidController.get('isRFIDEnabled') && OB.UTIL.RfidController.get('reconnectOnScanningFocus') && (OB.MobileApp.view.originalRFIDMode || (OB.MobileApp.view.originalRFIDMode === false && OB.MobileApp.model.get('lastPaneShown') !== 'payment'))) {
+      OB.UTIL.RfidController.connectRFIDDevice();
+    } else if (args.scanMode === false && OB.UTIL.RfidController.get('isRFIDEnabled')) {
+      OB.UTIL.RfidController.disconnectRFIDDevice();
+    }
   }
   OB.UTIL.HookManager.callbackExecutor(args, callbacks);
 });
\ No newline at end of file
diff -r 0349abe8cc31 -r 6400190a9a12 web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js
--- a/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js	Mon Dec 12 17:03:52 2016 +0100
+++ b/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js	Fri Dec 16 17:32:52 2016 +0530
@@ -10,7 +10,7 @@
 /*global, WebSocket, _ Backbone */
 
 OB.UTIL.RfidController = new Backbone.Model({
-  connected: true
+  connected: false
 });
 
 OB.UTIL.RfidController.isRfidConfigured = function () {
@@ -47,6 +47,7 @@
     }
     OB.UTIL.RfidController.set('barcodeActionHandler', new OB.UI.BarcodeActionHandler());
     OB.UTIL.RfidController.removeAllEpcs();
+    OB.UTIL.RfidController.set('connected', true);
     OB.UTIL.RfidController.set('connectionLost', false);
   };
 
@@ -55,6 +56,7 @@
     var data, ean, i, line;
     if (event.data.startsWith('doNotReconnect')) {
       OB.UTIL.RfidController.get('rfidWebsocket').onclose = function () {};
+      OB.UTIL.RfidController.set('connected', false);
       OB.UTIL.RfidController.set('connectionLost', true);
       OB.UTIL.RfidController.get('rfidWebsocket').close();
       return;
@@ -105,6 +107,7 @@
     setTimeout(function () {
       OB.UTIL.RfidController.startRfidWebsocket(websocketServerLocation, reconnectTimeout, currentRetrials, retrialsBeforeWarning);
     }, reconnectTimeout);
+    OB.UTIL.RfidController.set('connected', false);
     OB.UTIL.RfidController.set('connectionLost', true);
   };
 
@@ -400,4 +403,8 @@
       }
     }, 2000, OB.UTIL.get_UUID(), 5);
   }
-};
\ No newline at end of file
+};
+
+OB.UTIL.RfidController.on('change:isRFIDEnabled', function (model) {
+  OB.MobileApp.view.originalRFIDMode = OB.UTIL.RfidController.get('isRFIDEnabled');
+}, this);
\ No newline at end of file
  issue 34730 test 6033.patch [^] (5,509 bytes) 2016-12-16 13:11 [Show Content] [Hide Content] # HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1481889755 -19800
#      Fri Dec 16 17:32:35 2016 +0530
# Node ID c59c4e0486fe72a58eb7bb61e30dfc54b74384c3
# Parent  1441e29753f30f449e6d29354bdef05a078662ba
Verifies issue 34730 : Added automated test 'I34730_VerifyRFIDOnPaymentTab'
diff -r 1441e29753f3 -r c59c4e0486fe src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/rfid/I34730_VerifyRFIDOnPaymentTab.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/rfid/I34730_VerifyRFIDOnPaymentTab.java	Fri Dec 16 17:32:35 2016 +0530
@@ -0,0 +1,137 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2016 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @Author RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.rfid;
+
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.utils.OBWait;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSRFIDTerminalHelper;
+
+public class I34730_VerifyRFIDOnPaymentTab extends WebPOSRFIDTerminalHelper {
+
+  @Override
+  public void testRun() {
+    verify(TestIdPack.LABEL_NEW_RECEIPT, "New Receipt");
+
+    // Verify RFID Enabled on Scan tab
+    verifyRFIDIconEnabled();
+    sendEpcCode(BASE_CAMP_DUFFEL_EPC_NUMBER);
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_TITLE, "Base camp duffel 70 L");
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_SERIAL_NUMBER, "Serial Number: 000000000001");
+    verify(TestIdPack.LABEL_TOTALTOPAY, "89.50");
+    tap(TestIdPack.BUTTON_PAY);
+
+    // Verify RFID Disabled on Payment tab
+    verifyRFIDIconDisabled();
+
+    tap(TestIdPack.BUTTON_SCAN);
+
+    // Verify RFID Enabled on Scan tab
+    verifyRFIDIconEnabled();
+
+    tap(TestIdPack.BUTTON_PAY);
+
+    // Verify RFID Disabled on Payment tab
+    verifyRFIDIconDisabled();
+
+    // Verify RFID Disabled on Payment tab With Popup
+    tap(TestIdPack.LABEL_DOCUMENTNUMBER);
+    verifyRFIDIconDisabled();
+    tap(TestIdPack.BUTTON_RECEIPT_PROPERTIES_CANCEL);
+
+    tap(TestIdPack.BUTTON_PAYMENTSWITCH);
+    tap(TestIdPack.BUTTON_KEYPAD_5);
+    tap(TestIdPack.BUTTON_KEYPAD_0);
+    tap(TestIdPack.BUTTON_KEYPAD_ENTER);
+    verify(TestIdPack.LABEL_RECEIPT_PAY_REMAINING, "39.50€");
+    tap(TestIdPack.BUTTON_RECEIPT_PAYMENT_ROW1_REMOVE);
+
+    // Verify RFID Disabled on Popup
+    tap(TestIdPack.BUTTON_DELETERECEIPT);
+    verifyRFIDIconDisabled();
+    tap(TestIdPack.BUTTON_DELETERECEIPT_CONFIRM);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    // Verify RFID Enabled on Scan tab
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+    verifyRFIDIconEnabled();
+  }
+
+  private void verifyRFIDIconEnabled() {
+    new OBWait() {
+      @Override
+      protected boolean until(final int currentIteration) {
+        return (Boolean) TestIdPack.LABEL_RFID_ICON.enyoNode().executeExtensionWithReturn(
+            ".attributes.class === '" + CSSRFIDICONENABLED + "'");
+      }
+
+      @Override
+      protected void timeout() {
+        throw new RuntimeException("Scanning focus was expected to turn on with green color icon.");
+      }
+    };
+    new OBWait() {
+      @Override
+      protected boolean until(final int currentIteration) {
+        return (Boolean) SeleniumHelper.executeScriptWithReturn(
+            "OB.UTIL.RfidController.get('isRFIDEnabled')", (Object) null);
+      }
+
+      @Override
+      protected void timeout() {
+        throw new RuntimeException("isRfidController was expected to be true.");
+      }
+    };
+  }
+
+  private void verifyRFIDIconDisabled() {
+    new OBWait() {
+      @Override
+      protected boolean until(final int currentIteration) {
+        return (Boolean) TestIdPack.LABEL_RFID_ICON.enyoNode().executeExtensionWithReturn(
+            ".attributes.class === '" + CSSRFIDICONDISABLED + "'");
+      }
+
+      @Override
+      protected void timeout() {
+        throw new RuntimeException("Scanning focus was expected to turn on with green color icon.");
+      }
+    };
+    verifyRFIDDisabled();
+  }
+
+  private void verifyRFIDDisabled() {
+    new OBWait() {
+      @Override
+      protected boolean until(final int currentIteration) {
+        return !(Boolean) SeleniumHelper.executeScriptWithReturn(
+            "OB.UTIL.RfidController.get('isRFIDEnabled')", (Object) null);
+      }
+
+      @Override
+      protected void timeout() {
+        throw new RuntimeException("isRfidController was expected to be true.");
+      }
+    };
+  }
+}
 |