Skip to content

Commit

Permalink
Fixed issue #15227: Unable to Delete Questions
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Sep 5, 2019
1 parent 3f839ff commit e749edd
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 10,496 deletions.
10,371 changes: 0 additions & 10,371 deletions assets/packages/adminbasics/build/adminbasics.debug.js

This file was deleted.

232 changes: 118 additions & 114 deletions assets/packages/adminbasics/build/adminbasics.js
Expand Up @@ -27456,114 +27456,6 @@
});
};

/**
* Neccessary methods for the confirmation modal
*/

var ConfirmationModal = function ConfirmationModal(e) {
//////PREGENERATED VARIABLES
//Define the scope
var _this = this; //Set everything to null on default


var optionsDefault = {
onclick: null,
href: null,
message: null,
keepopen: null,
postDatas: null,
gridid: null,
"ajax-url": null
}; //////METHODS
//Parse available options from specific item.data settings, if not available load relatedTarget settings

var _parseOptions = function _parseOptions(e) {
return lodash.each(optionsDefault, function (value, key) {
optionsDefault[key] = $(_this).data(key) || $(e.relatedTarget).data(key) || optionsDefault[key];
});
},
//Generate a simple link on the ok button
_basicLink = function _basicLink() {
$(_this).find('.btn-ok').attr('href', options.href);
},
//Evaluate a function on ok button click
_onClickFunction = function _onClickFunction() {
var onclick_fn = new Function(options.onclick);

if (typeof onclick_fn == 'function') {
$(_this).find('.btn-ok').off('click');
$(_this).find('.btn-ok').on('click', function (ev) {
if (!options.keepopen) {
$('#confirmation-modal').modal('hide');
}

onclick_fn();
});
return;
}

console.error("Confirmation modal: onclick is not a function. Wrap data-onclick content in (function() { ... }).");
return;
},
//Set up an ajax call and regenerate a gridView on ok button click
_ajaxHandler = function _ajaxHandler() {
$(_this).find('.btn-ok').on('click', function (ev) {
$.ajax({
type: "POST",
url: options['ajax-url'],
data: options.postDatas,
success: function success(html, statut) {
$.fn.yiiGridView.update(options.gridid); // Update the surveys list

$('#confirmation-modal').modal('hide');
},
error: function error(html, statut) {
$('#confirmation-modal .modal-body-text').append(html.responseText);
}
});
});
},
_setTarget = function _setTarget() {
//Set up normal href
if (!!options.href) {
_basicLink();

return;
} //Set up a complete function


if (!!options.onclick) {
_onClickFunction();

return;
} //Set up an ajax post


if (!!options['ajax-url']) {
_ajaxHandler();

return;
}

console.error("Confirmation modal: Found neither data-href or data-onclick, nor ajax data.");
}; //////RUN BINDINGS
//Current options object


var options = _parseOptions(e); //Set the message if available


$(this).find('.modal-body-text').html(options.message); //Run setTarget to determine loading target

_setTarget();
};

var loadMethods = function loadMethods() {
$('#confirmation-modal').on('show.bs.modal', function (e) {
ConfirmationModal.call(this, e);
});
};

/**
* Check the browsers console capabilities and bundle them into general functions
* If the build environment was "production" only put out error messages.
Expand Down Expand Up @@ -27797,7 +27689,119 @@
return ConsoleShim;
}();

var adminCoreLSConsole = new ConsoleShim('AdminCore', !window.debugState.backend);
var adminCoreLSConsole = new ConsoleShim('AdminCore', window.debugState ? window.debugState.backend : false); //!window.debugState.backend);

/**
* Neccessary methods for the confirmation modal
*/

var ConfirmationModal = function ConfirmationModal(e) {
//////PREGENERATED VARIABLES
//Define the scope
var _this = this; //Set everything to null on default


var optionsDefault = {
onclick: null,
href: null,
message: null,
keepopen: null,
postDatas: null,
gridid: null,
"ajax-url": null
}; //////METHODS
//Parse available options from specific item.data settings, if not available load relatedTarget settings

var _parseOptions = function _parseOptions(e) {
return lodash.each(optionsDefault, function (value, key) {
optionsDefault[key] = $(_this).data(key) || $(e.relatedTarget).data(key) || optionsDefault[key];
});
},
//Generate a simple link on the ok button
_basicLink = function _basicLink() {
adminCoreLSConsole.log('Binding basicLink in notification panel');
$(_this).find('.btn-ok').attr('href', options.href);
},
//Evaluate a function on ok button click
_onClickFunction = function _onClickFunction() {
adminCoreLSConsole.log('Binding onClick-functions in notification panel');
var onclick_fn = eval(options.onclick);

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt Sep 16, 2019

Collaborator

How about triggering onclick instead of using eval?


if (typeof onclick_fn == 'function') {
$(_this).find('.btn-ok').off('click');
$(_this).find('.btn-ok').on('click', function (ev) {
if (!options.keepopen) {
$('#confirmation-modal').modal('hide');
}

onclick_fn();
});
return;
}

adminCoreLSConsole.error("Confirmation modal: onclick is not a function. Wrap data-onclick content in (function() { ... }).");
return;
},
//Set up an ajax call and regenerate a gridView on ok button click
_ajaxHandler = function _ajaxHandler() {
adminCoreLSConsole.log('Binding ajax handler in notification panel');
$(_this).find('.btn-ok').on('click', function (ev) {
$.ajax({
type: "POST",
url: options['ajax-url'],
data: options.postDatas,
success: function success(html, statut) {
$.fn.yiiGridView.update(options.gridid); // Update the surveys list

$('#confirmation-modal').modal('hide');
},
error: function error(html, statut) {
$('#confirmation-modal .modal-body-text').append(html.responseText);
}
});
});
},
_setTarget = function _setTarget() {
//Set up normal href
if (!!options.href) {
_basicLink();

return;
} //Set up a complete function


if (!!options.onclick) {
_onClickFunction();

return;
} //Set up an ajax post


if (!!options['ajax-url']) {
_ajaxHandler();

return;
}

adminCoreLSConsole.error("Confirmation modal: Found neither data-href or data-onclick, nor ajax data.");
}; //////RUN BINDINGS
//Current options object


var options = _parseOptions(e); //Set the message if available


$(this).find('.modal-body-text').html(options.message); //Run setTarget to determine loading target

_setTarget();
};

