From be4934e127fdaab71bcf8affb9030c1798b5dce7 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 18 Jul 2017 17:30:12 -0400 Subject: [PATCH] write card button disabled/enabled for vendors/customers --- ...id_write_credit.js => minigrid_write_card.js} | 15 +++++++++++---- minigrid/templates/minigrid_customers.html | 16 ++++++++-------- minigrid/templates/minigrid_vendors.html | 6 +++--- minigrid/templates/minigrid_write_credit.html | 6 +++--- webpack.config.js | 2 +- 5 files changed, 26 insertions(+), 19 deletions(-) rename minigrid/static/src/js/{minigrid_write_credit.js => minigrid_write_card.js} (63%) diff --git a/minigrid/static/src/js/minigrid_write_credit.js b/minigrid/static/src/js/minigrid_write_card.js similarity index 63% rename from minigrid/static/src/js/minigrid_write_credit.js rename to minigrid/static/src/js/minigrid_write_card.js index 9706984..c9a5e44 100644 --- a/minigrid/static/src/js/minigrid_write_credit.js +++ b/minigrid/static/src/js/minigrid_write_card.js @@ -7,7 +7,9 @@ import populateCardInfoTable from './populate_card_info.js'; (function(){ - const input = document.getElementById('card-value'); + const inputs = document.getElementsByClassName('card-value'); + + console.log('new input', inputs) let conn = new SockJS(http_protocol + '://' + window.location.host + '/cardconn'); let received_info; @@ -21,14 +23,19 @@ import populateCardInfoTable from './populate_card_info.js'; }; conn.onmessage = function(e) { - console.log('Received: ' + JSON.stringify(e.data['received_info'])); + console.log('Received!: ' + JSON.stringify(e.data)); received_info = e.data['received_info']; card_read_error = e.data['card_read_error']; + console.log('its different part 1', e.data['device_active']); if (e.data['device_active']!==device_active) { device_active = e.data['device_active']; - if (e.data['device_active']) input.disabled = false; - else input.disabled = true; + console.log('its different', device_active); + console.log(inputs); + [].forEach.call(inputs, function(input){ + if (e.data['device_active']) input.disabled = false; + else input.disabled = true; + }); populateCardInfoTable(received_info, card_read_error); }; }; diff --git a/minigrid/templates/minigrid_customers.html b/minigrid/templates/minigrid_customers.html index ff72282..f932c30 100644 --- a/minigrid/templates/minigrid_customers.html +++ b/minigrid/templates/minigrid_customers.html @@ -22,13 +22,13 @@

Minigrid Name: {{ minigrid.minigrid_name }}

User ID: {{ customer.customer_user_id }}

{% module xsrf_form_html() %} - - - {% if device_active %} - - {% else %} - - {% end %} + + + {% if device_active %} + + {% else %} + + {% end %}
{% module xsrf_form_html() %} @@ -62,5 +62,5 @@

Minigrid Name: {{ minigrid.minigrid_name }}

- + {% end %} diff --git a/minigrid/templates/minigrid_vendors.html b/minigrid/templates/minigrid_vendors.html index 82a75a0..797be91 100644 --- a/minigrid/templates/minigrid_vendors.html +++ b/minigrid/templates/minigrid_vendors.html @@ -25,9 +25,9 @@

Minigrid Name: {{ minigrid.minigrid_name }}

{% if device_active %} - + {% else %} - + {% end %}
@@ -63,5 +63,5 @@

Minigrid Name: {{ minigrid.minigrid_name }}

- + {% end %} diff --git a/minigrid/templates/minigrid_write_credit.html b/minigrid/templates/minigrid_write_credit.html index c5e6217..af4d7b4 100644 --- a/minigrid/templates/minigrid_write_credit.html +++ b/minigrid/templates/minigrid_write_credit.html @@ -14,9 +14,9 @@

Minigrid Name: {{ minigrid.minigrid_name }}

{% module xsrf_form_html() %}
{% if device_active %} - + {% else %} - + {% end %}
@@ -36,6 +36,6 @@

Minigrid Name: {{ minigrid.minigrid_name }}

var http_protocol = '{{ http_protocol }}'; - + {% end %} diff --git a/webpack.config.js b/webpack.config.js index 2730a27..087480c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ const webpack = require('webpack'); module.exports = { entry: { - write_credit: path.resolve(__dirname, 'minigrid/static/src/js/minigrid_write_credit.js'), + write_card: path.resolve(__dirname, 'minigrid/static/src/js/minigrid_write_card.js'), read_card: path.resolve(__dirname, 'minigrid/static/src/js/read_card.js'), tariffs: path.resolve(__dirname, 'minigrid/static/src/js/tariffs.js') },