wavelog/application/views/notes/edit.php

84 lines
3.8 KiB
PHP
Raw Permalink Normal View History

Notes overhaul: updated view of the notes, added "Contacts" category with required logic, first step for callsign sticky notes (#2362) * feat(notes): initial overhaul of notes with improved view, contact category, and better forms/validation * Notes: changes after draft PR review - improved security, avoided writing to $_POST - removing redundant $data variable passing - cleanup of xss_clean usage - changed to use existing callbook library instead new helper - migrated to plain SQL - changed name of the cat variable to category to avoid confusion - fixed translation (multiple places) * Translation of notes.js * Deleted not needed line. * Notes: Multiple fixes for after PR code review * Update application/views/notes/add.php Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> * Layout improvmen of the error box suggested by phl0 * Add checking of note ownership during duplication. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: improved translation of one of the strings Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: translation shall use double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using sprintf Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: update -> translations shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: missing translation of the error message. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: translation of the error message Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: moved loading of the library out of the constructor --------- Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org>
2025-10-02 20:20:35 +02:00
<!-- Notes edit view: form for editing an existing note -->
2019-05-13 18:28:16 +01:00
<div class="container notes">
<?php foreach ($note->result() as $row) { ?>
Notes overhaul: updated view of the notes, added "Contacts" category with required logic, first step for callsign sticky notes (#2362) * feat(notes): initial overhaul of notes with improved view, contact category, and better forms/validation * Notes: changes after draft PR review - improved security, avoided writing to $_POST - removing redundant $data variable passing - cleanup of xss_clean usage - changed to use existing callbook library instead new helper - migrated to plain SQL - changed name of the cat variable to category to avoid confusion - fixed translation (multiple places) * Translation of notes.js * Deleted not needed line. * Notes: Multiple fixes for after PR code review * Update application/views/notes/add.php Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> * Layout improvmen of the error box suggested by phl0 * Add checking of note ownership during duplication. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: improved translation of one of the strings Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: translation shall use double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using sprintf Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: update -> translations shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: missing translation of the error message. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: translation of the error message Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: moved loading of the library out of the constructor --------- Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org>
2025-10-02 20:20:35 +02:00
<div class="card">
<div class="card-header">
<h2 class="card-title"><?= __("Notes"); ?></h2>
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a class="nav-link" href="<?= site_url('notes'); ?>">
<i class="fa fa-sticky-note"></i> <?= __("Your Notes"); ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?= site_url('notes/add'); ?>">
<i class="fa fa-plus-square"></i> <?= __("Create Note"); ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="<?= site_url('notes/add'); ?>">
<i class="fa fa-pencil-square-o"></i> <?= __("Edit Note"); ?>
</a>
</li>
</ul>
</div>
<div class="card-body">
<!-- Show validation errors if any -->
<?php if (!empty(validation_errors())): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert" style="margin-top: 1rem;">
<span class="badge text-bg-info"><?= __("Warning"); ?></span>
<?php echo (validation_errors('<span>', '</span>')); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php endif; ?>
<!-- Note edit form -->
<form method="post" action="<?php echo site_url('notes/edit'); ?>/<?php echo $id; ?>" name="notes_add" id="notes_add">
<div class="mb-3">
<label for="inputTitle"><?= __("Title"); ?></label>
<input type="text" name="title" class="form-control <?= ($row->cat === 'Contacts') ? 'callsign' : '' ?>" value="<?php echo isset($suggested_title) && $suggested_title ? $suggested_title : set_value('title', $row->title); ?>" id="inputTitle">
Notes overhaul: updated view of the notes, added "Contacts" category with required logic, first step for callsign sticky notes (#2362) * feat(notes): initial overhaul of notes with improved view, contact category, and better forms/validation * Notes: changes after draft PR review - improved security, avoided writing to $_POST - removing redundant $data variable passing - cleanup of xss_clean usage - changed to use existing callbook library instead new helper - migrated to plain SQL - changed name of the cat variable to category to avoid confusion - fixed translation (multiple places) * Translation of notes.js * Deleted not needed line. * Notes: Multiple fixes for after PR code review * Update application/views/notes/add.php Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> * Layout improvmen of the error box suggested by phl0 * Add checking of note ownership during duplication. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: improved translation of one of the strings Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: translation shall use double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using sprintf Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: update -> translations shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: missing translation of the error message. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: translation of the error message Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: moved loading of the library out of the constructor --------- Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org>
2025-10-02 20:20:35 +02:00
</div>
<div class="mb-3">
<label for="catSelect">
<?= __("Category"); ?>
<?php if ($row->cat == 'Contacts'): ?>
2025-10-02 20:40:19 +02:00
<span class="ms-1" data-bs-toggle="tooltip" title="<?= __("Contacts is a special note category used in various places of Wavelog to store information about QSO partners. These notes are private and are not shared with other users nor exported to external services.") ?>">
Notes overhaul: updated view of the notes, added "Contacts" category with required logic, first step for callsign sticky notes (#2362) * feat(notes): initial overhaul of notes with improved view, contact category, and better forms/validation * Notes: changes after draft PR review - improved security, avoided writing to $_POST - removing redundant $data variable passing - cleanup of xss_clean usage - changed to use existing callbook library instead new helper - migrated to plain SQL - changed name of the cat variable to category to avoid confusion - fixed translation (multiple places) * Translation of notes.js * Deleted not needed line. * Notes: Multiple fixes for after PR code review * Update application/views/notes/add.php Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> * Layout improvmen of the error box suggested by phl0 * Add checking of note ownership during duplication. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: improved translation of one of the strings Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: translation shall use double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using sprintf Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: update -> translations shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: missing translation of the error message. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: translation of the error message Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: moved loading of the library out of the constructor --------- Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org>
2025-10-02 20:20:35 +02:00
<i class="fa fa-question-circle text-info"></i>
</span>
<?php endif; ?>
</label>
<select name="category" class="form-select" id="catSelect">
<?php foreach (Note::get_possible_categories() as $category_key => $category_label): ?>
<option value="<?= htmlspecialchars($category_key) ?>"<?= (set_value('category', $row->cat) == $category_key ? ' selected="selected"' : '') ?>><?= $category_label ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label for="inputTitle"><?= __("Note Contents"); ?></label>
<textarea name="content" style="display:none" id="notes"><?php echo set_value('content', $row->note); ?></textarea>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<div class="row">
<div class="col text-end">
<button type="submit" value="Submit" class="btn btn-primary">
<i class="fa fa-pencil-square-o btn-sm"></i> <?= __("Save Note"); ?>
</button>
</div>
</div>
</form>
</div>
2019-05-13 18:28:16 +01:00
</div>
Notes overhaul: updated view of the notes, added "Contacts" category with required logic, first step for callsign sticky notes (#2362) * feat(notes): initial overhaul of notes with improved view, contact category, and better forms/validation * Notes: changes after draft PR review - improved security, avoided writing to $_POST - removing redundant $data variable passing - cleanup of xss_clean usage - changed to use existing callbook library instead new helper - migrated to plain SQL - changed name of the cat variable to category to avoid confusion - fixed translation (multiple places) * Translation of notes.js * Deleted not needed line. * Notes: Multiple fixes for after PR code review * Update application/views/notes/add.php Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> * Layout improvmen of the error box suggested by phl0 * Add checking of note ownership during duplication. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: improved translation of one of the strings Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: translation shall use double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using sprintf Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Note: update -> translations shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix, translation shall be using double quotes Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: missing translation of the error message. Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: fix translation shall be using double quote Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: translation of the error message Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org> * Notes: moved loading of the library out of the constructor --------- Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: Fabian Berg <fabian.berg@hb9hil.org>
2025-10-02 20:20:35 +02:00
<?php } ?>
</div>
<script>
(function() {
var sel = document.getElementById('catSelect');
var inp = document.getElementById('inputTitle');
if (sel && inp) {
sel.addEventListener('change', function() {
inp.classList.toggle('callsign', sel.value === 'Contacts');
});
}
})();
</script>