Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

56
LINES

< > BotCompany Repo | #1029912 // Form wrapper for DynNewBot2 [dev.]

JavaX fragment (include)

1  
sclass FormInFlight {
2  
  Conversation conversation;
3  
  S hashTag;
4  
  new L<FormStep> steps;
5  
  int stepIndex; // in steps list
6  
  
7  
  S handleInput(S s) { null; }
8  
  
9  
  FormStep currentStep() {
10  
    ret get(steps, stepIndex);
11  
  }
12  
  
13  
  void update(Runnable onChange) {
14  
    if (currentStep() != null) currentStep().update(onChange);
15  
  }
16  
  
17  
  S complete() { ret "Form complete"; }
18  
  S cancel() { ret "Request cancelled"; }
19  
20  
  FormStep byKey(S key) {
21  
    ret objectWhere(steps, +key);
22  
  }
23  
  
24  
  S getValue(S key) {
25  
    FormStep step = byKey(key);
26  
    ret step?.value;
27  
  }
28  
  
29  
  SS allValues() {
30  
    SS map = litorderedmap();
31  
    for (FormStep step : steps)
32  
      map.put(step.key, step.value);
33  
    ret map;
34  
  }
35  
  
36  
  bool allowGeneralOverride() { false; }
37  
38  
  Conversation cancelMe() {
39  
    Conversation conv = conversation;
40  
    print("cancelMe called");
41  
    // TODO: conversation.cancelForm();
42  
    ret conv;
43  
  }
44  
  
45  
  void change {
46  
    if (conversation != null) conversation.change();
47  
  }
48  
}
49  
50  
abstract concept BotShowForm > BotStep {
51  
  abstract FormInFlight makeForm();
52  
  
53  
  bool run(Conversation conv) {
54  
    Form form = makeForm();
55  
    true;
56  
  }

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1029912
Snippet name: Form wrapper for DynNewBot2 [dev.]
Eternal ID of this version: #1029912/1
Text MD5: da88932ce16ebfea96822918f454083f
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-10-03 12:24:50
Source code size: 1183 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 162 / 196
Referenced in: [show references]