IDEMPIERE-5517: WTextEditorDialog : prevent user from losing text (#1609)
* IDEMPIERE-5517: WTextEditorDialog : prevent user from losing text * IDEMPIERE-5517: WTextEditorDialog : translate Text tab title
This commit is contained in:
parent
f1aee3ba14
commit
bddc400abf
|
@ -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')
|
||||
;
|
||||
|
|
@ -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')
|
||||
;
|
||||
|
|
@ -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<Event>{
|
|||
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<Event>{
|
|||
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<Event>{
|
|||
|
||||
}
|
||||
} else if (event.getTarget().getId().equals(ConfirmPanel.A_RESET)) {
|
||||
|
||||
Dialog.ask(0, "TextEditorDialogResetConfirmation", new Callback<Boolean>() {
|
||||
|
||||
@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) {
|
||||
|
|
Loading…
Reference in New Issue