Skip to content

Commit

Permalink
fix #932 Wrong UI interaction between datatable SummaryPlugin and Emp…
Browse files Browse the repository at this point in the history
…tyStatePlugin

Improve the construction of summary plugin config and add a global default configuration.
  • Loading branch information
vegegoku committed Jul 28, 2024
1 parent af02811 commit 51aa1f3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.dominokit.domino.ui.config;

public interface DatatableConfig extends ComponentConfig {
default boolean isRemoveSummaryRecordsForEmptyTable(){
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public interface UIConfig
StepperConfig,
CalendarConfig,
TimePickerConfig,
DelayedActionConfig {}
DelayedActionConfig,
DatatableConfig {
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SummaryPlugin<T, S>
private List<SummaryRow<T, S>> summaryRows = new ArrayList<>();
private DataTable<T> dataTable;
private TFootElement footer;
private SummaryPluginConfig config = new SummaryPluginConfig();
private SummaryPluginConfig config = SummaryPluginConfig.of();

/**
* Initializes the SummaryPlugin with the DataTable.
Expand Down Expand Up @@ -118,7 +118,7 @@ public void handleEvent(TableEvent event) {
@Override
public SummaryPlugin<T, S> setConfig(SummaryPluginConfig config) {
if (isNull(config)) {
this.config = new SummaryPluginConfig();
this.config = SummaryPluginConfig.of();
} else {
this.config = config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,29 @@
*/
package org.dominokit.domino.ui.datatable.plugins.summary;

import org.dominokit.domino.ui.config.DatatableConfig;
import org.dominokit.domino.ui.datatable.plugins.PluginConfig;
import org.dominokit.domino.ui.utils.DominoUIConfig;

public class SummaryPluginConfig implements PluginConfig {

private boolean removeOnEmptyData = false;
private boolean removeOnEmptyData;

public SummaryPluginConfig(boolean removeOnEmptyData) {
this.removeOnEmptyData = removeOnEmptyData;
}

public static SummaryPluginConfig of(){
return new SummaryPluginConfig(DominoUIConfig.CONFIG.getUIConfig().isRemoveSummaryRecordsForEmptyTable(););
}

public static SummaryPluginConfig of(boolean removeOnEmptyData){
return new SummaryPluginConfig(removeOnEmptyData);
}

/**
* @return boolean, true will cause the plugin to remove the summary records for empty data
* tables, false will keep them, default to false
* tables, false will keep them, default to {@link DatatableConfig#isRemoveSummaryRecordsForEmptyTable()}
*/
public boolean isRemoveOnEmptyData() {
return removeOnEmptyData;
Expand Down

0 comments on commit 51aa1f3

Please sign in to comment.