Test Failed
Push — master ( 4483e5...2e4197 )
by David
02:25
created

getItems   B

Complexity

Conditions 1
Paths 2

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 29
rs 8.8571
c 2
b 0
f 0
cc 1
nc 2
nop 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A ems 0 7 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.Detail', {
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.form.Panel',
20
    alias:'widget.template-manager-detail',
21
    cls:'template-manager-detail',
22
    collapsible : false,
23
    bodyPadding : 10,
24
    split       : false,
25
    region      : 'center',
26
    defaultType : 'textfield',
27
    autoScroll  : true,
28
    layout      : {
29
        type: 'vbox',
30
        align: 'stretch'
31
    },
32
    items : [],
33
    initComponent: function() {
34
        var me = this;
35
        
36
        me.dockedItems = [
37
            {
38
                xtype: 'toolbar',
39
                dock: 'bottom',
40
                cls: 'shopware-toolbar',
41
                ui: 'shopware-ui',
42
                items: me.getButtons()
43
            }
44
        ];
45
    
46
        me.editorField = Ext.create('Shopware.form.field.CodeMirror', {
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...
47
            title: '{s name="smartyFieldLabel"}Extension{/s}',
48
            xtype: 'codemirrorfield',
49
            mode: 'smarty',
50
            name: 'content',
51
            allowBlank: true
52
        });
53
54
        me.editorField2 = Ext.create('Shopware.form.field.CodeMirror', {
55
            title: '{s name="smarty2FieldLabel"}Base{/s}',
56
            xtype: 'codemirrorfield',
57
            readOnly: true,
58
            mode: 'smarty',
59
            name: 'oContent',
60
            allowBlank: true
61
        });
62
63
        me.on('resize', function(cmp, width, height) {
64
            me.resizeEditor(cmp, cmp.editorField, width, height);
65
            me.resizeEditor(cmp, cmp.editorField2, width, height);
66
        });
67
68
        me.editorField.on('editorready', function() {
69
            me.resizeEditor(me, me.editorField, me.getWidth(), me.getHeight());
70
        });
71
        me.editorField2.on('editorready', function() {
72
            me.resizeEditor(me, me.editorField2, me.getWidth(), me.getHeight());
73
        });
74
        
75
        me.items = me.getItems();
76
        
77
        me.callParent(arguments);
78
        me.loadRecord(me.record);
79
    },  
80
    getItems:function () {
81
        var me = this;
82
        return [
83
            {
84
                fieldLabel: '{s name="nameFieldLabel"}Name{/s}',
85
                labelWidth: 50,
86
                anchor: '100%',
87
                name: 'name',
88
                allowBlank: false
89
            },
90
            {
91
                xtype: 'tabpanel',
92
                flex: 1,
93
                items: [
94
                    me.editorField,
95
                    me.editorField2
96
                ],
97
                listeners: {
98
                    tabchange: function() {
99
                        if(!me.editorField.editor || !me.editorField2.editor) {
100
                            return;
101
                        }
102
                        me.editorField.editor.refresh();
103
                        me.editorField2.editor.refresh();
104
                    }
105
                }
106
            }
107
        ];
108
    },
109
    getButtons : function()
110
    {
111
        var me = this;
112
        return [
113
            '->',
114
            {
115
                text    : '{s name="reset"}Reset{/s}',
116
                scope   : me,
117
                cls: 'secondary',
118
                action  : 'reset'
119
            },
120
            {
121
                text    : '{s name="save"}Save{/s}',
122
                action  : 'save',
123
                cls     : 'primary',
124
                formBind: true
125
            }
126
        ];
127
    },
128
    resizeEditor : function(cmp, editorField, width, height) {
129
        var editor = editorField.editor,
130
            scroller;
131
132
        if(!editor || !editor.hasOwnProperty('display')) {
133
            return false;
134
        }
135
136
        scroller = editor.display.scroller;
137
138
        width -= cmp.bodyPadding * 2 + 5;
139
        // We need to remove the bodyPadding, the padding on the field itself and the scrollbars
140
        height -= cmp.bodyPadding * 5 + 90;
141
142
        editor.setSize(width, height);
143
        Ext.get(scroller).setSize({ width: width, height: height });
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...
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
144
    }
145
});