Test Setup Failed
Push — master ( 982d9a...a2862f )
by
unknown
03:40
created

create-customer-view.js ➔ ... ➔ CustomerView   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
define(function(require) {
2
    'use strict';
3
4
    var _ = require('underscore');
5
    var __ = require('orotranslation/js/translator');
6
    var mediator = require('oroui/js/mediator');
7
    var routing = require('routing');
8
    var DialogWidget = require('oro/dialog-widget');
9
    var BaseView = require('oroui/js/app/views/base/view');
10
11
    var CustomerView = BaseView.extend({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable CustomerView already seems to be declared on line 21. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
12
        events: {
13
            'click button': 'onCreate'
14
        },
15
16
        dialogWidget: null,
17
18
        /**
19
         * @inheritDoc
20
         */
21
        constructor: function CustomerView() {
22
            CustomerView.__super__.constructor.apply(this, arguments);
23
        },
24
25
        /**
26
         * @inheritDoc
27
         */
28
        initialize: function(options) {
29
            CustomerView.__super__.initialize.apply(this, arguments);
30
31
            this.options = _.defaults(options || {}, this.options);
32
        },
33
34
        onCreate: function() {
35
            var customer = this.$('[data-customer]').data('customer');
36
            var routeParams = this.$el.parents()
37
                .find(this.options.inputSelector)
38
                .data('select2_query_additional_params') || {};
39
40
            this.dialogWidget = new DialogWidget({
41
                title: __('Create {{ entity }}', {entity: this.$el.text()}),
42
                url: routing.generate(customer.routeCreate, routeParams),
43
                stateEnabled: false,
44
                incrementalPosition: true,
45
                dialogOptions: {
46
                    modal: true,
47
                    allowMaximize: true,
48
                    width: 1280,
49
                    height: 650
50
                }
51
            });
52
53
            this.dialogWidget.once('formSave', _.bind(function(id) {
54
                this.dialogWidget.remove();
55
                this.dialogWidget = null;
56
57
                mediator.trigger(
58
                    'customer-dialog:select',
59
                    JSON.stringify({entityClass: customer.className, entityId: id})
60
                );
61
            }, this));
62
63
            this.dialogWidget.render();
64
        }
65
    });
66
67
    return CustomerView;
68
});
69