Skip to content

Commit

Permalink
Dev: Populate edit participant blacklist switch
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Sep 27, 2016
1 parent 2ee819c commit 7294571
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Expand Up @@ -49,7 +49,7 @@
<label class='control-label col-sm-4'><?php eT("Should this user be blacklisted?"); ?></label>
<div class='col-sm-8'>
&nbsp;
<input name='Participant[blacklisted]' type='checkbox' data-size='small' data-on-color='warning' data-off-color='primary' data-off-text='<?php eT('No'); ?>' data-on-text='<?php eT('Yes'); ?>' class='action_changeBlacklistStatus ls-bootstrap-switch' />
<input name='Participant[blacklisted]' type='checkbox' value='<?php echo $model->blacklisted == 'Y' ? 1 : 0; ?>' data-size='small' data-on-color='warning' data-off-color='primary' data-off-text='<?php eT('No'); ?>' data-on-text='<?php eT('Yes'); ?>' class='action_changeBlacklistStatus ls-bootstrap-switch' />
</div>
</div>
<legend><?php eT("Custom attributes"); ?></legend>
Expand Down
45 changes: 28 additions & 17 deletions scripts/admin/participantpanel.js
Expand Up @@ -23,15 +23,18 @@ LS.CPDB = (function() {
* @param {object} result
* @todo
*/
var secondSuccess = function(result){
var secondSuccess = function(result) {
$(baseModal).modal('hide');
$.fn.yiiGridView.update(gridViewId,{});
if(result.successMessage != undefined){
if(result.successMessage != undefined) {
notifyFader(result.successMessage, 'well-lg bg-primary text-center');
} else {
try{
}
else {
try {
notifyFader(result.errorMessage, 'well-lg bg-danger text-center');
} catch(e){}
}
catch(e) {
}
}
};

Expand All @@ -41,7 +44,7 @@ LS.CPDB = (function() {
*/
var firstSuccess = function(page){
$(baseModal).find('.modal-content').html(page);
$(baseModal).find('.'+actionButtonClass).on('click', function(e){
$(baseModal).find('.'+actionButtonClass).on('click', function(e) {
e.preventDefault();
var action = $(baseModal).find('#'+formId).attr('action');
var formData = $(baseModal).find('#'+formId).serializeArray();
Expand All @@ -51,7 +54,7 @@ LS.CPDB = (function() {
method: 'POST',
dataType: "json",
success: secondSuccess,
error : function(){
error : function() {
console.log(arguments);
}
});
Expand Down Expand Up @@ -103,7 +106,7 @@ LS.CPDB = (function() {
$('#exportcsv').on('shown.bs.modal', function(e) {
var self = this;
$(this).find('h4.modal-title').text(count);
$(this).find('.exportButton').on('click', function(){
$(this).find('.exportButton').on('click', function() {
var dldata = postdata;
dldata.attributes =$('#attributes').val().join('+');
console.log(dldata);
Expand Down Expand Up @@ -156,15 +159,17 @@ LS.CPDB = (function() {
};
},

//JS-bindings especially for the participantPanel
// JS-bindings especially for the participantPanel
participantPanel = function(){

$('#removeAllFilters').on('click', function(e){
e.preventDefault();
$('#searchcondition').val('');
$('#ParticipantFilters').remove();
$.fn.yiiGridView.update('list_central_participants',{});
return false;
});

$('.action_participant_editModal').on('click', function(e){
e.preventDefault();
var data = {modalTarget: 'editparticipant', 'participant_id' : $(this).closest('tr').data('participant_id')};
Expand All @@ -176,7 +181,8 @@ LS.CPDB = (function() {
'editPartcipantActiveForm',
'list_central_participants'
).done(function() {
$('.ls-bootstrap-switch').bootstrapSwitch();
var val = $('#participantPanel_edit_modal .ls-bootstrap-switch').val();
$('.ls-bootstrap-switch').bootstrapSwitch('state', val == 1);
});
});

Expand Down Expand Up @@ -219,17 +225,22 @@ LS.CPDB = (function() {
'list_central_participants'
);
});

$('#addParticipantToCPP').on('click', function(e){
e.preventDefault();
var data = {modalTarget: 'editparticipant'};
var data = {
modalTarget: 'editparticipant'
};
//url, data, idString, actionButtonClass, formId, gridViewId
runBaseModal(
openModalParticipantPanel,
data,
'action_save_modal_editParticipant',
'editPartcipantActiveForm',
'list_central_participants'
);
openModalParticipantPanel,
data,
'action_save_modal_editParticipant',
'editPartcipantActiveForm',
'list_central_participants'
).done(function() {
$('.ls-bootstrap-switch').bootstrapSwitch();
});
});

/**
Expand Down

0 comments on commit 7294571

Please sign in to comment.