-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support drag drop for dashboard
- Loading branch information
1 parent
ab8d25b
commit cc333af
Showing
7 changed files
with
671 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...-flow/src/main/java/com/vaadin/flow/component/dashboard/DashboardItemReorderEndEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.dashboard; | ||
|
||
import com.vaadin.flow.component.ComponentEvent; | ||
import com.vaadin.flow.component.ComponentEventListener; | ||
import com.vaadin.flow.component.DomEvent; | ||
import com.vaadin.flow.component.EventData; | ||
|
||
import elemental.json.JsonArray; | ||
|
||
/** | ||
* Widget or section reorder end event of {@link Dashboard}. | ||
* | ||
* @author Vaadin Ltd. | ||
* @see Dashboard#addItemReorderEndListener(ComponentEventListener) | ||
*/ | ||
@DomEvent("dashboard-item-reorder-end-flow") | ||
public class DashboardItemReorderEndEvent extends ComponentEvent<Dashboard> { | ||
|
||
private final JsonArray items; | ||
|
||
/** | ||
* Creates a dashboard item reorder end event. | ||
* | ||
* @param source | ||
* Dashboard that contains the item that was dragged | ||
* @param fromClient | ||
* <code>true</code> if the event originated from the client | ||
* side, <code>false</code> otherwise | ||
*/ | ||
public DashboardItemReorderEndEvent(Dashboard source, boolean fromClient, | ||
@EventData("event.detail.items") JsonArray items) { | ||
super(source, fromClient); | ||
this.items = items; | ||
} | ||
|
||
/** | ||
* Returns the ordered items from the client side | ||
* | ||
* @return items the ordered items as a {@link JsonArray} | ||
*/ | ||
public JsonArray getItems() { | ||
return items; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...low/src/main/java/com/vaadin/flow/component/dashboard/DashboardItemReorderStartEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.dashboard; | ||
|
||
import com.vaadin.flow.component.ComponentEvent; | ||
import com.vaadin.flow.component.ComponentEventListener; | ||
import com.vaadin.flow.component.DomEvent; | ||
|
||
/** | ||
* Widget or section reorder start event of {@link Dashboard}. | ||
* | ||
* @author Vaadin Ltd. | ||
* @see Dashboard#addItemReorderStartListener(ComponentEventListener) | ||
*/ | ||
@DomEvent("dashboard-item-reorder-start") | ||
public class DashboardItemReorderStartEvent extends ComponentEvent<Dashboard> { | ||
|
||
/** | ||
* Creates a dashboard item reorder start event. | ||
* | ||
* @param source | ||
* Dashboard that contains the item that was dragged | ||
* @param fromClient | ||
* <code>true</code> if the event originated from the client | ||
* side, <code>false</code> otherwise | ||
*/ | ||
public DashboardItemReorderStartEvent(Dashboard source, | ||
boolean fromClient) { | ||
super(source, fromClient); | ||
} | ||
} |
Oops, something went wrong.