Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 49 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {PollState} from './helpers/interfaces'; |
||
2 | import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1'; |
||
3 | |||
4 | /** |
||
5 | * Build the add option form. |
||
6 | * |
||
7 | * @param {object} state - the current message state |
||
8 | * @returns {object} card |
||
9 | */ |
||
10 | export function buildAddOptionForm(state: PollState): chatV1.Schema$GoogleAppsCardV1Card { |
||
11 | return { |
||
12 | 'header': { |
||
13 | 'title': 'Add a new option/choice', |
||
14 | 'subtitle': 'Q:' + state.topic, |
||
15 | }, |
||
16 | 'sections': [ |
||
17 | { |
||
18 | 'widgets': [ |
||
19 | { |
||
20 | 'textInput': { |
||
21 | 'label': 'Option Name', |
||
22 | 'type': 'SINGLE_LINE', |
||
23 | 'name': 'value', |
||
24 | 'hintText': '', |
||
25 | 'value': '', |
||
26 | }, |
||
27 | 'horizontalAlignment': 'START', |
||
28 | }, |
||
29 | ], |
||
30 | }, |
||
31 | ], |
||
32 | 'fixedFooter': { |
||
33 | 'primaryButton': { |
||
34 | 'text': 'Add option', |
||
35 | 'onClick': { |
||
36 | 'action': { |
||
37 | 'function': 'add_option', |
||
38 | 'parameters': [ |
||
39 | { |
||
40 | key: 'state', |
||
41 | value: JSON.stringify(state), |
||
42 | }], |
||
43 | }, |
||
44 | }, |
||
45 | }, |
||
46 | }, |
||
47 | }; |
||
48 | } |
||
49 |