Fix submission of edit form by enter key. Fixes #341~

This commit is contained in:
Jonathan Kingston 2017-03-09 00:22:26 +00:00
parent e90e264beb
commit 6b995586fd

View file

@ -481,22 +481,28 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
Logic.showPreviousPanel(); Logic.showPreviousPanel();
}); });
document.querySelector("#edit-container-ok-link").addEventListener("click", () => { this._editForm = document.getElementById("edit-container-panel-form");
const identity = Logic.currentIdentity(); const editLink = document.querySelector("#edit-container-ok-link");
const formValues = new FormData(document.getElementById("edit-container-panel-form")); editLink.addEventListener("click", this._submitForm);
browser.runtime.sendMessage({ editLink.addEventListener("submit", this._submitForm);
method: identity.userContextId ? "updateIdentity" : "createIdentity", this._editForm.addEventListener("submit", this._submitForm);
userContextId: identity.userContextId || 0, },
name: document.getElementById("edit-container-panel-name-input").value || Logic.generateIdentityName(),
icon: formValues.get("container-icon") || DEFAULT_ICON, _submitForm() {
color: formValues.get("container-color") || DEFAULT_COLOR, const identity = Logic.currentIdentity();
}).then(() => { const formValues = new FormData(this._editForm);
return Logic.refreshIdentities(); browser.runtime.sendMessage({
}).then(() => { method: identity.userContextId ? "updateIdentity" : "createIdentity",
Logic.showPreviousPanel(); userContextId: identity.userContextId || 0,
}).catch(() => { name: document.getElementById("edit-container-panel-name-input").value || Logic.generateIdentityName(),
Logic.showPanel(P_CONTAINERS_LIST); icon: formValues.get("container-icon") || DEFAULT_ICON,
}); color: formValues.get("container-color") || DEFAULT_COLOR,
}).then(() => {
return Logic.refreshIdentities();
}).then(() => {
Logic.showPreviousPanel();
}).catch(() => {
Logic.showPanel(P_CONTAINERS_LIST);
}); });
}, },