copy billing address
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Account": "Create Account"
|
||||
"Create Account": "Create Account",
|
||||
"Copy Billing": "Copy Billing"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
"type": "varchar"
|
||||
},
|
||||
"shippingAddress": {
|
||||
"type": "address"
|
||||
"type": "address",
|
||||
"view": "Crm:Account.Fields.ShippingAddress"
|
||||
},
|
||||
"shippingAddressStreet": {
|
||||
"type": "text",
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('Crm:Views.Account.Fields.ShippingAddress', 'Views.Fields.Address', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
copyFrom: 'billingAddress',
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
|
||||
if (this.mode == 'edit') {
|
||||
var label = this.translate('Copy Billing', 'labels', 'Accounts');
|
||||
$btn = $('<button class="btn btn-default btn-sm">' + label + '</button>').on('click', function () {
|
||||
this.copy(this.copyFrom);
|
||||
}.bind(this));
|
||||
this.$el.append($btn);
|
||||
}
|
||||
},
|
||||
|
||||
copy: function (fieldFrom) {
|
||||
var attrList = Object.keys(this.getMetadata().get('fields.address.fields')).forEach(function (attr) {
|
||||
destField = this.name + Espo.Utils.upperCaseFirst(attr);
|
||||
sourceField = fieldFrom + Espo.Utils.upperCaseFirst(attr);
|
||||
|
||||
this.model.set(destField, this.model.get(sourceField));
|
||||
}, this);
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,14 +44,32 @@ Espo.define('Views.Fields.Address', 'Views.Fields.Base', function (Dep) {
|
||||
return data;
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
if (this.mode == 'edit') {
|
||||
afterRender: function () {
|
||||
var self = this;
|
||||
|
||||
if (this.mode == 'edit') {
|
||||
this.$street = this.$el.find('[name="' + this.streetField + '"]');
|
||||
this.$postalCode = this.$el.find('[name="' + this.postalCodeField + '"]');
|
||||
this.$state = this.$el.find('[name="' + this.stateField + '"]');
|
||||
this.$city = this.$el.find('[name="' + this.cityField + '"]');
|
||||
this.$country = this.$el.find('[name="' + this.countryField + '"]');
|
||||
|
||||
this.$street.on('change', function () {
|
||||
self.trigger('change');
|
||||
});
|
||||
this.$postalCode.on('change', function () {
|
||||
self.trigger('change');
|
||||
});
|
||||
this.$state.on('change', function () {
|
||||
self.trigger('change');
|
||||
});
|
||||
this.$city.on('change', function () {
|
||||
self.trigger('change');
|
||||
});
|
||||
this.$country.on('change', function () {
|
||||
self.trigger('change');
|
||||
});
|
||||
|
||||
this.$street.on('input', function (e) {
|
||||
var numberOfLines = e.currentTarget.value.split('\n').length;
|
||||
var numberOfRows = this.$street.prop('rows');
|
||||
|
||||
Reference in New Issue
Block a user