1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the zibios/sharep. |
7
|
|
|
* |
8
|
|
|
* (c) Zbigniew Ślązak |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace App\Slack\SlashCommand\Sharep; |
12
|
|
|
|
13
|
|
|
use App\Slack\MessageBuilder\Layout; |
14
|
|
|
use App\Slack\MessageBuilder\MessageFactory; |
15
|
|
|
use App\Slack\SlashCommand\Data\CommandData; |
16
|
|
|
use App\Slack\SlashCommand\TaskProcessorInterface; |
17
|
|
|
|
18
|
|
|
class SharepTakeTaskProcessor implements TaskProcessorInterface |
19
|
|
|
{ |
20
|
|
|
/** @var MessageFactory */ |
21
|
|
|
private $messageFactory; |
22
|
|
|
|
23
|
|
|
public function __construct(MessageFactory $messageFactory) |
24
|
|
|
{ |
25
|
|
|
$this->messageFactory = $messageFactory; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function supports(CommandData $commandData): bool |
29
|
|
|
{ |
30
|
|
|
return (bool) preg_match("/^take\s?/i", $commandData->text); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function process(CommandData $commandData): Layout |
34
|
|
|
{ |
35
|
|
|
$mf = $this->messageFactory; |
36
|
|
|
|
37
|
|
|
return $mf->layout( |
38
|
|
|
$mf->blockSection( |
39
|
|
|
$mf->elementPlainText('Please select dates to take'), |
40
|
|
|
$mf->elementMultiSelectStaticGroup( |
41
|
|
|
'Select dates', |
42
|
|
|
'sharep-take-multiselect-dates', |
43
|
|
|
null, |
44
|
|
|
null, |
45
|
|
|
$mf->objectOptionGroup( |
46
|
|
|
'Week 41', |
47
|
|
|
$mf->objectOption('Mo 2019-11-11', '2019-11-11'), |
48
|
|
|
$mf->objectOption('Tu 2019-11-12', '2019-11-12'), |
49
|
|
|
$mf->objectOption('We 2019-11-13', '2019-11-13'), |
50
|
|
|
$mf->objectOption('Th 2019-11-14', '2019-11-14'), |
51
|
|
|
$mf->objectOption('Fr 2019-11-15', '2019-11-15'), |
52
|
|
|
), |
|
|
|
|
53
|
|
|
$mf->objectOptionGroup( |
54
|
|
|
'Week 42', |
55
|
|
|
$mf->objectOption('Mo 2019-11-18', '2019-11-18'), |
56
|
|
|
$mf->objectOption('Tu 2019-11-19', '2019-11-19'), |
57
|
|
|
$mf->objectOption('We 2019-11-20', '2019-11-20'), |
58
|
|
|
$mf->objectOption('Th 2019-11-21', '2019-11-21'), |
59
|
|
|
$mf->objectOption('Fr 2019-11-22', '2019-11-22'), |
60
|
|
|
) |
61
|
|
|
) |
62
|
|
|
), |
63
|
|
|
$mf->blockActions( |
64
|
|
|
$mf->elementPlainText( |
65
|
|
|
'Take place for released date' |
66
|
|
|
), |
67
|
|
|
$mf->elementButton( |
68
|
|
|
'Mo 2019-11-11', |
69
|
|
|
'sharep-take-button-date', |
70
|
|
|
null, |
71
|
|
|
null, |
72
|
|
|
'2019-11-11' |
73
|
|
|
), |
74
|
|
|
$mf->elementButton( |
75
|
|
|
'Tu 2019-11-12', |
76
|
|
|
'sharep-take-button-date', |
77
|
|
|
null, |
78
|
|
|
null, |
79
|
|
|
'2019-11-12' |
80
|
|
|
) |
81
|
|
|
) |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|