Skip to content

Commit

Permalink
Dev: Database upgrades and more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jul 26, 2017
1 parent 38d3019 commit 428176d
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 103 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@

$config['versionnumber'] = '3.0.0-beta.1'; //The current version of this branch
$config['masterversion'] = '2.62.2'; //The current masters version merged into this branch
$config['dbversionnumber'] = 308;
$config['dbversionnumber'] = 309;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '2900';
Expand Down
Expand Up @@ -98,6 +98,7 @@ public function update($id)
if($model->save()){
$model->id = $model->getPrimaryKey();
$success = true;
SurveymenuEntries::reorderMenu($model->menu_id);
}
}

Expand Down
3 changes: 2 additions & 1 deletion application/controllers/admin/database.php
Expand Up @@ -1234,7 +1234,8 @@ private function _filterEmptyFields(&$oSurvey, $fieldArrayName, $newValue=null){
switch($options['type']){
case 'yesno':
if($newValue != 'Y' && $newValue != 'N')
$newValue = ($newValue=='1') ? 'Y' : 'N';
$newValue = (int) $newValue;
$newValue = ($newValue===1) ? 'Y' : 'N';
break;
case 'Int' :
$newValue = (int) $newValue;
Expand Down
23 changes: 23 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -342,6 +342,29 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>308),"stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Add survey template editing to menu
*/
if ($iOldDBVersion < 309) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->insert('{{surveymenu_entries}}',array_combine(
array(
"menu_id","ordering","name","title","menu_title","menu_description","menu_icon","menu_icon_type",
"menu_link","permission","permission_grade",
"data",
"language","changed_at","changed_by","created_at","created_by"),
array(
1,3,"template_options","Template options","Template options","Edit Template options for this survey","paint-brush","fontawesome",
"admin/templateoptions/sa/updatesurvey","surveysettings","read",
'{"render": {"link": { "pjaxed": false, "data": {"surveyid": ["survey","sid"], "gsid":["survey","gsid"]}}}}',
"en-GB",date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0
)
)
);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>309),"stg_name='DBVersion'");
$oTransaction->commit();
SurveymenuEntries::reorderMenu(1);
}


}
Expand Down
1 change: 1 addition & 0 deletions application/models/Survey.php
Expand Up @@ -627,6 +627,7 @@ private function _createSurveymenuArray($oSurveyMenuObjects)
$aResultCollected[$oSurveyMenuObject->id] = [
"id" => $oSurveyMenuObject->id,
"title" => $oSurveyMenuObject->title,
"ordering" => $oSurveyMenuObject->ordering,
"level" => $oSurveyMenuObject->level,
"description" => $oSurveyMenuObject->description,
"entries" => $entries,
Expand Down
7 changes: 3 additions & 4 deletions application/models/SurveymenuEntries.php
Expand Up @@ -73,19 +73,18 @@ public function relations()
);
}

