button for insert rows
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
7f5b30aa87
commit
ec41123772
|
@ -0,0 +1,75 @@
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
url="SupplierAgencyTerms"
|
||||||
|
primary-key="agencyFk"
|
||||||
|
data="$ctrl.supplierAgencyTerm"
|
||||||
|
insert-mode="true"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<vn-crud-model
|
||||||
|
auto-load="true"
|
||||||
|
url="Agencies"
|
||||||
|
filter="$ctrl.filter"
|
||||||
|
data="agencies">
|
||||||
|
</vn-crud-model>
|
||||||
|
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||||
|
<vn-card class="vn-pa-lg">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete vn-id="agency" vn-one
|
||||||
|
label="Agency"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.agencyFk"
|
||||||
|
data="agencies"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id"
|
||||||
|
rule>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Minimum M3"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.minimumM3"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Package Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.packagePrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Km Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.kmPrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="M3 Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.m3Price"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Route Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.routePrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Minimum Km"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.minimumKm"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit label="Save"></vn-submit>
|
||||||
|
<vn-button
|
||||||
|
label="Cancel"
|
||||||
|
ui-sref="supplier.card.agencyTerm.index">
|
||||||
|
</vn-button>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
|
@ -0,0 +1,34 @@
|
||||||
|
import ngModule from '../../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
|
||||||
|
this.filter = {
|
||||||
|
fields: [
|
||||||
|
'name'
|
||||||
|
],
|
||||||
|
include: [{
|
||||||
|
relation: 'supplierAgencyTerm',
|
||||||
|
where: {
|
||||||
|
supplierFk: 1
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$.watcher.submit().then(res => {
|
||||||
|
this.$state.go('supplier.card.address.index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnSupplierAgencyTermCreate', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
supplier: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,102 @@
|
||||||
|
import './index';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
|
||||||
|
describe('Supplier', () => {
|
||||||
|
describe('Component vnSupplierAddressCreate', () => {
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
let $element;
|
||||||
|
let $state;
|
||||||
|
|
||||||
|
beforeEach(ngModule('supplier'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$state = _$state_;
|
||||||
|
$state.params.id = '1234';
|
||||||
|
$element = angular.element('<vn-supplier-address-create></vn-supplier-address-create>');
|
||||||
|
controller = $componentController('vnSupplierAddressCreate', {$element, $scope});
|
||||||
|
controller.$.watcher = watcher;
|
||||||
|
controller.$.watcher.submit = () => {
|
||||||
|
return {
|
||||||
|
then: callback => {
|
||||||
|
callback({data: {id: 124}});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
controller.supplier = {id: 1};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it('should perform a PATCH and then redirect to the main section', () => {
|
||||||
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('town() setter', () => {
|
||||||
|
it(`should set provinceFk property`, () => {
|
||||||
|
controller.town = {
|
||||||
|
provinceFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
postcodes: []
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.address.provinceFk).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||||
|
controller.town = {
|
||||||
|
provinceFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
postcodes: [{code: '46001'}]
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.address.provinceFk).toEqual(1);
|
||||||
|
expect(controller.address.postalCode).toEqual('46001');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('postcode() setter', () => {
|
||||||
|
it(`should set the town and province properties`, () => {
|
||||||
|
controller.postcode = {
|
||||||
|
townFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
town: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New York',
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.address.city).toEqual('New York');
|
||||||
|
expect(controller.address.provinceFk).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -15,7 +15,7 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal ng-repeat="supplierAgencyTerm in $ctrl.supplierAgencyTerms">
|
<vn-horizontal ng-repeat="supplierAgencyTerm in $ctrl.supplierAgencyTerms">
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-id="text"
|
vn-id="agency"
|
||||||
label="Agency"
|
label="Agency"
|
||||||
ng-model="supplierAgencyTerm.agencyFk"
|
ng-model="supplierAgencyTerm.agencyFk"
|
||||||
url="Agencies"
|
url="Agencies"
|
||||||
|
@ -84,3 +84,11 @@
|
||||||
</vn-submit>
|
</vn-submit>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
</form>
|
</form>
|
||||||
|
<vn-float-button
|
||||||
|
vn-bind="+"
|
||||||
|
fixed-bottom-right
|
||||||
|
vn-tooltip="New row"
|
||||||
|
ui-sref="supplier.card.agencyTerm.create"
|
||||||
|
icon="add"
|
||||||
|
label="Add">
|
||||||
|
</vn-float-button>
|
|
@ -1,4 +1,4 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
|
@ -15,7 +15,7 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnSupplierAgencyTerm', {
|
ngModule.vnComponent('vnSupplierAgencyTermIndex', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
bindings: {
|
bindings: {
|
|
@ -18,4 +18,5 @@ import './billing-data';
|
||||||
import './address/index';
|
import './address/index';
|
||||||
import './address/create';
|
import './address/create';
|
||||||
import './address/edit';
|
import './address/edit';
|
||||||
import './agency-term';
|
import './agency-term/index';
|
||||||
|
import './agency-term/create';
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{"state": "supplier.card.address.index", "icon": "icon-delivery"},
|
{"state": "supplier.card.address.index", "icon": "icon-delivery"},
|
||||||
{"state": "supplier.card.account", "icon": "icon-account"},
|
{"state": "supplier.card.account", "icon": "icon-account"},
|
||||||
{"state": "supplier.card.contact", "icon": "contact_phone"},
|
{"state": "supplier.card.contact", "icon": "contact_phone"},
|
||||||
{"state": "supplier.card.agencyTerm", "icon": "contact_support"},
|
{"state": "supplier.card.agencyTerm.index", "icon": "contact_support"},
|
||||||
{"state": "supplier.card.log", "icon": "history"},
|
{"state": "supplier.card.log", "icon": "history"},
|
||||||
{"state": "supplier.card.consumption", "icon": "show_chart"}
|
{"state": "supplier.card.consumption", "icon": "show_chart"}
|
||||||
]
|
]
|
||||||
|
@ -90,9 +90,26 @@
|
||||||
{
|
{
|
||||||
"url": "/agency-term",
|
"url": "/agency-term",
|
||||||
"state": "supplier.card.agencyTerm",
|
"state": "supplier.card.agencyTerm",
|
||||||
"component": "vn-supplier-agency-term",
|
"component": "ui-view",
|
||||||
|
"abstract": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/index?q",
|
||||||
|
"state": "supplier.card.agencyTerm.index",
|
||||||
|
"component": "vn-supplier-agency-term-index",
|
||||||
"description": "Autonomous",
|
"description": "Autonomous",
|
||||||
"acl": ["administrative"]
|
"params": {
|
||||||
|
"supplier": "$ctrl.supplier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/create",
|
||||||
|
"state": "supplier.card.agencyTerm.create",
|
||||||
|
"component": "vn-supplier-agency-term-create",
|
||||||
|
"description": "New autonomous",
|
||||||
|
"params": {
|
||||||
|
"supplier": "$ctrl.supplier"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/consumption?q",
|
"url": "/consumption?q",
|
||||||
|
|
|
@ -16,5 +16,12 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": false
|
"required": false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"supplierAgencyTerm": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "SupplierAgencyTerm",
|
||||||
|
"foreignKey": "agencyFk"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue