Skip to content

Commit 52dc4fd

Browse files
authored
Merge pull request #550 from keeps/aflores-dev-permission_expiry_visibility
Pill buttons for permission expiry
2 parents 68bb86c + e63fad9 commit 52dc4fd

File tree

3 files changed

+50
-31
lines changed

3 files changed

+50
-31
lines changed

src/main/java/com/databasepreservation/common/client/common/utils/JavascriptUtils.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,4 @@ public static native void removeAttribute(String elementId, String attribute) /*
354354
var element = $wnd.jQuery("#" + elementId);
355355
element.removeAttr(attribute);
356356
}-*/;
357-
358-
public static native void setIndeterminate(String checkboxesJQuery) /*-{
359-
var checkboxes = $wnd.jQuery(checkboxesJQuery);
360-
checkboxes.prop("indeterminate", true);
361-
}-*/;
362357
}

src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@
3939
import com.google.gwt.cell.client.Cell;
4040
import com.google.gwt.cell.client.CheckboxCell;
4141
import com.google.gwt.core.client.GWT;
42-
import com.google.gwt.core.client.Scheduler;
4342
import com.google.gwt.i18n.client.DateTimeFormat;
4443
import com.google.gwt.i18n.client.TimeZone;
4544
import com.google.gwt.safehtml.shared.SafeHtml;
4645
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
4746
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
4847
import com.google.gwt.user.cellview.client.Column;
49-
import com.google.gwt.user.client.Command;
5048
import com.google.gwt.user.client.ui.Button;
5149
import com.google.gwt.user.client.ui.CheckBox;
5250
import com.google.gwt.user.client.ui.FlowPanel;
@@ -236,17 +234,6 @@ private FlowPanel getGroupsTables() {
236234
public Boolean getValue(AuthorizationGroup group) {
237235
return databasePermissionGroups.contains(group.getAttributeValue());
238236
}
239-
240-
@Override
241-
public String getCellStyleNames(Cell.Context context, AuthorizationGroup group) {
242-
if (groupDetails.getOrDefault(group.getAttributeValue(), new AuthorizationDetails()).hasExpiryDate()) {
243-
Date now = new Date();
244-
if (now.after(groupDetails.get(group.getAttributeValue()).getExpiry())) {
245-
return "expired";
246-
}
247-
}
248-
return "";
249-
}
250237
};
251238

252239
checkbox.setFieldUpdater((index, group, value) -> {
@@ -255,7 +242,6 @@ public String getCellStyleNames(Cell.Context context, AuthorizationGroup group)
255242
if (!databasePermissionGroups.contains(group.getAttributeValue())) {
256243
databasePermissionGroups.add(group.getAttributeValue());
257244
}
258-
deferSetIndeterminateCheckboxes();
259245
} else {
260246
// Remove
261247
databasePermissionGroups.remove(group.getAttributeValue());
@@ -277,13 +263,24 @@ public String getValue(AuthorizationGroup database) {
277263
return ret;
278264
}
279265

266+
@Override
267+
public String getCellStyleNames(Cell.Context context, AuthorizationGroup group) {
268+
if (groupDetails.getOrDefault(group.getAttributeValue(), new AuthorizationDetails()).hasExpiryDate()) {
269+
Date now = new Date();
270+
if (now.after(groupDetails.get(group.getAttributeValue()).getExpiry())) {
271+
return "expiry_column expired";
272+
}
273+
}
274+
return "expiry_column";
275+
}
276+
280277
@Override
281278
public void render(Cell.Context context, AuthorizationGroup object, SafeHtmlBuilder sb) {
282279
String value = getValue(object);
283280
if (databasePermissionGroups.contains(object.getAttributeValue())) {
284-
sb.appendHtmlConstant("<button class=\"btn btn-link-info\" type=\"button\" tabindex=\"-1\">");
281+
sb.appendHtmlConstant("<button class=\"btn tag-button\" type=\"button\" tabindex=\"-1\">");
285282
} else {
286-
sb.appendHtmlConstant("<button class=\"btn btn-link-info\" type=\"button\" tabindex=\"-1\" disabled>");
283+
sb.appendHtmlConstant("<button class=\"btn tag-button\" type=\"button\" tabindex=\"-1\" disabled>");
287284
}
288285
if (value != null) {
289286
sb.append(SafeHtmlUtils.fromString(value));
@@ -392,7 +389,6 @@ public void onSuccess(Boolean confirmation) {
392389
}
393390
groupDetails.put(currentGroup.getAttributeValue(), authorizationDetails);
394391
cellTable.refresh();
395-
deferSetIndeterminateCheckboxes();
396392
}
397393
}
398394
});
@@ -436,7 +432,6 @@ public SafeHtml getValue(AuthorizationGroup group) {
436432
new BasicTablePanel.ColumnInfo<AuthorizationGroup>(
437433
messages.SIARDHomePageLabelForPermissionsTableGroupExpiryDate(), 12, expiry,
438434
"force_column_ellipsis expiry_column"));
439-
deferSetIndeterminateCheckboxes();
440435
}
441436

442437
private void doSearch(String searchValue, FlowPanel permissionListPanel) {
@@ -493,12 +488,4 @@ private Map<String, AuthorizationDetails> createDatabasePermissionsMap() {
493488
}
494489
return permissions;
495490
}
496-
497-
private void deferSetIndeterminateCheckboxes() {
498-
Scheduler.get().scheduleDeferred(new Command() {
499-
public void execute() {
500-
JavascriptUtils.setIndeterminate(".expired input");
501-
}
502-
});
503-
}
504491
}

src/main/resources/com/databasepreservation/common/public/main.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,6 +3532,43 @@ rgba(0, 0, 0, .125);
35323532
flex: 1;
35333533
padding: 3px 0px;
35343534
font-size: 1.3rem;
3535+
border: 1px solid;
3536+
border-radius: 16px;
3537+
display: flex;
3538+
flex-direction: column;
3539+
align-items: center;
3540+
}
3541+
3542+
.tag-button {
3543+
transition: 0.1s;
3544+
color: #78BEE7;
3545+
border: 1px solid;
3546+
border-color: #78BEE7;
3547+
border-radius: 16px;
3548+
background-color: transparent;
3549+
display: flex;
3550+
justify-content: center;
3551+
}
3552+
3553+
.tag-button:hover {
3554+
color: white;
3555+
border: none;
3556+
background-color: #78BEE7;
3557+
}
3558+
3559+
.expiry_column.expired .tag-button {
3560+
color: #d9534f;
3561+
border-color: #d9534f;
3562+
}
3563+
3564+
.expiry_column.expired .tag-button:hover {
3565+
color: white;
3566+
border: none;
3567+
background-color: #d9534f;
3568+
}
3569+
3570+
.expiry_column.expired .tag-button:after {
3571+
content: "\f273";
35353572
}
35363573

35373574
.expiry_column button:disabled {

0 commit comments

Comments
 (0)