Merge branch 'dev' into 2285-ticket_closure
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-09-07 10:03:02 +00:00
commit 3c819b3350
16 changed files with 215 additions and 10 deletions

View File

@ -909,5 +909,12 @@ export default {
newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]', newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]',
latestBuysSectionButton: 'a[ui-sref="entry.latestBuys"]', latestBuysSectionButton: 'a[ui-sref="entry.latestBuys"]',
acceptEditBuysDialog: 'button[response="accept"]' acceptEditBuysDialog: 'button[response="accept"]'
},
entryIndex: {
createEntryButton: 'vn-entry-index vn-button[icon="add"]',
newEntrySupplier: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.supplierFk"]',
newEntryTravel: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.travelFk"]',
newEntryCompany: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.companyFk"]',
saveNewEntry: 'vn-entry-create button[type="submit"]'
} }
}; };

View File

@ -0,0 +1,33 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Entry create path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'entry');
});
afterAll(async() => {
await browser.close();
});
it('should click the create entry button to open the form', async() => {
await page.waitToClick(selectors.entryIndex.createEntryButton);
await page.waitForState('entry.create');
});
it('should fill the form to create a valid entry', async() => {
await page.autocompleteSearch(selectors.entryIndex.newEntrySupplier, '2');
await page.autocompleteSearch(selectors.entryIndex.newEntryTravel, 'Warehouse Three');
await page.autocompleteSearch(selectors.entryIndex.newEntryCompany, 'ORN');
await page.waitToClick(selectors.entryIndex.saveNewEntry);
});
it('should be redirected to entry basic data', async() => {
await page.waitForState('entry.card.basicData');
});
});

View File

@ -1,6 +1,6 @@
{ {
"name": "Entry", "name": "Entry",
"base": "VnModel", "base": "Loggable",
"log": { "log": {
"model":"EntryLog" "model":"EntryLog"
}, },
@ -62,6 +62,18 @@
}, },
"loadPriority": { "loadPriority": {
"type": "number" "type": "number"
},
"supplierFk": {
"type": "number",
"required": true
},
"travelFk": {
"type": "number",
"required": true
},
"companyFk": {
"type": "number",
"required": true
} }
}, },
"relations": { "relations": {

View File

@ -0,0 +1,10 @@
import ngModule from '../module';
import Section from 'salix/components/section';
ngModule.vnComponent('vnEntryBasicData', {
template: require('./index.html'),
controller: Section,
bindings: {
entry: '<'
}
});

View File

@ -0,0 +1,61 @@
<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-icon color-marginal
icon="info"
vn-tooltip="Required fields (*)">
</vn-icon>
<vn-horizontal>
<vn-autocomplete
vn-one
ng-model="$ctrl.entry.supplierFk"
url="Suppliers"
show-field="nickname"
search-function="{or: [{id: $search}, {nickname: {like: '%'+ $search +'%'}}]}"
value-field="id"
order="nickname"
label="Supplier"
required="true">
<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="id"
order="id"
label="Travel"
required="true">
<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"
required="true">
</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,43 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
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: [
{'agencyModeName': {like: `%${$search}%`}},
{'warehouseInName': {like: `%${$search}%`}},
{'warehouseOutName': {like: `%${$search}%`}},
{'shipped': new Date($search)},
{'landed': new Date($search)}
]};
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnEntryCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,2 @@
New entry: Nueva entrada
Required fields (*): Campos requeridos (*)

View File

@ -0,0 +1,10 @@
vn-entry-create {
vn-card {
position: relative
}
vn-icon[icon="info"] {
position: absolute;
top: 16px;
right: 16px
}
}

View File

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

View File

@ -70,3 +70,15 @@
<vn-travel-descriptor-popover <vn-travel-descriptor-popover
vn-id="travelDescriptor"> 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

@ -10,6 +10,7 @@
{"state": "entry.latestBuys", "icon": "icon-latestBuys"} {"state": "entry.latestBuys", "icon": "icon-latestBuys"}
], ],
"card": [ "card": [
{"state": "entry.card.basicData", "icon": "settings"},
{"state": "entry.card.buy", "icon": "icon-lines"}, {"state": "entry.card.buy", "icon": "icon-lines"},
{"state": "entry.card.log", "icon": "history"} {"state": "entry.card.log", "icon": "history"}
] ]
@ -33,6 +34,12 @@
"component": "vn-entry-latest-buys", "component": "vn-entry-latest-buys",
"description": "Latest buys", "description": "Latest buys",
"acl": ["buyer"] "acl": ["buyer"]
}, {
"url": "/create?supplierFk&travelFk&companyFk",
"state": "entry.create",
"component": "vn-entry-create",
"description": "New entry",
"acl": ["buyer"]
}, { }, {
"url": "/:id", "url": "/:id",
"state": "entry.card", "state": "entry.card",
@ -46,6 +53,14 @@
"params": { "params": {
"entry": "$ctrl.entry" "entry": "$ctrl.entry"
} }
}, {
"url": "/basic-data",
"state": "entry.card.basicData",
"component": "vn-entry-basic-data",
"description": "Basic data",
"params": {
"entry": "$ctrl.entry"
}
}, { }, {
"url" : "/log", "url" : "/log",
"state": "entry.card.log", "state": "entry.card.log",

View File

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

View File

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

View File

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

View File

@ -112,7 +112,8 @@ module.exports = Self => {
let stmts = []; let stmts = [];
let stmt; let stmt;
stmt = new ParameterizedSQL( stmt = new ParameterizedSQL(
`SELECT `SELECT * FROM
(SELECT
t.id, t.id,
t.shipped, t.shipped,
t.landed, t.landed,
@ -132,7 +133,7 @@ module.exports = Self => {
FROM vn.travel t FROM vn.travel t
JOIN vn.agencyMode am ON am.id = t.agencyFk JOIN vn.agencyMode am ON am.id = t.agencyFk
JOIN vn.warehouse win ON win.id = t.warehouseInFk JOIN vn.warehouse win ON win.id = t.warehouseInFk
JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk` JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk) AS t`
); );
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));