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

initComponent   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 47
rs 9.0303
c 1
b 0
f 0
cc 1
nc 1
nop 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A ent 0 3 1
A ent 0 4 1
A ent 0 3 1
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
            }
98
        ];
99
    },
100
    getButtons : function()
101
    {
102
        var me = this;
103
        return [
104
            '->',
105
            {
106
                text    : '{s name="reset"}Reset{/s}',
107
                scope   : me,
108
                cls: 'secondary',
109
                action  : 'reset'
110
            },
111
            {
112
                text    : '{s name="save"}Save{/s}',
113
                action  : 'save',
114
                cls     : 'primary',
115
                formBind: true
116
            }
117
        ];
118
    },
119
    resizeEditor : function(cmp, editorField, width, height) {
120
        var editor = editorField.editor,
121
            scroller;
122
123
        if(!editor || !editor.hasOwnProperty('display')) {
124
            return false;
125
        }
126
127
        scroller = editor.display.scroller;
128
129
        width -= cmp.bodyPadding * 2 + 5;
130
        // We need to remove the bodyPadding, the padding on the field itself and the scrollbars
131
        height -= cmp.bodyPadding * 5 + 90;
132
133
        editor.setSize(width, height);
134
        Ext.get(scroller).setSize({ width: width, height: height });
0 ignored issues
show
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...
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...
135
    }
136
});