Skip to content

Commit

Permalink
Dev: added twig version of group index.
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jan 6, 2017
1 parent 577db98 commit ec34739
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
5 changes: 4 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -303,15 +303,18 @@ public function run($surveyid,$args)
}

//READ TEMPLATES, INSERT DATA AND PRESENT PAGE

/**
* create question index only in SurveyRuntime, not needed elsewhere, add it to GlobalVar : must be always set even if empty
*
*/
if(!$previewquestion && !$previewgrp){
$questionindex = ls\helpers\questionIndexHelper::getInstance()->getIndexButton();
$questionindexmenu = ls\helpers\questionIndexHelper::getInstance()->getIndexLink();
$thissurvey['indexItems'] = ls\helpers\questionIndexHelper::getInstance()->getIndexItems();
}


sendCacheHeaders();
doHeader();

Expand All @@ -321,7 +324,7 @@ public function run($surveyid,$args)
echo "<!-- SurveyRunTimeHelper -->";

$thissurvey['upload_file'] = (isset($upload_file) && $upload_file)?true:false;
$thissurvey['surveyUrl'] = App()->createUrl("/survey/index",array("sid"=>$surveyid));
$thissurvey['surveyUrl'] = App()->createUrl("/survey/index",array("sid"=>$surveyid));
$hiddenfieldnames = $thissurvey['hiddenfieldnames'] = implode("|", $inputnames);


Expand Down
3 changes: 2 additions & 1 deletion templates/default/views/startpage.twig
Expand Up @@ -36,7 +36,8 @@
<ul class="nav navbar-nav navbar-right navbar-action-link">
{{ include('./subviews/save_links.twig') }}
{{ include('./subviews/clearall_links.twig') }}
{QUESTION_INDEX_MENU}
{{ include('./subviews/question_index.twig') }}
{QUESTION_INDEX_MENU} {# Can't remove from now because of the helper solutions... w #}
</ul>
</div>
</div>
Expand Down
41 changes: 41 additions & 0 deletions templates/default/views/subviews/question_index.twig
@@ -0,0 +1,41 @@
{#
Shows the question index
#}

{% if aSurveyInfo.oSurvey.questionindex > 1 %}
{% set indexType = 'full' %}
{% else %}
{% set indexType = 'incremental' %}
{% endif %}

{% if aSurveyInfo.format == 'G' %}
<!-- Question index, group, {{ indexType }} -->
<li class="dropdown ls-index-menu ls-no-js-hidden index-menu-{{ indexType }}">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
{{ "Question index" | t }}
<span class="caret"></span>
</a>

<ul class="dropdown-menu">
{% for step, indexItem in aSurveyInfo.indexItems %}
{% set statusClass = '' %}
{% if attribute(indexItem.stepStatus, 'index-item-unanswered') is defined and attribute(indexItem.stepStatus, 'index-item-unanswered') == true %}
{% set statusClass = statusClass ~ ' bg-warning' %}
{% endif %}
{% if attribute(indexItem.stepStatus, 'index-item-error') is defined and attribute(indexItem.stepStatus, 'index-item-error') == true %}
{% set statusClass = statusClass ~ ' bg-danger' %}
{% endif %}
{% if attribute(indexItem.stepStatus, 'index-item-current') is defined and attribute(indexItem.stepStatus, 'index-item-current') == true %}
{% set statusClass = statusClass ~ ' disabled' %}
{% endif %}


<li class="{{ indexItem.coreClass }} {{ statusClass }}">
<a href='{{ indexItem.url }}' data-limesurvey-submit='{{ indexItem.submit }}'>
{{ indexItem.text }}
</a>
</li>
{% endfor %}
</ul>
</li>
{% endif %}

0 comments on commit ec34739

Please sign in to comment.