|
@@ -1,6 +1,8 @@
|
|
<?php
|
|
<?php
|
|
/** @var App\Models\Note $note */
|
|
/** @var App\Models\Note $note */
|
|
/** @var App\Models\Pro $pro */
|
|
/** @var App\Models\Pro $pro */
|
|
|
|
+/** @var App\Models\Section $section */
|
|
|
|
+/** @var $allSections */
|
|
?>
|
|
?>
|
|
@extends ('layouts.patient')
|
|
@extends ('layouts.patient')
|
|
|
|
|
|
@@ -506,10 +508,70 @@
|
|
.find('textarea')
|
|
.find('textarea')
|
|
.first().focus();
|
|
.first().focus();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ generateTemplateOutput();
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $('.note-template-apply-trigger')
|
|
|
|
+ .off('mousedown.note-templates-apply')
|
|
|
|
+ .on('mousedown.note-templates-apply', function() {
|
|
|
|
+ let result = $('.note-template-output-text:visible').first().html();
|
|
|
|
+ $('.note-templates-underlay').hide();
|
|
|
|
+ $('.note-template-container').hide();
|
|
|
|
+ let editor = $('.ql-editor[contenteditable]').first();
|
|
|
|
+ result = $.trim(editor.text() !== '' ? editor.html() : '') + result;
|
|
|
|
+ editor.html(result).focus();
|
|
return false;
|
|
return false;
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ $('.note-template-item textarea')
|
|
|
|
+ .off('input paste')
|
|
|
|
+ .on('input paste', function() {
|
|
|
|
+ generateTemplateOutput();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function generateOutputForNode(_node) {
|
|
|
|
+ let template = _node.attr('template'),
|
|
|
|
+ value = template;
|
|
|
|
+ if(value.indexOf('{text}') !== -1) {
|
|
|
|
+ value = value.replace('{text}', _node.find('>.note-template-children>textarea').first().val());
|
|
|
|
+ }
|
|
|
|
+ else if(value.indexOf('{children}') !== -1) {
|
|
|
|
+ let values = [];
|
|
|
|
+ _node.find('>.note-template-children>.note-template-item.selected').each(function() {
|
|
|
|
+ values.push(generateOutputForNode($(this)));
|
|
|
|
+ });
|
|
|
|
+ let combined = '';
|
|
|
|
+ for (let i = 0; i < values.length; i++) {
|
|
|
|
+ combined += values[i];
|
|
|
|
+ if(values.length > 1 && i <= values.length - 2) {
|
|
|
|
+ if(i === values.length - 2) {
|
|
|
|
+ combined += ' and ';
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ combined += ', ';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ value = value.replace('{children}', combined);
|
|
|
|
+ }
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function generateTemplateOutput() {
|
|
|
|
+ let container = $('.note-template-container:visible').first();
|
|
|
|
+ if(!container.length) return '';
|
|
|
|
+ let lines = [];
|
|
|
|
+ container.find('>.note-template-item.selected').each(function() {
|
|
|
|
+ lines.push('<p class="note-template-output-line">' + generateOutputForNode($(this)) + '</p>');
|
|
|
|
+ });
|
|
|
|
+ $('.note-template-output-text:visible').first().html(lines.join(''));
|
|
}
|
|
}
|
|
|
|
+
|
|
addMCInitializer('note-single', init);
|
|
addMCInitializer('note-single', init);
|
|
})();
|
|
})();
|
|
</script>
|
|
</script>
|