-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
100 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = $('<li></li>').append(newForm); | ||
$collectionHolder.append($newFormLi); | ||
addTagFormDeleteLink($newFormLi); | ||
$newFormLi.find('input').first().focus(); | ||
} | ||
|
||
function addTagFormDeleteLink($tagFormLi) { | ||
var $removeFormButton = $('<a href="#" class="deleteFreeField" type="remove-group"><div class="text-danger px-1 " data-toggle="tooltip" title="Lösche Freifeld" data-original-title="Lösche Freifeld">X</div></a>'); | ||
$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}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' %} | ||
<div> | ||
<div> | ||
<div> | ||
<h5>{{ question.label }}</h5> | ||
{% if question.hint is not empty %} | ||
<p>{{ question.hint }}</p> | ||
{% endif %} | ||
<p>{% trans %}question.evaluationValue{% endtrans %}: {{ question.evalValue }}</p> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>{{ question.type }}</th> | ||
</tr> | ||
</thead> | ||
{% for answer in question.answers %} | ||
{% if answer.isCorrect %} | ||
<tr> | ||
<td>{{ answer.label }}</td> | ||
</tr> | ||
{% else %} | ||
<tr> | ||
<td>{{ answer.label }}</td> | ||
</tr> | ||
{% endif %} | ||
{% endfor %} | ||
</table> | ||
</div> | ||
<div> | ||
<a | ||
href="{{ path('question_edit', {'id': question.id}) }}">{% trans from 'general' %}edit{% endtrans %}</a> | ||
<a | ||
href="{{ path('question_delete', {'id': question.id}) }}">{% trans from 'general' %}remove{% endtrans %}</a> | ||
</div> | ||
<div class="dl-wrapper xl:!w-1/2 mb-5"> | ||
<div class="dl-head"> | ||
<h3>{{ question.label }}</h3> | ||
{% if question.hint is not empty %} | ||
<p>{{ question.hint }}</p> | ||
{% endif %} | ||
<p>{% trans %}question.evaluationValue{% endtrans %}: {{ question.evalValue }}</p> | ||
<p>Type: {{ question.type }}</p> | ||
</div> | ||
<div class="dl-content"> | ||
<dl> | ||
{% for answer in question.answers %} | ||
<div> | ||
<dt>{{ answer.label }}</dt> | ||
<dd>{{ answer.isCorrect ? '<span class="material-symbols-outlined">check_circle</span>' }}</dd> | ||
</div> | ||
{% endfor %} | ||
</dl> | ||
</div> | ||
</div> | ||
<div> | ||
<a class="btn" href="{{ path('question_edit', {'id': question.id}) }}">{% trans from 'general' %}edit{% endtrans %}</a> | ||
<a class="btn btn-danger" href="{{ path('question_delete', {'id': question.id}) }}">{% trans from 'general' %}remove{% endtrans %}</a> | ||
</div> | ||
{% endblock %} |