Skip to content

Commit

Permalink
Dev: SurveyGroup, set option for any template, first steps
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Oct 19, 2017
1 parent a7be4ad commit 21998ca
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 61 deletions.
16 changes: 5 additions & 11 deletions application/controllers/admin/SurveysGroupsController.php
Expand Up @@ -64,29 +64,23 @@ public function create()
*/
public function update($id)
{
$model=$this->loadModel($id);
$model = $this->loadModel($id);

// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['SurveysGroups']))
{
if(isset($_POST['SurveysGroups'])){
$model->attributes=$_POST['SurveysGroups'];
if($model->save())
$this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/listsurveys').'#surveygroups');
}

$aData['model'] = $model;
$oSurveySearch = new Survey('search');
$oSurveySearch->gsid = $model->gsid;
$aData['oSurveySearch'] = $oSurveySearch;

$oTemplateOptions = TemplateConfiguration::getInstanceFromSurveyGroup($model->gsid);

$oTemplateOptionsReplacement = TemplateConfiguration::model()->findByPk($oTemplateOptions->id);
$templateOptionPage = $oTemplateOptionsReplacement->optionPage;

$oTemplateOptions = new TemplateConfiguration();
$oTemplateOptions->scenario = 'surveygroup';
$aData['templateOptionsModel'] = $oTemplateOptions;
$aData['templateOptionPage'] = $templateOptionPage;

$this->_renderWrappedTemplate('surveysgroups', 'update', $aData);
}
Expand Down
22 changes: 18 additions & 4 deletions application/models/TemplateConfiguration.php
Expand Up @@ -429,7 +429,13 @@ public function getTypeIcon()
public function getButtons()
{
$sEditorUrl = Yii::app()->getController()->createUrl('admin/templates/sa/view', array("templatename"=>$this->template_name));
$sOptionUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/update', array("id"=>$this->id));
if (App()->getController()->action->id == "surveysgroups"){
$gisd = Yii::app()->request->getQuery('id', null);
$sOptionUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/update', array("id"=>$this->id, "gsid"=>$gisd));
}else{
$sOptionUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/update', array("id"=>$this->id));
}

$sUninstallUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/uninstall/', array("templatename"=>$this->template_name));

$sEditorLink = "<a
Expand Down Expand Up @@ -463,12 +469,20 @@ class='btn btn-default btn-danger'>
</a>";


$sButtons = $sEditorLink.'<br><br>'.$OptionLink;
if (App()->getController()->action->id == "surveysgroups"){
$sButtons = $OptionLink;
}else{
$sButtons = $sEditorLink.'<br><br>'.$OptionLink;

if (!$this->isStandard){
$sButtons .= '<br><br>'.$sUninstallLink ;
if (!$this->isStandard){
$sButtons .= '<br><br>'.$sUninstallLink ;
}
}





return $sButtons;
}

Expand Down
9 changes: 7 additions & 2 deletions application/views/admin/surveysgroups/update.php
Expand Up @@ -17,7 +17,7 @@
)
)
)); ?>

<div class="row">
<ul class="nav nav-tabs" id="surveygrouptabsystem" role="tablist">
<li class="active"><a href="#surveysInThisGroup"><?php eT('Surveys in this group'); ?></a></li>
Expand All @@ -40,7 +40,12 @@
<?php $this->renderPartial('./surveysgroups/_form', array('model'=>$model)); ?>
</div>
<div id="templateSettingsFortThisGroup" class="tab-pane">
<?php $this->renderPartial('./templateoptions/update', array('model'=>$templateOptionsModel, 'templateOptionPage'=>$templateOptionPage)); ?>
<?php
if (is_a($templateOptionsModel, 'TemplateConfiguration')){
// $this->renderPartial('./templateoptions/update', array('model'=>$templateOptionsModel, 'templateOptionPage'=>$templateOptionPage));
$this->renderPartial('./templateoptions/index', array('model'=>$templateOptionsModel, 'bFromSurveyGroup'=>true));
}
?>
</div>
</div>
</div>
Expand Down
86 changes: 49 additions & 37 deletions application/views/admin/templateoptions/index.php
Expand Up @@ -5,18 +5,30 @@
// TODO: rename to template_list.php

?>

<?php
//$bFromSurveyGroup = (isset($bFromSurveyGroup))?$bFromSurveyGroup:false;
$bFromSurveyGroup = ($model->scenario == 'surveygroup')?true:false;
?>

<div class="col-lg-12 list-surveys">

<?php $this->renderPartial('super/fullpagebar_view', array(
'fullpagebar' => array(
'returnbutton'=>array(
'url'=>'index',
'text'=>gT('Close'),
),
)
)); ?>
<?php
if (!$bFromSurveyGroup){
$this->renderPartial('super/fullpagebar_view', array(
'fullpagebar' => array(
'returnbutton'=>array(
'url'=>'index',
'text'=>gT('Close'),
),
)
));
echo '<h3>'.gT('Installed templates:').'</h3>';
}


