mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Simplifying station setup. Only view changed so far
This commit is contained in:
@@ -92,7 +92,7 @@ class Stationsetup extends CI_Controller {
|
||||
public function getActiveStation() {
|
||||
$active_loc = $this->stations->find_active();
|
||||
echo json_encode($active_loc);
|
||||
}
|
||||
}
|
||||
|
||||
public function setFavorite_json() {
|
||||
$id2fav = xss_clean($this->input->post('id2Favorite', true));
|
||||
@@ -160,6 +160,18 @@ class Stationsetup extends CI_Controller {
|
||||
$this->load->view('stationsetup/create', $data);
|
||||
}
|
||||
|
||||
public function editContainerName() {
|
||||
$this->load->model('stationsetup_model');
|
||||
$data['container'] = $this->stationsetup_model->getContainer(xss_clean($this->input->post('id', true)))->row();
|
||||
$data['page_title'] = "Edit container name";
|
||||
$this->load->view('stationsetup/edit', $data);
|
||||
}
|
||||
|
||||
public function saveContainerName() {
|
||||
$this->load->model('stationsetup_model');
|
||||
$this->stationsetup_model->saveContainer();
|
||||
}
|
||||
|
||||
public function newLocation() {
|
||||
$this->load->model('stations');
|
||||
$this->load->model('dxcc');
|
||||
|
||||
15
application/models/Stationsetup_model.php
Normal file
15
application/models/Stationsetup_model.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class Stationsetup_model extends CI_Model {
|
||||
|
||||
function getContainer($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where('logbook_id', $clean_id);
|
||||
return $this->db->get('station_logbooks');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
23
application/views/stationsetup/edit.php
Normal file
23
application/views/stationsetup/edit.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<div class="container" id="create_station_logbook">
|
||||
|
||||
<br>
|
||||
<!-- Display Message -->
|
||||
<div id="flashdata" class="alert-message error">
|
||||
</div>
|
||||
|
||||
<?php if($this->session->flashdata('notice')) { ?>
|
||||
<div id="message" >
|
||||
<?php echo $this->session->flashdata('notice'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php $this->load->helper('form'); ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="stationLogbookNameInput">Container name</label>
|
||||
<input type="text" class="form-control" name="logbook_name" id="logbook_name" aria-describedby="stationLogbookNameHelp" placeholder="Home QTH" required value="<?php echo $container->logbook_name; ?>">
|
||||
<small id="stationLogbookNameHelp" class="form-text text-muted">You can call a container anything.</small>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -20,6 +20,7 @@
|
||||
<div class="card-body">
|
||||
<p class="card-text"><?php echo lang('station_logbooks_description_text')?></p>
|
||||
<a class="btn btn-primary btn-sm" href="javascript:createStationLogbook();"><i class="fas fa-plus"></i> <?php echo lang('station_logbooks_create')?></a>
|
||||
<a class="btn btn-primary btn-sm" href="javascript:createStationLogbook();"><i class="fas fa-edit"></i> Linked locations</a>
|
||||
<?php if ($my_logbooks->num_rows() > 0) { ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
@@ -30,14 +31,14 @@
|
||||
<th scope="col"><?php echo lang('station_logbooks_status')?></th>
|
||||
<th scope="col"><?php echo lang('admin_edit')?></th>
|
||||
<th scope="col"><?php echo lang('admin_delete')?></th>
|
||||
<th scope="col"><?php echo lang('station_logbooks_link')?></th>
|
||||
<th scope="col">Visitor site</th>
|
||||
<th scope="col"><?php echo lang('station_logbooks_public_search')?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($my_logbooks->result() as $row) { ?>
|
||||
<tr>
|
||||
<td><?php echo $row->logbook_name;?></td>
|
||||
<td><?php echo $row->logbook_name;?> <i id="<?php echo $row->logbook_id ?>" class="editContainerName fas fa-edit" role="button"></i></td>
|
||||
<td>
|
||||
<?php if($this->session->userdata('active_station_logbook') != $row->logbook_id) { ?>
|
||||
<button id="<?php echo $row->logbook_id; ?>" class="setActiveLogbook btn btn-outline-primary btn-sm"><?php echo lang('station_logbooks_set_active')?></button>
|
||||
@@ -59,6 +60,7 @@
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="" title=<?php echo lang('admin_edit'); ?> class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i></a>
|
||||
<?php if($row->public_slug != '') { ?>
|
||||
<a target="_blank"
|
||||
href="<?php echo site_url('visitor')."/".$row->public_slug; ?>"
|
||||
@@ -69,10 +71,12 @@
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($row->public_search == 1) {
|
||||
echo "<span class='badge bg-success'>" . lang('general_word_enabled') . "</span>";
|
||||
} else {
|
||||
echo "<span class='badge bg-dark'>" . lang('general_word_disabled') . "</span>";
|
||||
} ?>
|
||||
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>
|
||||
<?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>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
@@ -55,6 +55,15 @@ $(document).ready(function () {
|
||||
await do_ajax('setFavorite_json', 'id2Favorite', reloadStations,e);
|
||||
});
|
||||
|
||||
$(document).on('click', '.editContainerName', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
|
||||
editContainerDialog(e);
|
||||
});
|
||||
|
||||
$(document).on('click', '.saveContainerName', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
|
||||
saveContainerName(e);
|
||||
});
|
||||
|
||||
|
||||
$("#station_logbooks_table").DataTable({
|
||||
stateSave: true,
|
||||
language: {
|
||||
@@ -94,6 +103,48 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
|
||||
function editContainerDialog(e) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/stationsetup/editContainerName',
|
||||
type: 'post',
|
||||
data: {
|
||||
id: e.currentTarget.id,
|
||||
},
|
||||
success: function (data) {
|
||||
BootstrapDialog.show({
|
||||
title: 'Edit container name',
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'options',
|
||||
id: "NewStationLogbookModal",
|
||||
nl2br: false,
|
||||
message: data,
|
||||
onshown: function(dialog) {
|
||||
},
|
||||
buttons: [{
|
||||
label: 'Save',
|
||||
cssClass: 'btn-primary btn-sm saveContainerName',
|
||||
},
|
||||
{
|
||||
label: lang_admin_close,
|
||||
cssClass: 'btn-sm',
|
||||
id: 'closeButton',
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}],
|
||||
});
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
},
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveContainerName() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function reloadLogbooks() {
|
||||
$.ajax({
|
||||
@@ -117,6 +168,7 @@ function reloadLogbooks() {
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function reloadStations() {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/stationsetup/fetchLocations',
|
||||
|
||||
Reference in New Issue
Block a user