Spaces:
Running
Running
Se agrega campo para el estilo de palabras en formulario basico
Browse files
tecnicas/forms/sesion_basic_form.py
CHANGED
|
@@ -2,6 +2,7 @@ from django import forms
|
|
| 2 |
|
| 3 |
from ..models import TipoEscala
|
| 4 |
from ..models import TipoTecnica
|
|
|
|
| 5 |
|
| 6 |
class SesionBasicForm(forms.Form):
|
| 7 |
id_tecnica = forms.IntegerField(widget=forms.HiddenInput())
|
|
@@ -26,6 +27,10 @@ class SesionBasicForm(forms.Form):
|
|
| 26 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
| 27 |
"placeholder": "Solo números"
|
| 28 |
}), required=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
tipo_escala = forms.ModelChoiceField(queryset=TipoEscala.objects.all(), widget=forms.RadioSelect(attrs={
|
| 31 |
"class":"uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
|
|
|
| 2 |
|
| 3 |
from ..models import TipoEscala
|
| 4 |
from ..models import TipoTecnica
|
| 5 |
+
from ..models import EstiloPalabra
|
| 6 |
|
| 7 |
class SesionBasicForm(forms.Form):
|
| 8 |
id_tecnica = forms.IntegerField(widget=forms.HiddenInput())
|
|
|
|
| 27 |
"class": "bg-gray-200 p-1 border-b-1 text-center w-full",
|
| 28 |
"placeholder": "Solo números"
|
| 29 |
}), required=True)
|
| 30 |
+
|
| 31 |
+
estilo_palabras = forms.ModelChoiceField(queryset=EstiloPalabra.objects.all(), widget=forms.RadioSelect(attrs={
|
| 32 |
+
"class":"uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
| 33 |
+
}), required=True, initial=EstiloPalabra.objects.first())
|
| 34 |
|
| 35 |
tipo_escala = forms.ModelChoiceField(queryset=TipoEscala.objects.all(), widget=forms.RadioSelect(attrs={
|
| 36 |
"class":"uppercase text-lg tracking-wider font-medium p-2 px-4 active:px-5 transition-all rounded-xl bg-blue-500 text-white",
|
tecnicas/static/js/panel-basic.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
| 1 |
const descriptons = {
|
| 2 |
estructurada: ["Establece número de segmentos:", "Puede ser 5, 7 o 9"],
|
| 3 |
continua: ["Establece la longitud de la escala:", "Puede ser 9, 12 o 15"],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
};
|
| 5 |
|
| 6 |
-
let
|
|
|
|
| 7 |
|
| 8 |
-
let
|
| 9 |
-
let
|
| 10 |
|
| 11 |
initPanel();
|
| 12 |
|
|
@@ -15,31 +20,42 @@ function initPanel() {
|
|
| 15 |
}
|
| 16 |
|
| 17 |
function initRadios() {
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
.
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
iSize.placeholder = descriptons["estructurada"][1];
|
| 30 |
-
|
| 31 |
-
for (let i = 0; i < labels.length; i++) {
|
| 32 |
-
labels
|
| 33 |
-
.item(i)
|
| 34 |
-
.getElementsByTagName("input")[0]
|
| 35 |
-
.addEventListener("change", () => {
|
| 36 |
-
showDescriptionTamanoScale(labels.item(i));
|
| 37 |
-
});
|
| 38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
function showDescriptionTamanoScale(label) {
|
| 42 |
const text = label.textContent.trim();
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 45 |
}
|
|
|
|
| 1 |
const descriptons = {
|
| 2 |
estructurada: ["Establece número de segmentos:", "Puede ser 5, 7 o 9"],
|
| 3 |
continua: ["Establece la longitud de la escala:", "Puede ser 9, 12 o 15"],
|
| 4 |
+
atributos:
|
| 5 |
+
"Con el estilo atributos elijes las palabras para evaluar los productos",
|
| 6 |
+
vocabulario:
|
| 7 |
+
"Los vocabularios son un conjunto de palabras especificas para evaluar aspectos de un producto.",
|
| 8 |
};
|
| 9 |
|
| 10 |
+
let inputsScale;
|
| 11 |
+
let inputTamano;
|
| 12 |
|
| 13 |
+
let inputsStyle;
|
| 14 |
+
let helpStyle;
|
| 15 |
|
| 16 |
initPanel();
|
| 17 |
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
function initRadios() {
|
| 23 |
+
inputsScale = document.getElementsByName("tipo_escala");
|
| 24 |
+
inputTamano = document.getElementsByName("tamano_escala").item(0);
|
| 25 |
+
|
| 26 |
+
for (let index = 0; index < inputsScale.length; index++) {
|
| 27 |
+
let parent = inputsScale.item(index).parentElement;
|
| 28 |
+
parent.addEventListener("click", () => {
|
| 29 |
+
showDescriptionTamanoScale(parent);
|
| 30 |
+
});
|
| 31 |
+
if (inputsScale.item(index).checked) {
|
| 32 |
+
showDescriptionTamanoScale(parent);
|
| 33 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
+
|
| 36 |
+
labelsStyle = document.getElementsByClassName("ct-radio-estilo");
|
| 37 |
+
helpStyle = document.getElementsByClassName("ct-ayuda-estilo")[0];
|
| 38 |
+
inputsStyle = document.getElementsByName("estilo_palabras");
|
| 39 |
+
|
| 40 |
+
for (let index = 0; index < inputsStyle.length; index++) {
|
| 41 |
+
let parent = inputsStyle.item(index).parentElement;
|
| 42 |
+
parent.addEventListener("click", () => {
|
| 43 |
+
showDescriptionStyle(parent);
|
| 44 |
+
});
|
| 45 |
+
if (inputsStyle.item(index).checked) {
|
| 46 |
+
showDescriptionStyle(parent);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function showDescriptionStyle(label) {
|
| 52 |
+
const text = label.textContent.trim();
|
| 53 |
+
helpStyle.textContent = descriptons[text];
|
| 54 |
}
|
| 55 |
|
| 56 |
function showDescriptionTamanoScale(label) {
|
| 57 |
const text = label.textContent.trim();
|
| 58 |
+
let parent = inputTamano.parentElement;
|
| 59 |
+
parent.getElementsByTagName("p").textContent = descriptons[text][0];
|
| 60 |
+
inputTamano.placeholder = descriptons[text][1];
|
| 61 |
}
|
tecnicas/templates/tecnicas/configuracion-panel-basic.html
CHANGED
|
@@ -54,6 +54,22 @@
|
|
| 54 |
</section>
|
| 55 |
</article>
|
| 56 |
<hr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
<article class="cs-escalas-radio flex flex-col gap-4">
|
| 58 |
<h2 class="text-2xl font-bold">Selecciona una escala</h2>
|
| 59 |
<section class="flex flex-row justify-around flex-wrap">
|
|
|
|
| 54 |
</section>
|
| 55 |
</article>
|
| 56 |
<hr>
|
| 57 |
+
<article class="cs-escalas-radio flex flex-col gap-4">
|
| 58 |
+
<h2 class="text-2xl font-bold">Selecciona estilo para las palabras</h2>
|
| 59 |
+
<section class="flex flex-row justify-around flex-wrap">
|
| 60 |
+
{% for escala in form_sesion.estilo_palabras %}
|
| 61 |
+
<label for="{{escala.id_for_label}}"
|
| 62 |
+
class="ct-radio-estilo uppercase text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 border-blue-800 transition-all rounded-xl bg-blue-500 text-white w-fit">
|
| 63 |
+
{{ escala.tag }}
|
| 64 |
+
{{ escala.choice_label }}
|
| 65 |
+
</label>
|
| 66 |
+
{% endfor %}
|
| 67 |
+
</section>
|
| 68 |
+
<p
|
| 69 |
+
class="ct-ayuda-estilo text-lg font-bold tracking-wide bg-gray-600 text-white text-center py-1 px-4 rounded-xl">
|
| 70 |
+
</p>
|
| 71 |
+
</article>
|
| 72 |
+
<hr>
|
| 73 |
<article class="cs-escalas-radio flex flex-col gap-4">
|
| 74 |
<h2 class="text-2xl font-bold">Selecciona una escala</h2>
|
| 75 |
<section class="flex flex-row justify-around flex-wrap">
|
tecnicas/views/configuration_panel_basic.py
CHANGED
|
@@ -13,11 +13,11 @@ def configuracionPanelBasic(req: HttpRequest):
|
|
| 13 |
values = {}
|
| 14 |
|
| 15 |
for name, value in form.cleaned_data.items():
|
| 16 |
-
if
|
| 17 |
-
values[name] = value
|
| 18 |
-
else:
|
| 19 |
values[name] = value.id
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
req.session['form_basic'] = values
|
| 22 |
return redirect(reverse("cata_system:panel_configuracion_tags"))
|
| 23 |
except KeyError:
|
|
|
|
| 13 |
values = {}
|
| 14 |
|
| 15 |
for name, value in form.cleaned_data.items():
|
| 16 |
+
if name == "estilo_palabras" or name == "tipo_escala":
|
|
|
|
|
|
|
| 17 |
values[name] = value.id
|
| 18 |
+
else:
|
| 19 |
+
values[name] = value
|
| 20 |
+
|
| 21 |
req.session['form_basic'] = values
|
| 22 |
return redirect(reverse("cata_system:panel_configuracion_tags"))
|
| 23 |
except KeyError:
|