diff --git a/customprompts/mzta-custom-prompts.css b/customprompts/mzta-custom-prompts.css index c785f153..cf668e15 100644 --- a/customprompts/mzta-custom-prompts.css +++ b/customprompts/mzta-custom-prompts.css @@ -82,4 +82,9 @@ table td.properties{ #formNew{ display: none; +} + +.text_output{ + width: 100%; + height: 9em; } \ No newline at end of file diff --git a/customprompts/mzta-custom-prompts.js b/customprompts/mzta-custom-prompts.js index 3c2eef1f..acb8447f 100644 --- a/customprompts/mzta-custom-prompts.js +++ b/customprompts/mzta-custom-prompts.js @@ -27,60 +27,60 @@ var idnumMax = 0; document.addEventListener('DOMContentLoaded', async () => { let options = { valueNames: [ { data: ['idnum'] }, 'is_default', 'id', 'name', 'text', 'type', 'action', 'position_compose', 'position_display', { name: 'need_selected', attr: 'checked_val'}, { name: 'need_signature', attr: 'checked_val'}, { name: 'need_custom_text', attr: 'checked_val'}, { name: 'enabled', attr: 'checked_val'} ], - item: function(values) { //TODO: manage ACTION edit with the select + item: function(values) { let type_output = ''; switch(String(values.type)){ case "0": - type_output = `__MSG_customPrompts_add_to_menu_always__`; + type_output = `__MSG_customPrompts_add_to_menu_always__`; break; case "1": - type_output = `__MSG_customPrompts_add_to_menu_reading__`; + type_output = `__MSG_customPrompts_add_to_menu_reading__`; break; case "2": - type_output = `__MSG_customPrompts_add_to_menu_composing__`; + type_output = `__MSG_customPrompts_add_to_menu_composing__`; break; } let action_output = ''; switch(String(values.action)){ case "0": - action_output = `__MSG_customPrompts_close_button__`; + action_output = `__MSG_customPrompts_close_button__`; break; case "1": - action_output = `__MSG_customPrompts_save_button__`; + action_output = `__MSG_customPrompts_save_button__`; break; case "2": - action_output = `__MSG_customPrompts_do_reply__`; + action_output = `__MSG_customPrompts_do_reply__`; break; } //console.log('>>>>>>>>>>>>> action_output: ' + JSON.stringify(action_output)); let output = ` - - - - ` + ((values.is_default == 1) ? type_output : - ` + + + ` + type_output + ` + `) + + ` + ` - Action: ` + ((values.is_default == 1) ? action_output : - ` - `) + + ` + `
- Need Select + Need Select
- Need Signature + Need Signature
- Need Custom Text + Need Custom Text
Enabled @@ -151,7 +151,7 @@ document.addEventListener('DOMContentLoaded', async () => { }); // Log data ID number from item row and prepare for edit action - function handleEditClick(e) { //TODO + function handleEditClick(e) { e.preventDefault(); const tr = e.target.parentNode.parentNode; //console.log('>>>>>>>> tr: ' + tr.getAttribute('data-idnum')); @@ -160,11 +160,45 @@ document.addEventListener('DOMContentLoaded', async () => { tr.querySelector('.btnCancelItem').style.display = 'inline'; // Cancel btn // tr.querySelector('.btnEditItem').style.display = 'none'; // Edit btn tr.querySelector('.btnDeleteItem').style.display = 'none'; // Delete btn + showItemRowEditor(tr); } let btnEditItem_elements = document.querySelectorAll(".btnEditItem"); btnEditItem_elements.forEach(element => { element.addEventListener('click', handleEditClick); }); + + function showItemRowEditor(tr) { + tr.querySelector('.id_output').style.display = 'inline'; + tr.querySelector('.id_show').style.display = 'none'; + tr.querySelector('.name_output').style.display = 'inline'; + tr.querySelector('.name_show').style.display = 'none'; + tr.querySelector('.text_output').style.display = 'inline'; + tr.querySelector('.text_show').style.display = 'none'; + tr.querySelector('.type_output').style.display = 'inline'; + tr.querySelector('.type_show').style.display = 'none'; + tr.querySelector('.action_output').style.display = 'inline'; + tr.querySelector('.action_show').style.display = 'none'; + tr.querySelector('input.need_selected').disabled = false; + tr.querySelector('input.need_signature').disabled = false; + tr.querySelector('input.need_custom_text').disabled = false; + } + + function hideItemRowEditor(tr) { + tr.querySelector('.id_output').style.display = 'none'; + tr.querySelector('.id_show').style.display = 'inline'; + tr.querySelector('.name_output').style.display = 'none'; + tr.querySelector('.name_show').style.display = 'inline'; + tr.querySelector('.text_output').style.display = 'none'; + tr.querySelector('.text_show').style.display = 'inline'; + tr.querySelector('.type_output').style.display = 'none'; + tr.querySelector('.type_show').style.display = 'inline'; + tr.querySelector('.action_output').style.display = 'none'; + tr.querySelector('.action_show').style.display = 'inline'; + tr.querySelector('input.need_selected').disabled = true; + tr.querySelector('input.need_signature').disabled = true; + tr.querySelector('input.need_custom_text').disabled = true; + } + // Confirm and log deletion action function handleDeleteClick(e) { @@ -191,6 +225,7 @@ document.addEventListener('DOMContentLoaded', async () => { // tr.querySelector('.btnCancelItem').style.display = 'none'; // Cancel btn tr.querySelector('.btnEditItem').style.display = 'inline'; // Edit btn tr.querySelector('.btnDeleteItem').style.display = 'inline'; // Delete btn + hideItemRowEditor(tr); } let btnCancelItem_elements = document.querySelectorAll(".btnCancelItem"); btnCancelItem_elements.forEach(element => {