Test Failed
Push — master ( f4d769...4483e5 )
by David
02:15
created

  A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
/**
2
 * Template 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/templatemanager}
17
//
18
Ext.define('Shopware.apps.WbmTemplateManager.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.template-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('openTemplateDetail', me, rowIndex);
28
        }
29
    },
30
    initComponent:function () {
31
        var me = this;
32
        me.columns = me.getColumns();
33
        me.dockedItems = [
34
            {
35
                xtype: 'toolbar',
36
                dock: 'top',
37
                cls: 'shopware-toolbar',
38
                ui: 'shopware-ui',
39
                items: me.getButtons()
40
            }
41
        ];
42
        me.callParent(arguments);
43
    },
44
    getColumns:function () {
45
        var me = this;
46
        return [
47
            {
48
                header: '{s name="nameColumnHeader"}Name{/s}',
49
                dataIndex:'name',
50
                flex:1,
51
                renderer:function(value, metaData, record) {
52
                    if (record.get('custom') != 1) {
53
                        return '<span style="color:#999">' + value + '</span>';
54
                    } else {
55
                        return value;
56
                    }
57
                }
58
            },
59
            {
60
                xtype:'actioncolumn',
61
                width:30,
62
                items:me.getActionColumnItems()
63
            }
64
        ];
65
    },
66
    getButtons : function()
67
    {
68
        var me = this;
69
            return [
70
                {
71
                    text    : '{s name="add"}Hinzufügen{/s}',
72
                    scope   : me,
73
                    iconCls : 'sprite-plus-circle-frame',
74
                    action : 'addTemplate'
75
                }
76
            ];
77
    },
78
    getActionColumnItems: function () {
79
        var me = this;
80
        return [
81
            {
82
                iconCls:'x-action-col-icon sprite-minus-circle-frame',
83
                cls:'duplicateColumn',
84
                tooltip:'{s name="delete"}Löschen{/s}',
85
                getClass: function(value, metadata, record) {
86
                    if (record.get("custom") != 1) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if record.get("custom") != 1 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...
87
                        return 'x-hidden';
88
                    }
89
                },
90
                handler:function (view, rowIndex, colIndex, item) {
91
                    me.fireEvent('deleteTemplate', view, rowIndex, colIndex, item);
92
                }
93
            }
94
        ];
95
    }
96
});
97