Search in sources :

Example 6 with Button

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;
}
Also used : Button(org.finos.symphony.toolkit.workflow.form.Button) RoomAndDropdown(org.finos.symphony.toolkit.workflow.fixture.RoomAndDropdown) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Example 7 with Button

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);
}
Also used : Expression(org.springframework.expression.Expression) Button(org.finos.symphony.toolkit.workflow.form.Button) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse)

Example 8 with Button

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;
}
Also used : Arrays(java.util.Arrays) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) User(org.finos.symphony.toolkit.workflow.content.User) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) WorkMode(org.finos.symphony.toolkit.workflow.annotations.WorkMode) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) ArrayList(java.util.ArrayList) ResponseHandlers(org.finos.symphony.toolkit.workflow.response.handlers.ResponseHandlers) Conversations(org.finos.symphony.toolkit.workflow.conversations.Conversations) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) ErrorMap(org.finos.symphony.toolkit.workflow.form.ErrorMap) Type(org.finos.symphony.toolkit.workflow.form.Button.Type) TaskScheduler(org.springframework.scheduling.TaskScheduler) Chat(org.finos.symphony.toolkit.workflow.content.Chat) UUID(java.util.UUID) Button(org.finos.symphony.toolkit.workflow.form.Button) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) History(org.finos.symphony.toolkit.workflow.history.History) List(java.util.List) ChatRequest(org.finos.symphony.toolkit.workflow.annotations.ChatRequest) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ChatResponseBody(org.finos.symphony.toolkit.workflow.annotations.ChatResponseBody) StringUtils(org.springframework.util.StringUtils) User(org.finos.symphony.toolkit.workflow.content.User) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) Button(org.finos.symphony.toolkit.workflow.form.Button) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton)

Example 9 with Button

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");
}
Also used : Errors(org.springframework.validation.Errors) Button(org.finos.symphony.toolkit.workflow.form.Button) TestObject(org.finos.symphony.toolkit.workflow.fixture.TestObject) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Test(org.junit.jupiter.api.Test)

Example 10 with Button

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;
}
Also used : WeirdObject(org.finos.symphony.toolkit.workflow.fixture.WeirdObject) Button(org.finos.symphony.toolkit.workflow.form.Button) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Aggregations

Button (org.finos.symphony.toolkit.workflow.form.Button)11 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)10 ButtonList (org.finos.symphony.toolkit.workflow.form.ButtonList)8 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)4 ChatButton (org.finos.symphony.toolkit.workflow.annotations.ChatButton)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 EntityJson (org.finos.symphony.toolkit.json.EntityJson)2 ChatRequest (org.finos.symphony.toolkit.workflow.annotations.ChatRequest)2 WorkMode (org.finos.symphony.toolkit.workflow.annotations.WorkMode)2 User (org.finos.symphony.toolkit.workflow.content.User)2 Type (org.finos.symphony.toolkit.workflow.form.Button.Type)2 ErrorMap (org.finos.symphony.toolkit.workflow.form.ErrorMap)2 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)2 Expression (org.springframework.expression.Expression)2 StringUtils (org.springframework.util.StringUtils)2 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1 V4SymphonyElementsAction (com.symphony.api.model.V4SymphonyElementsAction)1 Instant (java.time.Instant)1