Skip to content

Commit

Permalink
Merge branch 'release/2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed May 10, 2024
2 parents 919ba14 + 213a4ea commit 8d9f2a1
Show file tree
Hide file tree
Showing 26 changed files with 282 additions and 63 deletions.
2 changes: 1 addition & 1 deletion domino-ui-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>domino-ui-parent</artifactId>
<groupId>org.dominokit</groupId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion domino-ui-tools/mdi-icons-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>domino-ui-tools</artifactId>
<groupId>org.dominokit</groupId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion domino-ui-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>domino-ui-parent</artifactId>
<groupId>org.dominokit</groupId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion domino-ui-webjar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>domino-ui-parent</artifactId>
<groupId>org.dominokit</groupId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion domino-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.dominokit</groupId>
<artifactId>domino-ui-parent</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<artifactId>domino-ui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ public interface SearchConfig extends ComponentConfig {
default int getAutoSearchDelay() {
return 200;
}

/**
* Use this method to define the default auto search delay for datatable DelayedHeaderFilter in
* milliseconds
*
* <p>Defaults to : <b>{@link #getAutoSearchDelay()}</b>>
*
* @return an integer delay in milliseconds
*/
default int getTableTextHeaderFilterSearchDelay() {
return getAutoSearchDelay();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,12 @@ public CellStyler<T> getCellStyler() {
}

/**
* Checks if tooltips are shown for the column.
* Checks if tooltips are shown for the column and the column has a tooltip node or has a title.
*
* @return true if tooltips are shown, false otherwise
* @return true if tooltips are shown and there is a tooltip node or a title, false otherwise
*/
public boolean isShowTooltip() {
return showTooltip;
return showTooltip && (nonNull(tooltipNode) || (nonNull(title) && !title.trim().isEmpty()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class TableConfig<T>
private String minWidth;

private Consumer<TableRow<T>> onRowEditHandler = (tableRow) -> {};
private Consumer<TableRow<T>> onRowFinishEditHandler = (tableRow) -> {};

private final ColumnConfig<T> pluginUtilityColumn =
ColumnConfig.<T>create("plugin-utility-column")
Expand Down Expand Up @@ -582,6 +583,26 @@ Consumer<TableRow<T>> getOnRowEditHandler() {
return onRowEditHandler;
}

/**
* Use this to set a handler that will be called when ever a row editing finished.
*
* @param handler The handler to be called.
* @return same TableConfig instance.
*/
public TableConfig<T> setOnRowFinishEditHandler(Consumer<TableRow<T>> handler) {
if (isNull(handler)) {
this.onRowFinishEditHandler = tableRow -> {};
} else {
this.onRowFinishEditHandler = handler;
}
return this;
}

/** @return the handler to be called when a row editing finished. */
Consumer<TableRow<T>> getOnRowFinishEditHandler() {
return onRowFinishEditHandler;
}

/** A functional interface defining the behavior for appending rows. */
@FunctionalInterface
public interface RowAppender<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class TableRow<T> extends BaseDominoElement<HTMLTableRowElement, TableRow
private boolean selectable;

private FieldsGrouping rowFieldsGroup = FieldsGrouping.create();
private boolean draggable = true;

/**
* Constructs a table row with the given record, index, and parent table.
Expand Down Expand Up @@ -587,6 +588,7 @@ public void save() {
this.setEditable(false);
updateRow();
rowFieldsGroup.removeAllFormElements();
this.dataTable.getTableConfig().getOnRowFinishEditHandler().accept(this);
}
}

Expand All @@ -598,6 +600,7 @@ public void cancelEditing() {
this.setEditable(false);
updateRow();
rowFieldsGroup.removeAllFormElements();
this.dataTable.getTableConfig().getOnRowFinishEditHandler().accept(this);
}

/**
Expand Down Expand Up @@ -725,6 +728,22 @@ public FieldsGrouping getRowFieldsGroup() {
return rowFieldsGroup;
}

/** @return true if this table should be allowed to be dragged. */
public boolean isDraggable() {
return draggable;
}

/**
* Sets if the table row should be allowed to be dragged. the actual execution of this flag is
* upon the implementation of the dragging operation the flag here is just to give the
* implementation if the table should be dragged or not.
*
* @param draggable true to allow row dragging, false to prevent it.
*/
public void setDraggable(boolean draggable) {
this.draggable = draggable;
}

/**
* Represents a function to render a TableRow.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public void onHeaderAdded(DataTable<T> dataTable, ColumnConfig<T> column) {
*/
@Override
public void onRowAdded(DataTable<T> dataTable, TableRow<T> tableRow) {
dragSource.addDraggable(Draggable.of(tableRow));
Draggable<TableRow<T>> draggable = Draggable.of(tableRow);
draggable.setConfig(tableRow::isDraggable);
dragSource.addDraggable(draggable);
dropZone.addDropTarget(
tableRow, draggableId -> moveItem(dataTable, tableRow.getRecord(), draggableId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.dominokit.domino.ui.datatable.plugins.column.ColumnHeaderFilterPlugin;
import org.dominokit.domino.ui.forms.InputFormField;
import org.dominokit.domino.ui.utils.DelayedTextInput;
import org.dominokit.domino.ui.utils.DominoUIConfig;
import org.dominokit.domino.ui.utils.HasPlaceHolder;

/**
Expand Down Expand Up @@ -65,7 +66,10 @@ public DelayedHeaderFilterInput(String placeHolder) {
((HasPlaceHolder<B>) input).setPlaceholder(placeHolder);
}

delayedTextInput = DelayedTextInput.create(getInputElement(), 200);
delayedTextInput =
DelayedTextInput.create(
getInputElement(),
DominoUIConfig.CONFIG.getUIConfig().getTableTextHeaderFilterSearchDelay());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.dominokit.domino.ui.datatable.plugins.filter.header;

import static org.dominokit.domino.ui.utils.Domino.*;

import elemental2.dom.HTMLInputElement;
import org.dominokit.domino.ui.datatable.model.FilterTypes;
import org.dominokit.domino.ui.forms.TextBox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static java.util.Objects.nonNull;
import static org.dominokit.domino.ui.datatable.DataTableStyles.dui_datatable_row_selected;
import static org.dominokit.domino.ui.forms.FormsStyles.dui_form_select_check_box;
import static org.dominokit.domino.ui.utils.Domino.*;

import elemental2.dom.Element;
import elemental2.dom.HTMLElement;
Expand All @@ -34,6 +33,7 @@
import jsinterop.base.Js;
import org.dominokit.domino.ui.datatable.*;
import org.dominokit.domino.ui.datatable.events.OnBeforeDataChangeEvent;
import org.dominokit.domino.ui.datatable.events.TableDataUpdatedEvent;
import org.dominokit.domino.ui.datatable.events.TableEvent;
import org.dominokit.domino.ui.datatable.plugins.DataTablePlugin;
import org.dominokit.domino.ui.forms.CheckBox;
Expand All @@ -58,6 +58,7 @@ public class SelectionPlugin<T> implements DataTablePlugin<T> {
private DataTable<T> datatable;
private List<T> oldSelection = new ArrayList<>();
private boolean retainSelectionOnDataChange = false;
private CheckBox headerCheckBox;

/** Creates a new `SelectionPlugin` with default settings. */
public SelectionPlugin() {}
Expand Down Expand Up @@ -300,8 +301,8 @@ private void deselectRow(DataTable<T> dataTable, TableRow<T> tableRow) {
* @return The selection indicator element for a multi-selection header.
*/
private HTMLElement createMultiSelectHeader(DataTable<T> dataTable) {
CheckBox checkBox = createCheckBox(Optional.empty());
checkBox.addChangeListener(
headerCheckBox = createCheckBox(Optional.empty());
headerCheckBox.addChangeListener(
(oldValue, checked) -> {
if (checked) {
dataTable.selectAll(selectionCondition);
Expand All @@ -312,20 +313,24 @@ private HTMLElement createMultiSelectHeader(DataTable<T> dataTable) {

dataTable.addSelectionDeselectionListener(
(source, selectedRows) -> {
long selectableCount =
dataTable.getRows().stream()
.filter(tableRow -> selectionCondition.isAllowSelection(dataTable, tableRow))
.count();
if (selectedRows.size() > 0 && selectedRows.size() < selectableCount) {
checkBox.indeterminate();
} else if (selectedRows.size() == selectableCount) {
checkBox.check(true);
} else if (selectedRows.isEmpty()) {
checkBox.uncheck(true);
}
updateHeaderCheckBox(selectedRows);
});

return checkBox.element();
return headerCheckBox.element();
}

private void updateHeaderCheckBox(List<TableRow<T>> selectedRows) {
long selectableCount =
this.datatable.getRows().stream()
.filter(tableRow -> selectionCondition.isAllowSelection(this.datatable, tableRow))
.count();
if (selectedRows.size() > 0 && selectedRows.size() < selectableCount) {
headerCheckBox.indeterminate();
} else if (selectedRows.size() == selectableCount) {
headerCheckBox.check(true);
} else if (selectedRows.isEmpty()) {
headerCheckBox.uncheck(true);
}
}

/**
Expand Down Expand Up @@ -402,6 +407,12 @@ public void handleEvent(TableEvent event) {
this.oldSelection = this.datatable.getSelectedRecords();
}
}

if (TableDataUpdatedEvent.DATA_UPDATED.equals(event.getType())) {
if (this.datatable.getTableConfig().isMultiSelect()) {
updateHeaderCheckBox(this.datatable.getSelectedItems());
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,11 @@ private void expand(TableRow<T> row, boolean recursive) {
Optional<TreeGridRowToggleIcon> iconMeta = row.getMeta(TREE_GRID_ROW_TOGGLE_ICON);
iconMeta.ifPresent(
meta -> {
ToggleIcon<?, ?> icon = Js.uncheckedCast(meta.icon);
if (!icon.isToggled()) {
icon.toggle();
if (!row.getChildren().isEmpty()) {
ToggleIcon<?, ?> icon = Js.uncheckedCast(meta.icon);
if (!icon.isToggled()) {
icon.toggle();
}
}
});
}
Expand All @@ -355,8 +357,6 @@ private void showRow(TableRow<T> row) {
* Collapses a specific TableRow, hiding it, and optionally collapsing its child rows recursively.
*
* @param row The TableRow to collapse.
* @param recursive If true, child rows are collapsed recursively; otherwise, only the direct
* child rows are collapsed.
*/
private void collapse(TableRow<T> row) {
this.dataTable.fireTableEvent(new TreeRowOnBeforeCollapseEvent<>(row));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.dominokit.domino.ui.icons.MdiIcon;
import org.dominokit.domino.ui.icons.lib.Icons;
import org.dominokit.domino.ui.layout.NavBar;
import org.dominokit.domino.ui.utils.ChildHandler;
import org.dominokit.domino.ui.utils.Domino;
import org.dominokit.domino.ui.utils.PostfixAddOn;

/**
Expand Down Expand Up @@ -200,7 +202,7 @@ private void updatePosition() {
if (windowTop < (windowHeight - initialHeight)) {
modalElement.element().style.top = windowTop + "px";
} else {
modalElement.element().style.left =
modalElement.element().style.top =
windowTop
- ((windowLeft + initialHeight) - windowHeight - DomGlobal.window.pageYOffset)
+ "px";
Expand Down Expand Up @@ -255,8 +257,8 @@ private void addMoveListeners() {
"mousedown",
"touchstart");

headerElement.element().addEventsListener(stopMoveListener, true, "mouseup", "touchend");
headerElement.element().addEventsListener(moveListener, true, "mousemove", "touchmove");
Domino.body().addEventsListener(stopMoveListener, true, "mouseup", "touchend");
Domino.body().addEventsListener(moveListener, true, "mousemove", "touchmove");
body().addEventsListener(stopMoveListener, "mouseup", "touchend");
}

Expand Down Expand Up @@ -458,4 +460,20 @@ public MdiIcon getMaximizeIcon() {
public MdiIcon getCloseIcon() {
return closeIcon;
}

/** @return the NavBar of this window */
public NavBar getNavHeader() {
return navHeader;
}

/**
* Allows customization of the window NavBar using a {@code ChildHandler}.
*
* @param handler The handler for customizing the NavBar.
* @return This Window instance for method chaining.
*/
public Window withNavBar(ChildHandler<Window, NavBar> handler) {
handler.apply(this, navHeader);
return this;
}
}
Loading

0 comments on commit 8d9f2a1

Please sign in to comment.