|
@@ -227,7 +227,55 @@
|
|
|
</div>
|
|
|
<div class="card-body p-0">
|
|
|
<div>
|
|
|
+ <?php
|
|
|
+ function _renderNoteTemplate($template, $topLevel) {
|
|
|
+ echo
|
|
|
+ '<div class="note-template-item" ' .
|
|
|
+ 'template="' . (isset($template->template) ? $template->template : $template->text) . '" ' .
|
|
|
+ 'type="' . (isset($template->type) ? $template->type : "value") . '" ' .
|
|
|
+ '>' .
|
|
|
+ '<div class="note-template-text">' .
|
|
|
+ '<span class="label">' .
|
|
|
+ '<input type="checkbox" />' .
|
|
|
+ '<span>' . $template->text . '</span>' .
|
|
|
+ '</span>
|
|
|
+ </div>';
|
|
|
+ if(isset($template->children) && count($template->children)) {
|
|
|
+ echo '<i class="fa fa-chevron-right has-children"></i>';
|
|
|
+ echo '<div class="note-template-children">';
|
|
|
+ foreach ($template->children as $t) {
|
|
|
+ _renderNoteTemplate($t, false);
|
|
|
+ }
|
|
|
+ echo '</div>';
|
|
|
+ }
|
|
|
+ else if(isset($template->type) && $template->type === 'text') {
|
|
|
+ echo '<i class="fa fa-chevron-right has-children"></i>';
|
|
|
+ echo '<div class="note-template-children">' .
|
|
|
+ '<textarea class="form-control form-control-sm"></textarea>' .
|
|
|
+ '</div>';
|
|
|
+ }
|
|
|
+ echo '</div>';
|
|
|
+ }
|
|
|
|
|
|
+ function renderNoteTemplates($path) {
|
|
|
+ $templates = json_decode(file_get_contents($path));
|
|
|
+ echo '<div class="note-template-container">';
|
|
|
+ echo '<div class="position-relative w-100">' .
|
|
|
+ '<div class="note-template-output">' .
|
|
|
+ '<div class="font-weight-bold text-secondary">Result:</div>' .
|
|
|
+ '<div class="note-template-output-text"></div>' .
|
|
|
+ '</div>' .
|
|
|
+ '<div class="note-template-buttons d-flex align-items-center">' .
|
|
|
+ '<button class="btn btn-sm btn-default bg-white border text-primary border-primary note-template-apply-trigger">Apply</button>' .
|
|
|
+ '<button class="btn btn-sm btn-default bg-light border text-secondary border-secondary note-template-close-trigger">Close</button>' .
|
|
|
+ '</div>' .
|
|
|
+ '</div>';
|
|
|
+ foreach ($templates as $template) {
|
|
|
+ _renderNoteTemplate($template, true);
|
|
|
+ }
|
|
|
+ echo '</div>';
|
|
|
+ }
|
|
|
+ ?>
|
|
|
<div class="mb-3">
|
|
|
<div>
|
|
|
<?php
|
|
@@ -465,7 +513,12 @@
|
|
|
.off('click.note-templates-trigger')
|
|
|
.on('click.note-templates-trigger', function() {
|
|
|
$('.note-templates-underlay').show();
|
|
|
- $(this).closest('.note-section').find('.note-template-container').show();
|
|
|
+ let container = $(this).closest('.note-section').find('.note-template-container');
|
|
|
+ container.find('.note-template-children').hide();
|
|
|
+ container.find('.note-template-item.selected').removeClass('selected');
|
|
|
+ container.find('input[type="checkbox"]').prop('checked', false);
|
|
|
+ container.find('.note-template-output-text').empty();
|
|
|
+ container.show();
|
|
|
return false;
|
|
|
});
|
|
|
|