diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php index 3a30990a1..501d8aacf 100644 --- a/application/controllers/Contesting.php +++ b/application/controllers/Contesting.php @@ -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 { diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 00b9cd850..802e81aee 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -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; diff --git a/application/views/contesting/index.php b/application/views/contesting/index.php index 0e2cb6e2d..c4b6e2e4b 100644 --- a/application/views/contesting/index.php +++ b/application/views/contesting/index.php @@ -1,3 +1,7 @@ + +

LIVE" : " POST"); ?> @@ -22,14 +26,15 @@
- +
- " . $contest['name'] . ""; } ?> +
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index a13de10c7..fa56065b7 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2472,7 +2472,6 @@ function viewEqsl(picture, callsign) { - uri->segment(2) == "counties" || $this->uri->segment(2) == "counties_details") { ?> diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js index 18402d47f..ca3564537 100644 --- a/assets/js/sections/contesting.js +++ b/assets/js/sections/contesting.js @@ -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");