mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Toggle public search works
This commit is contained in:
@@ -366,5 +366,20 @@ class Stationsetup extends CI_Controller {
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public function togglePublicSearch() {
|
||||
$id = xss_clean($this->input->post('id',true));
|
||||
$publicSearch = xss_clean($this->input->post('checked',true));
|
||||
if ($id ?? '' != '') {
|
||||
$this->load->model('stationsetup_model');
|
||||
$this->stationsetup_model->togglePublicSearch($id, $publicSearch);
|
||||
$data['success']=1;
|
||||
} else {
|
||||
$data['success']=0;
|
||||
$data['flashdata']='Not allowed';
|
||||
}
|
||||
echo json_encode($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,16 @@ class Stationsetup_model extends CI_Model {
|
||||
$this->db->where('logbook_id', xss_clean($this->input->post('id', true)));
|
||||
$this->db->update('station_logbooks');
|
||||
}
|
||||
|
||||
function togglePublicSearch($id, $publicSearch) {
|
||||
$data = array(
|
||||
'public_search' => ($publicSearch === 'true' ? 1 : 0)
|
||||
);
|
||||
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where('logbook_id', $id);
|
||||
$this->db->update('station_logbooks', $data);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -70,10 +70,10 @@
|
||||
<td>
|
||||
<?php if ($row->public_search == 1) {
|
||||
echo "<span class='badge bg-success'>" . lang('general_word_enabled') . "</span>";?>
|
||||
<div class="form-check" style="margin-top: -1.5em"><input class="form-check-input" type="checkbox" checked /></div>
|
||||
<div class="form-check" style="margin-top: -1.5em"><input id="<?php echo $row->logbook_id; ?>" class="form-check-input publicSearchCheckbox" type="checkbox" checked /></div>
|
||||
<?php } else {
|
||||
echo "<span class='badge bg-dark'>" . lang('general_word_disabled') . "</span>"; ?>
|
||||
<div class="form-check" style="margin-top: -1.5em"><input class="form-check-input" type="checkbox" /></div>
|
||||
<div class="form-check" style="margin-top: -1.5em"><input id="<?php echo $row->logbook_id; ?>" class="form-check-input publicSearchCheckbox" type="checkbox" /></div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -71,6 +71,10 @@ $(document).ready(function () {
|
||||
await do_ajax('remove_publicslug', 'id', reloadLogbooks,e);
|
||||
});
|
||||
|
||||
$(document).on('click', '.publicSearchCheckbox', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
|
||||
togglePublicSearch(e.currentTarget.id, this);
|
||||
});
|
||||
|
||||
$("#station_logbooks_table").DataTable({
|
||||
stateSave: true,
|
||||
language: {
|
||||
@@ -110,6 +114,24 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
|
||||
function togglePublicSearch(id, thisvar) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/stationsetup/togglePublicSearch',
|
||||
type: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
checked: $(thisvar).is(':checked')
|
||||
},
|
||||
success: function (data) {
|
||||
reloadLogbooks();
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
},
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function editContainerDialog(e) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/stationsetup/editContainerName',
|
||||
|
||||
Reference in New Issue
Block a user