mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Add support for the select input
This commit is contained in:
@@ -4,10 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public record DialogInputs(
|
||||
List<DialogTextField> textFields
|
||||
List<DialogTextField> textFields,
|
||||
List<DialogSelect> selects
|
||||
) {
|
||||
|
||||
public static final DialogInputs EMPTY = new DialogInputs(List.of());
|
||||
public static final DialogInputs EMPTY = new DialogInputs(List.of(), List.of());
|
||||
|
||||
public List<DialogInput> all() {
|
||||
List<DialogInput> all = new ArrayList<>();
|
||||
@@ -15,6 +16,10 @@ public record DialogInputs(
|
||||
all.addAll(textFields);
|
||||
}
|
||||
|
||||
if (selects != null) {
|
||||
all.addAll(selects);
|
||||
}
|
||||
|
||||
all.sort((o1, o2) -> {
|
||||
if (o1.getOrder() == o2.getOrder()) {
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.fancyinnovations.fancydialogs.api.data.inputs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DialogSelect extends DialogInput {
|
||||
|
||||
private final List<Entry> options;
|
||||
|
||||
public DialogSelect(String key, String label, int order, List<Entry> options) {
|
||||
super(key, label, order);
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public List<Entry> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public record Entry(
|
||||
String value,
|
||||
String display,
|
||||
boolean initial
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user