Completed
Push — master ( 57c78c...4fcad4 )
by Muhammad Dyas
15s queued 13s
created

src/add-option-form.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 49
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 29
mnd 0
bc 0
fnc 1
dl 0
loc 49
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A add-option-form.ts ➔ buildAddOptionForm 0 39 1
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