Skip to content

Commit

Permalink
Merge branch 'master' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Aug 14, 2015
2 parents 8114750 + 82c068f commit 910277b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
38 changes: 21 additions & 17 deletions src/gwt/org/bbop/apollo/gwt/client/GroupPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface UserGroupBrowserPanelUiBinder extends UiBinder<Widget, GroupPanel> {
@UiField(provided = true)
SimplePager organismPager = new SimplePager(SimplePager.TextLocation.CENTER);
@UiField(provided = true)
DataGrid<GroupOrganismPermissionInfo> organismPermissionsGrid = new DataGrid<>(4,tablecss);
DataGrid<GroupOrganismPermissionInfo> organismPermissionsGrid = new DataGrid<>(4, tablecss);
private ListDataProvider<GroupInfo> dataProvider = new ListDataProvider<>();
private List<GroupInfo> groupInfoList = dataProvider.getList();
private SingleSelectionModel<GroupInfo> selectionModel = new SingleSelectionModel<>();
Expand Down Expand Up @@ -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<Integer> event) {
organismPermissionsGrid.redraw();
Expand All @@ -179,7 +180,7 @@ void onTabSelection(SelectionEvent<Integer> event) {
public void createGroup(ClickEvent clickEvent) {
GroupInfo groupInfo = getGroupFromUI();

if(groupInfo==null) return ;
if (groupInfo == null) return;

GroupRestService.addNewGroup(groupInfo);
}
Expand All @@ -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<String> 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<String> 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 {
Expand Down
44 changes: 23 additions & 21 deletions src/gwt/org/bbop/apollo/gwt/client/UserPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +80,7 @@ interface UserBrowserPanelUiBinder extends UiBinder<Widget, UserPanel> {
@UiField
TabLayoutPanel userDetailTab;
@UiField(provided = true)
DataGrid<UserOrganismPermissionInfo> organismPermissionsGrid = new DataGrid<>(4,tablecss);
DataGrid<UserOrganismPermissionInfo> organismPermissionsGrid = new DataGrid<>(4, tablecss);
@UiField(provided = true)
SimplePager pager = new SimplePager(SimplePager.TextLocation.CENTER);
@UiField(provided = true)
Expand Down Expand Up @@ -213,13 +214,13 @@ public void onUserChanged(UserChangeEvent userChangeEvent) {
}
});
}

@UiHandler("userDetailTab")
void onTabSelection(SelectionEvent<Integer> event) {
organismPermissionsGrid.redraw();
}



private void createOrganismPermissionsTable() {
TextColumn<UserOrganismPermissionInfo> organismNameColumn = new TextColumn<UserOrganismPermissionInfo>() {
@Override
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
Expand All @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<String> 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<String> 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);
}
}
}
}
Expand Down

0 comments on commit 910277b

Please sign in to comment.