Commit b10b3783 by Georgina Mondino

Merge branch 'master' of http://git.anacsoft.com/Lusho/mini-web

2 parents b25076c2 1bc58c48
......@@ -115,3 +115,43 @@ function maxChild(container,number){
);
return fixinput(max);
}
function validate(obj){
const internal = "Hubo un error en la generación del formulario";
if (typeof obj != "object") return triggerError(internal,"not object");
for (let t_it = 0; t_it < obj.length; t_it++) {
let tab = obj[t_it];
if ("Title" in tab && "Fields" in tab){
if (typeof tab.Title != "string") return triggerError(internal,"wrong type in tab title");
if (typeof tab.Fields != "object") return triggerError(internal,"wrong type in tab fields");
if (tab.Title == "") return triggerError("La tab " + (t_it + 1) + " necesita un título","empty tab title");
if (tab.Fields.length == 0) return triggerError("La tab " + (t_it + 1) + " requiere campos","empty tab fields");
for (let f_it = 0; f_it < tab.Fields.length; f_it++) {
let field = tab.Fields[f_it];
if ("Title" in field && "Input" in field && "Required" in field) {
if (typeof field.Title != "string") return triggerError(internal,"wrong type in field title");
if (typeof field.Input != "string") return triggerError(internal,"wrong type in field input");
if (typeof field.Required != "boolean") return triggerError(internal,"wrong type in field required");
if (field.Title == "") return triggerError("El campo " + (f_it + 1) + " del tab " + (t_it + 1) + " necesita un título","empty field title");
if (field.Input == "") return triggerError("El campo " + (f_it + 1) + " del tab " + (t_it + 1) + " necesita un input","empty field input");
} else { return triggerError(internal,"field lacks property") }
}
} else { return triggerError(internal,"tab lacks property") }
}
}
function triggerError(type,log){
let out = "triggerError => \nerror_message = " + type;
if (log) out += "\nlog_message = " + log;
console.log(out);
document.getElementById("ErrorMessage").innerText = type;
}
\ No newline at end of file
......@@ -25,6 +25,7 @@
+
</button>
</div>
<p id="ErrorMessage" style="font-weight: bold; text-align: center; color: red;"></p>
<h3 id="ContinuarText">Cuando se encuentre conforme con el formulario presione Continuar</h3>
<button id="ContinuarButton" onclick="ArmarForm( generate(document.getElementById('tabs')) )"> Continuar
</button>
......
......@@ -13,7 +13,7 @@ function ArmarForm(data) {
boton.setAttribute("id", "Boton" + n);
boton.setAttribute("value", n);
boton.setAttribute("class", "Botones");
boton.addEventListener("click", HabilitarTab);
//boton.setAttribute("onclick", HabilitarTab(this) );
let ancho = ((100 - (0.2 * m)) / m) + "%";
boton.style.width = ancho;
let tab = document.createElement("div");
......@@ -25,9 +25,3 @@ function ArmarForm(data) {
document.getElementById("Tab0").style.display="block";
}
function HabilitarTab() {
for (let n = 0; n < m; n++) {
document.getElementById("Tab" + n).style.display="none"
}
}
\ No newline at end of file
......@@ -70,7 +70,9 @@ function processField(field){
function processTab(tab){
let dict = [];
let container = getDescendantByAttribute(tab,"name","Field").parentElement;
let container = getDescendantByAttribute(tab,"name","Field");
if (container == null) return dict;
container = container.parentElement;
for(let i = 0; i < container.children.length; i++){
if (container.children[i].getAttribute("name") == "Field") {
dict.push(processField(container.children[i]));
......@@ -113,3 +115,43 @@ function maxChild(container,number){
);
return fixinput(max);
}
function validate(obj){
const internal = "Hubo un error en la generación del formulario";
if (typeof obj != "object") return triggerError(internal,"not object");
for (let t_it = 0; t_it < obj.length; t_it++) {
let tab = obj[t_it];
if ("Title" in tab && "Fields" in tab){
if (typeof tab.Title != "string") return triggerError(internal,"wrong type in tab title");
if (typeof tab.Fields != "object") return triggerError(internal,"wrong type in tab fields");
if (tab.Title == "") return triggerError("La tab " + (t_it + 1) + " necesita un título","empty tab title");
if (tab.Fields.length == 0) return triggerError("La tab " + (t_it + 1) + " requiere campos","empty tab fields");
for (let f_it = 0; f_it < tab.Fields.length; f_it++) {
let field = tab.Fields[f_it];
if ("Title" in field && "Input" in field && "Required" in field) {
if (typeof field.Title != "string") return triggerError(internal,"wrong type in field title");
if (typeof field.Input != "string") return triggerError(internal,"wrong type in field input");
if (typeof field.Required != "boolean") return triggerError(internal,"wrong type in field required");
if (field.Title == "") return triggerError("El campo " + (f_it + 1) + " del tab " + (t_it + 1) + " necesita un título","empty field title");
if (field.Input == "") return triggerError("El campo " + (f_it + 1) + " del tab " + (t_it + 1) + " necesita un input","empty field input");
} else { return triggerError(internal,"field lacks property") }
}
} else { return triggerError(internal,"tab lacks property") }
}
}
function triggerError(type,log){
let out = "triggerError => \nerror_message = " + type;
if (log) out += "\nlog_message = " + log;
console.log(out);
document.getElementById("ErrorMessage").innerText = type;
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ html {
margin: 0.1%;
}
.Botones:active {
.BotonesActive {
background-color: var(--Color);
border-bottom: none;
height: 6%;
......
......@@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="{{url_for('static',filename='Style/Templates.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='Style/ArmadoDeForm.css')}}">
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
<title>Generador de Formularios</title>
<link rel="icon" href="{{url_for('static',filename='Assets/ICONO ANACSOFT 48 SIN TRASNSF.png')}}" type="image/png">
......@@ -24,6 +25,7 @@
+
</button>
</div>
<p id="ErrorMessage" style="font-weight: bold; text-align: center; color: red;"></p>
<h3 id="ContinuarText">Cuando se encuentre conforme con el formulario presione Continuar</h3>
<button id="ContinuarButton" onclick="ArmarForm( generate(document.getElementById('tabs')) )"> Continuar </button>
</section>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!