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 6e38c23
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright © 2019 Dominokit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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,5 @@ 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 6e38c23

Please sign in to comment.