Files
wavelog/application/views/notes/edit.php
Szymon Porwolik b349755031 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

73 lines
3.4 KiB
PHP

<!-- Notes edit view: form for editing an existing note -->
<div class="container notes">
<?php foreach ($note->result() as $row) { ?>
<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" value="<?php echo isset($suggested_title) && $suggested_title ? $suggested_title : set_value('title', $row->title); ?>" id="inputTitle">
</div>
<div class="mb-3">
<label for="catSelect">
<?= __("Category"); ?>
<?php if ($row->cat == 'Contacts'): ?>
<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. This notes are private and are not shared with other users nor exported to external services.") ?>">
<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>
</div>
<?php } ?>
</div>