Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 8abdb6...83f266 )
by Pierre
10:15
created

Module.extend._renderClientAddresses   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
1
/*
2
 * This file is part of CSBill package.
3
 *
4
 * (c) 2013-2015 Pierre du Plessis <[email protected]>
5
 *
6
 * This source file is subject to the MIT license that is bundled
7
 * with this source code in the file LICENSE.
8
 */
9
10
define(
11
    ['jquery', 'core/module', 'backbone', 'bootstrap.bootbox', 'routing', 'translator', 'client/view/info', './credit', './contacts', 'client/view/address_collection', 'client/model/address_collection'],
12
    function($, Module, Backbone, Bootbox, Routing, __, InfoView, ClientCredit, ClientContact, AddressView, AddressCollection) {
13
        'use strict';
14
15
        return Module.extend({
16
            regions: {
17
                'clientCredit': '#client-credit',
18
                'clientInfo': '#client-info'
19
            },
20
            _renderCredit: function(options) {
21
                this.app.showChildView('clientCredit', ClientCredit.getView(options));
22
            },
23
            _renderContactCollection: function(layoutView, options) {
24
                layoutView.renderContactsRegion(ClientContact.getView(options));
25
            },
26
            _renderClientAddresses: function(layoutView, options) {
27
                var addressCollection = new AddressCollection(options.addresses, {'id': options.id});
28
29
                var that = this;
30
31
                addressCollection.on('remove', function() {
32
                    addressCollection
33
                        .fetch({reset: true, url: Routing.generate('_xhr_clients_address_list', {'id': options.id})})
34
                        .done(function() {
35
                            layoutView.model.set('addresses', addressCollection.toArray());
36
                            options.addresses = layoutView.model.get('addresses');
37
38
                            layoutView.render();
39
                            that._renderContactCollection(layoutView, options);
40
                            if (addressCollection.length > 0) {
41
                                layoutView.getRegion('clientAddress').show(new AddressView({collection: addressCollection}));
42
                            }
43
                        }
44
                    );
45
                });
46
47
                if (addressCollection.length > 0) {
48
                    layoutView.getRegion('clientAddress').show(new AddressView({collection: addressCollection}));
49
                }
50
            },
51
            _renderClientInfo: function(options) {
52
                var infoView = new InfoView({
53
                    model: new Backbone.Model(options)
54
                });
55
56
                this.app.showChildView('clientInfo', infoView);
57
58
                return infoView;
59
            },
60
            initialize: function(options) {
61
                this._renderCredit(options);
62
63
                var infoView = this._renderClientInfo(options);
64
                this.render(infoView, options);
65
66
                $('#delete-client').on('click', this.deleteClient);
67
            },
68
            render: function(infoView, options) {
69
                this._renderContactCollection(infoView, options);
70
                this._renderClientAddresses(infoView, options);
71
            },
72
            deleteClient: function(event) {
73
                event.preventDefault();
74
75
                var link = $(this);
76
77
                Bootbox.confirm(__('client.confirm_delete'), function(confirm) {
78
                    if (true === confirm) {
79
                        $('body').modalmanager('loading');
80
81
                        $.ajax({
82
                            "url": link.attr("href"),
83
                            "dataType": "json",
84
                            "method": "delete"
85
                        }).done(function() {
86
                            window.document.location = Routing.generate("_clients_index");
87
                        });
88
                    }
89
                });
90
            }
91
        });
92
    }
93
);