Completed
Push — master ( ad8ce0...eb51fb )
by David
09:59
created

activeColumnRenderer   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
nc 2
nop 1
1
/**
2
 * Query Manager
3
 * Copyright (c) Webmatch GmbH
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 */
15
16
//{namespace name=backend/plugins/wbm/querymanager}
17
//
18
Ext.define('Shopware.apps.WbmQueryManager.view.main.List', {
0 ignored issues
show
Bug introduced by
The variable Ext seems to be never declared. If this is a global, consider adding a /** global: Ext */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
19
    extend:'Ext.grid.Panel',
20
    border: false,
21
    alias:'widget.query-manager-list',
22
    region:'center',
23
    autoScroll:true,
24
    listeners: {
25
        itemclick: function(dv, record, item, rowIndex, e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
26
            var me = this;
27
            me.fireEvent('openQueryDetail', me, rowIndex);                                     
28
        }
29
    },
30
    initComponent:function () {
31
        var me = this;
32
        me.registerEvents();
33
        me.columns = me.getColumns();
34
        me.dockedItems = [
35
            {
36
                xtype: 'toolbar',
37
                dock: 'top',
38
                cls: 'shopware-toolbar',
39
                ui: 'shopware-ui',
40
                items: me.getButtons()
41
            }
42
        ];
43
        me.callParent(arguments);
44
    },
45
    registerEvents:function () {
46
        this.addEvents(
47
            );
48
        return true;
49
    },
50
    getColumns:function () {
51
        var me = this;
52
        return [
53
            {
54
                header: '{s name="nameColumnHeader"}Name{/s}',
55
                dataIndex:'name',
56
                flex:1
57
            },
58
            {
59
                header: 'C',
60
                width:25,
61
                dataIndex: 'hasCronjob',
62
                xtype: 'booleancolumn',
63
                renderer: me.activeColumnRenderer
64
            },
65
            {
66
                xtype:'actioncolumn',
67
                width:50,
68
                items:me.getActionColumnItems()
69
            }
70
        ];
71
    },
72
    getButtons : function()
73
    {
74
        var me = this;
75
        return [
76
            {
77
                text    : '{s name="add"}Hinzufügen{/s}',
78
                scope   : me,
79
                iconCls : 'sprite-plus-circle-frame',
80
                action : 'addQuery'
81
            }
82
        ];
83
    },
84
    getActionColumnItems: function () {
85
        var me = this;
86
        return [
87
            {
88
                iconCls:'x-action-col-icon sprite-minus-circle-frame',
89
                cls:'duplicateColumn',
90
                tooltip:'{s name="delete"}Löschen{/s}',
91
                getClass: function(value, metadata, record) {
92
                    if (!record.get("id")) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !record.get("id") is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
93
                        return 'x-hidden';
94
                    }
95
                },
96
                handler:function (view, rowIndex, colIndex, item) {
97
                    me.fireEvent('deleteQuery', view, rowIndex, colIndex, item);
98
                }
99
            },
100
            {
101
                iconCls:'x-action-col-icon sprite-blue-document-copy',
102
                cls:'duplicateColumn',
103
                tooltip:'{s name="duplicate"}Duplizieren{/s}',
104
                getClass: function(value, metadata, record) {
105
                    if (!record.get("id")) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !record.get("id") is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
106
                        return 'x-hidden';
107
                    }
108
                },
109
                handler:function (view, rowIndex, colIndex, item) {
110
                    me.fireEvent('cloneQuery', view, rowIndex, colIndex, item);
111
                }
112
            }
113
        ];
114
    },
115
    activeColumnRenderer: function(value) {
116
        if (value) {
117
            return '<div class="sprite-tick-small">&nbsp;</div>';
118
        } else {
119
            return '<div class="sprite-cross-small">&nbsp;</div>';
120
        }
121
    }
122
});
123