?>

<h3><?php eT('Installed templates:'); ?></h3>
<div class="row">
<div class="col-sm-12 content-right">

Expand Down Expand Up @@ -75,37 +87,37 @@
</div>
</div>

<?php if (count($model->templatesWithNoDb) > 0):?>
<h3><?php eT('Available Templates:'); ?></h3>
<div class="row">
<div class="col-sm-12 content-right">
<?php if (count($model->templatesWithNoDb) > 0 && !$bFromSurveyGroup):?>
<h3><?php eT('Available Templates:'); ?></h3>
<div class="row">
<div class="col-sm-12 content-right">

<div id="templates_no_db" class="grid-view">
<table class="items table">
<thead>
<tr>
<th><?php eT('Preview'); ?></th><th><?php eT('Folder'); ?></th><th><?php eT('Description'); ?></th><th><?php eT('type'); ?></th><th><?php eT('extends'); ?></th><th></th>
</tr>
</thead>

<tbody>
<?php foreach ($model->templatesWithNoDb as $oTemplate):?>
<?php // echo $oTemplate; ?>
<tr class="odd">
<td class="col-md-1"><?php echo $oTemplate->preview; ?></td>
<td class="col-md-2"><?php echo $oTemplate->sTemplateName; ?></td>
<td class="col-md-3"><?php echo $oTemplate->config->metadatas->description; ?></td>
<td class="col-md-2"><?php eT('XML template');?></td>
<td class="col-md-2"><?php echo $oTemplate->config->metadatas->extends; ?></td>
<td class="col-md-1"><?php echo $oTemplate->buttons; ?></td>
<div id="templates_no_db" class="grid-view">
<table class="items table">
<thead>
<tr>
<th><?php eT('Preview'); ?></th><th><?php eT('Folder'); ?></th><th><?php eT('Description'); ?></th><th><?php eT('type'); ?></th><th><?php eT('extends'); ?></th><th></th>
</tr>
<?php endforeach;?>
</tbody>
</table>
</thead>

<tbody>
<?php foreach ($model->templatesWithNoDb as $oTemplate):?>
<?php // echo $oTemplate; ?>
<tr class="odd">
<td class="col-md-1"><?php echo $oTemplate->preview; ?></td>
<td class="col-md-2"><?php echo $oTemplate->sTemplateName; ?></td>
<td class="col-md-3"><?php echo $oTemplate->config->metadatas->description; ?></td>
<td class="col-md-2"><?php eT('XML template');?></td>
<td class="col-md-2"><?php echo $oTemplate->config->metadatas->extends; ?></td>
<td class="col-md-1"><?php echo $oTemplate->buttons; ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>

</div>

</div>

</div>
</div>
<?php endif;?>
<?php endif;?>
</div>
13 changes: 6 additions & 7 deletions application/views/admin/templateoptions/update.php
Expand Up @@ -6,7 +6,6 @@




<div class="container">
<div class="row h1"><?php eT('Update TemplateOptions for '); echo '<em>' . $model->template_name . '</em>'; ?></div>
<!-- Using bootstrap tabs to differ between just hte options and advanced direct settings -->
Expand Down Expand Up @@ -53,19 +52,19 @@
?>
</div>
<div role="tabpanel" class="tab-pane" id="advanced">
<?php
<?php
$actionBaseUrl = 'admin/templateoptions/sa/update/';
$actionUrlArray = array('id' => $model->id);

if($model->sid) {
unset($actionUrlArray['id']);
$actionUrlArray['sid'] = $model->sid;
unset($actionUrlArray['id']);
$actionUrlArray['sid'] = $model->sid;
$actionUrlArray['surveyd'] = $model->sid;
$actionUrlArray['gsid'] = $model->gsid;
$actionBaseUrl = 'admin/templateoptions/sa/updatesurvey/';
}
if($model->gsid) {
unset($actionUrlArray['id']);
unset($actionUrlArray['id']);
$actionBaseUrl = 'admin/templateoptions/sa/updatesurveygroup/';
$actionUrlArray['gsid'] = $model->gsid;
}
Expand Down Expand Up @@ -153,7 +152,7 @@
if($('.action_update_options_string_form').length > 0){
var optionObject = {};
optionObject = JSON.parse($('#TemplateConfiguration_options').val());
$('.action_update_options_string_form').find('.selector_option_value_field').each(function(i,item){
var itemValue = optionObject[$(item).attr('name')];
$(item).val(itemValue);
Expand Down

0 comments on commit 21998ca

Please sign in to comment.