mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge pull request #905 from HB9HIL/contesting
[CONTESTING] Fix some issues in contesting
This commit is contained in:
@@ -38,6 +38,11 @@ class Contesting extends CI_Controller {
|
||||
$data['contestnames'] = $this->contesting_model->getActivecontests();
|
||||
$data['bands'] = $this->bands->get_user_bands_for_qso_entry();
|
||||
|
||||
$footerData = [];
|
||||
$footerData['scripts'] = [
|
||||
'assets/js/sections/contesting.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/contesting.js")),
|
||||
];
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('start_date', 'Date', 'required');
|
||||
@@ -48,7 +53,7 @@ class Contesting extends CI_Controller {
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('contesting/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
|
||||
public function getSessionQsos() {
|
||||
@@ -109,11 +114,16 @@ class Contesting extends CI_Controller {
|
||||
|
||||
$data['contests'] = $this->Contesting_model->getAllContests();
|
||||
|
||||
$footerData = [];
|
||||
$footerData['scripts'] = [
|
||||
'assets/js/sections/contesting.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/contesting.js")),
|
||||
];
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = __("Contests");
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('contesting/add');
|
||||
$this->load->view('interface_assets/footer');
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
|
||||
public function edit($id) {
|
||||
@@ -126,6 +136,11 @@ class Contesting extends CI_Controller {
|
||||
|
||||
$data['page_title'] = __("Update Contest");
|
||||
|
||||
$footerData = [];
|
||||
$footerData['scripts'] = [
|
||||
'assets/js/sections/contesting.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/contesting.js")),
|
||||
];
|
||||
|
||||
$this->form_validation->set_rules('name', 'Contest Name', 'required');
|
||||
$this->form_validation->set_rules('adifname', 'Adif Contest Name', 'required');
|
||||
|
||||
@@ -133,7 +148,7 @@ class Contesting extends CI_Controller {
|
||||
{
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('contesting/edit');
|
||||
$this->load->view('interface_assets/footer');
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -100,6 +100,16 @@ class Contesting_model extends CI_Model {
|
||||
$data['qso'] = $result->qso;
|
||||
}
|
||||
|
||||
/**
|
||||
* catch the case if the user already logged a QSO with contest a and then switches to contest b
|
||||
* this case is similar to a new session, therefore we need to reset the qso list.
|
||||
* Anyway we try to catch this case by disabling the contest field in the form if the user already logged a QSO.
|
||||
* Only "Start a new contest session" is allowed to change the contest. So this is just the fallback.
|
||||
*/
|
||||
if ($qsoarray[2] != $this->input->post('contestname', true)) {
|
||||
$data['qso'] = $qso;
|
||||
}
|
||||
|
||||
$this->updateSession($data, $station_id);
|
||||
|
||||
return;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<script>
|
||||
var lang_contestname_warning = "<?= __("You need to start a new session before you can change the contest name!"); ?>";
|
||||
</script>
|
||||
|
||||
<div class="container qso_panel contesting">
|
||||
<button type="button" class="btn btn-sm btn-warning float-end" onclick="reset_contest_session()"><i class="fas fa-sync-alt"></i> <?= __("Start new Contest Session"); ?></button>
|
||||
<h2 style="display:inline"><?= __("Contest Logging"); ?> </h2> <?php echo ($manual_mode == 0 ? " <span style='display:inline' class='align-text-top badge text-bg-success'>LIVE</span>" : " <span style='display:inline' class='align-text-top badge text-bg-danger'>POST</span>"); ?>
|
||||
@@ -22,14 +26,15 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="col-auto control-label" for="contestname"><?= __("Contest Name"); ?></label>
|
||||
<label class="col-auto control-label" for="contestname_select"><?= __("Contest Name"); ?></label>
|
||||
|
||||
<div class="col-auto">
|
||||
<select class="form-select form-select-sm" id="contestname" name="contestname">
|
||||
<select class="form-select form-select-sm" id="contestname_select" name="contestname_select">
|
||||
<?php foreach($contestnames as $contest) {
|
||||
echo "<option value='" . $contest['adifname'] . "'>" . $contest['name'] . "</option>";
|
||||
} ?>
|
||||
</select>
|
||||
<input type="hidden" id="contestname" name="contestname" />
|
||||
</div>
|
||||
|
||||
<label class="col-auto control-label" for="operatorcall"><?= __("Operator Callsign"); ?></label>
|
||||
|
||||
@@ -2472,7 +2472,6 @@ function viewEqsl(picture, callsign) {
|
||||
<script>
|
||||
var manual = <?php echo $manual_mode; ?>;
|
||||
</script>
|
||||
<script src="<?php echo base_url() ;?>assets/js/sections/contesting.js?v2"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(2) == "counties" || $this->uri->segment(2) == "counties_details") { ?>
|
||||
|
||||
@@ -6,8 +6,33 @@ $(document).ready(async function () {
|
||||
sessiondata=await getSession(); // save sessiondata global (we need it later, when adding qso)
|
||||
await restoreContestSession(sessiondata); // wait for restoring until finished
|
||||
setRst($("#mode").val());
|
||||
$('#contestname').val($('#contestname_select').val());
|
||||
});
|
||||
|
||||
// Always update the contestname
|
||||
$('#contestname_select').change(function () {
|
||||
$('#contestname').val($('#contestname_select').val());
|
||||
});
|
||||
|
||||
function disabledContestnameSelect(disabled) {
|
||||
if (disabled) {
|
||||
$("#contestname_select")
|
||||
.prop('disabled', true)
|
||||
.attr({
|
||||
'title': lang_contestname_warning,
|
||||
'data-bs-toggle': 'tooltip',
|
||||
'data-bs-html': 'true',
|
||||
'data-bs-placement': 'top'
|
||||
})
|
||||
.tooltip();
|
||||
} else {
|
||||
$("#contestname_select")
|
||||
.prop('disabled', false)
|
||||
.removeAttr('title data-bs-toggle data-bs-html data-bs-placement')
|
||||
.tooltip('dispose');
|
||||
}
|
||||
}
|
||||
|
||||
// Resets the logging form and deletes session from database
|
||||
async function reset_contest_session() {
|
||||
await $.ajax({
|
||||
@@ -17,6 +42,9 @@ async function reset_contest_session() {
|
||||
|
||||
}
|
||||
});
|
||||
// the user is now allowed again to change the contest name
|
||||
disabledContestnameSelect(false);
|
||||
// reset the form
|
||||
$('#name').val("");
|
||||
$('.callsign-suggestions').text("");
|
||||
$('#callsign').val("");
|
||||
@@ -32,7 +60,7 @@ async function reset_contest_session() {
|
||||
setRst($("#mode").val());
|
||||
$("#exchangetype").val("None");
|
||||
setExchangetype("None");
|
||||
$("#contestname").val("Other").change();
|
||||
$("#contestname_select").val("Other").change();
|
||||
$(".contest_qso_table_contents").empty();
|
||||
$('#copyexchangeto').val("None");
|
||||
|
||||
@@ -72,8 +100,17 @@ async function reset_contest_session() {
|
||||
}
|
||||
|
||||
function sort_exchange() {
|
||||
|
||||
// Get the selected sequence
|
||||
let exchangeSelect = $('#exchangesequence_select');
|
||||
|
||||
// If the sequence is not set, we need to set one to prevent errors
|
||||
if (!exchangeSelect.val()) {
|
||||
exchangeSelect.val('s-g-e');
|
||||
}
|
||||
|
||||
// Split the squence into an array
|
||||
var selectedOrder = $('#exchangesequence_select').val().split('-');
|
||||
let selectedOrder = exchangeSelect.val().split('-');
|
||||
|
||||
// Map sequence to corresponding SENT elements
|
||||
let mapping = {
|
||||
@@ -583,6 +620,10 @@ function setExchangetype(exchangetype) {
|
||||
function logQso() {
|
||||
if ($("#callsign").val().length > 0) {
|
||||
|
||||
// To prevent changing the contest name while logging we disable the select
|
||||
// Only "Start a new contest session" will enable it again
|
||||
disabledContestnameSelect(true);
|
||||
|
||||
$('.callsign-suggestions').text("");
|
||||
$('#callsign_info').text("");
|
||||
|
||||
@@ -698,7 +739,7 @@ async function restoreContestSession(data) {
|
||||
}
|
||||
|
||||
if (data.contestid != "") {
|
||||
$("#contestname").val(data.contestid);
|
||||
$("#contestname_select").val(data.contestid);
|
||||
}
|
||||
|
||||
if (settings.exchangetype != "") {
|
||||
@@ -732,7 +773,11 @@ async function restoreContestSession(data) {
|
||||
}
|
||||
|
||||
if (data.qso != "") {
|
||||
disabledContestnameSelect(true);
|
||||
await refresh_qso_table(data);
|
||||
} else {
|
||||
disabledContestnameSelect(false);
|
||||
$("#contestname_select").val("Other").change();
|
||||
}
|
||||
} else {
|
||||
$("#exch_serial_s").val("1");
|
||||
|
||||
Reference in New Issue
Block a user