Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 1eb1f37

Browse files
author
Lennart Koopmann
committed
better UX for user editing form. fixes #615
1 parent 0d117fc commit 1eb1f37

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

app/controllers/UsersController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,15 @@ public Result resetPermissions(String username) {
308308
final DynamicForm requestForm = Form.form().bindFromRequest();
309309

310310
boolean isAdmin = false;
311-
final String field = requestForm.get("admin");
312-
if (field != null && field.equalsIgnoreCase("on")) {
311+
final String field = requestForm.get("permissiontype");
312+
if (field != null && field.equalsIgnoreCase("admin")) {
313313
isAdmin = true;
314314
}
315315
final User user = userService.load(username);
316316

317317
if (!Permissions.isPermitted(USERS_PERMISSIONSEDIT) || user.isReadonly()) {
318318
flash("error", "Unable to reset permissions!");
319-
return redirect(routes.UsersController.index());
319+
return redirect(routes.UsersController.editUserForm(username));
320320
}
321321

322322
final ChangeUserRequest changeRequest = new ChangeUserRequest(user);
@@ -331,7 +331,7 @@ public Result resetPermissions(String username) {
331331
} else {
332332
flash("error", "Unable to reset permissions for user " + user.getFullName());
333333
}
334-
return redirect(routes.UsersController.index());
334+
return redirect(routes.UsersController.editUserForm(username));
335335
}
336336

337337
private static BreadcrumbList breadcrumbs() {

app/views/system/users/edit.scala.html

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -163,44 +163,57 @@ <h1><i class="icon icon-edit"></i> Edit user &raquo;@username&laquo;</h1>
163163
}
164164
</div>
165165
</div>
166+
166167
@if(isPermitted(USERS_PERMISSIONSEDIT)) {
167168
<div class="row-fluid">
168169
<h2><h2><i class="icon icon-bolt"></i> Change Permissions</h2>
169170

170171
<form class="form form-horizontal" action="@routes.UsersController.resetPermissions(user.getName)" method="POST">
171-
<button class="btn btn-danger" type="submit" data-confirm="Really reset permissions for @user.getName?" style="margin-top: 10px; margin-bottom: 10px;">
172-
Reset Permissions
173-
</button>
174172

175-
<label class="checkbox">
176-
<input type="checkbox" id="admin" name="admin" @if(isPermitted(user, "*")) {selected} />
177-
Assign administrator permissions?
173+
<label class="radio" style="margin-top: 5px;">
174+
<input type="radio" name="permissiontype" value="admin" @if(isPermitted(user, "*")) { checked="checked" } />
175+
Set to administrator permissions
176+
</label>
177+
178+
<label class="radio">
179+
<input type="radio" name="permissiontype" value="reader" @if(!isPermitted(user, "*")) { checked="checked" } />
180+
Set to reader permissions
178181
</label>
179182

180-
All permissions will be reset, assigned stream permissions will be lost!
183+
<button class="btn btn-warning btn-small" type="submit" data-confirm="Really reset permissions for @user.getName?" style="margin-top: 10px; margin-bottom: 10px;">
184+
Set default permissions
185+
</button>
186+
187+
<p>
188+
Previously assigned stream and dashboard permissions will be lost!
189+
</p>
181190
</form>
182191

183192
</div>
184193
}
194+
185195
<div class="row-fluid">
186-
<form action="@routes.StartpageController.reset(user.getName)" method="POST" class="pull-right">
187-
<button type="submit" class="btn btn-danger btn-small" data-confirm="Really reset startpage?">
196+
<h2><i class="icon icon-circle-arrow-right"></i> Custom startpage</h2>
197+
198+
<p>
199+
@if(user.getStartpage == null) {
200+
No custom startpage configured yet.
201+
} else {
202+
The startpage is currently set to
203+
<em>@user.getStartpage.getType.toString.toLowerCase</em> with ID
204+
<em>@user.getStartpage.getId</em>.
205+
206+
<a href="@user.getStartpage.getCall">
207+
&nbsp;<i class="icon icon-angle-right"></i> Open
208+
</a>
209+
210+
}
211+
</p>
212+
213+
<form action="@routes.StartpageController.reset(user.getName)" method="POST">
214+
<button type="submit" class="btn btn-primary btn-small" data-confirm="Really reset startpage?">
188215
Reset custom startpage
189216
</button>
190217
</form>
191-
192-
<h2><i class="icon icon-circle-arrow-right"></i> Custom startpage</h2>
193-
@if(user.getStartpage == null) {
194-
No custom startpage configured yet.
195-
} else {
196-
The startpage is currently set to
197-
<em>@user.getStartpage.getType.toString.toLowerCase</em> with ID
198-
<em>@user.getStartpage.getId</em>.
199-
200-
<a href="@user.getStartpage.getCall">
201-
&nbsp;<i class="icon icon-angle-right"></i> Open
202-
</a>
203-
204-
}
205218
</div>
206219
}

0 commit comments

Comments
 (0)