cec-nuxt-lib 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/cecCanvas.vue +102 -53
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -380,51 +380,66 @@ const makeAddressItem = (prop, text) => {
|
|
|
380
380
|
const makeQuestions = (data, id) => {
|
|
381
381
|
data.question.forEach((qu, j) => {
|
|
382
382
|
qu.stack = [0];
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
383
|
+
if (qu.responseForQuestionComponent.length < 4) {
|
|
384
|
+
qu.buttons = qu.responseForQuestionComponent.reduce((acc, r, i) => {
|
|
385
|
+
return (
|
|
386
|
+
acc +
|
|
387
|
+
`<div class="col w-auto ps-0 pe-3">
|
|
387
388
|
<button
|
|
388
389
|
type="button"
|
|
389
|
-
id="${id}_${j}_${i}"
|
|
390
|
+
id="${data.title}_${qu.question.replace('?', '').replace(/\W/g, '-')}_${r.buttonText.replace(/\W/g, '-')}_${id}_${j}_${i}"
|
|
390
391
|
class="cec-button question-btns"
|
|
391
392
|
>
|
|
392
393
|
${r.buttonText}
|
|
393
394
|
</button>
|
|
394
395
|
</div>`
|
|
396
|
+
);
|
|
397
|
+
}, '');
|
|
398
|
+
} else {
|
|
399
|
+
qu.select = qu.responseForQuestionComponent.reduce(
|
|
400
|
+
(acc, r) => {
|
|
401
|
+
return `${acc}<option value="${r.buttonText}">${r.buttonText}</option>`;
|
|
402
|
+
},
|
|
403
|
+
`<select class="question-select" name="${id}_${j}" id="${data.title.replace(/\W/g, '-')}_${qu.question.trim().replace('?', '').replace(/\W/g, '-')}_select_${id}_${j}">`
|
|
395
404
|
);
|
|
396
|
-
|
|
405
|
+
qu.select += '</select>';
|
|
406
|
+
}
|
|
397
407
|
questions.value.push({ id: id, question: data.question, stack: [0] });
|
|
398
408
|
});
|
|
399
409
|
|
|
400
|
-
let
|
|
410
|
+
let inner = data.question[0].select
|
|
411
|
+
? `
|
|
412
|
+
<div id="${id}_buttons">${data.question[0].select}</div>
|
|
413
|
+
`
|
|
414
|
+
: `
|
|
415
|
+
<div class="row row-cols-auto btns-div" id="${id}_buttons">
|
|
416
|
+
${data.question[0].buttons}
|
|
417
|
+
</div>`;
|
|
401
418
|
return `
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
${buttons}
|
|
419
|
+
<div class="mt-3 questions">
|
|
420
|
+
<fieldset class="p-1 mb-3">
|
|
421
|
+
<legend>${data.entryTitle}</legend>
|
|
422
|
+
<div class="ps-2 question align-items-middle row g-0">
|
|
423
|
+
<div class="mb-3" id="${id}_display">${data.question[0].question}
|
|
424
|
+
</div>
|
|
425
|
+
${inner}
|
|
410
426
|
</div>
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
</
|
|
426
|
-
</
|
|
427
|
-
</div>`;
|
|
427
|
+
<button
|
|
428
|
+
type="button"
|
|
429
|
+
class="mt-4 btn btn-light previous"
|
|
430
|
+
id="${id}_prev"
|
|
431
|
+
>
|
|
432
|
+
Previous question
|
|
433
|
+
</button>
|
|
434
|
+
<button
|
|
435
|
+
type="button"
|
|
436
|
+
class="mt-4 btn btn-light reset"
|
|
437
|
+
id="${id}_reset"
|
|
438
|
+
>
|
|
439
|
+
Restart
|
|
440
|
+
</button>
|
|
441
|
+
</fieldset>
|
|
442
|
+
</div>`;
|
|
428
443
|
};
|
|
429
444
|
|
|
430
445
|
const processTime = (str) => {
|
|
@@ -744,6 +759,47 @@ canvasHtml = canvasHtml.replace(
|
|
|
744
759
|
);
|
|
745
760
|
|
|
746
761
|
onMounted(() => {
|
|
762
|
+
const getQuInfo = (b) => {
|
|
763
|
+
let temp = b.id.split('_');
|
|
764
|
+
let id = temp[3];
|
|
765
|
+
let q = questions.value.find((e) => e.id === id);
|
|
766
|
+
if (q) {
|
|
767
|
+
let myQ = q.question[parseInt(temp[4])];
|
|
768
|
+
if (temp.length === 6) {
|
|
769
|
+
let resp = myQ.responseForQuestionComponent[parseInt(temp[5])];
|
|
770
|
+
let content = resp.display;
|
|
771
|
+
let target = resp.id;
|
|
772
|
+
return { content, target, id };
|
|
773
|
+
} else {
|
|
774
|
+
return { q: myQ, id: b.id, divId: id };
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
const setSelectBehaviour = (e) => {
|
|
780
|
+
let { q, id, divId } = getQuInfo(e);
|
|
781
|
+
let value = document.getElementById(id).value;
|
|
782
|
+
let resp = q.responseForQuestionComponent.find(
|
|
783
|
+
(r) => r.buttonText === value
|
|
784
|
+
);
|
|
785
|
+
let content = resp.display;
|
|
786
|
+
let target = resp.id;
|
|
787
|
+
if (content) {
|
|
788
|
+
display(divId, content);
|
|
789
|
+
} else if (target) {
|
|
790
|
+
goto(divId, target);
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
const setOnClick = (b) => {
|
|
795
|
+
let { content, target, id } = getQuInfo(b);
|
|
796
|
+
if (content) {
|
|
797
|
+
b.onclick = () => display(id, content);
|
|
798
|
+
} else if (id) {
|
|
799
|
+
b.onclick = () => goto(id, target);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
|
|
747
803
|
// Expand all buttons
|
|
748
804
|
const expandAll = (btn) => {
|
|
749
805
|
btn.addEventListener('click', (e) => {
|
|
@@ -758,6 +814,7 @@ onMounted(() => {
|
|
|
758
814
|
expandAll(b);
|
|
759
815
|
});
|
|
760
816
|
|
|
817
|
+
// Forms title & path
|
|
761
818
|
let forms = Array.from(document.querySelectorAll('a')).filter(
|
|
762
819
|
(a) =>
|
|
763
820
|
regex.test(a.href) &&
|
|
@@ -771,25 +828,17 @@ onMounted(() => {
|
|
|
771
828
|
});
|
|
772
829
|
|
|
773
830
|
const setUpListeners = () => {
|
|
831
|
+
let qSelects = Array.from(
|
|
832
|
+
document.getElementsByClassName('question-select')
|
|
833
|
+
);
|
|
834
|
+
qSelects.forEach((s) => {
|
|
835
|
+
s.onchange = function (e) {
|
|
836
|
+
setSelectBehaviour(e.target);
|
|
837
|
+
};
|
|
838
|
+
});
|
|
774
839
|
let qBtns = Array.from(document.getElementsByClassName('question-btns'));
|
|
775
840
|
qBtns.forEach((b) => {
|
|
776
|
-
|
|
777
|
-
let id = temp[0];
|
|
778
|
-
let qInd = parseInt(temp[1]);
|
|
779
|
-
let rInd = parseInt(temp[2]);
|
|
780
|
-
let q = questions.value.find((e) => e.id === id);
|
|
781
|
-
if (q) {
|
|
782
|
-
let content =
|
|
783
|
-
q.question[qInd].responseForQuestionComponent[rInd].display;
|
|
784
|
-
let target = q.question[qInd].responseForQuestionComponent[rInd].id;
|
|
785
|
-
if (!b.onclick) {
|
|
786
|
-
if (content) {
|
|
787
|
-
b.onclick = () => display(id, content);
|
|
788
|
-
} else {
|
|
789
|
-
b.onclick = () => goto(id, target);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}
|
|
841
|
+
setOnClick(b);
|
|
793
842
|
});
|
|
794
843
|
};
|
|
795
844
|
|
|
@@ -800,13 +849,14 @@ onMounted(() => {
|
|
|
800
849
|
}
|
|
801
850
|
let q = qTop.question[index];
|
|
802
851
|
document.getElementById(id + '_display').innerHTML = q.question;
|
|
803
|
-
document.getElementById(id + '_buttons').innerHTML = q.buttons;
|
|
852
|
+
document.getElementById(id + '_buttons').innerHTML = q.buttons || q.select;
|
|
804
853
|
setUpListeners();
|
|
805
854
|
};
|
|
806
855
|
|
|
807
856
|
const display = (id, display) => {
|
|
857
|
+
console.log();
|
|
808
858
|
document.getElementById(id + '_display').innerHTML = display;
|
|
809
|
-
document.getElementById(id + '_buttons').innerHTML = '
|
|
859
|
+
document.getElementById(id + '_buttons').innerHTML = '';
|
|
810
860
|
};
|
|
811
861
|
|
|
812
862
|
const prev = (id) => {
|
|
@@ -838,7 +888,6 @@ onMounted(() => {
|
|
|
838
888
|
pb.onclick = () => prev(id);
|
|
839
889
|
}
|
|
840
890
|
});
|
|
841
|
-
|
|
842
891
|
setUpListeners();
|
|
843
892
|
});
|
|
844
893
|
</script>
|
|
@@ -847,5 +896,5 @@ onMounted(() => {
|
|
|
847
896
|
<div v-html="canvasHtml"></div>
|
|
848
897
|
</template>
|
|
849
898
|
<style type="text/css" scoped>
|
|
850
|
-
:deep(fieldset){border:1px solid #000}:deep(legend){float:none;font-size:1.5rem;margin-left:20px;width:auto}:deep(button.carousel-control-prev:focus,button.carousel-control-next:focus){border:4px solid #000!important}:deep(.icon-wrapper){background-color:#000;border-radius:10px;padding-top:.5rem;width:50px}:deep(.carousel-indicators){margin-bottom:.5rem}:deep(.carousel-indicators [data-bs-target].active){color:blue;font-weight:600}:deep(.carousel-indicators [data-bs-target]){background-clip:unset;background-color:#fff;border-radius:10px;cursor:pointer;height:unset;margin-bottom:0;margin-left:3px;margin-right:3px;opacity:.7;text-indent:unset;transition:opacity .6s ease;width:40px}@media (min-width:769px){:deep(#overlay){border-radius:10px!important}}@media (max-width:768px){:deep(#overlay){border-radius:none}}
|
|
899
|
+
:deep(select){font-size:1.2rem;max-width:20rem}:deep(fieldset){border:1px solid #000}:deep(legend){float:none;font-size:1.5rem;margin-left:20px;width:auto}:deep(button.carousel-control-prev:focus,button.carousel-control-next:focus){border:4px solid #000!important}:deep(.icon-wrapper){background-color:#000;border-radius:10px;padding-top:.5rem;width:50px}:deep(.carousel-indicators){margin-bottom:.5rem}:deep(.carousel-indicators [data-bs-target].active){color:blue;font-weight:600}:deep(.carousel-indicators [data-bs-target]){background-clip:unset;background-color:#fff;border-radius:10px;cursor:pointer;height:unset;margin-bottom:0;margin-left:3px;margin-right:3px;opacity:.7;text-indent:unset;transition:opacity .6s ease;width:40px}@media (min-width:769px){:deep(#overlay){border-radius:10px!important}}@media (max-width:768px){:deep(#overlay){border-radius:none}}
|
|
851
900
|
</style>
|
package/package.json
CHANGED