Tarea #808 order.basic-data cr juan
This commit is contained in:
parent
ffea839250
commit
6e421d8442
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "salix-front",
|
||||
"version": "1.0.0",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "Salix frontend",
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
|
|
|
@ -31,5 +31,6 @@
|
|||
"Worker cannot be blank": "Worker cannot be blank",
|
||||
"You must delete the claim id %d first": "You must delete the claim id %d first",
|
||||
"You don't have enough privileges": "You don't have enough privileges",
|
||||
"Tag value cannot be blank": "Tag value cannot be blank"
|
||||
"Tag value cannot be blank": "Tag value cannot be blank",
|
||||
"You don't have enough privileges to do that": "You don't have enough privileges to do that"
|
||||
}
|
|
@ -66,5 +66,6 @@
|
|||
"You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado",
|
||||
"You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo",
|
||||
"Tag value cannot be blank": "El valor del tag no puede quedar en blanco",
|
||||
"ORDER_EMPTY": "Cesta vacía"
|
||||
"ORDER_EMPTY": "Cesta vacía",
|
||||
"You don't have enough privileges to do that": "No tienes permisos para cambiar esto"
|
||||
}
|
|
@ -168,6 +168,11 @@
|
|||
"model": "CreditClassification",
|
||||
"foreignKey": "client"
|
||||
},
|
||||
"defaultAddress": {
|
||||
"type": "belongsTo",
|
||||
"model": "Address",
|
||||
"foreignKey": "defaultAddressFk"
|
||||
},
|
||||
"contacts": {
|
||||
"type": "hasMany",
|
||||
"model": "ClientContact",
|
||||
|
@ -178,20 +183,20 @@
|
|||
"model": "BankEntity",
|
||||
"foreignKey": "bankEntityFk"
|
||||
},
|
||||
"defaulters": {
|
||||
"type": "hasMany",
|
||||
"model": "Defaulter",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"clientRisks": {
|
||||
"type": "hasMany",
|
||||
"model": "ClientRisk",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"claimsRatio": {
|
||||
"type": "hasMany",
|
||||
"model": "ClaimRatio",
|
||||
"foreignKey": "clientFk"
|
||||
}
|
||||
"defaulters": {
|
||||
"type": "hasMany",
|
||||
"model": "Defaulter",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"clientRisks": {
|
||||
"type": "hasMany",
|
||||
"model": "ClientRisk",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"claimsRatio": {
|
||||
"type": "hasMany",
|
||||
"model": "ClaimRatio",
|
||||
"foreignKey": "clientFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,8 +37,9 @@ module.exports = Self => {
|
|||
|
||||
let validUpdateParams = [
|
||||
'clientFk',
|
||||
'companyFk',
|
||||
'address_id',
|
||||
'landed',
|
||||
'agency_id',
|
||||
'note',
|
||||
];
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
},
|
||||
"landed": {
|
||||
"type": "date",
|
||||
"required": true,
|
||||
"mysql": {
|
||||
"columnName": "date_send"
|
||||
}
|
||||
|
@ -27,6 +28,7 @@
|
|||
},
|
||||
"companyFk": {
|
||||
"type": "Number",
|
||||
"required": true,
|
||||
"mysql": {
|
||||
"columnName": "company_id"
|
||||
}
|
||||
|
@ -73,6 +75,7 @@
|
|||
},
|
||||
"address": {
|
||||
"type": "belongsTo",
|
||||
"required": true,
|
||||
"model": "Address",
|
||||
"foreignKey": "address_id"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<mg-ajax path="/order/api/Orders/{{patch.params.id}}/updateBasicData" options="vnPatch"></mg-ajax>
|
||||
<vn-crud-model
|
||||
vn-id="address-model"
|
||||
url="/api/Addresses"
|
||||
data="address"
|
||||
order="nickname"
|
||||
autoload = "false">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.order"
|
||||
|
@ -12,27 +19,42 @@
|
|||
vn-one
|
||||
url="/api/Clients"
|
||||
label="Client"
|
||||
search-function="{or: [{id: $search}, {name: {regexp: $search}}]}"
|
||||
search-function="{or: [{id: $search}, {name: {like: '%'+$search+'%'}}]}"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
field="$ctrl.order.clientFk"
|
||||
order="id">
|
||||
<tpl-item>{{id}}: {{name}}</tpl-item>
|
||||
selection="$ctrl.selection"
|
||||
fields="['defaultAddressFk']">
|
||||
<tpl-item>{{::id}}: {{::name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
url="/api/Companies"
|
||||
label="Company"
|
||||
show-field="code"
|
||||
data="address"
|
||||
label="Address"
|
||||
search-function="{or: [{id: $search}, {nickname: {like: '%'+$search+'%'}}]}"
|
||||
show-field="nickname"
|
||||
value-field="id"
|
||||
field="$ctrl.order.companyFk">
|
||||
field="$ctrl.order.address_id">
|
||||
<tpl-item>{{::nickname}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="Landed"
|
||||
model="$ctrl.order.landed"
|
||||
ini-options="{enableTime: false}">
|
||||
</vn-date-picker>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
url="/api/AgencyModes"
|
||||
label="Agency"
|
||||
search-function="{or: [{id: $search}, {name: {like: '%'+$search+'%'}}]}"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
field="$ctrl.order.agency_id">
|
||||
<tpl-item>{{::id}}: {{::name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textarea
|
||||
|
|
|
@ -1,7 +1,29 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($scope) {
|
||||
let isDirty = false;
|
||||
$scope.$watch('$ctrl.selection', newValue=>{
|
||||
if (newValue) {
|
||||
$scope.addressModel.where = {clientFk: newValue.id};
|
||||
$scope.addressModel.refresh();
|
||||
if (isDirty)
|
||||
this.order.address_id = newValue.defaultAddressFk;
|
||||
isDirty = true;
|
||||
} else {
|
||||
$scope.addressModel.clear();
|
||||
if (isDirty)
|
||||
this.order.address_id = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope'];
|
||||
|
||||
ngModule.component('vnOrderBasicData', {
|
||||
controller: Controller,
|
||||
template: require('./index.html'),
|
||||
bindings: {
|
||||
order: '<'
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Order', () => {
|
||||
describe('Component vnOrderBasicData', () => {
|
||||
let $httpBackend;
|
||||
let controller;
|
||||
let $scope;
|
||||
|
||||
beforeEach(ngModule('order'));
|
||||
|
||||
beforeEach(angular.mock.inject(($compile, _$httpBackend_, $rootScope) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
|
||||
$httpBackend.whenGET(/^\/api\/Addresses/)
|
||||
.respond([{id: 2, nickname: 'address 2'}]);
|
||||
$httpBackend.whenGET(/^\/api\/Clients/)
|
||||
.respond([{id: 1, defaultAddressFk: 1}]);
|
||||
$scope.order = {clientFk: 1, address_id: 1};
|
||||
|
||||
let $element = $compile('<vn-order-basic-data order="order"></vn-order-basic-data>')($scope);
|
||||
$httpBackend.flush();
|
||||
controller = $element.controller('vnOrderBasicData');
|
||||
}));
|
||||
|
||||
describe('constructor()', () => {
|
||||
it('should update the address after the client changes', async() => {
|
||||
controller.selection = {id: 2, defaultAddressFk: 2};
|
||||
$scope.$digest();
|
||||
|
||||
expect(controller.order.address_id).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -3762,7 +3762,7 @@
|
|||
"dot-prop": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
|
||||
"integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==",
|
||||
"integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-obj": "^1.0.0"
|
||||
|
@ -3935,7 +3935,7 @@
|
|||
},
|
||||
"jsonfile": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -7863,7 +7863,7 @@
|
|||
"karma-chrome-launcher": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
||||
"integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
|
||||
"integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs-access": "^1.0.0",
|
||||
|
@ -13367,7 +13367,7 @@
|
|||
"split2": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz",
|
||||
"integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==",
|
||||
"integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"through2": "^2.0.2"
|
||||
|
@ -14368,7 +14368,7 @@
|
|||
"touch": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
|
||||
"integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
|
||||
"integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"nopt": "~1.0.10"
|
||||
|
@ -15966,7 +15966,7 @@
|
|||
"write-file-atomic": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz",
|
||||
"integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==",
|
||||
"integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.11",
|
||||
|
|
Loading…
Reference in New Issue