Skip to content

Commit

Permalink
Fixed issue #13900: Unable to update Manadtory switch widget on Quest…
Browse files Browse the repository at this point in the history
…ion edit
  • Loading branch information
lacrioque committed Jul 26, 2018
1 parent 647d36f commit 7503b52
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
Expand Up @@ -62,6 +62,9 @@
<?php
Yii::app()->getClientScript()->registerScript( "editLocalSettings_submit_".$entryData['name'], "
window.LS.unrenderBootstrapSwitch();
window.LS.renderBootstrapSwitch();
$('#".$entryData['name']."').off('.editLocalsettings');
$('#".$entryData['name']."').on('submit.editLocalsettings', function(e){
Expand Down
12 changes: 6 additions & 6 deletions assets/packages/adminbasics/build/adminbasics.debug.js

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions assets/packages/adminbasics/build/adminbasics.js
Expand Up @@ -17347,9 +17347,8 @@ const adminCoreLSConsole = new ConsoleShim('AdminCore');
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return globalStartUpMethods; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return globalWindowMethods; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return globalOnloadMethods; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return globalStartUpMethods; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return globalWindowMethods; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_lslog__ = __webpack_require__(1);
/**
* Define global setters for LimeSurvey
Expand All @@ -17360,7 +17359,16 @@ const adminCoreLSConsole = new ConsoleShim('AdminCore');
const globalWindowMethods = {
renderBootstrapSwitch : () => {
try{
$('[data-is-bootstrap-switch]').bootstrapSwitch();
if(!$('[data-is-bootstrap-switch]').parent().hasClass('bootstrap-switch-container')) {
$('[data-is-bootstrap-switch]').bootstrapSwitch({
onInit: () => __WEBPACK_IMPORTED_MODULE_0__components_lslog__["a" /* default */].log("BootstrapSwitch Initialized")
});
}
} catch(e) { __WEBPACK_IMPORTED_MODULE_0__components_lslog__["a" /* default */].error(e); }
},
unrenderBootstrapSwitch : () => {
try{
$('[data-is-bootstrap-switch]').bootstrapSwitch('destroy');
} catch(e) { __WEBPACK_IMPORTED_MODULE_0__components_lslog__["a" /* default */].error(e); }
},
validatefilename: (form, strmessage) => {
Expand Down Expand Up @@ -17473,9 +17481,7 @@ const globalStartUpMethods = {
globalWindowMethods.fixAccordionPosition();
}
};
const globalOnloadMethods = () => {
globalWindowMethods.renderBootstrapSwitch();
}




