added order catalogue #408

This commit is contained in:
Joan Sanchez 2018-07-24 09:35:23 +02:00
parent d2904bd065
commit 896c033594
16 changed files with 1019 additions and 374 deletions

View File

@ -1,7 +1,7 @@
{
"module": "order",
"name": "Orders",
"icon": "shopping_basket",
"icon": "shopping_cart",
"validations": true,
"routes": [
{
@ -30,6 +30,18 @@
"order": "$ctrl.order"
}
},
{
"url": "/catalogue",
"state": "order.card.catalogue",
"component": "vn-order-catalogue",
"params": {
"order": "$ctrl.order"
},
"menu": {
"description": "Catalogue",
"icon": "shopping_cart"
}
},
{
"url": "/create",
"state": "order.create",

View File

@ -0,0 +1,31 @@
<vn-crud-model
vn-id="model"
url="/order/api/Orders/ItemFilter"
filter="::$ctrl.filter"
data="items" auto-load="false">
</vn-crud-model>
<vn-horizontal>
<vn-vertical vn-one>
<vn-card>
<vn-vertical>
<vn-horizontal class="catalogue header" pad-medium>
<vn-one>{{model.data.length}} <span translate>results</span></vn-one>
<vn-one>-</vn-one>
</vn-horizontal>
<vn-horizontal class="catalogue list" pad-small>
<vn-order-product
ng-repeat="item in items"
item="::item">
</vn-order-product>
<vn-one style="text-align: center" pad-small translate>No results</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>
</vn-vertical>
<vn-auto class="right-block">
<vn-filter order="$ctrl.order"></vn-filter>
</vn-auto>
</vn-horizontal>

View File

@ -0,0 +1,41 @@
import ngModule from '../module';
import './style.scss';
class Controller {
constructor($scope, $stateParams) {
this.$scope = $scope;
this.$stateParams = $stateParams;
}
applyFilter() {
this.$scope.model.filter = this.filter;
this.$scope.model.refresh();
}
set order(value) {
this._order = value;
if (!value) return;
this.filter = {
where: {
id: value.id,
typeFk: 1
}
};
}
get order() {
return this._order;
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnOrderCatalogue', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});

View File

@ -0,0 +1,50 @@
<vn-one>
<vn-horizontal>
<vn-one class="image">
<img
ng-src="//verdnatura.es/vn-image-data/catalog/200x200/{{::$ctrl.item.image}}"
zoom-image="//verdnatura.es/vn-image-data/catalog/1600x900/{{::$ctrl.item.image}}"
on-error-src pointer/>
</vn-one>
<vn-one pad-small class="description ellipsize">
<vn-vertical>
<h2 class="ellipsize" vn-tooltip="{{::$ctrl.item.name}}">
{{::$ctrl.item.name}}
</h2>
<span class="ellipsize" vn-tooltip="{{::$ctrl.item.subName}}">
{{::$ctrl.item.subName}}
</span>
<vn-label-value
label="{{::$ctrl.item.tag5}}"
value="{{::$ctrl.item.value5}}">
</vn-label-value>
<vn-label-value
label="{{::$ctrl.item.tag6}}"
value="{{::$ctrl.item.value6}}">
</vn-label-value>
<vn-label-value
label="{{::$ctrl.item.tag7}}"
value="{{::$ctrl.item.value7}}">
</vn-label-value>
<vn-label-value
label="{{::$ctrl.item.tag8}}"
value="{{::$ctrl.item.value8}}">
</vn-label-value>
<vn-horizontal class="price">
<vn-one>
<span>{{::$ctrl.item.available}}</span>
<span translate>from</span>
<span>{{::$ctrl.item.price | currency: ' €': 2}}</span>
</vn-one>
<vn-auto>
<a href="" vn-tooltip="Add">
<vn-icon icon="add_circle"></vn-icon>
</a>
</vn-auto>
</section>
</vn-vertical>
</vn-one>
</vn-horizontal>
</vn-one>

View File

@ -0,0 +1,11 @@
import ngModule from '../module';
ngModule.component('vnOrderProduct', {
template: require('./product.html'),
bindings: {
item: '<'
},
require: {
index: '^vnOrderCatalogue'
}
});

View File

@ -0,0 +1,111 @@
@import "./colors";
vn-order-catalogue {
@media screen and (max-width: 1920px){
vn-order-product {
width: 25%;
}
}
@media screen and (max-width: 1800px){
vn-order-product {
width: 33.33%
}
}
@media screen and (max-width: 1600px){
vn-order-product {
width: 50%
}
}
@media screen and (max-width: 1280px){
vn-order-product {
width: 100%
}
}
.catalogue.header {
border-color: $lines;
border-bottom: 1px solid rgba($lines, 0.5);
span {
color: $secondary-font-color
}
}
.catalogue.list {
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap
}
vn-order-product {
box-sizing: border-box;
padding: 4px;
& > vn-one {
border: 1px solid rgba($lines, 0.5);
display: block
}
.image {
min-width: 10em;
max-width: 10em;
min-height: 10em;
max-height: 10em;
img {
width: 100%;
height: 100%
}
}
.description {
box-sizing: border-box;
& > vn-vertical {
height: 100%;
& > h2 {
text-transform: uppercase;
font-family: vn-font;
margin: 0 0 0.5em 0;
font-weight: 100;
line-height: 1em;
font-size: 0.9em;
}
& > span {
color: $secondary-font-color;
text-transform: uppercase;
margin-bottom: 0.5em;
font-weight: bold;
font-size: 0.8em
}
& > vn-label-value {
font-size: 0.8em
}
}
}
.price {
align-items: center;
margin-top: auto;
font-size: 0.8em;
& > vn-one span:first-child {
color: $secondary-font-color
}
& > vn-one span:first-child, & > vn-one span:last-child {
font-size: 1.2em
}
vn-icon[icon="add_circle"] {
color: $main-01
}
}
}
}

View File

@ -0,0 +1,10 @@
<vn-horizontal>
<vn-vertical vn-one>
<vn-card pad-medium>
<vn-vertical margin-medium>
<vn-submit ng-click="$ctrl.setFilter()" label="Filter"></vn-submit>
</vn-vertical>
</vn-card>
</vn-vertical>
</vn-horizontal>

View File

@ -0,0 +1,22 @@
import ngModule from '../module';
class Controller {
constructor() {
}
setFilter() {
this.catalogue.applyFilter();
}
}
ngModule.component('vnFilter', {
template: require('./index.html'),
controller: Controller,
require: {
catalogue: '^vnOrderCatalogue'
},
bindings: {
order: '<'
}
});

View File

@ -1,6 +1,9 @@
export * from './module';
import './descriptor';
import './index/';
import './card';
import './descriptor';
import './filter';
import './index/';
import './summary';
import './catalogue';
import './catalogue/product';

View File

@ -18,7 +18,7 @@
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="order in orders" class="clickable"
ui-sref="order.card.summary({id: {{::order.id}}})">
ui-sref="order.card.catalogue({id: {{::order.id}}})">
<vn-td>{{::order.id}}</vn-td>
<vn-td>{{::order.clientFk}}</vn-td>
<vn-td>{{::order.companyFk}}</vn-td>

View File

@ -0,0 +1,4 @@
Catalogue: Catálogo
from: desde
results: resultados
No results: Sin resultados

1040
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
"js-yaml": "^3.10.0",
"material-design-lite": "^1.3.0",
"mg-crud": "^1.1.2",
"npm": "^5.8.0",
"npm": "^5.10.0",
"oclazyload": "^0.6.3",
"require-yaml": "0.0.1",
"validator": "^6.2.1"

View File

@ -11,6 +11,7 @@
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
@ -23,6 +24,7 @@
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
@ -35,6 +37,7 @@
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
@ -47,6 +50,7 @@
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
@ -59,6 +63,7 @@
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
@ -71,6 +76,7 @@
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
}

View File

@ -0,0 +1,41 @@
module.exports = Self => {
Self.remoteMethod('itemFilter', {
description: 'Find all instances of the model matched by filter from the data source.',
accessType: 'READ',
accepts: [
{
arg: 'filter',
type: 'Object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'}
}
],
returns: {
type: ['Object'],
root: true
},
http: {
path: `/itemFilter`,
verb: 'GET'
}
});
Self.itemFilter = async filter => {
let where = filter.where;
let order = await Self.findById(where.id);
let stmt = `CALL vn2008.bionic_from_type(?, ?, ?, ?);
SELECT bi.*, i.* FROM tmp.bionic_item bi
JOIN vn.item i ON i.id = bi.item_id
ORDER BY relevancy DESC, item_id ASC, producer DESC;`;
let [rs, items] = await Self.rawSql(stmt, [
order.landed,
order.address_id,
order.agency_id,
where.typeFk
]);
return items;
};
};

View File

@ -2,4 +2,5 @@ module.exports = Self => {
require('../methods/new')(Self);
//require('../methods/order/getTotalVolume')(Self);
require('../methods/order/getTotal')(Self);
require('../methods/order/itemFilter')(Self);
};