39
39
import org .roda .core .data .v2 .jobs .IndexedReport ;
40
40
import org .roda .core .data .v2 .log .LogEntry ;
41
41
import org .roda .core .data .v2 .notifications .Notification ;
42
+ import org .roda .wui .client .common .ActionsToolbar ;
42
43
import org .roda .wui .client .common .NoAsyncCallback ;
43
44
import org .roda .wui .client .common .actions .Actionable ;
44
45
import org .roda .wui .client .common .actions .model .ActionableObject ;
@@ -126,6 +127,7 @@ public abstract class AsyncTableCell<T extends IsIndexed> extends FlowPanel
126
127
private Actionable <T > actionable ;
127
128
private FlowPanel mainPanel ;
128
129
private FlowPanel sidePanel ;
130
+ private FlowPanel facetsPanel ;
129
131
private MyAsyncDataProvider <T > dataProvider ;
130
132
private SingleSelectionModel <T > selectionModel ;
131
133
private AccessibleSimplePager resultsPager ;
@@ -250,6 +252,55 @@ protected void fireChangeEvent(IndexResult<T> result) {
250
252
csvDownloadButton .addStyleName ("btn btn-link btn-download csvDownloadButton" );
251
253
csvDownloadButton .setVisible (options .isCsvDownloadButtonVisibility ());
252
254
255
+ ActionsToolbar toolbar = new ActionsToolbar ();
256
+ if (options .getActionable () != null && options .getActionable ().hasAnyRoles () && isSelectable ()) {
257
+ ActionableWidgetBuilder <T > builder = new ActionableWidgetBuilder <>(options .getActionable ());
258
+ toolbar .setLabel (messages .actions ());
259
+ toolbar .setIcon (null );
260
+ toolbar .setTagsVisible (false );
261
+ toolbar .setActionableMenu (builder .buildListWithObjectsAndDefaults (getActionableObject ()));
262
+ addCheckboxSelectionListener (new CheckboxSelectionListener <T >() {
263
+ @ Override
264
+ public void onSelectionChange (SelectedItems <T > selected ) {
265
+ builder .withActionCallback (new NoAsyncCallback <Actionable .ActionImpact >() {
266
+ @ Override
267
+ public void onSuccess (Actionable .ActionImpact impact ) {
268
+ if (!Actionable .ActionImpact .NONE .equals (impact )) {
269
+ Timer timer = new Timer () {
270
+ @ Override
271
+ public void run () {
272
+ refresh ();
273
+ }
274
+ };
275
+ timer .schedule (RodaConstants .ACTION_TIMEOUT / 2 );
276
+ }
277
+ if (actionableCallback != null ) {
278
+ actionableCallback .onSuccess (impact );
279
+ }
280
+ }
281
+
282
+ @ Override
283
+ public void onFailure (Throwable caught ) {
284
+ Timer timer = new Timer () {
285
+ @ Override
286
+ public void run () {
287
+ refresh ();
288
+ }
289
+ };
290
+ timer .schedule (RodaConstants .ACTION_TIMEOUT / 2 );
291
+ super .onFailure (caught );
292
+ if (actionableCallback != null ) {
293
+ actionableCallback .onFailure (caught );
294
+ }
295
+ }
296
+ });
297
+ toolbar .setActionableMenu (builder .buildListWithObjectsAndDefaults (getActionableObject ()));
298
+ }
299
+ });
300
+ } else {
301
+ toolbar .setVisible (false );
302
+ }
303
+
253
304
sidePanel = new FlowPanel ();
254
305
sidePanel .addStyleName ("my-asyncdatagrid-side-panel" );
255
306
add (sidePanel );
@@ -261,17 +312,27 @@ protected void fireChangeEvent(IndexResult<T> result) {
261
312
autoUpdatePanel = new AccessibleFocusPanel ();
262
313
autoUpdatePanel .add (autoUpdateSignal );
263
314
315
+ facetsPanel = new FlowPanel ();
316
+ facetsPanel .addStyleName ("my-asyncdatagrid-facets-panel" );
317
+
318
+ FlowPanel footer = new FlowPanel ();
319
+ footer .addStyleName ("my-asyncdatagrid-footer" );
320
+
264
321
mainPanel .add (display );
265
- mainPanel .add (resultsPager );
266
- mainPanel .add (pageSizePager );
267
- mainPanel .add (autoUpdatePanel );
268
- mainPanel .add (csvDownloadButton );
322
+ mainPanel .add (footer );
323
+ footer .add (csvDownloadButton );
324
+ footer .add (pageSizePager );
325
+ footer .add (resultsPager );
326
+ footer .add (autoUpdatePanel );
327
+
328
+ sidePanel .add (toolbar );
329
+ sidePanel .add (facetsPanel );
269
330
270
331
SimplePanel clearfix = new SimplePanel ();
271
332
clearfix .addStyleName ("clearfix" );
272
333
add (clearfix );
273
334
274
- toggleSidePanel (createAndBindFacets (sidePanel ));
335
+ toggleFacetsPanel (createAndBindFacets (facetsPanel ));
275
336
276
337
csvDownloadButton .addClickHandler (event -> {
277
338
Services services = new Services ("Retrieve export limit" , "get" );
@@ -361,13 +422,13 @@ public AsyncTableCellOptions<T> getOptions() {
361
422
return options ;
362
423
}
363
424
364
- private void toggleSidePanel (boolean toggle ) {
425
+ private void toggleFacetsPanel (boolean toggle ) {
365
426
if (toggle ) {
366
427
mainPanel .removeStyleName ("my-asyncdatagrid-main-panel-full" );
367
- sidePanel .removeStyleName ("my-asyncdatagrid-side-panel-hidden" );
428
+ facetsPanel .removeStyleName ("my-asyncdatagrid-side-panel-hidden" );
368
429
} else {
369
430
mainPanel .addStyleName ("my-asyncdatagrid-main-panel-full" );
370
- sidePanel .addStyleName ("my-asyncdatagrid-side-panel-hidden" );
431
+ facetsPanel .addStyleName ("my-asyncdatagrid-side-panel-hidden" );
371
432
}
372
433
}
373
434
@@ -725,13 +786,13 @@ public Facets getFacets() {
725
786
public void setFacets (Facets facets ) {
726
787
this .facets = facets ;
727
788
refresh ();
728
- toggleSidePanel (createAndBindFacets (sidePanel ));
789
+ toggleFacetsPanel (createAndBindFacets (facetsPanel ));
729
790
}
730
791
731
792
public void set (Filter filter , boolean justActive , Facets facets ) {
732
793
this .facets = facets ;
733
794
set (filter , justActive );
734
- toggleSidePanel (createAndBindFacets (sidePanel ));
795
+ toggleFacetsPanel (createAndBindFacets (facetsPanel ));
735
796
}
736
797
737
798
public void set (Filter filter , boolean justActive ) {
0 commit comments