Skip to content

Commit

Permalink
Deal with UI glitches in toolbar when switching between Devices/Geo-f…
Browse files Browse the repository at this point in the history
…ences tabs
  • Loading branch information
vitalidze committed Mar 30, 2015
1 parent 50d02ab commit 887af18
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/main/java/org/traccar/web/client/view/DeviceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,25 @@ protected void onMouseDown(Event e) {
editing.addEditor(colFollow, new CheckBox());
editing.addEditor(colRecordTrace, new CheckBox());

boolean readOnly = ApplicationContext.getInstance().getUser().getReadOnly();
boolean admin = ApplicationContext.getInstance().getUser().getAdmin();
boolean manager = ApplicationContext.getInstance().getUser().getManager();

settingsButton.setVisible(admin || !readOnly);
settingsAccount.setVisible(!readOnly);
settingsPreferences.setVisible(!readOnly);

settingsGlobal.setVisible(!readOnly && admin);
showTrackerServerLog.setVisible(admin);
settingsUsers.setVisible(!readOnly && (admin || manager));
settingsNotifications.setVisible(!readOnly && (admin || manager));
shareButton.setVisible(!readOnly && (admin || manager));

addButton.setVisible(!readOnly);
editButton.setVisible(!readOnly);
removeButton.setVisible(!readOnly);
fillItem.setVisible(!readOnly);
separatorItem.setVisible(!readOnly);
toggleManagementButtons();
}

Expand Down Expand Up @@ -398,27 +417,12 @@ private boolean editingGeoFences() {
}

private void toggleManagementButtons() {
boolean readOnly = ApplicationContext.getInstance().getUser().getReadOnly();
boolean admin = ApplicationContext.getInstance().getUser().getAdmin();
boolean manager = ApplicationContext.getInstance().getUser().getManager();
boolean allowDeviceManagement = editingGeoFences() || !ApplicationContext.getInstance().getApplicationSettings().isDisallowDeviceManagementByUsers();

settingsButton.setVisible(admin || !readOnly);
settingsAccount.setVisible(!readOnly);
settingsPreferences.setVisible(!readOnly);

settingsGlobal.setVisible(!readOnly && admin);
showTrackerServerLog.setVisible(admin);
settingsUsers.setVisible(!readOnly && (admin || manager));
settingsNotifications.setVisible(!readOnly && (admin || manager));
shareButton.setVisible(!readOnly && (admin || manager));

addButton.setVisible(!readOnly && (allowDeviceManagement || admin || manager));
editButton.setVisible(!readOnly && (allowDeviceManagement || admin || manager));
removeButton.setVisible(!readOnly && (allowDeviceManagement || admin || manager));
fillItem.setVisible(!readOnly && (allowDeviceManagement || admin || manager));
separatorItem.setVisible(!readOnly && (allowDeviceManagement || admin || manager));
boolean allowDeviceManagement = !ApplicationContext.getInstance().getApplicationSettings().isDisallowDeviceManagementByUsers();

toolbar.forceLayout();
addButton.setEnabled(allowDeviceManagement || editingGeoFences() || admin || manager);
editButton.setEnabled(allowDeviceManagement || editingGeoFences() || admin || manager);
removeButton.setEnabled(allowDeviceManagement || editingGeoFences() || admin || manager);
}
}

0 comments on commit 887af18

Please sign in to comment.