Completed
Push — master ( 91f8d9...64265e )
by Mohamed
09:45 queued 06:57
created

ExportIssues::fields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 4
Bugs 2 Features 0
Metric Value
c 4
b 2
f 0
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 8.8571
cc 1
eloc 15
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Form;
13
14
use Tinyissue\Services\Exporter;
15
16
/**
17
 * ExportIssues is a class to defines fields & rules for project issues export form.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 */
21
class ExportIssues extends FilterIssue
22
{
23
    /**
24
     * @return array
25
     */
26 29
    public function actions()
27
    {
28
        return [
29
            'export-issue' => [
30
                'name'  => 'export-issue',
31
                'label' => 'export',
32
                'type'  => 'info_submit',
33 29
            ],
34
        ];
35
    }
36
37
    /**
38
     * @return array
39
     */
40 29
    public function fields()
41
    {
42 29
        $fields = parent::fields();
43
44
        // Remove sort fields
45 29
        unset($fields['sort']);
46
47
        // Remove extra group class
48 29
        $fields = array_map(function ($field) {
49 29
            unset($field['onGroupAddClass']);
50
51 29
            return $field;
52 29
        }, $fields);
53
54
        // Add extra fields
55 29
        $fields['format'] = [
56 29
            'type'        => 'select',
57 29
            'placeholder' => trans('tinyissue.export_format'),
58
            'options'     => [
59 29
                Exporter::TYPE_XLS  => trans('tinyissue.xls'),
60 29
                Exporter::TYPE_XLSX => trans('tinyissue.xlsx'),
61 29
                Exporter::TYPE_CSV  => trans('tinyissue.csv'),
62
            ],
63
        ];
64
65 29
        return $fields;
66
    }
67
68
    /**
69
     * @return string
70
     */
71 29
    public function openType()
72
    {
73 29
        return 'open';
74
    }
75
}
76