diff --git a/assets/app.js b/assets/app.js index 0252c349..7b73864d 100644 --- a/assets/app.js +++ b/assets/app.js @@ -7,4 +7,12 @@ import './styles/app.css'; import './scripts/tailmater.js'; import './scripts/datatables.js'; -document.getElementById('snackbar-trigger')?.click(); \ No newline at end of file +import $ from 'jquery'; +global.$ = global.jQuery = $; +import {initFreeFields} from "./scripts/freeField"; + +document.getElementById('snackbar-trigger')?.click(); + +$(document).ready(function() { + initFreeFields(); +}); \ No newline at end of file diff --git a/assets/scripts/freeField.js b/assets/scripts/freeField.js new file mode 100644 index 00000000..e1edb7a5 --- /dev/null +++ b/assets/scripts/freeField.js @@ -0,0 +1,39 @@ +import $ from "jquery"; + +function addFormToCollection($collectionHolderClass) { + var $collectionHolder = $('.' + $collectionHolderClass); + var prototype = $collectionHolder.data('prototype'); + var index = $collectionHolder.data('index'); + var newForm = prototype; + newForm = newForm.replace(/__name__/g, index); + $collectionHolder.data('index', index + 1); + //console.log('index', index); + let $newFormLi = $('
  • ').append(newForm); + $collectionHolder.append($newFormLi); + addTagFormDeleteLink($newFormLi); + $newFormLi.find('input').first().focus(); +} + +function addTagFormDeleteLink($tagFormLi) { + var $removeFormButton = $('
    X
    '); + $tagFormLi.append($removeFormButton); + $removeFormButton.on('click', function(e) { + e.preventDefault(); + $tagFormLi.remove(); + }); +} + +function initFreeFields(){ + $('#add_item_link').off('click') + var $groupsCollectionHolder = $('ul.freeField'); + $groupsCollectionHolder.find('li').each(function() { + addTagFormDeleteLink($(this)); + }); + $groupsCollectionHolder.data('index', $groupsCollectionHolder.find('input').length); + $('#add_item_link').on('click', function(e) { + var $collectionHolderClass = $(e.currentTarget).data('collectionHolderClass'); + addFormToCollection($collectionHolderClass); + }) +}; + +export {initFreeFields}; \ No newline at end of file diff --git a/assets/styles/tailmater.css b/assets/styles/tailmater.css index 8b4eedbc..b253dbd8 100644 --- a/assets/styles/tailmater.css +++ b/assets/styles/tailmater.css @@ -714,6 +714,10 @@ td, th { .shadow-material { box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15); } + + .text-muted { + @apply text-gray-400; + } } html, body { @@ -822,6 +826,10 @@ footer > ul > li { } } +form > fieldset .btn { + @apply !bg-surface-200; +} + form > fieldset { @apply card-filled !bg-surface-100 dark:bg-surfacedark-300 w-full max-w-2xl mb-5; } @@ -905,12 +913,6 @@ hr { @apply text-red-600 hover:text-red-800; } -@layer base { - .text-muted { - @apply text-gray-400; - } -} - main > article > #content a { @apply text-primary-600 hover:underline; } @@ -1070,3 +1072,7 @@ ul.stacked-list > li > div:first-child > p:nth-child(2) { ul.stacked-list > li > div:last-child { @apply shrink-0 sm:flex sm:flex-col sm:items-end text-sm; } + +ul.dynamic-list > li { + @apply flex pb-3 gap-x-5; +} \ No newline at end of file diff --git a/src/Controller/QuestionController.php b/src/Controller/QuestionController.php index cec5d437..fcbe27fd 100644 --- a/src/Controller/QuestionController.php +++ b/src/Controller/QuestionController.php @@ -130,7 +130,7 @@ public function delete( $this->em->remove($question); $this->em->flush(); - return $this->redirectToRoute('question'); + return $this->redirectToRoute('akademie_admin'); } private function handleForm(FormInterface $form, ?Question $originalQuestion = null): ?Question diff --git a/src/Form/Type/Questionnaire/QuestionnaireType.php b/src/Form/Type/Questionnaire/QuestionnaireType.php index 9c1ae278..003fa0e8 100644 --- a/src/Form/Type/Questionnaire/QuestionnaireType.php +++ b/src/Form/Type/Questionnaire/QuestionnaireType.php @@ -46,7 +46,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void SubmitType::class, [ 'attr' => [ - 'class' => 'btn btn-primary' + 'class' => 'btn' ], 'label' => 'save.word', 'translation_domain' => 'general', diff --git a/templates/questionnaire/question/create.html.twig b/templates/questionnaire/question/create.html.twig index b34557e8..453b1f0b 100644 --- a/templates/questionnaire/question/create.html.twig +++ b/templates/questionnaire/question/create.html.twig @@ -20,33 +20,26 @@ {% if error %}
    {% trans %}question.error{% endtrans %}
    {% endif %} - - -
    - Answers - {{ form_row(form.answers) }} -
    {{ form_row(form.save, {row_attr: {class: 'form-buttons'}}) }} - + {{ form_end(form) }} {% endblock %} \ No newline at end of file diff --git a/templates/questionnaire/question/details.html.twig b/templates/questionnaire/question/details.html.twig index d5da0d32..c9c94304 100644 --- a/templates/questionnaire/question/details.html.twig +++ b/templates/questionnaire/question/details.html.twig @@ -1,40 +1,34 @@ {% extends 'base.html.twig' %} {% trans_default_domain 'questionnaire' %} + +{% block title %} + {% trans %}question.show{% endtrans %} +{% endblock %} + {% block body %} {% trans_default_domain 'questionnaire' %} -
    -
    -
    -
    {{ question.label }}
    - {% if question.hint is not empty %} -

    {{ question.hint }}

    - {% endif %} -

    {% trans %}question.evaluationValue{% endtrans %}: {{ question.evalValue }}

    - - - - - - - {% for answer in question.answers %} - {% if answer.isCorrect %} - - - - {% else %} - - - - {% endif %} - {% endfor %} -
    {{ question.type }}
    {{ answer.label }}
    {{ answer.label }}
    -
    -
    - {% trans from 'general' %}edit{% endtrans %} - {% trans from 'general' %}remove{% endtrans %} -
    +
    +
    +

    {{ question.label }}

    + {% if question.hint is not empty %} +

    {{ question.hint }}

    + {% endif %} +

    {% trans %}question.evaluationValue{% endtrans %}: {{ question.evalValue }}

    +

    Type: {{ question.type }}

    +
    +
    +
    + {% for answer in question.answers %} +
    +
    {{ answer.label }}
    +
    {{ answer.isCorrect ? 'check_circle' }}
    +
    + {% endfor %} +
    +
    + {% trans from 'general' %}edit{% endtrans %} + {% trans from 'general' %}remove{% endtrans %} +
    {% endblock %} \ No newline at end of file