forked from verdnatura/hedera-web
refs #3971 Form input locking when loading
This commit is contained in:
parent
be43a38b38
commit
c463e967ca
|
@ -1,4 +1,4 @@
|
|||
hedera-web (22.48.7) stable; urgency=low
|
||||
hedera-web (22.48.8) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -28,46 +28,53 @@ export default new Class({
|
|||
}
|
||||
|
||||
,async onPassModifyClick() {
|
||||
var oldPassword = this.$.oldPassword.value;
|
||||
var newPassword = this.$.newPassword.value;
|
||||
var repeatedPassword = this.$.repeatPassword.value;
|
||||
|
||||
const form = this.$.changePassword.node;
|
||||
Vn.Node.disableInputs(form);
|
||||
try {
|
||||
if (newPassword == '' && repeatedPassword == '')
|
||||
throw new Error(_('Passwords empty'));
|
||||
if (newPassword !== repeatedPassword)
|
||||
throw new Error(_('Passwords doesn\'t match'));
|
||||
} catch (err) {
|
||||
return Htk.Toast.showError(err.message);
|
||||
}
|
||||
const oldPassword = this.$.oldPassword.value;
|
||||
const newPassword = this.$.newPassword.value;
|
||||
const repeatedPassword = this.$.repeatPassword.value;
|
||||
|
||||
var verificationToken = this.hash.$.verificationToken;
|
||||
var params = {newPassword};
|
||||
|
||||
try {
|
||||
if (verificationToken) {
|
||||
params.verificationToken = verificationToken;
|
||||
await this.conn.send('user/restore-password', params);
|
||||
} else {
|
||||
let userId = this.gui.user.id;
|
||||
params.oldPassword = oldPassword;
|
||||
await this.conn.patch(
|
||||
`Accounts/${userId}/changePassword`, params);
|
||||
try {
|
||||
if (newPassword == '' && repeatedPassword == '')
|
||||
throw new Error(_('Passwords empty'));
|
||||
if (newPassword !== repeatedPassword)
|
||||
throw new Error(_('Passwords doesn\'t match'));
|
||||
} catch (err) {
|
||||
return Htk.Toast.showError(err.message);
|
||||
}
|
||||
} catch(err) {
|
||||
Htk.Toast.showError(err.message);
|
||||
|
||||
const verificationToken = this.hash.$.verificationToken;
|
||||
const params = {newPassword};
|
||||
|
||||
if (this.hash.$.verificationToken)
|
||||
this.$.newPassword.select();
|
||||
else
|
||||
this.$.oldPassword.select();
|
||||
try {
|
||||
if (verificationToken) {
|
||||
params.verificationToken = verificationToken;
|
||||
await this.conn.send('user/restore-password', params);
|
||||
} else {
|
||||
let userId = this.gui.user.id;
|
||||
params.oldPassword = oldPassword;
|
||||
await this.conn.patch(
|
||||
`Accounts/${userId}/changePassword`, params);
|
||||
}
|
||||
} catch(err) {
|
||||
Htk.Toast.showError(err.message);
|
||||
|
||||
return;
|
||||
if (verificationToken)
|
||||
this.$.newPassword.select();
|
||||
else
|
||||
this.$.oldPassword.select();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.hash.unset('verificationToken');
|
||||
await this.conn.open(this.gui.user.name, newPassword);
|
||||
this.$.changePassword.hide();
|
||||
} finally {
|
||||
Vn.Node.disableInputs(form, false);
|
||||
}
|
||||
|
||||
this.$.changePassword.hide();
|
||||
this.hash.unset('verificationToken');
|
||||
await this.conn.open(this.gui.user.name, newPassword);
|
||||
|
||||
Htk.Toast.showMessage(_('Password changed!'));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,11 +89,13 @@
|
|||
<input
|
||||
id="new-password"
|
||||
type="password"
|
||||
placeholder="_New password"/>
|
||||
placeholder="_New password"
|
||||
autocomplete="new-password"/>
|
||||
<input
|
||||
id="repeat-password"
|
||||
type="password"
|
||||
placeholder="_Repeat password"/>
|
||||
placeholder="_Repeat password"
|
||||
autocomplete="new-password"/>
|
||||
</div>
|
||||
<div class="button-bar">
|
||||
<button class="thin" on-click="this.onPassModifyClick()">
|
||||
|
|
|
@ -111,19 +111,14 @@ export default new Class({
|
|||
},
|
||||
|
||||
async onConfirmClick() {
|
||||
this.disableButtons(true);
|
||||
Vn.Node.disableInputs(this.node);
|
||||
try {
|
||||
await this.conn.execQuery('CALL myBasket_confirm');
|
||||
this.$.successDialog.show();
|
||||
} finally {
|
||||
this.disableButtons(false);
|
||||
Vn.Node.disableInputs(this.node, false);
|
||||
}
|
||||
},
|
||||
|
||||
disableButtons(disable) {
|
||||
this.$.modify.disabled = disable;
|
||||
this.$.confirm.disabled = disable;
|
||||
},
|
||||
|
||||
async onDialogResponse() {
|
||||
if (this.$.payMethod.value === 'CARD') {
|
||||
|
|
|
@ -1,66 +1,63 @@
|
|||
|
||||
module.exports =
|
||||
{
|
||||
removeChilds: function (node)
|
||||
{
|
||||
module.exports = {
|
||||
removeChilds(node) {
|
||||
var childs = node.childNodes;
|
||||
|
||||
if (childs)
|
||||
while (childs.length > 0)
|
||||
node.removeChild (childs[0]);
|
||||
}
|
||||
node.removeChild(childs[0]);
|
||||
},
|
||||
|
||||
,remove: function (node)
|
||||
{
|
||||
remove(node) {
|
||||
if (node.parentNode)
|
||||
node.parentNode.removeChild (node);
|
||||
}
|
||||
node.parentNode.removeChild(node);
|
||||
},
|
||||
|
||||
,setText: function (node, text)
|
||||
{
|
||||
Vn.Node.removeChilds (node);
|
||||
setText(node, text) {
|
||||
Vn.Node.removeChilds(node);
|
||||
|
||||
if (text)
|
||||
node.appendChild (
|
||||
node.ownerDocument.createTextNode (text));
|
||||
}
|
||||
node.appendChild(
|
||||
node.ownerDocument.createTextNode(text));
|
||||
},
|
||||
|
||||
,addClass: function (node, className)
|
||||
{
|
||||
/* var classes = node.className.split (' ');
|
||||
addClass(node, className) {
|
||||
/* var classes = node.className.split(' ');
|
||||
|
||||
if (classes.split (' ').indexOf (className) == -1)
|
||||
if (classes.split(' ').indexOf(className) == -1)
|
||||
*/ node.className = className +' '+ node.className;
|
||||
}
|
||||
},
|
||||
|
||||
,removeClass: function (node, className)
|
||||
{
|
||||
removeClass(node, className) {
|
||||
var index = 0;
|
||||
var found = false;
|
||||
var classes = node.className.split (' ');
|
||||
var classes = node.className.split(' ');
|
||||
|
||||
while ((index = classes.indexOf (className, index)) != -1)
|
||||
{
|
||||
classes.splice (index, 1);
|
||||
while ((index = classes.indexOf(className, index)) != -1) {
|
||||
classes.splice(index, 1);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found)
|
||||
node.className = classes.join (' ');
|
||||
}
|
||||
node.className = classes.join(' ');
|
||||
},
|
||||
|
||||
,hide: function (node)
|
||||
{
|
||||
hide: function(node) {
|
||||
node.style.display = 'none';
|
||||
}
|
||||
},
|
||||
|
||||
,show: function (node)
|
||||
{
|
||||
show: function(node) {
|
||||
node.style.display = 'block';
|
||||
},
|
||||
|
||||
disableInputs(formNode, disable = true) {
|
||||
const inputs = formNode
|
||||
.querySelectorAll('input, textarea, button, select');
|
||||
for (const input of inputs)
|
||||
input.disabled = disable;
|
||||
}
|
||||
};
|
||||
|
||||
$ = function (id)
|
||||
{
|
||||
return document.getElementById (id);
|
||||
$ = function(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "hedera-web",
|
||||
"version": "22.48.7",
|
||||
"version": "22.48.8",
|
||||
"description": "Verdnatura web page",
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
|
|
Loading…
Reference in New Issue