cloudlog/application/views/notes/add.php
Peter Goodhall 5c5bdf2f2f Add categories and management to notes feature
Introduces note categories with support for filtering, assigning, and managing categories. Adds category selection and creation to add/edit forms, category filtering to the notes list, and modals for deleting/merging categories and confirming note deletion. Updates controller and model logic to handle categories, and improves UI for notes management.
2026-01-09 13:17:56 +00:00

78 lines
3.4 KiB
PHP

<div class="container notes">
<div class="row">
<div class="col-12 col-xl-10">
<div class="card shadow-sm">
<div class="card-header">
<div class="d-flex flex-wrap justify-content-between align-items-start gap-2">
<div class="d-flex flex-column">
<a class="small text-decoration-none" href="<?php echo site_url('notes'); ?>">&larr; <?php echo lang('notes_menu_notes'); ?></a>
<h2 class="card-title mb-0"><?php echo lang('notes_create_note'); ?></h2>
</div>
<ul class="nav nav-tabs card-header-tabs ms-auto">
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('notes'); ?>"><?php echo lang('notes_menu_notes'); ?></a>
</li>
<li class="nav-item">
<a class="nav-link active" href="<?php echo site_url('notes/add'); ?>"><?php echo lang('notes_create_note'); ?></a>
</li>
</ul>
</div>
</div>
<div class="card-body">
<?php if (!empty(validation_errors())): ?>
<div class="alert alert-danger">
<a class="btn-close" data-bs-dismiss="alert" title="close">x</a>
<ul><?php echo (validation_errors('<li>', '</li>')); ?></ul>
</div>
<?php endif; ?>
<?php
$defaultCategories = array('General', 'Antennas', 'Satellites');
$existingCategories = isset($categories) && is_array($categories) ? $categories : array();
$categoryOptions = array_values(array_unique(array_merge($defaultCategories, $existingCategories)));
$selectedCategory = set_value('category', 'General');
?>
<form method="post" action="<?php echo site_url('notes/add'); ?>" name="notes_add" id="notes_add">
<div class="mb-3">
<label for="inputTitle" class="form-label"><?php echo lang('notes_input_title'); ?></label>
<input type="text" name="title" class="form-control" id="inputTitle" value="<?php echo set_value('title'); ?>" placeholder="e.g. Field day setup" autocomplete="off" required>
</div>
<div class="mb-3">
<label for="catSelect" class="form-label"><?php echo lang('notes_input_category'); ?></label>
<select name="category" class="form-select" id="catSelect">
<?php foreach ($categoryOptions as $catOption) { ?>
<option value="<?php echo $catOption; ?>" <?php echo ($selectedCategory === $catOption) ? 'selected' : ''; ?>><?php echo $catOption; ?></option>
<?php } ?>
</select>
<small class="text-muted d-block mt-1">Select an existing category or type a new one below.</small>
</div>
<div class="mb-3">
<label for="newCategoryInput" class="form-label">New category (optional)</label>
<input type="text" name="new_category" class="form-control" id="newCategoryInput" value="<?php echo set_value('new_category'); ?>" placeholder="e.g. Portable Ops" autocomplete="off">
<small class="text-muted">If filled, this will be used instead of the selected category.</small>
</div>
<div class="mb-3">
<label for="hiddenArea" class="form-label"><?php echo lang('notes_input_notes_content'); ?></label>
<div id="quillArea"></div>
<textarea name="content" style="display:none" id="hiddenArea"></textarea>
</div>
<div class="d-flex flex-wrap gap-2">
<button type="submit" value="Submit" class="btn btn-primary"><?php echo lang('notes_input_btn_save_note'); ?></button>
<a href="<?php echo site_url('notes'); ?>" class="btn btn-outline-secondary"><?php echo lang('general_word_cancel') ?: 'Cancel'; ?></a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>