Conditions | 1 |
Paths | 2 |
Total Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | define(function(require) { |
||
2 | 'use strict'; |
||
3 | |||
4 | var ConfigureIntegrationView; |
||
5 | var BaseView = require('oroui/js/app/views/base/view'); |
||
6 | var $ = require('jquery'); |
||
7 | var mediator = require('oroui/js/mediator'); |
||
8 | var widgetManager = require('oroui/js/widget-manager'); |
||
9 | |||
10 | ConfigureIntegrationView = BaseView.extend({ |
||
11 | optionNames: BaseView.prototype.optionNames.concat(['wid', 'dataFieldSelector', 'apiKeyFieldSelector']), |
||
12 | |||
13 | /** |
||
14 | * @inheritDoc |
||
15 | */ |
||
16 | constructor: function ConfigureIntegrationView() { |
||
17 | ConfigureIntegrationView.__super__.constructor.apply(this, arguments); |
||
18 | }, |
||
19 | |||
20 | /** |
||
21 | * @inheritDoc |
||
22 | */ |
||
23 | initialize: function(options) { |
||
24 | ConfigureIntegrationView.__super__.initialize.call(this, options); |
||
25 | |||
26 | widgetManager.getWidgetInstance(this.wid, this.onWidgetLoad.bind(this)); |
||
27 | }, |
||
28 | |||
29 | onWidgetLoad: function(widget) { |
||
30 | mediator.on('integrationFormReload:before', function(event) { |
||
31 | event.reloadManually = false; |
||
32 | widget.loadContent($.param(event.data), event.formEl.attr('method')); |
||
33 | }); |
||
34 | |||
35 | widget.on('contentLoad', function() { |
||
36 | var $dataField = this.$(this.dataFieldSelector); |
||
37 | var $apiKeyField = this.$(this.apiKeyFieldSelector); |
||
38 | |||
39 | if ($dataField.val() && !$apiKeyField.val()) { |
||
40 | var data = JSON.parse($dataField.val()); |
||
41 | |||
42 | if (data.transport.apiKey) { |
||
43 | $apiKeyField.val(data.transport.apiKey); |
||
44 | } |
||
45 | } |
||
46 | }.bind(this)); |
||
47 | } |
||
48 | }); |
||
49 | |||
50 | return ConfigureIntegrationView; |
||
51 | }); |
||
52 | |||
53 |