From f4e1b47d9dd1ad575b74850d6905b059bb10b17a Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 2 Jul 2018 08:57:41 +0200 Subject: [PATCH] Improved groups creation form --- assets/js/pages/groups/pages/create.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/assets/js/pages/groups/pages/create.js b/assets/js/pages/groups/pages/create.js index cba56841..e152612b 100644 --- a/assets/js/pages/groups/pages/create.js +++ b/assets/js/pages/groups/pages/create.js @@ -50,7 +50,7 @@ ComunicWeb.pages.groups.pages.create = { type: "div", class: "submit-button-container" }); - createElem2({ + var submitButton = createElem2({ appendTo: submitContainer, type: "input", elemType: "submit", @@ -61,14 +61,32 @@ ComunicWeb.pages.groups.pages.create = { //Handle form submit formContainer.onsubmit = function(){ + //Check if a request is already pending + if(submitButton.disabled) + return; + //Check user inputs if(!ComunicWeb.common.formChecker.checkInput(nameInput, true)){ notify("Please specify the name of the group!", "danger"); return false; } + var name = nameInput.value; + + //Check the length of the name of the group + if(name.length < 4){ + notify("The name of the group is too short !", "danger"); + return false; + } + + //Disable submit button + submitButton.disabled = true; + //Perform a request on the server to create the group - ComunicWeb.components.groups.interface.create(nameInput.value, function(res){ + ComunicWeb.components.groups.interface.create(name, function(res){ + + //Enable submit button + submitButton.disabled = false; //Check for errors if(res.error){