4002-item.itemType #974

Merged
carlosjr merged 10 commits from 4002-item.itemType into dev 2022-05-23 12:31:24 +00:00
23 changed files with 132 additions and 96 deletions
Showing only changes of commit 13a6f1f8c1 - Show all commits

View File

@ -0,0 +1,3 @@
INSERT INTO salix.ACL
vicent marked this conversation as resolved Outdated

you are inserting in the same table using the INSERT INTO twice...

you can wrap both in the same insert ie:

INSERT INTO salix.ACL(model, property, accessType, permission, principalType, principalId)
VALUES
('ItemType', '', 'READ', 'ALLOW', 'ROLE', 'employee'),
('ItemType', '
', 'WRITE', 'ALLOW', 'ROLE', 'buyer');

you are inserting in the same table using the INSERT INTO twice... you can wrap both in the same insert ie: INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), ('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer');
(model, property, accessType, permission, principalType, principalId)
VALUES('ItemType', '*', '*', 'ALLOW', 'ROLE', 'employee');

View File

@ -773,14 +773,19 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code`
(7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'),
(8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit');
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`)
INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
VALUES
(1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0),
(2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0),
(3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0),
(4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1),
(5, 'CON', 'Container', 3, 1, NULL, 35, 1),
(6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0);
('warm', 'Warm', 'Warm'),
('cool', 'Cool', 'Cool');
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`)
VALUES
(1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0, 'cool'),
(2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0, 'cool'),
(3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0, 'cool'),
(4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1, 'warm'),
(5, 'CON', 'Container', 3, 1, NULL, 35, 1, 'warm'),
(6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0, 'warm');
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
VALUES
@ -2310,11 +2315,6 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
VALUES
('warm', 'Warm', 'Warm'),
('cool', 'Cool', 'Cool');
INSERT INTO `vn`.`thermograph`(`id`, `model`)
VALUES
('TMM190901395', 'TEMPMATE'),

View File

@ -6,8 +6,6 @@ class Controller extends Component {
this._role = value;
this.$.summary = null;
if (!value) return;
console.log(value);
this.$http.get(`Roles/${value.id}`)
.then(res => this.$.summary = res.data);
}

View File

@ -22,10 +22,10 @@
"type": "number"
},
"categoryFk": {
vicent marked this conversation as resolved Outdated

it's important to add the relations to any foreign key instead of a siemple field (just the foreign key)

it's important to add the relations to any foreign key instead of a siemple field (just the foreign key)
"type": "boolean"
"type": "number"
},
"temperatureFk": {
"type": "boolean"
"type": "string"
}
},
vicent marked this conversation as resolved Outdated

relation still missing

relation still missing
"relations": {

View File

@ -1,7 +1,7 @@
<vn-watcher
vn-id="watcher"
url="ItemTypes"
data="$ctrl.role"
data="$ctrl.itemType"
form="form">
</vn-watcher>
<form
@ -11,16 +11,40 @@
<vn-card class="vn-pa-lg">
<vn-vertical>
<vn-textfield
label="Name"
ng-model="$ctrl.role.name"
label="Code"
ng-model="$ctrl.itemType.code"
rule
vn-focus>
</vn-textfield>
<vn-textfield
label="Description"
ng-model="$ctrl.role.description"
label="Name"
ng-model="$ctrl.itemType.name"
rule>
</vn-textfield>
<vn-autocomplete
label="Worker"
ng-model="$ctrl.itemType.workerFk"
url="Workers"
show-field="firstName"
value-field="id"
rule>
</vn-autocomplete>
<vn-autocomplete
label="Category"
ng-model="$ctrl.itemType.categoryFk"
url="ItemCategories"
show-field="name"
value-field="id"
rule>
</vn-autocomplete>
<vn-autocomplete
label="Temperature"
ng-model="$ctrl.itemType.temperatureFk"
url="Temperatures"
show-field="name"
value-field="code"
rule>
</vn-autocomplete>
</vn-vertical>
</vn-card>
<vn-button-bar>

View File

@ -7,6 +7,6 @@ ngModule.component('vnItemTypeBasicData', {
template: require('./index.html'),
controller: Controller,
bindings: {
role: '<'
itemType: '<'
}
});

View File

@ -1,5 +1,5 @@
<vn-portal slot="menu">
<vn-item-type-descriptor itemType="$ctrl.itemType"></vn-item-type-descriptor>
<vn-item-type-descriptor item-type="$ctrl.itemType"></vn-item-type-descriptor>
<vn-left-menu source="itemType"></vn-left-menu>
</vn-portal>
<ui-view></ui-view>

View File

@ -4,10 +4,7 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
this.$http.get(`ItemTypes/${this.$params.id}`)
.then(res => {
this.itemType = res.data;
console.log(this.itemType);
});
.then(res => this.itemType = res.data);
}
}

View File

@ -1,25 +1,25 @@
import './index';
describe('component vnRoleCard', () => {
describe('component vnItemTypeCard', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('account'));
beforeEach(ngModule('item'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnRoleCard', {$element: null});
controller = $componentController('vnItemTypeCard', {$element: null});
}));
describe('reload()', () => {
it('should reload the controller data', () => {
controller.$params.id = 1;
$httpBackend.expectGET('Roles/1').respond('foo');
$httpBackend.expectGET('ItemTypes/1').respond('foo');
vicent marked this conversation as resolved Outdated

"foo" doesn't give context, therefore not making code maintenance easier.

"foo" doesn't give context, therefore not making code maintenance easier.
controller.reload();
$httpBackend.flush();
expect(controller.role).toBe('foo');
expect(controller.itemType).toBe('foo');
});
});
});

View File

@ -1,7 +1,7 @@
<vn-watcher
vn-id="watcher"
url="Roles"
data="$ctrl.role"
url="ItemTypes"
data="$ctrl.itemType"
insert-mode="true"
form="form">
</vn-watcher>
@ -12,16 +12,40 @@
<vn-card class="vn-pa-lg">
<vn-vertical>
<vn-textfield
label="Name"
ng-model="$ctrl.role.name"
label="Code"
ng-model="$ctrl.itemType.code"
rule
vn-focus>
</vn-textfield>
<vn-textfield
label="Description"
ng-model="$ctrl.role.description"
label="Name"
ng-model="$ctrl.itemType.name"
rule>
</vn-textfield>
<vn-autocomplete
label="Worker"
ng-model="$ctrl.itemType.workerFk"
url="Workers"
show-field="firstName"
value-field="id"
rule>
</vn-autocomplete>
<vn-autocomplete
label="Category"
ng-model="$ctrl.itemType.categoryFk"
url="ItemCategories"
show-field="name"
value-field="id"
rule>
</vn-autocomplete>
<vn-autocomplete
label="Temperature"
ng-model="$ctrl.itemType.temperatureFk"
url="Temperatures"
show-field="name"
value-field="code"
rule>
</vn-autocomplete>
</vn-vertical>
</vn-card>
<vn-button-bar>
@ -32,7 +56,7 @@
<vn-button
class="cancel"
label="Cancel"
ui-sref="account.role">
ui-sref="item.itemType">
</vn-button>
</vn-button-bar>
</form>

View File

@ -4,7 +4,7 @@ import Section from 'salix/components/section';
export default class Controller extends Section {
onSubmit() {
return this.$.watcher.submit().then(res =>
this.$state.go('account.role.card.basicData', {id: res.data.id})
this.$state.go('item.itemType.card.basicData', {id: res.data.id})
);
}
}

View File

@ -1,7 +1,7 @@
<vn-descriptor-content
module="item"
base-state="item.itemType"
description="$ctrl.itemType.name">
description="$ctrl.itemType.code">
<slot-menu>
<vn-item
ng-click="deleteItemType.show()"
@ -12,6 +12,10 @@
</slot-menu>
<slot-body>
<div class="attributes">
<vn-label-value
label="Code"
value="{{$ctrl.itemType.code}}">
</vn-label-value>
<vn-label-value
label="Name"
value="{{$ctrl.itemType.name}}">

View File

@ -2,10 +2,6 @@ import ngModule from '../../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
$onInit() {
console.log(this.itemType, this.entity);
}
get itemType() {
return this.entity;
}

View File

@ -1,16 +1,16 @@
import './index';
describe('component vnRoleDescriptor', () => {
describe('component vnItemTypeDescriptor', () => {
let controller;
let $httpBackend;
let role = {id: 1, name: 'foo'};
let itemType = {id: 1, name: 'foo'};
beforeEach(ngModule('account'));
beforeEach(ngModule('item'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnRoleDescriptor', {$element: null}, {role});
controller = $componentController('vnItemTypeDescriptor', {$element: null}, {itemType});
}));
describe('onDelete()', () => {
@ -18,11 +18,11 @@ describe('component vnRoleDescriptor', () => {
controller.$state.go = jest.fn();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectDELETE('Roles/1').respond();
$httpBackend.expectDELETE('ItemTypes/1').respond();
controller.onDelete();
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('account.role');
expect(controller.$state.go).toHaveBeenCalledWith('item.itemType');
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});

View File

@ -3,6 +3,5 @@ import './index/';
import './summary';
import './card';
import './descriptor';
import './search-panel';
import './create';
import './basic-data';

View File

@ -33,14 +33,11 @@
</vn-card>
</vn-data-viewer>
<vn-popup vn-id="summary">
<vn-item-type-summary itemType="$ctrl.selectedItemType"></vn-item-type-summary>
<vn-item-type-summary item-type="$ctrl.selectedItemType"></vn-item-type-summary>
</vn-popup>
<a ui-sref="account.role.create"
ui-sref-opts="{inherit: false}"
vn-tooltip="New role"
<a ui-sref="item.itemType.create"
vn-tooltip="New itemType"
vn-bind="+"
vn-acl="it"
vn-acl-action="remove"
fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -4,7 +4,6 @@ import Section from 'salix/components/section';
export default class Controller extends Section {
preview(itemType) {
this.selectedItemType = itemType;
console.log(this.selectedItemType);
this.$.summary.show();
}
}

View File

@ -1 +1,2 @@
Item Type: Familia
New itemType: Nueva familia

View File

@ -1,21 +0,0 @@
<div class="search-panel">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="Code"
ng-model="filter.code">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Name"
ng-model="filter.name">
</vn-textfield>
</vn-horizontal>
<vn-horizontal class="vn-mt-lg">
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -1,7 +0,0 @@
import ngModule from '../../module';
import SearchPanel from 'core/components/searchbar/search-panel';
ngModule.component('vnItemTypePanel', {
template: require('./index.html'),
controller: SearchPanel
});

View File

@ -1,5 +1,7 @@
<vn-card class="summary">
<h5>{{summary.name}}</h5>
<h5>
<span>{{summary.id}} - {{summary.name}} - {{summary.worker.firstName}} {{summary.worker.lastName}}</span>
</h5>
<vn-horizontal class="vn-pa-md">
<vn-one>
<h4 translate>Basic data</h4>
@ -7,13 +9,25 @@
label="Id"
value="{{summary.id}}">
</vn-label-value>
<vn-label-value
label="Code"
value="{{summary.code}}">
</vn-label-value>
<vn-label-value
label="Name"
value="{{summary.name}}">
</vn-label-value>
<vn-label-value
label="Description"
value="{{summary.description}}">
label="Worker"
value="{{summary.worker.firstName}} {{summary.worker.lastName}}">
</vn-label-value>
<vn-label-value
label="Category"
value="{{summary.category.name}}">
</vn-label-value>
<vn-label-value
label="Temperature"
value="{{summary.temperatureFk}}">
</vn-label-value>
</vn-one>
</vn-horizontal>

View File

@ -6,10 +6,15 @@ class Controller extends Component {
this._itemType = value;
this.$.summary = null;
if (!value) return;
console.log(value);
this.$http.get(`ItemTypes/${value.id}`)
.then(res => console.log(res.data));
const filter = {
include: [
{relation: 'worker'},
{relation: 'category'}
]
};
this.$http.get(`ItemTypes/${value.id}`, {filter})
.then(res => this.$.summary = res.data);
}
get itemType() {

View File

@ -21,6 +21,9 @@
{"state": "item.card.diary", "icon": "icon-transaction"},
{"state": "item.card.last-entries", "icon": "icon-regentry"},
{"state": "item.card.log", "icon": "history"}
],
"itemType": [
{"state": "item.itemType.card.basicData", "icon": "settings"}
]
},
"keybindings": [
@ -198,7 +201,7 @@
"component": "vn-item-type-summary",
"description": "Summary",
"params": {
"itemType": "$ctrl.itemType"
"item-type": "$ctrl.itemType"
},
"acl": ["buyer"]
},
@ -208,7 +211,7 @@
"component": "vn-item-type-basic-data",
"description": "Basic data",
"params": {
"itemType": "$ctrl.itemType"
"item-type": "$ctrl.itemType"
},
"acl": ["buyer"]
}