public function reorderMenu($menuId){
public static function reorderMenu($menuId){
$criteriaItems = new CDbCriteria();
$criteriaItems->addCondition(['menu_id = :menu_id']);
$criteriaItems->order='ordering ASC';
$criteriaItems->params = ['menu_id' => (int) $menuId];
$menuEntriesInMenu = SurveymenuEntries::model()->find(criteriaItems);
$menuEntriesInMenu = SurveymenuEntries::model()->findAll($criteriaItems);

$statistics =
Yii::app()->db->createCommand()->select('MIN(ordering) as lowOrder, MAX(ordering) as highOrder, COUNT(id) as count')
->from('{{surveymenu_entries}}')
->where(['menu_id = :menu_id'],['menu_id' => (int) $menuId])
->queryAll();

->queryRow();
if( ($statistics['lowOrder'] != 1) || ($statistics['highOrder'] != $statistics['count']) ){
$current = 1;
foreach($menuEntriesInMenu as $menuEntry){
Expand Down
10 changes: 5 additions & 5 deletions assets/packages/adminpanel/build/lsadminpanel.js
Expand Up @@ -29562,15 +29562,15 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
computed: {
sortedMenues() {
return __WEBPACK_IMPORTED_MODULE_1_lodash___default.a.orderBy(this.$store.state.sidemenus, a => {
return parseInt(a.order || 999999);
return parseInt(a.ordering || 999999);
}, ['asc']);
}
},
methods: {
sortedMenuEntries(entries) {
const self = this;
let orderedArray = __WEBPACK_IMPORTED_MODULE_1_lodash___default.a.orderBy(entries, a => {
return parseInt(a.order || 999999);
return parseInt(a.ordering || 999999);
}, ['asc']);
return orderedArray;
},
Expand Down Expand Up @@ -29767,7 +29767,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
computed: {
sortedMenuEntries() {
return __WEBPACK_IMPORTED_MODULE_1_lodash___default.a.orderBy(this.menu.entries, a => {
return parseInt(a.order || 999999);
return parseInt(a.ordering || 999999);
}, ['asc']);
}
},
Expand Down Expand Up @@ -30058,15 +30058,15 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
computed: {
sortedMenues() {
return __WEBPACK_IMPORTED_MODULE_1_lodash___default.a.orderBy(this.$store.state.collapsedmenus, a => {
return parseInt(a.order || 999999);
return parseInt(a.ordering || 999999);
}, ['asc']);
}
},
methods: {
sortedMenuEntries(entries) {
const self = this;
let orderedArray = __WEBPACK_IMPORTED_MODULE_1_lodash___default.a.orderBy(entries, a => {
return parseInt(a.order || 999999);
return parseInt(a.ordering || 999999);
}, ['asc']);
return orderedArray;
},
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminpanel/build/lsadminpanel.js.map

Large diffs are not rendered by default.

Expand Up @@ -16,13 +16,13 @@ export default {
},
computed: {
sortedMenues(){
return _.orderBy(this.$store.state.collapsedmenus,(a)=>{return parseInt((a.order || 999999)) }, ['asc']);
return _.orderBy(this.$store.state.collapsedmenus,(a)=>{return parseInt((a.ordering || 999999)) }, ['asc']);
}
},
methods:{
sortedMenuEntries(entries) {
const self = this;
let orderedArray = _.orderBy(entries,(a)=>{return parseInt((a.order || 999999)) }, ['asc']);
let orderedArray = _.orderBy(entries,(a)=>{return parseInt((a.ordering || 999999)) }, ['asc']);
return orderedArray;
},
setActiveMenuIndex(menuItem){
Expand Down
Expand Up @@ -22,13 +22,13 @@ export default {
},
computed: {
sortedMenues(){
return _.orderBy(this.$store.state.sidemenus,(a)=>{return parseInt((a.order || 999999)) }, ['asc']);
return _.orderBy(this.$store.state.sidemenus,(a)=>{return parseInt((a.ordering || 999999)) }, ['asc']);
}
},
methods:{
sortedMenuEntries(entries) {
const self = this;
let orderedArray = _.orderBy(entries,(a)=>{return parseInt((a.order || 999999)) }, ['asc']);
let orderedArray = _.orderBy(entries,(a)=>{return parseInt((a.ordering || 999999)) }, ['asc']);
return orderedArray;
},
setActiveMenuIndex(menuItem){
Expand Down
Expand Up @@ -20,7 +20,7 @@ export default {
},
computed: {
sortedMenuEntries() {
return _.orderBy(this.menu.entries,(a)=>{return parseInt((a.order || 999999)) }, ['asc']);
return _.orderBy(this.menu.entries,(a)=>{return parseInt((a.ordering || 999999)) }, ['asc']);
},
},
methods:{
Expand Down
5 changes: 5 additions & 0 deletions assets/styles-admin/Sea_Green/scripts/save.js
Expand Up @@ -66,6 +66,11 @@ if ($('#save-button').length > 0){
ev.preventDefault();
var $form = getForm(this);
formSubmitting = true;

for(var instanceName in CKEDITOR.instances) {
CKEDITOR.instances[instanceName].updateElement();
}

$form.find('[type="submit"]').first().trigger('click');
});
}
Expand Down

0 comments on commit 428176d

Please sign in to comment.