From 3dd1ebbc736cdce7c1e2d726a49e9458649da72d Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 22 Oct 2013 17:29:23 +0800 Subject: [PATCH] 1003129 Configure import/export toolbar availability for advanced roles only. IDEMPIERE-454 --- .../i1.0z/oracle/201310220920_1003129.sql | 56 +++++++++++++++++++ .../i1.0z/postgresql/201310220920_1003129.sql | 53 ++++++++++++++++++ .../compiere/model/I_AD_ToolBarButton.java | 13 +++++ .../org/compiere/model/MToolBarButton.java | 13 +++++ .../compiere/model/X_AD_ToolBarButton.java | 28 +++++++++- .../adempiere/webui/adwindow/ADWindow.java | 18 ++++++ .../webui/adwindow/ADWindowToolbar.java | 17 ++++++ 7 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 migration/i1.0z/oracle/201310220920_1003129.sql create mode 100644 migration/i1.0z/postgresql/201310220920_1003129.sql diff --git a/migration/i1.0z/oracle/201310220920_1003129.sql b/migration/i1.0z/oracle/201310220920_1003129.sql new file mode 100644 index 0000000000..24557ada24 --- /dev/null +++ b/migration/i1.0z/oracle/201310220920_1003129.sql @@ -0,0 +1,56 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Oct 22, 2013 4:00:00 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,Name,Description,PrintName,AD_Element_UU,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType) VALUES ('IsAdvancedButton',202620,'The button with advanced functionality is only displayed for role that can access advanced functionality','Advanced Button','This Button contains advanced Functionality','Advanced Button','cb2580bd-1c17-47ce-a149-4e55176a2424',TO_DATE('2013-10-22 15:59:57','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-10-22 15:59:57','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y',0,'D') +; + +-- Oct 22, 2013 4:01:38 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,AD_Element_ID,IsUseLuceneIndex,IsSecure) VALUES (0,'N',1,200003,210880,'Y','N','N',0,'N',1,'N',20,'N','N','Y','5f6b8aa3-5e3c-4a94-9177-1e81fd5dc406','Y','IsAdvancedButton','This Button contains advanced Functionality','N','The button with advanced functionality is only displayed for role that can access advanced functionality','Advanced Button','Y',TO_DATE('2013-10-22 16:01:35','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2013-10-22 16:01:35','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N',202620,'N','N') +; + +-- Oct 22, 2013 4:02:24 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,EntityType,IsAdvancedField,IsDefaultFocus) VALUES (0,'N',200002,0,'N','N',210880,100,'Y',202527,'N','The button with advanced functionality is only displayed for role that can access advanced functionality','This Button contains advanced Functionality','Advanced Button','d8129ffc-6856-4651-9480-e25763223f35','Y','N',100,0,TO_DATE('2013-10-22 16:02:21','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-10-22 16:02:21','YYYY-MM-DD HH24:MI:SS'),'Y','Y',100,1,'N',0,2,1,'D','N','N') +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=80, IsDisplayed='Y', XPosition=2,Updated=TO_DATE('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202527 +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=90,Updated=TO_DATE('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200053 +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=100,Updated=TO_DATE('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200753 +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=0,Updated=TO_DATE('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200062 +; + +-- Oct 22, 2013 4:06:03 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +ALTER TABLE AD_ToolBarButton ADD IsAdvancedButton CHAR(1) DEFAULT 'N' CHECK (IsAdvancedButton IN ('Y','N')) NOT NULL +; + +-- Oct 22, 2013 5:01:11 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_ToolBarButton SET IsAdvancedButton='Y',Updated=TO_DATE('2013-10-22 17:01:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200057 +; + +-- Oct 22, 2013 5:01:23 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_ToolBarButton SET IsAdvancedButton='Y',Updated=TO_DATE('2013-10-22 17:01:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200067 +; + +SELECT register_migration_script('201310220920_1003129.sql') FROM dual +; + diff --git a/migration/i1.0z/postgresql/201310220920_1003129.sql b/migration/i1.0z/postgresql/201310220920_1003129.sql new file mode 100644 index 0000000000..61f3aea51f --- /dev/null +++ b/migration/i1.0z/postgresql/201310220920_1003129.sql @@ -0,0 +1,53 @@ +-- Oct 22, 2013 4:00:00 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,Name,Description,PrintName,AD_Element_UU,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType) VALUES ('IsAdvancedButton',202620,'The button with advanced functionality is only displayed for role that can access advanced functionality','Advanced Button','This Button contains advanced Functionality','Advanced Button','cb2580bd-1c17-47ce-a149-4e55176a2424',TO_TIMESTAMP('2013-10-22 15:59:57','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-10-22 15:59:57','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y',0,'D') +; + +-- Oct 22, 2013 4:01:38 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,AD_Element_ID,IsUseLuceneIndex,IsSecure) VALUES (0,'N',1,200003,210880,'Y','N','N',0,'N',1,'N',20,'N','N','Y','5f6b8aa3-5e3c-4a94-9177-1e81fd5dc406','Y','IsAdvancedButton','This Button contains advanced Functionality','N','The button with advanced functionality is only displayed for role that can access advanced functionality','Advanced Button','Y',TO_TIMESTAMP('2013-10-22 16:01:35','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2013-10-22 16:01:35','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N',202620,'N','N') +; + +-- Oct 22, 2013 4:02:24 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,EntityType,IsAdvancedField,IsDefaultFocus) VALUES (0,'N',200002,0,'N','N',210880,100,'Y',202527,'N','The button with advanced functionality is only displayed for role that can access advanced functionality','This Button contains advanced Functionality','Advanced Button','d8129ffc-6856-4651-9480-e25763223f35','Y','N',100,0,TO_TIMESTAMP('2013-10-22 16:02:21','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-10-22 16:02:21','YYYY-MM-DD HH24:MI:SS'),'Y','Y',100,1,'N',0,2,1,'D','N','N') +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=80, IsDisplayed='Y', XPosition=2,Updated=TO_TIMESTAMP('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202527 +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=90,Updated=TO_TIMESTAMP('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200053 +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=100,Updated=TO_TIMESTAMP('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200753 +; + +-- Oct 22, 2013 4:04:30 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_Field SET SeqNo=0,Updated=TO_TIMESTAMP('2013-10-22 16:04:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200062 +; + +-- Oct 22, 2013 4:06:03 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +ALTER TABLE AD_ToolBarButton ADD COLUMN IsAdvancedButton CHAR(1) DEFAULT 'N' CHECK (IsAdvancedButton IN ('Y','N')) NOT NULL +; + +-- Oct 22, 2013 5:01:11 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_ToolBarButton SET IsAdvancedButton='Y',Updated=TO_TIMESTAMP('2013-10-22 17:01:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200057 +; + +-- Oct 22, 2013 5:01:23 PM MYT +-- 1003129 Configure import/export toolbar availability for Bizidium Tenant only +UPDATE AD_ToolBarButton SET IsAdvancedButton='Y',Updated=TO_TIMESTAMP('2013-10-22 17:01:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200067 +; + +SELECT register_migration_script('201310220920_1003129.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_ToolBarButton.java b/org.adempiere.base/src/org/compiere/model/I_AD_ToolBarButton.java index 8e54384e8c..d80ae0e77b 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_ToolBarButton.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_ToolBarButton.java @@ -200,6 +200,19 @@ public interface I_AD_ToolBarButton */ public boolean isActive(); + /** Column name IsAdvancedButton */ + public static final String COLUMNNAME_IsAdvancedButton = "IsAdvancedButton"; + + /** Set Advanced Button. + * This Button contains advanced Functionality + */ + public void setIsAdvancedButton (boolean IsAdvancedButton); + + /** Get Advanced Button. + * This Button contains advanced Functionality + */ + public boolean isAdvancedButton(); + /** Column name IsCustomization */ public static final String COLUMNNAME_IsCustomization = "IsCustomization"; diff --git a/org.adempiere.base/src/org/compiere/model/MToolBarButton.java b/org.adempiere.base/src/org/compiere/model/MToolBarButton.java index 2f184701c8..daf5b1e1a8 100644 --- a/org.adempiere.base/src/org/compiere/model/MToolBarButton.java +++ b/org.adempiere.base/src/org/compiere/model/MToolBarButton.java @@ -74,4 +74,17 @@ public class MToolBarButton extends X_AD_ToolBarButton { return buttons; } + + public static MToolBarButton[] getWindowAdvancedButtons() { + MToolBarButton[] buttons = new MToolBarButton[0]; + + Query query = new Query(Env.getCtx(), MTable.get(Env.getCtx(), Table_ID), "Action=?" + + " AND IsAdvancedButton='Y' AND AD_Client_ID=0", null); + List list = query.setParameters("W").setOnlyActiveRecords(true).list(); + if (list != null && !list.isEmpty()) { + buttons = list.toArray(buttons); + } + + return buttons; + } } diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_ToolBarButton.java b/org.adempiere.base/src/org/compiere/model/X_AD_ToolBarButton.java index 50f41c372c..29003e17f4 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_ToolBarButton.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_ToolBarButton.java @@ -30,7 +30,7 @@ public class X_AD_ToolBarButton extends PO implements I_AD_ToolBarButton, I_Pers /** * */ - private static final long serialVersionUID = 20130626L; + private static final long serialVersionUID = 20131022L; /** Standard Constructor */ public X_AD_ToolBarButton (Properties ctx, int AD_ToolBarButton_ID, String trxName) @@ -42,6 +42,8 @@ public class X_AD_ToolBarButton extends PO implements I_AD_ToolBarButton, I_Pers // W setAD_ToolBarButton_ID (0); setComponentName (null); + setIsAdvancedButton (false); +// N setIsCustomization (false); // N setName (null); @@ -267,6 +269,30 @@ public class X_AD_ToolBarButton extends PO implements I_AD_ToolBarButton, I_Pers return (String)get_Value(COLUMNNAME_DisplayLogic); } + /** Set Advanced Button. + @param IsAdvancedButton + This Button contains advanced Functionality + */ + public void setIsAdvancedButton (boolean IsAdvancedButton) + { + set_Value (COLUMNNAME_IsAdvancedButton, Boolean.valueOf(IsAdvancedButton)); + } + + /** Get Advanced Button. + @return This Button contains advanced Functionality + */ + public boolean isAdvancedButton () + { + Object oo = get_Value(COLUMNNAME_IsAdvancedButton); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + /** Set Customization. @param IsCustomization The change is a customization of the data dictionary and can be applied after Migration diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java index 62d3e87af3..634d7e145b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java @@ -31,6 +31,7 @@ import org.adempiere.webui.session.SessionManager; import org.compiere.model.MImage; import org.compiere.model.MQuery; import org.compiere.model.MRole; +import org.compiere.model.MToolBarButton; import org.compiere.model.MToolBarButtonRestrict; import org.compiere.model.X_AD_ToolBarButton; import org.compiere.util.CCache; @@ -64,6 +65,8 @@ public class ADWindow extends AbstractUIPart private List windowToolbarRestrictList = null; + private List windowToolbarAdvancedList = null; + /** * * @param ctx @@ -205,6 +208,21 @@ public class ADWindow extends AbstractUIPart return windowToolbarRestrictList; } + public List getWindowAdvancedButtonList() { + if (windowToolbarAdvancedList == null) { + //load window advance buttons + windowToolbarAdvancedList = new ArrayList(); + MToolBarButton[] buttons = MToolBarButton.getWindowAdvancedButtons(); + + for (int i = 0; i < buttons.length; i++) + { + String restrictName = ADWindowToolbar.BTNPREFIX + buttons[i].getComponentName(); + windowToolbarAdvancedList.add(restrictName); + } // All restrictions + } + return windowToolbarAdvancedList; + } + /** * * @param windowNo diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index 94855d05d9..8b8a4e47f9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -610,6 +610,23 @@ public class ADWindowToolbar extends FToolbar implements EventListener } } // All restrictions + + if (!MRole.getDefault().isAccessAdvanced()) + { + List advancedList = adwindow.getWindowAdvancedButtonList(); + for (String advancedName : advancedList) + { + for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) { + if (p instanceof ToolBarButton) { + if ( advancedName.equals(((ToolBarButton)p).getName()) ) { + this.removeChild(p); + break; + } + } + } + + } // All advanced btn + } dynamicDisplay(); // If no workflow set for the table => disable btnWorkflow