Merge pull request #1245 from AndreasK79/contests_activate_deactivate_all
[Contests] Added buttons for activate/deactivate all
这个提交包含在:
当前提交
76d9e639b0
共有 4 个文件被更改,包括 109 次插入 和 22 次删除
|
|
@ -134,4 +134,20 @@ class Contesting extends CI_Controller {
|
||||||
echo json_encode(array('message' => 'OK'));
|
echo json_encode(array('message' => 'OK'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deactivateall() {
|
||||||
|
$this->load->model('Contesting_model');
|
||||||
|
$this->Contesting_model->deactivateall();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode(array('message' => 'OK'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activateall() {
|
||||||
|
$this->load->model('Contesting_model');
|
||||||
|
$this->Contesting_model->activateall();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode(array('message' => 'OK'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,4 +122,24 @@ class Contesting_model extends CI_Model {
|
||||||
$this->db->where('id', $id);
|
$this->db->where('id', $id);
|
||||||
$this->db->update('contest', $data);
|
$this->db->update('contest', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activateall() {
|
||||||
|
$data = array(
|
||||||
|
'active' => '1',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->update('contest', $data);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivateall() {
|
||||||
|
$data = array(
|
||||||
|
'active' => '0',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->update('contest', $data);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@
|
||||||
<table>
|
<table>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<p><button onclick="createContestDialog();" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> Add a Contest</button></p>
|
<p>
|
||||||
|
<button onclick="createContestDialog();" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> Add a Contest</button>
|
||||||
|
<button onclick="activateAllContests();" class="btn btn-primary btn-sm">Activate All</button>
|
||||||
|
<button onclick="deactivateAllContests();" class="btn btn-primary btn-sm">Deactivate All </button>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ $('.contesttable').DataTable({
|
||||||
"pageLength": 25,
|
"pageLength": 25,
|
||||||
responsive: false,
|
responsive: false,
|
||||||
ordering: false,
|
ordering: false,
|
||||||
"scrollY": "400px",
|
"scrollY": "400px",
|
||||||
"scrollCollapse": true,
|
"scrollCollapse": true,
|
||||||
"paging": false,
|
"paging": false,
|
||||||
"scrollX": true,
|
"scrollX": true,
|
||||||
dom: 'Bfrtip',
|
dom: 'Bfrtip',
|
||||||
buttons: [
|
buttons: [
|
||||||
|
|
@ -13,7 +13,7 @@ $('.contesttable').DataTable({
|
||||||
});
|
});
|
||||||
|
|
||||||
// using this to change color of csv-button if dark mode is chosen
|
// using this to change color of csv-button if dark mode is chosen
|
||||||
var background = $('body').css( "background-color");
|
var background = $('body').css("background-color");
|
||||||
|
|
||||||
if (background != ('rgb(255, 255, 255)')) {
|
if (background != ('rgb(255, 255, 255)')) {
|
||||||
$(".buttons-csv").css("color", "white");
|
$(".buttons-csv").css("color", "white");
|
||||||
|
|
@ -23,7 +23,7 @@ function createContestDialog() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/create',
|
url: base_url + 'index.php/contesting/create',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
success: function(html) {
|
success: function (html) {
|
||||||
BootstrapDialog.show({
|
BootstrapDialog.show({
|
||||||
title: 'Add Contest',
|
title: 'Add Contest',
|
||||||
size: BootstrapDialog.SIZE_WIDE,
|
size: BootstrapDialog.SIZE_WIDE,
|
||||||
|
|
@ -46,9 +46,11 @@ function createContest(form) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/create',
|
url: base_url + 'index.php/contesting/create',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'name': form.contestname.value,
|
data: {
|
||||||
'adifname': form.adifcontestname.value},
|
'name': form.contestname.value,
|
||||||
success: function(html) {
|
'adifname': form.adifcontestname.value
|
||||||
|
},
|
||||||
|
success: function (html) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -59,11 +61,11 @@ function deactivateContest(contestid) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/deactivate',
|
url: base_url + 'index.php/contesting/deactivate',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'id': contestid },
|
data: { 'id': contestid },
|
||||||
success: function(html) {
|
success: function (html) {
|
||||||
$(".contest_" + contestid).text('not active');
|
$(".contest_" + contestid).text('not active');
|
||||||
$('.btn_'+contestid).html('Activate');
|
$('.btn_' + contestid).html('Activate');
|
||||||
$('.btn_'+contestid).attr('onclick', 'activateContest('+contestid+')')
|
$('.btn_' + contestid).attr('onclick', 'activateContest(' + contestid + ')')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -72,11 +74,11 @@ function activateContest(contestid) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/activate',
|
url: base_url + 'index.php/contesting/activate',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'id': contestid },
|
data: { 'id': contestid },
|
||||||
success: function(html) {
|
success: function (html) {
|
||||||
$('.contest_'+contestid).text('active');
|
$('.contest_' + contestid).text('active');
|
||||||
$('.btn_'+contestid).html('Deactivate');
|
$('.btn_' + contestid).html('Deactivate');
|
||||||
$('.btn_'+contestid).attr('onclick', 'deactivateContest('+contestid+')')
|
$('.btn_' + contestid).attr('onclick', 'deactivateContest(' + contestid + ')')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -84,19 +86,20 @@ function activateContest(contestid) {
|
||||||
function deleteContest(id, contest) {
|
function deleteContest(id, contest) {
|
||||||
BootstrapDialog.confirm({
|
BootstrapDialog.confirm({
|
||||||
title: 'DANGER',
|
title: 'DANGER',
|
||||||
message: 'Warning! Are you sure you want to delete the following contest: ' + contest + '?' ,
|
message: 'Warning! Are you sure you want to delete the following contest: ' + contest + '?',
|
||||||
type: BootstrapDialog.TYPE_DANGER,
|
type: BootstrapDialog.TYPE_DANGER,
|
||||||
closable: true,
|
closable: true,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
btnOKClass: 'btn-danger',
|
btnOKClass: 'btn-danger',
|
||||||
callback: function(result) {
|
callback: function (result) {
|
||||||
if(result) {
|
if (result) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/delete',
|
url: base_url + 'index.php/contesting/delete',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'id': id
|
data: {
|
||||||
|
'id': id
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function (data) {
|
||||||
$(".contest_" + id).parent("tr:first").remove(); // removes mode from table
|
$(".contest_" + id).parent("tr:first").remove(); // removes mode from table
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -104,3 +107,47 @@ function deleteContest(id, contest) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activateAllContests() {
|
||||||
|
BootstrapDialog.confirm({
|
||||||
|
title: 'DANGER',
|
||||||
|
message: 'Warning! Are you sure you want to activate all contests?',
|
||||||
|
type: BootstrapDialog.TYPE_DANGER,
|
||||||
|
closable: true,
|
||||||
|
draggable: true,
|
||||||
|
btnOKClass: 'btn-danger',
|
||||||
|
callback: function (result) {
|
||||||
|
if (result) {
|
||||||
|
$.ajax({
|
||||||
|
url: base_url + 'index.php/contesting/activateall',
|
||||||
|
type: 'post',
|
||||||
|
success: function (data) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivateAllContests() {
|
||||||
|
BootstrapDialog.confirm({
|
||||||
|
title: 'DANGER',
|
||||||
|
message: 'Warning! Are you sure you want to deactivate all contests?',
|
||||||
|
type: BootstrapDialog.TYPE_DANGER,
|
||||||
|
closable: true,
|
||||||
|
draggable: true,
|
||||||
|
btnOKClass: 'btn-danger',
|
||||||
|
callback: function (result) {
|
||||||
|
if (result) {
|
||||||
|
$.ajax({
|
||||||
|
url: base_url + 'index.php/contesting/deactivateall',
|
||||||
|
type: 'post',
|
||||||
|
success: function (data) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
正在加载…
在新工单中引用