From f2e0a0dda19511b66035f0071b21e49588070226 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Fri, 16 Feb 2024 13:52:20 +0100
Subject: [PATCH 01/47] [LBA] Batch QSO edit
---
application/controllers/Logbookadvanced.php | 13 ++
application/models/Logbookadvanced_model.php | 21 +++
application/views/logbookadvanced/edit.php | 86 +++++++++++
application/views/logbookadvanced/index.php | 1 +
assets/js/sections/logbookadvanced.js | 147 +++++++++++++++++++
5 files changed, 268 insertions(+)
create mode 100644 application/views/logbookadvanced/edit.php
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index 5be9b787f..e2bf0ff70 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -495,4 +495,17 @@ class Logbookadvanced extends CI_Controller {
$this->user_options_model->set_option('LogbookAdvancedMap', 'ituzones_layer', array('boolean' => xss_clean($this->input->post('ituzone_layer'))));
$this->user_options_model->set_option('LogbookAdvancedMap', 'nightshadow_layer', array('boolean' => xss_clean($this->input->post('nightshadow_layer'))));
}
+
+ public function editDialog() {
+ $this->load->view('logbookadvanced/edit');
+ }
+
+ public function saveBatchEditQsos() {
+ $ids = xss_clean($this->input->post('ids'));
+ $column = xss_clean($this->input->post('column'));
+ $value = xss_clean($this->input->post('value'));
+
+ $this->load->model('logbookadvanced_model');
+ $this->logbookadvanced_model->saveEditedQsos($ids, $column, $value);
+ }
}
diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php
index e35cb5626..ceaa0f2e1 100644
--- a/application/models/Logbookadvanced_model.php
+++ b/application/models/Logbookadvanced_model.php
@@ -466,4 +466,25 @@ class Logbookadvanced_model extends CI_Model {
return $this->db->get()->result();
}
+
+ function saveEditedQsos($ids, $column, $value) {
+ switch($column) {
+ case "cqz": $column = 'COL_CQZ'; break;
+ case "dxcc": $column = 'COL_DXCC'; break;
+ case "iota": $column = 'COL_IOTA'; break;
+ case "was": $column = 'COL_STATE'; break;
+ case "propagation": $column = 'COL_PROP_MODE'; break;
+ default: return;
+ }
+ $this->load->model('user_model');
+
+ $data = array(
+ $column => $value
+ );
+
+ $this->db->where_in('COL_PRIMARY_KEY', $ids);
+ $this->db->update($this->config->item('table_name'), $data);
+
+ return array('message' => 'OK');
+ }
}
diff --git a/application/views/logbookadvanced/edit.php b/application/views/logbookadvanced/edit.php
new file mode 100644
index 000000000..c6367a941
--- /dev/null
+++ b/application/views/logbookadvanced/edit.php
@@ -0,0 +1,86 @@
+
diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php
index e40559a83..ff141d7d8 100644
--- a/application/views/logbookadvanced/index.php
+++ b/application/views/logbookadvanced/index.php
@@ -417,6 +417,7 @@ $options = json_decode($options);
+
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js
index 23467a508..50200771f 100644
--- a/assets/js/sections/logbookadvanced.js
+++ b/assets/js/sections/logbookadvanced.js
@@ -542,6 +542,10 @@ $(document).ready(function () {
dupeSearch();
});
+ $('#editButton').click(function (event) {
+ editQsos();
+ });
+
$('#optionButton').click(function (event) {
$('#optionButton').prop("disabled", true);
$.ajax({
@@ -1464,3 +1468,146 @@ function loadMap(data, iconsList) {
map.addLayer(item);
});
}
+
+ function editQsos() {
+ var elements = $('#qsoList tbody input:checked');
+ var nElements = elements.length;
+ if (nElements == 0) {
+ return;
+ }
+ var id_list=[];
+ elements.each(function() {
+ let id = $(this).first().closest('tr').data('qsoID')
+ id_list.push(id);
+ });
+
+ $('#editButton').prop("disabled", true);
+
+ $.ajax({
+ url: base_url + 'index.php/logbookadvanced/editDialog',
+ type: 'post',
+ success: function (html) {
+ BootstrapDialog.show({
+ title: 'Batch edit for QSOs',
+ size: BootstrapDialog.SIZE_NORMAL,
+ cssClass: 'options',
+ nl2br: false,
+ message: html,
+ onshown: function(dialog) {
+ $('#editDxcc').html($('#dxcc').html());
+ $('#editDxcc option[value="-"]').remove();
+ $('#editDxcc').val('').trigger('chosen:updated');
+
+ $('#editIota').html($('#iota').html());
+ $('#editIota option[value="-"]').remove();
+ $('#editIota').val('').trigger('chosen:updated');
+
+ $('#editPropagation').html($('#selectPropagation').html());
+ $('#editPropagation option[value="All"]').remove();
+ $('#editPropagation').val('').trigger('chosen:updated');
+
+ $('#editColumn').change(function(){
+ var type = $('#editColumn').val();
+ changeEditType(type);
+ });
+ },
+ buttons: [{
+ label: 'Save',
+ cssClass: 'btn-primary btn-sm',
+ id: 'saveButton',
+ action: function (dialogItself) {
+ saveBatchEditQsos(id_list);
+ $('#editButton').prop("disabled", false);
+ $('#closeButton').prop("disabled", true);
+ dialogItself.close();
+ }
+ },
+ {
+ label: lang_admin_close,
+ cssClass: 'btn-sm',
+ id: 'closeButton',
+ action: function (dialogItself) {
+ $('#editButton').prop("disabled", false);
+ dialogItself.close();
+ }
+ }],
+ onhide: function(dialogRef){
+ $('#editButton').prop("disabled", false);
+ },
+ });
+ }
+ });
+ }
+
+ function saveBatchEditQsos(id_list) {
+ var column = $("#editColumn").val();
+ var value;
+ if (column == 'cqz') {
+ value = $("#editCqz").val();
+ }
+ if (column == 'dxcc') {
+ value = $("#editDxcc").val();
+ }
+ if (column == 'iota') {
+ value = $("#editIota").val();
+ }
+ if (column == 'was') {
+ value = $("#editState").val();
+ }
+ if (column == 'propagation') {
+ value = $("#editPropagation").val();
+ }
+
+ $.ajax({
+ url: base_url + 'index.php/logbookadvanced/saveBatchEditQsos',
+ type: 'post',
+ data: {
+ ids: id_list,
+ column: column,
+ value: value
+ },
+ success: function (html) {
+
+ }
+ });
+ }
+
+ function changeEditType(type) {
+ if (type == "dxcc") {
+ $('#editCqz').hide();
+ $('#editIota').hide();
+ $('#editDxcc').show();
+ $('#editState').hide();
+ $('#editPropagation').hide();
+ } else if (type == "iota") {
+ $('#editCqz').hide();
+ $('#editIota').show();
+ $('#editDxcc').hide();
+ $('#editState').hide();
+ $('#editPropagation').hide();
+ } else if (type == "vucc" || type == "sota" || type == "wwff") {
+ $('#editCqz').hide();
+ $('#editIota').hide();
+ $('#editDxcc').hide();
+ $('#editState').hide();
+ $('#editPropagation').hide();
+ } else if (type == "cqz") {
+ $('#editCqz').show();
+ $('#editIota').hide();
+ $('#editDxcc').hide();
+ $('#editState').hide();
+ $('#editPropagation').hide();
+ } else if (type == "was") {
+ $('#editCqz').hide();
+ $('#editIota').hide();
+ $('#editDxcc').hide();
+ $('#editState').show();
+ $('#editPropagation').hide();
+ } else if (type == "propagation") {
+ $('#editCqz').hide();
+ $('#editIota').hide();
+ $('#editDxcc').hide();
+ $('#editState').hide();
+ $('#editPropagation').show();
+ }
+ }
From 9fc7cbfd44de8fccfa2ffbe91d90a7a86841c604 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Fri, 16 Feb 2024 14:57:41 +0100
Subject: [PATCH 02/47] Tweaked JS for dropdowns a bit
---
assets/js/sections/logbookadvanced.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js
index 50200771f..2b8051945 100644
--- a/assets/js/sections/logbookadvanced.js
+++ b/assets/js/sections/logbookadvanced.js
@@ -1495,15 +1495,15 @@ function loadMap(data, iconsList) {
message: html,
onshown: function(dialog) {
$('#editDxcc').html($('#dxcc').html());
- $('#editDxcc option[value="-"]').remove();
- $('#editDxcc').val('').trigger('chosen:updated');
+ $('#editDxcc option[value=""]').remove();
$('#editIota').html($('#iota').html());
- $('#editIota option[value="-"]').remove();
- $('#editIota').val('').trigger('chosen:updated');
$('#editPropagation').html($('#selectPropagation').html());
- $('#editPropagation option[value="All"]').remove();
+ $('#editPropagation option[value=""]').remove();
+ var option = $('