Added some dialogs

This commit is contained in:
Andreas Kristiansen
2024-03-14 14:49:28 +01:00
parent d26bb3592c
commit bef09734b0
5 changed files with 174 additions and 2 deletions

View File

@@ -172,6 +172,24 @@ class Stationsetup extends CI_Controller {
$this->stationsetup_model->saveContainer();
}
public function editLinkedLocations() {
$this->load->model('logbooks_model');
$station_logbook_details_query = $this->logbooks_model->logbook(xss_clean($this->input->post('id', true)));
$data['station_logbook_details'] = $station_logbook_details_query->row();
$data['station_locations_linked'] = $this->logbooks_model->list_logbooks_linked($this->input->post('id', true));
$data['page_title'] = "Edit lined locations";
$this->load->view('stationsetup/linkedlocations', $data);
}
public function editVisitorLink() {
$this->load->model('logbooks_model');
$station_logbook_details_query = $this->logbooks_model->logbook(xss_clean($this->input->post('id', true)));
$data['station_logbook_details'] = $station_logbook_details_query->row();
$data['station_locations_list'] = $this->stations->all_of_user();
$data['page_title'] = "Edit visitor site";
$this->load->view('stationsetup/visitor', $data);
}
public function newLocation() {
$this->load->model('stations');
$this->load->model('dxcc');

View File

@@ -0,0 +1,42 @@
<div class="card">
<div class="card-header">
<?php echo lang('station_logbooks_linked_loc'); ?>
</div>
<div class="table-responsive m-4">
<table id="station_logbooks_linked_table" class="table table-hover">
<thead class="thead-light">
<tr>
<th scope="col"><?php echo lang('station_location_name'); ?></th>
<th scope="col"><?php echo lang('station_location_callsign'); ?></th>
<th scope="col"><?php echo lang('gen_hamradio_dxcc'); ?></th>
<th scope="col"><?php echo lang('station_logbooks_unlink_station_location'); ?></th>
</tr>
</thead>
<tbody>
<?php
if ($station_locations_linked) {
foreach ($station_locations_linked->result() as $row) {
?>
<tr>
<td style="text-align: center; vertical-align: middle;"><?php echo $row->station_profile_name;?></td>
<td style="text-align: center; vertical-align: middle;"><?php echo $row->station_callsign;?></td>
<td style="text-align: center; vertical-align: middle;"><?php echo $row->station_country; if ($row->end != NULL) { echo ' <span class="badge text-bg-danger">'.lang('gen_hamradio_deleted_dxcc').'</span>'; } ?></td>
<td style="text-align: center; vertical-align: middle;"><a href="<?php echo site_url('logbooks/delete_relationship/'); ?><?php echo $station_logbook_details->logbook_id; ?>/<?php echo $row->station_id;?>" class="btn btn-danger"><i class="fas fa-unlink"></i></a></td>
</tr>
<?php
}
} else {
?>
<tr>
<td style="text-align: center; vertical-align: middle;" colspan="2"><?php echo lang('station_logbooks_no_linked_loc'); ?></td>
<td style="text-align: center; vertical-align: middle;"></td>
<td style="text-align: center; vertical-align: middle;"></td>
<td style="text-align: center; vertical-align: middle;"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>

View File

@@ -47,7 +47,7 @@
}?>
</td>
<td>
<a class="btn btn-outline-primary btn-sm" href="javascript:editLinkedLocations(<?php echo $row->logbook_id; ?>);"><i class="fas fa-edit"></i></a>
<button class="btn btn-outline-primary btn-sm editLinkedLocations" id="<?php echo $row->logbook_id; ?>);"><i class="fas fa-edit"></i></button>
</td>
<td>
<?php if($this->session->userdata('active_station_logbook') != $row->logbook_id) { ?>
@@ -57,7 +57,7 @@
<?php } ?>
</td>
<td>
<a href="" title=<?php echo lang('admin_edit'); ?> class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i></a>
<button class="btn btn-outline-primary btn-sm editVisitorLink" id="<?php echo $row->logbook_id; ?>"><i class="fas fa-edit"></i></button>
<?php if($row->public_slug != '') { ?>
<a target="_blank"
href="<?php echo site_url('visitor')."/".$row->public_slug; ?>"

View File

@@ -0,0 +1,28 @@
<p><?php echo lang('station_logbooks_public_slug_hint'); ?></p>
<p><?php echo lang('station_logbooks_public_slug_format1')?><br>
<?php echo site_url('visitor'); ?>/<?php echo lang('station_logbooks_public_slug_format2'); ?></p>
<form hx-post="<?php echo site_url('logbooks/save_publicslug/'); ?>" hx-target="#publicSlugForm" style="display: inline;">
<div id="publicSlugForm">
</div>
<div class="mb-3">
<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>">
<label for="publicSlugInput"><?php echo lang('station_logbooks_public_slug_input'); ?></label>
<div hx-target="this" hx-swap="outerHTML">
<input class="form-control" name="public_slug" id="publicSlugInput" pattern="[a-zA-Z0-9-]+" value="<?php echo $station_logbook_details->public_slug; ?>" hx-post="<?php echo site_url('logbooks/publicslug_validate/'); ?>" hx-trigger="keyup changed delay:500ms" required>
</div>
</div>
<button type="submit" class="btn btn-primary" style="display:inline-block;"><i class="fas fa-plus-square"></i> <?php echo lang('admin_save'); ?></button>
</form>
<form hx-post="<?php echo site_url('logbooks/remove_publicslug/'); ?>" hx-target="#publicSlugForm" style="display: inline; margin-left: 5px;">
<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>">
<button type="submit" class="btn btn-primary" style="display:inline-block;" onclick="removeSlug()"><i class="fas fa-minus-square"></i> <?php echo lang('admin_remove'); ?></button>
</form>
<?php if($station_logbook_details->public_slug != "") { ?>
<div id="slugLink" class="alert alert-info" role="alert" style="margin-top: 20px;">
<p><?php echo lang('station_logbooks_public_slug_visit') . " "; ?></p>
<p><a href="<?php echo site_url('visitor'); ?>/<?php echo $station_logbook_details->public_slug; ?>" target="_blank"><?php echo site_url('visitor'); ?>/<?php echo $station_logbook_details->public_slug; ?></a></p>
</div>
<?php } ?>

View File

@@ -63,6 +63,14 @@ $(document).ready(function () {
saveContainerName(e);
});
$(document).on('click', '.editLinkedLocations', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
editLinkedLocations(e);
});
$(document).on('click', '.editVisitorLink', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
editVisitorLink(e);
});
$("#station_logbooks_table").DataTable({
stateSave: true,
@@ -145,6 +153,82 @@ $(document).ready(function () {
}
function editLinkedLocations(e) {
$.ajax({
url: base_url + 'index.php/stationsetup/editLinkedLocations',
type: 'post',
data: {
id: e.currentTarget.id,
},
success: function (data) {
BootstrapDialog.show({
title: 'Edit linked locations',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'options',
id: "NewStationLogbookModal",
nl2br: false,
message: data,
onshown: function(dialog) {
},
buttons: [{
label: 'Save',
cssClass: 'btn-primary btn-sm',
},
{
label: lang_admin_close,
cssClass: 'btn-sm',
id: 'closeButton',
action: function (dialogItself) {
dialogItself.close();
}
}],
});
},
error: function (data) {
},
});
return false;
}
function editVisitorLink(e) {
$.ajax({
url: base_url + 'index.php/stationsetup/editVisitorLink',
type: 'post',
data: {
id: e.currentTarget.id,
},
success: function (data) {
BootstrapDialog.show({
title: 'Edit visitor link',
size: BootstrapDialog.SIZE_NORMAL,
cssClass: 'options',
id: "NewStationLogbookModal",
nl2br: false,
message: data,
onshown: function(dialog) {
},
buttons: [{
label: 'Save',
cssClass: 'btn-primary btn-sm',
},
{
label: lang_admin_close,
cssClass: 'btn-sm',
id: 'closeButton',
action: function (dialogItself) {
dialogItself.close();
}
}],
});
},
error: function (data) {
},
});
return false;
}
function reloadLogbooks() {
$.ajax({