#166 - Item list ordered by name

This commit is contained in:
Juan 2018-04-04 19:59:03 +02:00
parent 04ac260738
commit ded0c6a53a
35 changed files with 177 additions and 63 deletions

View File

@ -0,0 +1,34 @@
<form name="form" ng-submit="$ctrl.submit()">
<vn-card pad-large>
<vn-title>Item barcode</vn-title>
<vn-horizontal ng-repeat="barcode in $ctrl.barcodes track by $index">
<vn-textfield
vn-three
label="Code"
model="barcode.code"
vn-acl="buyer, replenisher">
</vn-textfield>
<vn-one pad-medium-top>
<vn-icon
vn-acl="buyer, replenisher"
pointer
medium-grey
icon="remove_circle_outline"
ng-click="$ctrl.removeBarcode($index)">
</vn-icon>
<vn-icon
vn-acl="buyer, replenisher"
pointer
margin-medium-left
orange
icon="add_circle"
ng-if = "barcode.showAddIcon"
ng-click="$ctrl.addBarcode()"
></vn-icon>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -125,6 +125,6 @@ export default class Controller {
Controller.$inject = ['$state', '$scope', '$http', '$q', '$translate', 'vnApp'];
ngModule.component('vnItemBarcode', {
template: require('./item-barcode.html'),
template: require('./barcode.html'),
controller: Controller
});

View File

@ -1,4 +1,4 @@
import './item-barcode.js';
import './barcode.js';
describe('Item', () => {
describe('Component vnItemBarcode', () => {

View File

@ -31,6 +31,6 @@ class ItemBotanical {
ItemBotanical.$inject = ['$http', '$state'];
ngModule.component('vnItemBotanical', {
template: require('./item-botanical.html'),
template: require('./botanical.html'),
controller: ItemBotanical
});

View File

@ -1,4 +1,4 @@
import './item-botanical.js';
import './botanical.js';
describe('ItemBotanical', () => {
describe('Component vnItemBotanical', () => {

View File

@ -60,6 +60,6 @@ class ItemCard {
ItemCard.$inject = ['$http', '$state', '$timeout'];
ngModule.component('vnItemCard', {
template: require('./item-card.html'),
template: require('./card.html'),
controller: ItemCard
});

View File

@ -1,4 +1,4 @@
import './item-card.js';
import './card.js';
describe('Item', () => {
describe('Component vnItemCard', () => {

View File

@ -18,6 +18,6 @@ class ItemCreate {
ItemCreate.$inject = ['$scope', '$state'];
ngModule.component('vnItemCreate', {
template: require('./item-create.html'),
template: require('./create.html'),
controller: ItemCreate
});

View File

@ -1,4 +1,4 @@
import './item-create.js';
import './create.js';
describe('Item', () => {
describe('Component vnItemCreate', () => {

View File

@ -15,7 +15,7 @@ class ItemData {
ItemData.$inject = ['$scope', '$timeout'];
ngModule.component('vnItemData', {
template: require('./item-data.html'),
template: require('./data.html'),
bindings: {
item: '<'
},

View File

@ -1,7 +1,7 @@
import ngModule from '../module';
ngModule.component('vnItemDescriptor', {
template: require('./item-descriptor.html'),
template: require('./descriptor.html'),
bindings: {
item: '<',
itemTags: '<',

View File

@ -1,22 +1,47 @@
<div pad-large style="min-width: 30em">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield vn-one label="Id" model="$ctrl.filter.id" vn-focus></vn-textfield>
<vn-textfield vn-three label="Description" model="$ctrl.filter.description"></vn-textfield>
<vn-textfield
vn-one
label="Id"
model="$ctrl.filter.id"
vn-focus>
</vn-textfield>
<vn-textfield
vn-three
label="Description"
model="$ctrl.filter.description">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Category" type="number" model="$ctrl.filter.category"></vn-textfield>
<vn-textfield vn-one label="Size" type="number" model="$ctrl.filter.itemSize"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
<vn-autocomplete
vn-one
url="/item/api/ItemTypes"
label="Type"
show-field="name"
value-field="id"
field="$ctrl.filter.typeFk">
</vn-autocomplete>
<vn-autocomplete vn-one
<vn-autocomplete
vn-one
url="/item/api/Producers"
label="Producer"
show-field="name"
value-field="id"
field="$ctrl.filter.producerFk">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
url="/item/api/Origins"
label="Origin"
show-field="name"
value-field="id"
field="$ctrl.filter.originFk">
</vn-autocomplete>
<vn-autocomplete
vn-one
url="/item/api/Inks"
label="Ink"
show-field="name"
@ -25,20 +50,17 @@
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
url="/item/api/Origins"
label="Origin"
show-field="name"
value-field="id"
field="$ctrl.filter.originFk">
</vn-autocomplete>
<vn-autocomplete vn-one
url="/item/api/Producers"
label="Producer"
show-field="name"
value-field="id"
field="$ctrl.filter.producerFk">
</vn-autocomplete>
<vn-textfield
vn-one
label="Category"
model="$ctrl.filter.category">
</vn-textfield>
<vn-textfield
vn-one
label="Size"
type="number"
model="$ctrl.filter.itemSize">
</vn-textfield>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-submit label="Search"></vn-submit>

View File

@ -2,6 +2,6 @@ import ngModule from '../module';
import FilterItemList from '../filter-item-list';
ngModule.component('vnItemHistory', {
template: require('./item-history.html'),
template: require('./history.html'),
controller: FilterItemList
});

View File

@ -3,15 +3,15 @@ export * from './module';
import './filter-item-list';
import './list/list';
import './filter-panel/filter-panel';
import './create/item-create';
import './card/item-card';
import './descriptor/item-descriptor';
import './data/item-data';
import './tags/item-tags';
import './tax/item-tax';
import './history/item-history';
import './niche/item-niche';
import './botanical/item-botanical';
import './barcode/item-barcode';
import './summary/item-summary';
import './create/create';
import './card/card';
import './descriptor/descriptor';
import './data/data';
import './tags/tags';
import './tax/tax';
import './history/history';
import './niche/niche';
import './botanical/botanical';
import './barcode/barcode';
import './summary/summary';

View File

@ -1,5 +1,5 @@
import ngModule from '../module';
import './item-product';
import './product';
import './style.scss';
class ItemList {

View File

@ -18,7 +18,7 @@ class ItemProduct {
}
ngModule.component('vnItemProduct', {
template: require('./item-product.html'),
template: require('./product.html'),
bindings: {
item: '<'
},

View File

@ -0,0 +1,58 @@
<vn-watcher
vn-id="watcher"
data="$ctrl.item"
form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.submit()">
<vn-card pad-large>
<vn-title>Item niches</vn-title>
<vn-horizontal ng-repeat="itemNiche in $ctrl.niches track by $index">
<vn-autocomplete
ng-if="!itemNiche.id"
vn-one
data="$ctrl.warehouses"
show-field="name"
value-field="id"
initial-data="itemNiche.warehouse"
field="itemNiche.warehouseFk"
label="Warehouse"
vn-acl="buyer,replenisher">
</vn-autocomplete>
<vn-textfield
ng-if="itemNiche.id"
vn-one
label="Warehouse"
model="itemNiche.warehouse.name"
disabled="true">
</vn-textfield>
<vn-textfield
vn-two
label="Code"
model="itemNiche.code"
rule="itemNiche.code"
vn-acl="buyer,replenisher">
</vn-textfield>
<vn-one pad-medium-top>
<vn-icon
vn-acl="buyer,replenisher"
pointer
medium-grey
icon="remove_circle_outline"
ng-click="$ctrl.removeNiche($index)">
</vn-icon>
<vn-icon
vn-acl="buyer, replenisher"
pointer
margin-medium-left
orange
icon="add_circle"
ng-if="itemNiche.showAddIcon"
ng-click="$ctrl.addNiche()">
</vn-icon>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -144,6 +144,6 @@ export default class Controller {
Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];
ngModule.component('vnItemNiche', {
template: require('./item-niche.html'),
template: require('./niche.html'),
controller: Controller
});

View File

@ -1,4 +1,4 @@
import './item-niche.js';
import './niche.js';
describe('Item', () => {
describe('Component vnItemNiche', () => {

View File

@ -86,7 +86,7 @@ class ItemSummary {
ItemSummary.$inject = ['$http'];
ngModule.component('vnItemSummary', {
template: require('./item-summary.html'),
template: require('./summary.html'),
controller: ItemSummary,
bindings: {
item: '<'

View File

@ -144,7 +144,7 @@ class ItemTags {
ItemTags.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];
ngModule.component('vnItemTags', {
template: require('./item-tags.html'),
template: require('./tags.html'),
controller: ItemTags,
bindings: {
itemTags: '='

View File

@ -1,4 +1,4 @@
import './item-tags.js';
import './tags.js';
describe('Item', () => {
describe('Component vnItemTags', () => {

View File

@ -38,7 +38,7 @@ export default class Controller {
Controller.$inject = ['$stateParams', '$http'];
ngModule.component('vnItemTax', {
template: require('./item-tax.html'),
template: require('./tax.html'),
controller: Controller,
bindings: {
item: '<'

View File

@ -42,11 +42,11 @@ module.exports = function(Self) {
provinceFk: data.provinceFk,
isEqualizated: data.isEqualizated
};
newClient = await Self.create(client, {transaction});
newClient = await Self.create(client);
await transaction.commit();
return newClient;
} catch (e) {
transaction.rollback();
await transaction.rollback();
throw e;
}
};

View File

@ -2,15 +2,15 @@ module.exports = Self => {
Self.installMethod('filter', filterParams);
function filterParams(params) {
let filters = {
let filter = {
where: {},
skip: (params.page - 1) * params.size,
limit: params.size,
order: params.order || 'relevancy DESC',
order: params.order || 'name, relevancy DESC',
include: {
relation: "itemType",
relation: 'itemType',
scope: {
fields: ["id", "name"]
fields: ['id', 'name']
}
}
};
@ -20,7 +20,7 @@ module.exports = Self => {
delete params.order;
if (params.search) {
filters.where.and = [
filter.where.and = [
{
or: [
{id: params.search},
@ -38,16 +38,16 @@ module.exports = Self => {
Object.keys(params).forEach(
key => {
if (filters.where.and) {
if (filter.where.and) {
let filter = {};
filter[key] = (key === 'description' || key === 'name') ? {regexp: params[key]} : params[key];
filters.where.and.push(filter);
filter.where.and.push(filter);
} else {
filters.where[key] = (key === 'description' || key === 'name') ? {regexp: params[key]} : params[key];
filter.where[key] = (key === 'description' || key === 'name') ? {regexp: params[key]} : params[key];
}
}
);
return filters;
return filter;
}
};