|
@@ -68,7 +68,20 @@ function __initRTEs(_collection) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ formats: [
|
|
|
|
+ 'bold',
|
|
|
|
+ 'italic',
|
|
|
|
+ 'link',
|
|
|
|
+ 'size',
|
|
|
|
+ 'strike',
|
|
|
|
+ 'underline',
|
|
|
|
+ 'blockquote',
|
|
|
|
+ 'header',
|
|
|
|
+ 'indent',
|
|
|
|
+ 'list',
|
|
|
|
+ 'align',
|
|
|
|
+ ]
|
|
});
|
|
});
|
|
|
|
|
|
var toolbar = $(quill.container).prev('.ql-toolbar');
|
|
var toolbar = $(quill.container).prev('.ql-toolbar');
|
|
@@ -91,7 +104,8 @@ function __initRTEs(_collection) {
|
|
if(!pElem.length) {
|
|
if(!pElem.length) {
|
|
pElem = $(el).closest('form');
|
|
pElem = $(el).closest('form');
|
|
}
|
|
}
|
|
- let v = pElem.find('input[name="' + ($(el).attr('data-container-name') ? $(el).attr('data-container-name') : 'data') + '"]').val();
|
|
|
|
|
|
+ let dataElem = pElem.find('input[name="' + ($(el).attr('data-container-name') ? $(el).attr('data-container-name') : 'data') + '"]');
|
|
|
|
+ let v = dataElem.val();
|
|
if(!!v) {
|
|
if(!!v) {
|
|
try {
|
|
try {
|
|
v = JSON.parse(v);
|
|
v = JSON.parse(v);
|
|
@@ -106,7 +120,7 @@ function __initRTEs(_collection) {
|
|
v = JSON.stringify(dataObject);
|
|
v = JSON.stringify(dataObject);
|
|
}
|
|
}
|
|
|
|
|
|
- pElem.find('input[name=' + ($(el).attr('data-container-name') ? $(el).attr('data-container-name') : 'data') + ']').val(v);
|
|
|
|
|
|
+ dataElem.val(v);
|
|
|
|
|
|
$(el).trigger('rich-text-input');
|
|
$(el).trigger('rich-text-input');
|
|
};
|
|
};
|
|
@@ -834,12 +848,13 @@ function newRow(_tr) {
|
|
newTr.find('input, textarea').val('');
|
|
newTr.find('input, textarea').val('');
|
|
newTr.find('textarea').attr('rows', 1).css({minHeight: '', height: ''});
|
|
newTr.find('textarea').attr('rows', 1).css({minHeight: '', height: ''});
|
|
newTr.find('[stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
|
|
newTr.find('[stag-suggest-initialized]').removeAttr('stag-suggest-initialized');
|
|
|
|
+ newTr.find('.stag-suggestions-container').remove();
|
|
return newTr;
|
|
return newTr;
|
|
}
|
|
}
|
|
|
|
|
|
function createAndMoveToNextRowInput(_td) {
|
|
function createAndMoveToNextRowInput(_td) {
|
|
let tr = createRowAfter(_td.closest('tr'));
|
|
let tr = createRowAfter(_td.closest('tr'));
|
|
- tr.find('td:eq(0)').find('input, textarea').first().focus();
|
|
|
|
|
|
+ tr.find('input, textarea').first().focus();
|
|
}
|
|
}
|
|
|
|
|
|
function moveToNextRowInput(_td, _forceCreate = false) {
|
|
function moveToNextRowInput(_td, _forceCreate = false) {
|
|
@@ -868,6 +883,9 @@ function generateData(_parentSegment) {
|
|
$(this).find('input, textarea').each(function() {
|
|
$(this).find('input, textarea').each(function() {
|
|
line[$(this).attr('bucket')][$(this).attr('key')] = this.value;
|
|
line[$(this).attr('bucket')][$(this).attr('key')] = this.value;
|
|
});
|
|
});
|
|
|
|
+ $(this).find('[note-rte][key][bucket]').each(function() {
|
|
|
|
+ line[$(this).attr('bucket')][$(this).attr('key')] = $(this).find('.ql-editor[contenteditable]').first().html();
|
|
|
|
+ });
|
|
line.data = JSON.stringify(line.data);
|
|
line.data = JSON.stringify(line.data);
|
|
line.childReviewData = JSON.stringify(line.childReviewData);
|
|
line.childReviewData = JSON.stringify(line.childReviewData);
|
|
line.childPlanData = JSON.stringify(line.childPlanData);
|
|
line.childPlanData = JSON.stringify(line.childPlanData);
|
|
@@ -884,6 +902,7 @@ parentSegment
|
|
if (!_e.shiftKey || !$(this).is('textarea')) {
|
|
if (!_e.shiftKey || !$(this).is('textarea')) {
|
|
if($(this).closest('.stag-sheet').is('.allow-row-addition')) {
|
|
if($(this).closest('.stag-sheet').is('.allow-row-addition')) {
|
|
createAndMoveToNextRowInput($(this).closest('td'));
|
|
createAndMoveToNextRowInput($(this).closest('td'));
|
|
|
|
+ initStagSuggest();
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
moveToNextRowInput($(this).closest('td'), false);
|
|
moveToNextRowInput($(this).closest('td'), false);
|
|
@@ -921,6 +940,16 @@ parentSegment
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+parentSegment
|
|
|
|
+ .off('click', '.stag-sheet tbody td')
|
|
|
|
+ .on('click', '.stag-sheet tbody td', function(_e) {
|
|
|
|
+ let focusable = $(this).find('input, textarea, .ql-editor[contenteditable]').first();
|
|
|
|
+ if(!focusable.is(':focus')) {
|
|
|
|
+ focusable.focus();
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
parentSegment
|
|
parentSegment
|
|
.off('click.delete-line', '.stag-sheet .delete-line')
|
|
.off('click.delete-line', '.stag-sheet .delete-line')
|
|
.on('click.delete-line', '.stag-sheet .delete-line', function() {
|
|
.on('click.delete-line', '.stag-sheet .delete-line', function() {
|
|
@@ -945,14 +974,37 @@ parentSegment
|
|
parentSegment
|
|
parentSegment
|
|
.off('click.btn-save-lines', '.btn-save-lines')
|
|
.off('click.btn-save-lines', '.btn-save-lines')
|
|
.on('click.btn-save-lines', '.btn-save-lines', function() {
|
|
.on('click.btn-save-lines', '.btn-save-lines', function() {
|
|
|
|
+ let numRows = parentSegment.find('.stag-sheet').find('tbody>tr').length;
|
|
|
|
+ let numEmptyRows = numRows;
|
|
|
|
+ let emptyRows = [];
|
|
|
|
+ parentSegment.find('.stag-sheet').find('tbody>tr').each(function() { // loop A
|
|
|
|
+ let isEmptyRow = true;
|
|
|
|
+ $(this).find('input, textarea').each(function() { // loop B
|
|
|
|
+ if($.trim($(this).val())) {
|
|
|
|
+ isEmptyRow = false;
|
|
|
|
+ return false; // break from B
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if(!isEmptyRow) numEmptyRows--;
|
|
|
|
+ else emptyRows.push(this);
|
|
|
|
+ });
|
|
|
|
+ if(numEmptyRows > 0) {
|
|
|
|
+ if(numEmptyRows === numRows && numRows === 1) return false; // if only 1 row and all empty in that - ignore and stop
|
|
|
|
+ else { // else clear empty rows
|
|
|
|
+ for (let i = 0; i < emptyRows.length; i++) {
|
|
|
|
+ $(emptyRows[i]).remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
parentSegment.find('[name="dataJson"]').val(generateData(parentSegment));
|
|
parentSegment.find('[name="dataJson"]').val(generateData(parentSegment));
|
|
saveVisitForm(this);
|
|
saveVisitForm(this);
|
|
return false;
|
|
return false;
|
|
});
|
|
});
|
|
|
|
|
|
parentSegment
|
|
parentSegment
|
|
- .off('click.switch-to-edit', '.point-table [if-read-mode] .inline-html-container')
|
|
|
|
- .on('click.switch-to-edit', '.point-table [if-read-mode] .inline-html-container', function() {
|
|
|
|
|
|
+ .off('click.switch-to-edit', '.point-table [if-read-mode] .inline-html-container:not(.click-to-copy)')
|
|
|
|
+ .on('click.switch-to-edit', '.point-table [if-read-mode] .inline-html-container:not(.click-to-copy)', function() {
|
|
let trigger = $(this).closest('[if-read-mode]')
|
|
let trigger = $(this).closest('[if-read-mode]')
|
|
.find('form[url="/api/visitPoint/upsertChildReview"], form[url="/api/visitPoint/upsertChildPlan"]')
|
|
.find('form[url="/api/visitPoint/upsertChildReview"], form[url="/api/visitPoint/upsertChildPlan"]')
|
|
.first().closest('[moe], [visit-moe]')
|
|
.first().closest('[moe], [visit-moe]')
|