Skip to content

Commit

Permalink
Dev: fixed template survey options
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jul 26, 2017
1 parent 8822acc commit e64723d
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 19 deletions.
57 changes: 47 additions & 10 deletions application/controllers/admin/templateoptions.php
Expand Up @@ -66,6 +66,29 @@ public function create()
));
}


private function _updateCommon($model,$sid=null){

$templateOptionPage = $model->optionPage;

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

yii::app()->clientScript->registerPackage('bootstrap-switch');
$aData = array(
'model'=>$model,
'templateOptionPage' => $templateOptionPage
);
if($sid !== null){
$aData['surveyid'] = $sid;
$aData['title_bar']['title'] = gT("Survey template options");
$aData['subaction'] = gT("Survey template options");
}

// TODO: twig file from template folder
$this->_renderWrappedTemplate('templateoptions', 'update', $aData);
}

/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
Expand All @@ -77,25 +100,39 @@ public function update($id)
Yii::app()->setFlashMessage(gT('Access denied!'),'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/templateoptions"));
}

$model = $this->loadModel($id);

$templateOptionPage = $model->optionPage;

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

if(isset($_POST['TemplateConfiguration'])){
$model->attributes=$_POST['TemplateConfiguration'];
if($model->save())
$this->getController()->redirect(array('admin/templateoptions/sa/update/id/'.$model->id));
}

yii::app()->clientScript->registerPackage('bootstrap-switch');
// TODO: twig file from template folder
$this->_renderWrappedTemplate('templateoptions', 'update', array(
'model'=>$model, 'templateOptionPage' => $templateOptionPage));
$this->_updateCommon($model);

}