var loadMethods = function loadMethods() {
adminCoreLSConsole.log('ConfirmationModal calling');
$('#confirmation-modal').on('show.bs.modal', function (e) {
ConfirmationModal.call(this, e);
});
};

/**
* Define global setters for LimeSurvey
Expand Down Expand Up @@ -29110,11 +29114,11 @@
if (form.length < 1) throw "No form Found this can't be!";
return form;
},
// displayLoadingState = (el) => {
// const loadingSpinner = '<i class="fa fa-cog fa-spin lsLoadingStateIndicator"></i>';
// $(el).prop('disabled', true).append(loadingSpinner);
// },
stopDisplayLoadingState = function stopDisplayLoadingState() {
displayLoadingState = function displayLoadingState(el) {
var loadingSpinner = '<i class="fa fa-cog fa-spin lsLoadingStateIndicator"></i>';
$(el).prop('disabled', true).append(loadingSpinner);
},
stopDisplayLoadingState = function stopDisplayLoadingState() {
adminCoreLSConsole.log('StopLoadingIconAnimation');
LS.EventBus.$emit('loadingFinished'); // $('.lsLoadingStateIndicator').each((i,item) => {$(item).remove();});
},
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminbasics/build/adminbasics.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/packages/adminbasics/build/adminbasics.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/packages/adminbasics/build/adminbasics.rtl.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/packages/adminbasics/src/components/lslog.js
Expand Up @@ -154,6 +154,6 @@ class ConsoleShim {
}
}

const adminCoreLSConsole = new ConsoleShim('AdminCore', !window.debugState.backend);
const adminCoreLSConsole = new ConsoleShim('AdminCore', (window.debugState ? window.debugState.backend : false)); //!window.debugState.backend);

export default adminCoreLSConsole;
11 changes: 8 additions & 3 deletions assets/packages/adminbasics/src/parts/confirmationModal.js
Expand Up @@ -2,6 +2,7 @@
* Neccessary methods for the confirmation modal
*/
import _ from 'lodash';
import LOG from "../components/lslog";

const ConfirmationModal = function(e){
//////PREGENERATED VARIABLES
Expand All @@ -27,11 +28,13 @@ const ConfirmationModal = function(e){
},
//Generate a simple link on the ok button
_basicLink = () => {
LOG.log('Binding basicLink in notification panel');
$(_this).find('.btn-ok').attr('href', options.href);
},
//Evaluate a function on ok button click
_onClickFunction = () => {
const onclick_fn = new Function(options.onclick);
LOG.log('Binding onClick-functions in notification panel');
const onclick_fn = eval(options.onclick);
if (typeof onclick_fn == 'function') {
$(_this).find('.btn-ok').off('click');

Expand All @@ -41,11 +44,12 @@ const ConfirmationModal = function(e){
});
return
}
console.error("Confirmation modal: onclick is not a function. Wrap data-onclick content in (function() { ... }).");
LOG.error("Confirmation modal: onclick is not a function. Wrap data-onclick content in (function() { ... }).");
return;
},
//Set up an ajax call and regenerate a gridView on ok button click
_ajaxHandler = () => {
LOG.log('Binding ajax handler in notification panel');
$(_this).find('.btn-ok').on('click', function(ev) {
$.ajax({
type: "POST",
Expand Down Expand Up @@ -80,7 +84,7 @@ const ConfirmationModal = function(e){
_ajaxHandler();
return;
}
console.error("Confirmation modal: Found neither data-href or data-onclick, nor ajax data.");
LOG.error("Confirmation modal: Found neither data-href or data-onclick, nor ajax data.");
};

//////RUN BINDINGS
Expand All @@ -93,6 +97,7 @@ const ConfirmationModal = function(e){
};

const loadMethods = ()=>{
LOG.log('ConfirmationModal calling');
$('#confirmation-modal').on('show.bs.modal', function(e) {
ConfirmationModal.call(this,e);
});
Expand Down
8 changes: 4 additions & 4 deletions assets/packages/adminbasics/src/parts/save.js
Expand Up @@ -33,10 +33,10 @@ const SaveController = () => {

return form;
},
// displayLoadingState = (el) => {
// const loadingSpinner = '<i class="fa fa-cog fa-spin lsLoadingStateIndicator"></i>';
// $(el).prop('disabled', true).append(loadingSpinner);
// },
displayLoadingState = (el) => {
const loadingSpinner = '<i class="fa fa-cog fa-spin lsLoadingStateIndicator"></i>';
$(el).prop('disabled', true).append(loadingSpinner);
},
stopDisplayLoadingState = () => {
LOG.log('StopLoadingIconAnimation');
LS.EventBus.$emit('loadingFinished');
Expand Down

0 comments on commit e749edd

Please sign in to comment.