From 141cb7cba5c36a9c5415772e2de9823f927d7abb Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 31 Oct 2015 20:04:06 +0100 Subject: web: o Better form interaction: enter to submit and autofocus on the field. --- src/DillerDao.js | 3 +- web/static/app/app.js | 2 - .../app/templates/device-edit-attribute.modal.html | 48 ++++++++++++---------- web/static/app/templates/device.html | 6 ++- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/DillerDao.js b/src/DillerDao.js index fa27aa1..e372841 100644 --- a/src/DillerDao.js +++ b/src/DillerDao.js @@ -32,7 +32,8 @@ function DillerDao(tx) { var fields = _(attributes).chain() .map(function (value, attribute) { if (attribute == 'name' || attribute == 'description') { - values.push(value); + value = (value || '').trim(); + values.push(value.length > 0 ? value : null); return attribute + ' = $' + i++; } }) diff --git a/web/static/app/app.js b/web/static/app/app.js index fedfb54..a76aa33 100644 --- a/web/static/app/app.js +++ b/web/static/app/app.js @@ -20,8 +20,6 @@ ctrl.label = attributeName.substr(0, 1).toUpperCase() + attributeName.substr(1); ctrl.value = outer.device[attributeName]; - ctrl.error = 'fail'; - ctrl.update = function () { DillerRpc.patchDevice(outer.device.id, {attribute: attributeName, value: ctrl.value}) .then(function (res) { diff --git a/web/static/app/templates/device-edit-attribute.modal.html b/web/static/app/templates/device-edit-attribute.modal.html index fc22d7b..10314e5 100644 --- a/web/static/app/templates/device-edit-attribute.modal.html +++ b/web/static/app/templates/device-edit-attribute.modal.html @@ -1,28 +1,32 @@ - -