1003129 Configure import/export toolbar availability for advanced roles only. IDEMPIERE-454

This commit is contained in:
Heng Sin Low 2013-10-22 17:29:23 +08:00
parent abbfb5be74
commit 3dd1ebbc73
7 changed files with 197 additions and 1 deletions

View File

@ -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
;

View File

@ -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
;

View File

@ -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";

View File

@ -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<MToolBarButton> list = query.setParameters("W").setOnlyActiveRecords(true).list();
if (list != null && !list.isEmpty()) {
buttons = list.toArray(buttons);
}
return buttons;
}
}

View File

@ -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

View File

@ -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<String> windowToolbarRestrictList = null;
private List<String> windowToolbarAdvancedList = null;
/**
*
* @param ctx
@ -205,6 +208,21 @@ public class ADWindow extends AbstractUIPart
return windowToolbarRestrictList;
}
public List<String> getWindowAdvancedButtonList() {
if (windowToolbarAdvancedList == null) {
//load window advance buttons
windowToolbarAdvancedList = new ArrayList<String>();
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

View File

@ -611,6 +611,23 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
} // All restrictions
if (!MRole.getDefault().isAccessAdvanced())
{
List<String> 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
if (!btnActiveWorkflows.isDisabled()) {