Search in sources :

Example 1 with ButtonList

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);
}
Also used : FormResponse(org.finos.symphony.toolkit.workflow.response.FormResponse) EntityJson(org.finos.symphony.toolkit.json.EntityJson) Button(org.finos.symphony.toolkit.workflow.form.Button) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) ErrorResponse(org.finos.symphony.toolkit.workflow.response.ErrorResponse) Exposed(org.finos.symphony.toolkit.workflow.java.Exposed)

Example 2 with ButtonList

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;
}
Also used : Button(org.finos.symphony.toolkit.workflow.form.Button) 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 3 with ButtonList

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);
}
Also used : Button(org.finos.symphony.toolkit.workflow.form.Button) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) ChatRequest(org.finos.symphony.toolkit.workflow.annotations.ChatRequest)

Example 4 with ButtonList

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;
}
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 5 with ButtonList

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;
}
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)

Aggregations

Button (org.finos.symphony.toolkit.workflow.form.Button)8 ButtonList (org.finos.symphony.toolkit.workflow.form.ButtonList)8 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)7 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 ChatRequest (org.finos.symphony.toolkit.workflow.annotations.ChatRequest)2 WorkMode (org.finos.symphony.toolkit.workflow.annotations.WorkMode)2 Type (org.finos.symphony.toolkit.workflow.form.Button.Type)2 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)2 StringUtils (org.springframework.util.StringUtils)2 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1