Implement logbook/location quick switcher UI for main logbook view

Co-authored-by: magicbug <84308+magicbug@users.noreply.github.com>
这个提交包含在:
copilot-swe-agent[bot] 2025-09-14 16:28:28 +00:00
父节点 e803714c30
当前提交 3a90e523f2
共有 6 个文件被更改,包括 104 次插入1 次删除

查看文件

@ -35,6 +35,7 @@ class Logbook extends CI_Controller
}
$this->load->model('logbook_model');
$this->load->model('logbooks_model');
$this->load->library('pagination');
$config['base_url'] = base_url() . 'index.php/logbook/index/';
@ -72,6 +73,10 @@ class Logbook extends CI_Controller
// Get available logbooks and stations for the switcher
$data['available_logbooks'] = $this->logbooks_model->show_all();
$data['available_stations'] = $this->stations->all_of_user();
// load the view
$data['page_title'] = "Logbook";

查看文件

@ -183,4 +183,40 @@ class Logbooks extends CI_Controller {
}
}
public function switch_logbook_location() {
$this->load->model('logbooks_model');
$this->load->model('stations');
$logbook_id = $this->input->post('logbook_id');
$station_id = $this->input->post('station_id');
$success = true;
$messages = array();
// Switch logbook if provided and different from current
if ($logbook_id && $logbook_id != $this->session->userdata('active_station_logbook')) {
$this->logbooks_model->set_logbook_active($logbook_id);
$messages[] = 'Logbook switched to: ' . $this->logbooks_model->find_name($logbook_id);
}
// Switch station location if provided and different from current
if ($station_id && $station_id != $this->stations->find_active()) {
$current_station = $this->stations->find_active();
$this->stations->set_active($current_station, $station_id);
$station_name = $this->stations->profile_clean($station_id);
$messages[] = 'Location switched to: ' . $station_name->station_profile_name;
}
// Update session data
$this->user_model->update_session($this->session->userdata('user_id'));
// Set flash message
if (!empty($messages)) {
$this->session->set_flashdata('notice', implode('. ', $messages));
}
// Redirect back to logbook view
redirect('logbook');
}
}

查看文件

@ -1,7 +1,42 @@
<div class="alert alert-secondary" role="alert" style="margin-bottom: 0px !important;">
<div class="container">
<?php if ($results) { ?>
<p style="margin-bottom: 0px !important;"><?php echo lang('gen_hamradio_logbook'); ?>: <span class="badge text-bg-info"><?php echo $this->logbooks_model->find_name($this->session->userdata('active_station_logbook')); ?></span> <?php echo lang('general_word_location'); ?>: <span class="badge text-bg-info"><?php echo $this->stations->find_name(); ?></span></p>
<div class="row align-items-center">
<div class="col-md-8">
<p style="margin-bottom: 0px !important;">
<?php echo lang('gen_hamradio_logbook'); ?>: <span class="badge text-bg-info"><?php echo $this->logbooks_model->find_name($this->session->userdata('active_station_logbook')); ?></span>
<?php echo lang('general_word_location'); ?>: <span class="badge text-bg-info"><?php echo $this->stations->find_name(); ?></span>
</p>
</div>
<div class="col-md-4">
<form method="post" action="<?php echo site_url('logbooks/switch_logbook_location'); ?>" class="d-flex align-items-center gap-2" id="switcher_form">
<select name="logbook_id" class="form-select form-select-sm" style="min-width: 120px;" id="logbook_switcher">
<option value="">Select Logbook</option>
<?php if (isset($available_logbooks)) {
foreach ($available_logbooks->result() as $logbook) { ?>
<option value="<?php echo $logbook->logbook_id; ?>" <?php echo ($logbook->logbook_id == $this->session->userdata('active_station_logbook')) ? 'selected' : ''; ?>>
<?php echo $logbook->logbook_name; ?>
</option>
<?php }
} ?>
</select>
<select name="station_id" class="form-select form-select-sm" style="min-width: 120px;" id="location_switcher">
<option value="">Select Location</option>
<?php if (isset($available_stations)) {
$active_station_id = $this->stations->find_active();
foreach ($available_stations->result() as $station) { ?>
<option value="<?php echo $station->station_id; ?>" <?php echo ($station->station_id == $active_station_id) ? 'selected' : ''; ?>>
<?php echo $station->station_profile_name; ?>
</option>
<?php }
} ?>
</select>
<button type="submit" class="btn btn-primary btn-sm" id="change_button">
<i class="fas fa-sync-alt me-1"></i>Change
</button>
</form>
</div>
</div>
<?php } ?>
</div>
</div>
@ -23,3 +58,30 @@
<div style="padding-top: 10px; margin-top: 0px;" class="container logbook">
<?php $this->load->view('view_log/partial/log_ajax') ?>
<script>
// Enable/disable change button based on selections
document.addEventListener('DOMContentLoaded', function() {
const logbookSelect = document.getElementById('logbook_switcher');
const locationSelect = document.getElementById('location_switcher');
const changeButton = document.getElementById('change_button');
function updateButtonState() {
const logbookChanged = logbookSelect.value && logbookSelect.value !== logbookSelect.dataset.original;
const locationChanged = locationSelect.value && locationSelect.value !== locationSelect.dataset.original;
changeButton.disabled = !(logbookChanged || locationChanged);
}
// Store original values
logbookSelect.dataset.original = logbookSelect.value;
locationSelect.dataset.original = locationSelect.value;
// Initial button state
updateButtonState();
// Add event listeners
logbookSelect.addEventListener('change', updateButtonState);
locationSelect.addEventListener('change', updateButtonState);
});
</script>

二进制
cloudlog-switcher-both-changed.png 普通文件

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 40 KiB

二进制
cloudlog-switcher-changed.png 普通文件

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 40 KiB

二进制
cloudlog-switcher-demo.png 普通文件

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 40 KiB