Expand Down Expand Up @@ -17631,7 +17637,7 @@ const onSuccess = (response) => {
// Put HTML into element.
if (response.outputType == 'jsonoutputhtml') {
$('#' + response.target).html(response.html);
__WEBPACK_IMPORTED_MODULE_0__globalMethods__["c" /* globalWindowMethods */].doToolTip();
__WEBPACK_IMPORTED_MODULE_0__globalMethods__["b" /* globalWindowMethods */].doToolTip();
}

// Success popup
Expand Down Expand Up @@ -17789,9 +17795,8 @@ const AdminCore = function(){

const
onLoadRegister = () => {
__WEBPACK_IMPORTED_MODULE_10__parts_globalMethods__["b" /* globalStartUpMethods */].bootstrapping();
__WEBPACK_IMPORTED_MODULE_10__parts_globalMethods__["a" /* globalStartUpMethods */].bootstrapping();
Object(__WEBPACK_IMPORTED_MODULE_8__pages_surveyGrid__["a" /* onExistBinding */])();
appendToLoad(__WEBPACK_IMPORTED_MODULE_10__parts_globalMethods__["a" /* globalOnloadMethods */]);
appendToLoad(__WEBPACK_IMPORTED_MODULE_13__parts_save__["a" /* default */]);
appendToLoad(__WEBPACK_IMPORTED_MODULE_9__parts_confirmationModal__["a" /* default */]);
appendToLoad(__WEBPACK_IMPORTED_MODULE_5__pages_questionEditing__["a" /* default */]);
Expand Down Expand Up @@ -17839,7 +17844,7 @@ const AdminCore = function(){
appendToLoad: appendToLoad
}
};
const LsNameSpace = __WEBPACK_IMPORTED_MODULE_0_lodash___default.a.merge(BaseNameSpace, __WEBPACK_IMPORTED_MODULE_10__parts_globalMethods__["c" /* globalWindowMethods */], __WEBPACK_IMPORTED_MODULE_12__parts_ajaxHelper__, __WEBPACK_IMPORTED_MODULE_11__parts_notifyFader__, __WEBPACK_IMPORTED_MODULE_7__pages_subquestionandanswers__["a" /* subquestionAndAnswersGlobalMethods */], __WEBPACK_IMPORTED_MODULE_17__components_notifications__["a" /* default */]);
const LsNameSpace = __WEBPACK_IMPORTED_MODULE_0_lodash___default.a.merge(BaseNameSpace, __WEBPACK_IMPORTED_MODULE_10__parts_globalMethods__["b" /* globalWindowMethods */], __WEBPACK_IMPORTED_MODULE_12__parts_ajaxHelper__, __WEBPACK_IMPORTED_MODULE_11__parts_notifyFader__, __WEBPACK_IMPORTED_MODULE_7__pages_subquestionandanswers__["a" /* subquestionAndAnswersGlobalMethods */], __WEBPACK_IMPORTED_MODULE_17__components_notifications__["a" /* default */]);

/*
* Set the namespace to the global variable LS
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminbasics/build/adminbasics.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions assets/packages/adminbasics/src/main.js
Expand Up @@ -62,7 +62,6 @@ const AdminCore = function(){
onLoadRegister = () => {
globalStartUpMethods.bootstrapping();
surveyGrid();
appendToLoad(globalOnloadMethods);
appendToLoad(saveBindings);
appendToLoad(confirmationModal);
appendToLoad(questionEdit);
Expand All @@ -89,7 +88,6 @@ const AdminCore = function(){
$(root).on(events.join(' '), fn);
}
}
//fn();
},
refreshAdminCore = () => {
_.each(eventsBound, (eventMap, root) => {
Expand Down
17 changes: 12 additions & 5 deletions assets/packages/adminbasics/src/parts/globalMethods.js
Expand Up @@ -7,7 +7,16 @@ import LOG from '../components/lslog';
const globalWindowMethods = {
renderBootstrapSwitch : () => {
try{
$('[data-is-bootstrap-switch]').bootstrapSwitch();
if(!$('[data-is-bootstrap-switch]').parent().hasClass('bootstrap-switch-container')) {
$('[data-is-bootstrap-switch]').bootstrapSwitch({
onInit: () => LOG.log("BootstrapSwitch Initialized")
});
}
} catch(e) { LOG.error(e); }
},
unrenderBootstrapSwitch : () => {
try{
$('[data-is-bootstrap-switch]').bootstrapSwitch('destroy');
} catch(e) { LOG.error(e); }
},
validatefilename: (form, strmessage) => {
Expand Down Expand Up @@ -120,8 +129,6 @@ const globalStartUpMethods = {
globalWindowMethods.fixAccordionPosition();
}
};
const globalOnloadMethods = () => {
globalWindowMethods.renderBootstrapSwitch();
}

export {globalStartUpMethods, globalWindowMethods, globalOnloadMethods};

export {globalStartUpMethods, globalWindowMethods};
6 changes: 2 additions & 4 deletions assets/scripts/admin/questions.js
Expand Up @@ -134,7 +134,6 @@ var QuestionFunctions = function () {
return false;
}
});

};
return {
init: init
Expand All @@ -151,7 +150,6 @@ $(document).on('ready pjax:scriptcomplete', function () {
function updatequestionattributes(question_template_name = '', oldQuestionTemplate = '') {
var type = $('#question_type').val();
OtherSelection(type);

$('.loader-advancedquestionsettings').removeClass("hidden");
$('.panel-advancedquestionsettings').remove();

Expand All @@ -167,14 +165,15 @@ function updatequestionattributes(question_template_name = '', oldQuestionTempla
if (Object.prototype.toString.call(question_template_name) == '[object String]'){
postData['question_template'] = question_template_name;
}

window.LS.unrenderBootstrapSwitch();
$.ajax({
url: attr_url,
data: postData,
method: 'POST',
success: function (data) {
$('#container-advanced-question-settings').html(data);
$('.loader-advancedquestionsettings').addClass("hidden");
window.LS.renderBootstrapSwitch();
if(question_template_name) {
//$('#collapse-cat1').collapse('toggle');
}
Expand Down Expand Up @@ -205,7 +204,6 @@ function updatequestionattributes(question_template_name = '', oldQuestionTempla
}
}
});
window.LS.renderBootstrapSwitch();
}
});
}
Expand Down

0 comments on commit 7503b52

Please sign in to comment.