From 82c068f1b1d5dc876b91ffd50aed73bdc4ddfd84 Mon Sep 17 00:00:00 2001 From: Nathan Dunn Date: Thu, 13 Aug 2015 17:22:22 -0700 Subject: [PATCH] #542 --- .../bbop/apollo/gwt/client/GroupPanel.java | 38 +++++++++------- .../org/bbop/apollo/gwt/client/UserPanel.java | 44 ++++++++++--------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/gwt/org/bbop/apollo/gwt/client/GroupPanel.java b/src/gwt/org/bbop/apollo/gwt/client/GroupPanel.java index 0b737feeb6..9aeb998262 100644 --- a/src/gwt/org/bbop/apollo/gwt/client/GroupPanel.java +++ b/src/gwt/org/bbop/apollo/gwt/client/GroupPanel.java @@ -60,7 +60,7 @@ interface UserGroupBrowserPanelUiBinder extends UiBinder { @UiField(provided = true) SimplePager organismPager = new SimplePager(SimplePager.TextLocation.CENTER); @UiField(provided = true) - DataGrid organismPermissionsGrid = new DataGrid<>(4,tablecss); + DataGrid organismPermissionsGrid = new DataGrid<>(4, tablecss); private ListDataProvider dataProvider = new ListDataProvider<>(); private List groupInfoList = dataProvider.getList(); private SingleSelectionModel selectionModel = new SingleSelectionModel<>(); @@ -161,14 +161,15 @@ public void deleteGroup(ClickEvent clickEvent) { private GroupInfo getGroupFromUI() { String groupName = name.getText().trim(); - if(groupName.length()<3){ + if (groupName.length() < 3) { Window.alert("Group must be at least 3 characters long"); - return null ; + return null; } GroupInfo groupInfo = new GroupInfo(); groupInfo.setName(groupName); return groupInfo; } + @UiHandler("userDetailTab") void onTabSelection(SelectionEvent event) { organismPermissionsGrid.redraw(); @@ -179,7 +180,7 @@ void onTabSelection(SelectionEvent event) { public void createGroup(ClickEvent clickEvent) { GroupInfo groupInfo = getGroupFromUI(); - if(groupInfo==null) return ; + if (groupInfo == null) return; GroupRestService.addNewGroup(groupInfo); } @@ -201,24 +202,27 @@ private void setSelectedGroup() { deleteButton.setVisible(true); userData.removeAllRows(); - for(UserInfo userInfo : selectedGroupInfo.getUserInfoList()){ - int rowCount = userData.getRowCount() ; - userData.setHTML(rowCount,0,userInfo.getName()); + for (UserInfo userInfo : selectedGroupInfo.getUserInfoList()) { + int rowCount = userData.getRowCount(); + userData.setHTML(rowCount, 0, userInfo.getName()); } // only show organisms that this user is an admin on . . . https://github.com/GMOD/Apollo/issues/540 -// permissionProviderList.addAll(selectedGroupInfo.getOrganismPermissionMap().values()); - - List organismsToShow = new ArrayList<>(); - for(UserOrganismPermissionInfo userOrganismPermission : MainPanel.getInstance().getCurrentUser().getOrganismPermissionMap().values()){ - if(userOrganismPermission.isAdmin()){ - organismsToShow.add(userOrganismPermission.getOrganismName()); - } + if (MainPanel.getInstance().isCurrentUserAdmin()) { + permissionProviderList.addAll(selectedGroupInfo.getOrganismPermissionMap().values()); } + else{ + List organismsToShow = new ArrayList<>(); + for (UserOrganismPermissionInfo userOrganismPermission : MainPanel.getInstance().getCurrentUser().getOrganismPermissionMap().values()) { + if (userOrganismPermission.isAdmin()) { + organismsToShow.add(userOrganismPermission.getOrganismName()); + } + } - for(GroupOrganismPermissionInfo userOrganismPermission : selectedGroupInfo.getOrganismPermissionMap().values()){ - if (organismsToShow.contains(userOrganismPermission.getOrganismName())){ - permissionProviderList.add(userOrganismPermission); + for (GroupOrganismPermissionInfo userOrganismPermission : selectedGroupInfo.getOrganismPermissionMap().values()) { + if (organismsToShow.contains(userOrganismPermission.getOrganismName())) { + permissionProviderList.add(userOrganismPermission); + } } } } else { diff --git a/src/gwt/org/bbop/apollo/gwt/client/UserPanel.java b/src/gwt/org/bbop/apollo/gwt/client/UserPanel.java index fc4ebac8c8..f2be530f56 100644 --- a/src/gwt/org/bbop/apollo/gwt/client/UserPanel.java +++ b/src/gwt/org/bbop/apollo/gwt/client/UserPanel.java @@ -33,6 +33,7 @@ import org.bbop.apollo.gwt.client.rest.UserRestService; import org.gwtbootstrap3.client.ui.*; import org.gwtbootstrap3.client.ui.constants.IconType; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -79,7 +80,7 @@ interface UserBrowserPanelUiBinder extends UiBinder { @UiField TabLayoutPanel userDetailTab; @UiField(provided = true) - DataGrid organismPermissionsGrid = new DataGrid<>(4,tablecss); + DataGrid organismPermissionsGrid = new DataGrid<>(4, tablecss); @UiField(provided = true) SimplePager pager = new SimplePager(SimplePager.TextLocation.CENTER); @UiField(provided = true) @@ -213,13 +214,13 @@ public void onUserChanged(UserChangeEvent userChangeEvent) { } }); } + @UiHandler("userDetailTab") void onTabSelection(SelectionEvent event) { organismPermissionsGrid.redraw(); } - private void createOrganismPermissionsTable() { TextColumn organismNameColumn = new TextColumn() { @Override @@ -339,9 +340,9 @@ public int compare(UserOrganismPermissionInfo o1, UserOrganismPermissionInfo o2) private void setCurrentUserInfoFromUI() { String emailString = email.getText().trim(); - if(emailString.indexOf("@")>=emailString.lastIndexOf(".")){ - Window.alert("Does not appear to be a valid email "+emailString); - return ; + if (emailString.indexOf("@") >= emailString.lastIndexOf(".")) { + Window.alert("Does not appear to be a valid email " + emailString); + return; } selectedUserInfo.setEmail(emailString); selectedUserInfo.setFirstName(firstName.getText()); @@ -391,7 +392,7 @@ public void cancel(ClickEvent clickEvent) { @UiHandler("deleteButton") public void delete(ClickEvent clickEvent) { - if(Window.confirm("Delete user "+selectedUserInfo.getName()+"?")){ + if (Window.confirm("Delete user " + selectedUserInfo.getName() + "?")) { UserRestService.deleteUser(userInfoList, selectedUserInfo); selectedUserInfo = null; updateUserInfo(); @@ -408,16 +409,15 @@ private void filterSequences() { filteredUserInfoList.clear(); String nameText = nameSearchBox.getText().toLowerCase().trim(); - if(nameText.length()>0){ + if (nameText.length() > 0) { for (UserInfo userInfo : userInfoList) { if (userInfo.getName().toLowerCase().contains(nameText) - || userInfo.getEmail().toLowerCase().contains(nameText) + || userInfo.getEmail().toLowerCase().contains(nameText) ) { filteredUserInfoList.add(userInfo); } } - } - else{ + } else { filteredUserInfoList.addAll(userInfoList); } GWT.log("filtered size: " + filteredUserInfoList.size()); @@ -461,8 +461,7 @@ private void updateUserInfo() { userRow1.setVisible(true); userRow2.setVisible(true); passwordRow.setVisible(true); - } - else{ + } else { userRow1.setVisible(false); userRow2.setVisible(false); passwordRow.setVisible(false); @@ -509,17 +508,20 @@ private void updateUserInfo() { permissionProviderList.clear(); // only show organisms that this user is an admin on . . . https://github.com/GMOD/Apollo/issues/540 -// permissionProviderList.addAll(selectedUserInfo.getOrganismPermissionMap().values()); - List organismsToShow = new ArrayList<>(); - for(UserOrganismPermissionInfo userOrganismPermission : MainPanel.getInstance().getCurrentUser().getOrganismPermissionMap().values()){ - if(userOrganismPermission.isAdmin()){ - organismsToShow.add(userOrganismPermission.getOrganismName()); + if (MainPanel.getInstance().isCurrentUserAdmin()) { + permissionProviderList.addAll(selectedUserInfo.getOrganismPermissionMap().values()); + } else { + List organismsToShow = new ArrayList<>(); + for (UserOrganismPermissionInfo userOrganismPermission : MainPanel.getInstance().getCurrentUser().getOrganismPermissionMap().values()) { + if (userOrganismPermission.isAdmin()) { + organismsToShow.add(userOrganismPermission.getOrganismName()); + } } - } - for(UserOrganismPermissionInfo userOrganismPermission : selectedUserInfo.getOrganismPermissionMap().values()){ - if (organismsToShow.contains(userOrganismPermission.getOrganismName())){ - permissionProviderList.add(userOrganismPermission); + for (UserOrganismPermissionInfo userOrganismPermission : selectedUserInfo.getOrganismPermissionMap().values()) { + if (organismsToShow.contains(userOrganismPermission.getOrganismName())) { + permissionProviderList.add(userOrganismPermission); + } } } }