浏览代码

fix(polls): Disable submit button if no answers have been chosen

master
Vlad Piersec 3 年前
父节点
当前提交
7f4fb7f447

+ 1
- 0
css/_polls.scss 查看文件

406
     &:disabled {
406
     &:disabled {
407
         background-color: #00225A;
407
         background-color: #00225A;
408
         color: #858585;
408
         color: #858585;
409
+        cursor: default;
409
     }
410
     }
410
 
411
 
411
     & > *:not(:last-child) {
412
     & > *:not(:last-child) {

+ 2
- 1
react/features/polls/components/native/PollAnswer.js 查看文件

5
 import { Button } from 'react-native-paper';
5
 import { Button } from 'react-native-paper';
6
 
6
 
7
 import { BUTTON_MODES } from '../../../chat/constants';
7
 import { BUTTON_MODES } from '../../../chat/constants';
8
+import { isSubmitAnswerDisabled } from '../../functions';
8
 import AbstractPollAnswer from '../AbstractPollAnswer';
9
 import AbstractPollAnswer from '../AbstractPollAnswer';
9
 import type { AbstractProps } from '../AbstractPollAnswer';
10
 import type { AbstractProps } from '../AbstractPollAnswer';
10
 
11
 
12
 
13
 
13
 
14
 
14
 const PollAnswer = (props: AbstractProps) => {
15
 const PollAnswer = (props: AbstractProps) => {
15
-
16
     const {
16
     const {
17
         checkBoxStates,
17
         checkBoxStates,
18
         poll,
18
         poll,
50
                 </Button>
50
                 </Button>
51
                 <Button
51
                 <Button
52
                     color = '#17a0db'
52
                     color = '#17a0db'
53
+                    disabled = { isSubmitAnswerDisabled(checkBoxStates) }
53
                     mode = { BUTTON_MODES.CONTAINED }
54
                     mode = { BUTTON_MODES.CONTAINED }
54
                     onPress = { submitAnswer }
55
                     onPress = { submitAnswer }
55
                     style = { chatStyles.pollCreateButton } >
56
                     style = { chatStyles.pollCreateButton } >

+ 3
- 3
react/features/polls/components/web/PollAnswer.js 查看文件

3
 import { Checkbox } from '@atlaskit/checkbox';
3
 import { Checkbox } from '@atlaskit/checkbox';
4
 import React from 'react';
4
 import React from 'react';
5
 
5
 
6
+import { isSubmitAnswerDisabled } from '../../functions';
6
 import AbstractPollAnswer from '../AbstractPollAnswer';
7
 import AbstractPollAnswer from '../AbstractPollAnswer';
7
 import type { AbstractProps } from '../AbstractPollAnswer';
8
 import type { AbstractProps } from '../AbstractPollAnswer';
8
 
9
 
9
-
10
 const PollAnswer = (props: AbstractProps) => {
10
 const PollAnswer = (props: AbstractProps) => {
11
-
12
     const {
11
     const {
13
         checkBoxStates,
12
         checkBoxStates,
14
         poll,
13
         poll,
51
                 </button>
50
                 </button>
52
                 <button
51
                 <button
53
                     aria-label = { t('polls.answer.submit') }
52
                     aria-label = { t('polls.answer.submit') }
54
-                    className = { 'poll-small-primary-button' }
53
+                    className = 'poll-small-primary-button'
54
+                    disabled = { isSubmitAnswerDisabled(checkBoxStates) }
55
                     onClick = { submitAnswer }>
55
                     onClick = { submitAnswer }>
56
                     <span>{t('polls.answer.submit')}</span>
56
                     <span>{t('polls.answer.submit')}</span>
57
                 </button>
57
                 </button>

+ 10
- 0
react/features/polls/functions.js 查看文件

21
 
21
 
22
     return nbUnreadPolls;
22
     return nbUnreadPolls;
23
 }
23
 }
24
+
25
+/**
26
+ * Determines if the submit poll answer button should be disabled.
27
+ *
28
+ * @param {Array<boolean>} checkBoxStates - The states of the checkboxes.
29
+ * @returns {boolean}
30
+ */
31
+export function isSubmitAnswerDisabled(checkBoxStates: Array<boolean>) {
32
+    return !checkBoxStates.find(checked => checked);
33
+}

正在加载...
取消
保存