From 7bf606a06a3f90545aab044c494e8a561f52b6f5 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 13 Mar 2024 07:54:34 +0100 Subject: [PATCH] Simplifying station setup. Only view changed so far --- application/controllers/Stationsetup.php | 14 ++++- application/models/Stationsetup_model.php | 15 ++++++ application/views/stationsetup/edit.php | 23 ++++++++ .../views/stationsetup/stationsetup.php | 16 +++--- assets/js/sections/stationsetup.js | 52 +++++++++++++++++++ 5 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 application/models/Stationsetup_model.php create mode 100644 application/views/stationsetup/edit.php diff --git a/application/controllers/Stationsetup.php b/application/controllers/Stationsetup.php index 0d0fca6c7..c95bf6008 100644 --- a/application/controllers/Stationsetup.php +++ b/application/controllers/Stationsetup.php @@ -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'); diff --git a/application/models/Stationsetup_model.php b/application/models/Stationsetup_model.php new file mode 100644 index 000000000..5741827b4 --- /dev/null +++ b/application/models/Stationsetup_model.php @@ -0,0 +1,15 @@ +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'); + } +} + +?> diff --git a/application/views/stationsetup/edit.php b/application/views/stationsetup/edit.php new file mode 100644 index 000000000..c7d8ffa10 --- /dev/null +++ b/application/views/stationsetup/edit.php @@ -0,0 +1,23 @@ +
+ +
+ +
+
+ + session->flashdata('notice')) { ?> +
+ session->flashdata('notice'); ?> +
+ + + load->helper('form'); ?> + +
+ + + You can call a container anything. +
+ + +
diff --git a/application/views/stationsetup/stationsetup.php b/application/views/stationsetup/stationsetup.php index 3fdeb647d..baadee980 100644 --- a/application/views/stationsetup/stationsetup.php +++ b/application/views/stationsetup/stationsetup.php @@ -20,6 +20,7 @@

+ Linked locations num_rows() > 0) { ?>
@@ -30,14 +31,14 @@ - + Visitor site result() as $row) { ?> - logbook_name;?> + logbook_name;?> session->userdata('active_station_logbook') != $row->logbook_id) { ?> @@ -59,6 +60,7 @@ + class="btn btn-outline-primary btn-sm"> public_slug != '') { ?> public_slug; ?>" @@ -69,10 +71,12 @@ public_search == 1) { - echo "" . lang('general_word_enabled') . ""; - } else { - echo "" . lang('general_word_disabled') . ""; - } ?> + echo "" . lang('general_word_enabled') . "";?> +
+ " . lang('general_word_disabled') . ""; ?> +
+ diff --git a/assets/js/sections/stationsetup.js b/assets/js/sections/stationsetup.js index 8a69d2a32..9cea13d6a 100644 --- a/assets/js/sections/stationsetup.js +++ b/assets/js/sections/stationsetup.js @@ -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',