diff --git a/migration/iD10/oracle/202212121023_IDEMPIERE-5517.sql b/migration/iD10/oracle/202212121023_IDEMPIERE-5517.sql new file mode 100644 index 0000000000..23749fb373 --- /dev/null +++ b/migration/iD10/oracle/202212121023_IDEMPIERE-5517.sql @@ -0,0 +1,18 @@ +-- IDEMPIERE-5517 +SELECT register_migration_script('202212121023_IDEMPIERE-5517.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Dec 12, 2022, 10:23:47 AM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Your text is too long and exceed maximum size ({0} / {1}) ; please reduce it before proceeding',0,0,'Y',TO_TIMESTAMP('2022-12-12 10:23:46','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2022-12-12 10:23:46','YYYY-MM-DD HH24:MI:SS'),10,200806,'TextEditorDialogCurrentSizeExceedMaxSize','D','8c6b6bac-9050-4abb-bdb7-3698f14a4ef3') +; + +-- Dec 12, 2022, 10:23:55 AM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','You''ll lose all your unsaved changes ; proceed?',0,0,'Y',TO_TIMESTAMP('2022-12-12 10:23:54','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2022-12-12 10:23:54','YYYY-MM-DD HH24:MI:SS'),10,200807,'TextEditorDialogResetConfirmation','D','be8f0bc2-a758-43b2-8fad-8da3f95351f7') +; + +-- Dec 14, 2022, 1:58:58 PM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Text',0,0,'Y',TO_TIMESTAMP('2022-12-14 13:58:57','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2022-12-14 13:58:57','YYYY-MM-DD HH24:MI:SS'),10,200808,'Text','D','4306a604-0bfe-4aee-b719-bff41279cf5c') +; + diff --git a/migration/iD10/postgresql/202212121023_IDEMPIERE-5517.sql b/migration/iD10/postgresql/202212121023_IDEMPIERE-5517.sql new file mode 100644 index 0000000000..b789def320 --- /dev/null +++ b/migration/iD10/postgresql/202212121023_IDEMPIERE-5517.sql @@ -0,0 +1,15 @@ +-- IDEMPIERE-5517 +SELECT register_migration_script('202212121023_IDEMPIERE-5517.sql') FROM dual; + +-- Dec 12, 2022, 10:23:47 AM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Your text is too long and exceed maximum size ({0} / {1}) ; please reduce it before proceeding',0,0,'Y',TO_TIMESTAMP('2022-12-12 10:23:46','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2022-12-12 10:23:46','YYYY-MM-DD HH24:MI:SS'),10,200806,'TextEditorDialogCurrentSizeExceedMaxSize','D','8c6b6bac-9050-4abb-bdb7-3698f14a4ef3') +; + +-- Dec 12, 2022, 10:23:55 AM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','You''ll lose all your unsaved changes ; proceed?',0,0,'Y',TO_TIMESTAMP('2022-12-12 10:23:54','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2022-12-12 10:23:54','YYYY-MM-DD HH24:MI:SS'),10,200807,'TextEditorDialogResetConfirmation','D','be8f0bc2-a758-43b2-8fad-8da3f95351f7') +; + +-- Dec 14, 2022, 1:58:58 PM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Text',0,0,'Y',TO_TIMESTAMP('2022-12-14 13:58:57','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2022-12-14 13:58:57','YYYY-MM-DD HH24:MI:SS'),10,200808,'Text','D','4306a604-0bfe-4aee-b719-bff41279cf5c') +; + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java index 2279331888..7096b76a05 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java @@ -15,6 +15,7 @@ package org.adempiere.webui.window; import java.util.HashMap; import java.util.Map; +import org.adempiere.util.Callback; import org.adempiere.webui.ClientInfo; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Label; @@ -27,7 +28,9 @@ import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.util.Env; import org.compiere.util.Language; +import org.compiere.util.Msg; import org.owasp.html.PolicyFactory; import org.owasp.html.Sanitizers; import org.zkforge.ckez.CKeditor; @@ -125,7 +128,7 @@ public class WTextEditorDialog extends Window implements EventListener{ ZKUpdateUtil.setVflex(tabbox, "1"); ZKUpdateUtil.setHflex(tabbox, "1"); - Tab tab = new Tab("Text"); + Tab tab = new Tab(Msg.getMsg(Env.getCtx(), "Text")); tabs.appendChild(tab); Tabpanel tabPanel = new Tabpanel(); @@ -219,6 +222,20 @@ public class WTextEditorDialog extends Window implements EventListener{ onCancel(); } else if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) { if (editable) { + + if (maxSize > 0) { + int currentSize = 0; + if (tabbox.getSelectedIndex() == 0) + currentSize = textBox.getText().length(); + else + currentSize = editor.getValue().length(); + + if (currentSize > maxSize) { + Dialog.error(0, "Error", Msg.getMsg(Env.getCtx(), "TextEditorDialogCurrentSizeExceedMaxSize", new Object[] {currentSize, maxSize})); + return; + } + } + if (tabbox.getSelectedIndex() == 0) { text = textBox.getText(); detach(); @@ -230,9 +247,18 @@ public class WTextEditorDialog extends Window implements EventListener{ } } else if (event.getTarget().getId().equals(ConfirmPanel.A_RESET)) { - textBox.setText(text); - if (editor != null) - editor.setValue(text); + + Dialog.ask(0, "TextEditorDialogResetConfirmation", new Callback() { + + @Override + public void onCallback(Boolean result) { + if (result) { + textBox.setText(text); + if (editor != null) + editor.setValue(text); + } + } + }); } else if (event.getName().equals(Events.ON_SELECT)) { if (editable) { if (tabbox.getSelectedIndex() == 0) {