ConfirmationInput should have resultValue
- Add flow hooks to ConfirmationInput so that user is able to pass a flag from an options so that component can bypass interactive mode. - Fixes #445
This commit is contained in:
@@ -35,6 +35,8 @@ public abstract class BaseConfirmationInput extends BaseInput<ConfirmationInputS
|
||||
|
||||
private String name;
|
||||
private Boolean defaultValue;
|
||||
private Boolean resultValue;
|
||||
private ResultMode resultMode;
|
||||
private Function<ConfirmationInputContext, List<AttributedString>> renderer;
|
||||
private List<Consumer<ConfirmationInputContext>> preHandlers = new ArrayList<>();
|
||||
private List<Consumer<ConfirmationInputContext>> postHandlers = new ArrayList<>();
|
||||
@@ -52,6 +54,18 @@ public abstract class BaseConfirmationInput extends BaseInput<ConfirmationInputS
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfirmationInputSpec resultValue(Boolean resultValue) {
|
||||
this.resultValue = resultValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfirmationInputSpec resultMode(ResultMode resultMode) {
|
||||
this.resultMode = resultMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfirmationInputSpec defaultValue(Boolean defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
@@ -113,6 +127,14 @@ public abstract class BaseConfirmationInput extends BaseInput<ConfirmationInputS
|
||||
return defaultValue != null ? defaultValue : true;
|
||||
}
|
||||
|
||||
public Boolean getResultValue() {
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
public ResultMode getResultMode() {
|
||||
return resultMode;
|
||||
}
|
||||
|
||||
public Function<ConfirmationInputContext, List<AttributedString>> getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@@ -521,6 +521,11 @@ public interface ComponentFlow {
|
||||
return confirmationInputs.stream().map(input -> {
|
||||
ConfirmationInput selector = new ConfirmationInput(terminal, input.getName(), input.getDefaultValue());
|
||||
Function<ComponentContext<?>, ComponentContext<?>> operation = (context) -> {
|
||||
if (input.getResultMode() == ResultMode.ACCEPT && input.isStoreResult()
|
||||
&& input.getResultValue() != null) {
|
||||
context.put(input.getId(), input.getResultValue());
|
||||
return context;
|
||||
}
|
||||
selector.setResourceLoader(resourceLoader);
|
||||
selector.setTemplateExecutor(templateExecutor);
|
||||
if (StringUtils.hasText(input.getTemplateLocation())) {
|
||||
|
||||
@@ -39,6 +39,21 @@ public interface ConfirmationInputSpec extends BaseInputSpec<ConfirmationInputSp
|
||||
* @return a builder
|
||||
*/
|
||||
ConfirmationInputSpec name(String name);
|
||||
/**
|
||||
* Sets a result value.
|
||||
*
|
||||
* @param resultValue the result value
|
||||
* @return a builder
|
||||
*/
|
||||
ConfirmationInputSpec resultValue(Boolean resultValue);
|
||||
|
||||
/**
|
||||
* Sets a result mode.
|
||||
*
|
||||
* @param resultMode the result mode
|
||||
* @return a builder
|
||||
*/
|
||||
ConfirmationInputSpec resultMode(ResultMode resultMode);
|
||||
|
||||
/**
|
||||
* Sets a default value.
|
||||
|
||||
Reference in New Issue
Block a user