/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function updatesurvey($sid)
{
if (! Permission::model()->hasGlobalPermission('templates', 'update')){
Yii::app()->setFlashMessage(gT('Access denied!'),'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/templateoptions/sa/updatesurvey",['surveyid'=>$sid,'sid'=>$sid]));
}

$model = Template::getTemplateConfiguration(null, $sid);

if(isset($_POST['TemplateConfiguration'])){
$model->attributes=$_POST['TemplateConfiguration'];
if($model->save())
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/templateoptions/sa/updatesurvey",['surveyid'=>$sid,'sid'=>$sid]));
}

$this->_updateCommon($model, $sid);
}

/**
Expand Down
1 change: 1 addition & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -343,6 +343,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oTransaction->commit();
}


}
catch(Exception $e)
{
Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Expand Up @@ -621,7 +621,7 @@ private function _createSurveymenuArray($oSurveyMenuObjects)
$aEntry['link'] = $oDataAttribute->linkCreator();
$aEntry['link_external'] = $oDataAttribute->linkExternal;
$aEntry['debugData'] = $oDataAttribute->attributes;

$aEntry['pjax'] = $oDataAttribute->pjaxed;
$entries[$aEntry['id']] = $aEntry;
}
$aResultCollected[$oSurveyMenuObject->id] = [
Expand Down
2 changes: 2 additions & 0 deletions application/models/SurveymenuEntryData.php
Expand Up @@ -9,6 +9,7 @@ class SurveymenuEntryData extends CFormModel {
public $linkExternal = false;
public $surveyid = 0;
public $menuEntry = null;
public $pjaxed = true;
public $isActive = null;

public function apply($menuEntry, $surveyid){
Expand All @@ -35,6 +36,7 @@ private function _parseDataAttribute(){

$this->isActive = $this->_recursiveIssetWithDefault($this->rawData , array('render','isActive'), 0, $this->isActive);
$this->linkExternal = $this->_recursiveIssetWithDefault($this->rawData , array('render', 'link','external'), 0, $this->linkExternal);
$this->pjaxed = $this->_recursiveIssetWithDefault($this->rawData , array('render', 'link','pjaxed'), 0, $this->pjaxed);
$alinkData = $this->_recursiveIssetWithDefault($this->rawData , array('render', 'link','data'), 0, $this->linkData);

foreach($alinkData as $key => $value){
Expand Down
7 changes: 5 additions & 2 deletions application/models/TemplateConfiguration.php
Expand Up @@ -114,10 +114,13 @@ public function search()

$criteria=new CDbCriteria;

//Don't show surveyspecifi settings on the overview
$criteria->addCondition('sid IS NULL');
$criteria->addCondition('gsid IS NULL');


$criteria->compare('id',$this->id);
$criteria->compare('templates_name',$this->templates_name,true);
$criteria->compare('sid',$this->sid);
$criteria->compare('gsid',$this->gsid);
$criteria->compare('files_css',$this->files_css,true);
$criteria->compare('files_js',$this->files_js,true);
$criteria->compare('files_print_css',$this->files_print_css,true);
Expand Down
9 changes: 7 additions & 2 deletions assets/packages/adminpanel/build/lsadminpanel.js
Expand Up @@ -29794,6 +29794,12 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
},
debugOut(obj) {
return JSON.stringify(obj);
},
getLinkClass(menuItem) {
let classes = "ls-flex-row nowrap align-item-center align-content-center ";
classes += menuItem.pjax ? 'pjax' : '';
classes += menuItem.menu_class;
return classes;
}
},
created() {
Expand Down Expand Up @@ -29870,7 +29876,7 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
}
}
}, [_c('a', {
staticClass: "ls-flex-row nowrap align-item-center align-content-center pjax",
class: _vm.getLinkClass(menuItem),
attrs: {
"href": menuItem.link,
"title": menuItem.menu_description,
Expand Down Expand Up @@ -30908,7 +30914,6 @@ const getAppState = function(userid){
state.pjax = new __WEBPACK_IMPORTED_MODULE_4_pjax___default.a({
elements: "a.pjax", // default is "a[href], form[action]"
selectors: [
'#YII_RENDER_BODY_SCRIPTS',
'#pjax-content',
'#breadcrumb-container'
]
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminpanel/build/lsadminpanel.js.map

Large diffs are not rendered by default.

Expand Up @@ -48,6 +48,12 @@ export default {
},
debugOut(obj){
return JSON.stringify(obj);
},
getLinkClass(menuItem){
let classes = "ls-flex-row nowrap align-item-center align-content-center ";
classes += (menuItem.pjax ? 'pjax' : '');
classes += menuItem.menu_class;
return classes;
}
},
created(){
Expand Down Expand Up @@ -82,7 +88,7 @@ export default {
<submenu v-if="checkIsOpen(submenu)" :menu="submenu"></submenu>
</li>
<li v-for="(menuItem, index) in sortedMenuEntries" class="list-group-item" @click="setActiveMenuItemIndex(menuItem)" v-bind:key="menuItem.id" v-bind:class="$store.state.lastMenuItemOpen==menuItem.id ? 'selected' : '' ">
<a :href="menuItem.link" :title="menuItem.menu_description" data-toggle="tooltip" class="ls-flex-row nowrap align-item-center align-content-center pjax">
<a :href="menuItem.link" :title="menuItem.menu_description" data-toggle="tooltip" :class="getLinkClass(menuItem)">
<div class="ls-space padding all-0" v-bind:class="$store.state.lastMenuItemOpen == menuItem.id ? 'col-sm-10' : 'col-sm-12' ">
<menuicon :icon-type="menuItem.menu_icon_type" :icon="menuItem.menu_icon"></menuicon>
<span v-html="menuItem.menu_title"></span>
Expand Down
1 change: 0 additions & 1 deletion assets/packages/adminpanel/src/store/vuex-store.js
Expand Up @@ -122,7 +122,6 @@ const getAppState = function(userid){
state.pjax = new Pjax({
elements: "a.pjax", // default is "a[href], form[action]"
selectors: [
'#YII_RENDER_BODY_SCRIPTS',
'#pjax-content',
'#breadcrumb-container'
]
Expand Down
1 change: 1 addition & 0 deletions templates/default/options/options.js
Expand Up @@ -71,6 +71,7 @@ var prepare = function(){
return deferred.promise();
};
$(document).on('ready pjax:complete',function(){
$('.simple-template-edit-loading').css('display','block');
prepare().then(function(){
$('.simple-template-edit-loading').remove();
})
Expand Down
2 changes: 1 addition & 1 deletion templates/default/options/options.twig
Expand Up @@ -140,7 +140,7 @@
<option value="css/yeti.css">Yeti</option>
'
%}
<div class="simple-template-edit-loading" style="height:100%;height:100vh;width:100%;width:100vw;position:fixed;left:0;top:0;background:rgb(255,255,255);background:rgba(235,235,235,0.8);z-index:2000;" class="">
<div class="simple-template-edit-loading" style="display:none;height:100%;height:100vh;width:100%;width:100vw;position:fixed;left:0;top:0;background:rgb(255,255,255);background:rgba(235,235,235,0.8);z-index:2000;" class="">
<div style="position:absolute; left:49%;top:35%;" class="text-center"><i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i></div>
</div>
<form class='form form-horizontal action_update_options_string_form' action=''>
Expand Down

0 comments on commit e64723d

Please sign in to comment.