use of org.finos.symphony.toolkit.workflow.form.Button 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.Button in project spring-bot by finos.
the class TableEditRow method createEditForm.
protected void createEditForm(FormAction in, String verb) {
String tableLocation = verb.substring(0, verb.length() - EDIT_SUFFIX.length() - 1);
tableLocation = fixSpel(tableLocation);
Expression e = spel.parseExpression(tableLocation);
Object data = in.getData().get(WorkResponse.OBJECT_KEY);
Object o = e.getValue(data);
Class<?> c = o.getClass();
Map<String, Object> json = WorkResponse.createEntityMap(o, ButtonList.of(new Button(tableLocation + "." + UPDATE_SUFFIX, Type.ACTION, "Update")), null);
json.put(WORKFLOW_001, data);
WorkResponse wr = new WorkResponse(in.getAddressable(), json, WorkResponse.getTemplateNameForClass(WorkMode.EDIT, c), WorkMode.EDIT, c);
rh.accept(wr);
}
use of org.finos.symphony.toolkit.workflow.form.Button 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;
}
use of org.finos.symphony.toolkit.workflow.form.Button in project spring-bot by finos.
the class TestFormMessageML method testValidation.
@Test
public void testValidation() throws Exception {
TestObject a = new TestObject("83274239874", true, true, "rob", 234786, 2138);
SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
ButtonList bl = new ButtonList();
Button submit = new Button("submit", Type.ACTION, "GO");
bl.add(submit);
Errors eh = ErrorHelp.createErrorHolder();
validator.validate(a, eh);
WorkResponse wr = new WorkResponse(theRoom, a, WorkMode.EDIT, bl, ElementsHandler.convertErrorsToMap(eh));
testTemplating(wr, "abc123", "testValidation.ml", "testValidation.json");
}
use of org.finos.symphony.toolkit.workflow.form.Button in project spring-bot by finos.
the class TestFormMessageML method createWeirdFieldsWorkResponse.
protected WorkResponse createWeirdFieldsWorkResponse(WorkMode wm) {
SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
SymphonyUser someUser = new SymphonyUser(2678l, "bob", "bob@example.com");
WeirdObject to4 = new WeirdObject();
to4.setTheId(new HashTag("adf360dd-06fe-43a4-9a62-2c17fe2deefa"));
to4.setC(Choice.C);
to4.setSomeUser(someUser);
to4.setCashTag(new CashTag("rameses"));
to4.setB(true);
to4.setC(Choice.B);
Button submit = new Button("submit", Type.ACTION, "GO");
WorkResponse wr = new WorkResponse(theRoom, to4, wm);
ButtonList bl = (ButtonList) wr.getData().get(ButtonList.KEY);
bl.add(submit);
return wr;
}
Aggregations