2402 - Added create entry section
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-09-02 14:08:56 +02:00
parent 11e1a6f845
commit a3382300f9
10 changed files with 122 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"name": "Entry",
"base": "VnModel",
"base": "Loggable",
"log": {
"model":"EntryLog"
},

View File

@ -0,0 +1,54 @@
<mg-ajax path="Entries" options="vnPost"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.entry"
form="form"
save="post">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-autocomplete
vn-one
ng-model="$ctrl.entry.supplierFk"
url="Suppliers"
show-field="nickname"
search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
value-field="id"
order="nickname"
label="Supplier">
<tpl-item>
{{::id}} - {{::nickname}}
</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
ng-model="$ctrl.entry.travelFk"
url="Travels/filter"
search-function="$ctrl.searchFunction($search)"
value-field="t.id"
order="t.id"
label="Travel">
<tpl-item>
{{::agencyModeName}} - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) &#x2192;
{{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}})
</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
url="Companies"
label="Company"
show-field="code"
value-field="id"
ng-model="$ctrl.entry.companyFk">
</vn-autocomplete>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Create"></vn-submit>
<vn-button ui-sref="entry.index" label="Cancel"></vn-button>
</vn-button-bar>
</form>

View File

@ -0,0 +1,42 @@
import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.entry = {
companyFk: this.vnConfig.companyFk
};
if (this.$params && this.$params.supplierFk)
this.entry.supplierFk = parseInt(this.$params.supplierFk);
if (this.$params && this.$params.travelFk)
this.entry.travelFk = parseInt(this.$params.travelFk);
if (this.$params && this.$params.companyFk)
this.entry.companyFk = parseInt(this.$params.companyFk);
}
onSubmit() {
this.$.watcher.submit().then(
res => this.$state.go('entry.card.basicData', {id: res.data.id})
);
}
searchFunction($search) {
return {or: [
{'am.name': {like: `%${$search}%`}},
{'win.name': {like: `%${$search}%`}},
{'wout.name': {like: `%${$search}%`}},
{'t.shipped': new Date($search)},
{'t.landed': new Date($search)}
]};
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnEntryCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1 @@
New entry: Nueva entrada

View File

@ -2,6 +2,7 @@ export * from './module';
import './main';
import './index/';
import './create';
import './search-panel';
import './descriptor';
import './card';

View File

@ -69,4 +69,16 @@
</vn-data-viewer>
<vn-travel-descriptor-popover
vn-id="travelDescriptor">
</vn-travel-descriptor-popover>
</vn-travel-descriptor-popover>
<div fixed-bottom-right>
<vn-vertical style="align-items: center;">
<a ui-sref="entry.create" vn-bind="+">
<vn-button class="round md vn-mb-sm"
icon="add"
vn-tooltip="New entry"
tooltip-position="left">
</vn-button>
</a>
</vn-vertical>
</div>

View File

@ -25,6 +25,12 @@
"state": "entry.index",
"component": "vn-entry-index",
"description": "Entries"
}, {
"url": "/create?supplierFk&travelFk&companyFk",
"state": "entry.create",
"component": "vn-entry-create",
"description": "New entry",
"acl": ["buyer"]
}, {
"url": "/:id",
"state": "entry.card",

View File

@ -33,13 +33,13 @@
"retAccount": {
"type": "Number"
},
"commision": {
"commission": {
"type": "Boolean"
},
"created": {
"type": "Date"
},
"poscodeFk": {
"postcodeFk": {
"type": "Number"
},
"isActive": {

View File

@ -79,10 +79,9 @@
tooltip-position="left">
</vn-button>
<a ui-sref="route.create">
<a ui-sref="route.create" vn-bind="+">
<vn-button class="round md vn-mb-sm"
icon="add"
vn-bind="+"
vn-tooltip="New route"
tooltip-position="left">
</vn-button>

View File

@ -143,10 +143,9 @@
vn-tooltip="Payment on account..."
tooltip-position="left">
</vn-button>
<a ui-sref="ticket.create">
<a ui-sref="ticket.create" vn-bind="+">
<vn-button class="round md vn-mb-sm"
icon="add"
vn-bind="+"
vn-tooltip="New ticket"
tooltip-position="left">
</vn-button>