use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class WebHookOps method template.
@Exposed(description = "Change the template used by the last called webhook", addToHelp = true, isButton = true, isMessage = true)
public static Response template(SymphonyHistory hist, Addressable a, Workflow wf) {
Optional<EntityJson> ej = hist.getLastEntityJsonFromHistory(ActiveWebHooks.class, a);
if (ej.isEmpty()) {
return new ErrorResponse(wf, a, "No webhooks defined");
}
Optional<WebHook> activeHook = hist.getFromEntityJson(ej.get(), WebHook.class);
if (activeHook.isEmpty()) {
return new ErrorResponse(wf, a, "Active Hook not set");
}
Template t = activeHook.get().getTemplate();
ButtonList bl = new ButtonList();
bl.add(new Button(TEMPLATE_UPDATE, Type.ACTION, "Update Template"));
return new FormResponse(wf, a, ej.get(), "Template Edit", "Update the template used by " + activeHook.get().getDisplayName(), t, true, bl);
}
use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class AbstractMockSymphonyTest method createWorkAddSubmit.
protected WorkResponse createWorkAddSubmit(WorkMode wm, Object ob5) {
SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
WorkResponse wr = new WorkResponse(theRoom, ob5, wm);
ButtonList bl = (ButtonList) wr.getData().get(ButtonList.KEY);
Button submit = new Button("submit", Type.ACTION, "GO");
bl.add(submit);
return wr;
}
use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class OurController method form1.
@ChatRequest(description = "Do blah with a form", value = "form1")
public WorkResponse form1(Addressable a) {
ButtonList bl = new ButtonList();
bl.add(new Button("go", Type.ACTION, "Do The Thing"));
return new WorkResponse(a, new TestObject(), WorkMode.EDIT, bl, null);
}
use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class RoomAndDropdownMessageML method dropdownsWork.
protected WorkResponse dropdownsWork(WorkMode wm) {
SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
String strangeOption = "a";
RoomAndDropdown to4 = new RoomAndDropdown(theRoom, strangeOption);
Button submit = new Button("submit", Type.ACTION, "GO");
WorkResponse wr = new WorkResponse(theRoom, to4, wm);
// ensure buttons
ButtonList bl = (ButtonList) wr.getData().get(ButtonList.KEY);
bl.add(submit);
// ensure rooms
wr.getData().put("rooms", getSomeRooms());
// ensure dynamic dropdown options
wr.getData().put("dynoptions", getDynamicOptions());
return wr;
}
use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class PollController method poll.
@ChatButton(buttonText = "start", showWhen = WorkMode.EDIT, value = PollCreateForm.class)
public List<WorkResponse> poll(PollCreateForm cf, Chat r, User a) {
int[] i = { 0 };
List<String> options = Arrays.asList(cf.option1, cf.option2, cf.option3, cf.option4, cf.option5, cf.option6).stream().filter(s -> StringUtils.hasText(s)).collect(Collectors.toList());
ButtonList buttons = new ButtonList(options.stream().map(s -> new Button(PollController.class, "poll" + (i[0]++), Type.ACTION, s)).collect(Collectors.toList()));
HashTag id = new HashTag(UUID.randomUUID().toString());
Poll p = new Poll(options);
p.setPoller(a);
p.setQuestion(cf.getQuestion());
p.setOptions(options);
p.setId(id);
List<User> users = rooms.getChatMembers(r);
List<WorkResponse> out = users.stream().filter(u -> !isMe(u)).map(u -> createResponseForUser(cf, options, id, buttons, u)).collect(Collectors.toList());
out.add(new WorkResponse(r, p, WorkMode.VIEW));
doScheduling(p, cf, r);
return out;
}
Aggregations