feat: added itemShelving
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-05-20 09:17:18 +02:00
parent bf8e7eed57
commit c5683ab880
30 changed files with 656 additions and 11 deletions

View File

@ -0,0 +1,2 @@
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Parking','*','*','ALLOW','ROLE','employee')

View File

@ -0,0 +1,2 @@
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Shelving','*','*','ALLOW','ROLE','employee')

View File

@ -147,14 +147,29 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES
('1', '700', '01', '1', '700-01', '70001'),
('2', '700', '02', '2', '700-02', '70002');
('1', 700, '01', 1, '700-01', 70001),
('2', 700, '02', 2, '700-02', 70002),
('3', 100, '01', 1, '100-01', 1),
(32397, 100, '02', 1, 'A-47-1', 1165),
(34831, 200, '01', 1, 'K-26-2', 20220),
(34965, 200, '02', 2, 'L-08-4', 21800),
(39096, 200, '03', 2, 'LR-02-3', 99999);
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`)
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`)
VALUES
('GVC', 1, 0, 1, 0, 1106),
('HEJ', 2, 0, 1, 0, 1106),
('UXN', 1, 0, 1, 0, 1106);
('AA6', 34965, 1, 0, NULL, 0),
('AA7', 34965, 1, 0, NULL, 0),
('AA8', 34965, 1, 0, NULL, 0),
('AA9', NULL, 1, 0, NULL, 0),
('AAA', NULL, 0, 0, 1109, 1),
('AAB', NULL, 0, 0, 1109, 1),
('AAC', NULL, 1, 99, 1109, 1),
('AAD', NULL, 0, 0, 1109, 1),
('AAE', 39096, 1, 0, 1109, 1),
('AAF', 34831, 1, 0, 1109, 1),
('GVC', 1, 0, 1, 1106, 1),
('HEJ', 2, 0, 1, 1106, 1),
('UXN', 1, 0, 1, 1106, 1);
INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`)
VALUES
@ -1120,10 +1135,6 @@ INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`)
(2, 2, 1),
(3, 3, 2);
INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES
('100', '01', 1, '100-01', 1);
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `level`)
VALUES
(1, 1, 1);

View File

@ -86,6 +86,9 @@
"ClientSample": {
"dataSource": "vn"
},
"Parking": {
"dataSource": "vn"
},
"Sms": {
"dataSource": "vn"
},
@ -98,6 +101,9 @@
"SageTransactionType": {
"dataSource": "vn"
},
"Shelving": {
"dataSource": "vn"
},
"TpvError": {
"dataSource": "vn"
},

View File

@ -0,0 +1,33 @@
{
"name": "Parking",
"base": "VnModel",
"options": {
"mysql": {
"table": "parking"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"column": {
"type": "string",
"required": true
},
"row": {
"type": "string",
"required": true
},
"sectorFk": {
"type": "number"
},
"code": {
"type": "string"
},
"pickingOrder": {
"type": "number"
}
}
}

View File

@ -0,0 +1,45 @@
{
"name": "Shelving",
"base": "VnModel",
"options": {
"mysql": {
"table": "shelving"
}
},
"properties": {
"code": {
"type": "string",
"id": true,
"description": "Identifier"
},
"parkingFk": {
"type": "number",
"required": true
},
"isPrinted": {
"type": "boolean",
"required": true
},
"priority": {
"type": "number"
},
"userFk": {
"type": "number"
},
"isRecyclable": {
"type": "boolean"
}
},
"relations": {
"parking": {
"type": "belongsTo",
"model": "Parking",
"foreignKey": "parkingFk"
},
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "userFk"
}
}
}

View File

@ -47,3 +47,4 @@ import './consumption-search-panel';
import './defaulter';
import './notification';
import './unpaid';
import './shelving';

View File

@ -8,7 +8,8 @@
"main": [
{"state": "client.index", "icon": "person"},
{"state": "client.notification", "icon": "campaign"},
{"state": "client.defaulter", "icon": "icon-defaulter"}
{"state": "client.defaulter", "icon": "icon-defaulter"},
{"state": "client.shelving", "icon": "contact_support"}
],
"card": [
{"state": "client.card.basicData", "icon": "settings"},
@ -36,6 +37,9 @@
{"state": "client.card.unpaid", "icon": "icon-defaulter"}
]
}
],
"shelving": [
{"state": "client.shelving.card.basicData", "icon": "settings"}
]
},
"keybindings": [
@ -381,6 +385,43 @@
"component": "vn-client-unpaid",
"acl": ["administrative"],
"description": "Unpaid"
},
{
"url": "/shelving?q",
"state": "client.shelving",
"component": "vn-shelving",
"description": "Shelvings"
},
{
"url": "/create",
"state": "client.shelving.create",
"component": "vn-shelving-create",
"description": "New shelving"
},
{
"url": "/:id",
"state": "client.shelving.card",
"component": "vn-shelving-card",
"abstract": true,
"description": "Detail"
},
{
"url": "/summary",
"state": "client.shelving.card.summary",
"component": "vn-shelving-summary",
"description": "Summary",
"params": {
"shelving": "$ctrl.shelving"
}
},
{
"url": "/basic-data",
"state": "client.shelving.card.basicData",
"component": "vn-shelving-basic-data",
"description": "Basic data",
"params": {
"shelving": "$ctrl.shelving"
}
}
]
}

View File

@ -0,0 +1,55 @@
<vn-watcher
vn-id="watcher"
url="Shelvings"
data="$ctrl.shelving"
id-field="code"
form="form">
</vn-watcher>
<form
name="form"
ng-submit="watcher.submit()"
class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-vertical>
<vn-horizontal>
<vn-textfield
label="Code"
ng-model="$ctrl.shelving.code"
rule
vn-focus>
</vn-textfield>
<vn-autocomplete
vn-one
url="Parkings"
label="Parking"
show-field="code"
value-field="id"
ng-model="$ctrl.shelving.parkingFk">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
label="Priority"
ng-model="$ctrl.shelving.priority"
rule>
</vn-textfield>
<vn-check
label="Recyclable"
ng-model="$ctrl.shelving.isRecyclable">
</vn-check>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
label="Save">
</vn-submit>
<vn-button
class="cancel"
label="Undo changes"
disabled="!watcher.dataChanged()"
ng-click="watcher.loadOriginalData()">
</vn-button>
</vn-button-bar>
</form>

View File

@ -0,0 +1,12 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
export default class Controller extends Section {}
ngModule.component('vnShelvingBasicData', {
template: require('./index.html'),
controller: Controller,
bindings: {
shelving: '<'
}
});

View File

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

View File

@ -0,0 +1,20 @@
import ngModule from '../../module';
import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
const filter = {
include: [
{relation: 'worker'},
{relation: 'parking'}
]
};
this.$http.get(`Shelvings/${this.$params.id}`, {filter})
.then(res => this.shelving = res.data);
}
}
ngModule.vnComponent('vnShelvingCard', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,25 @@
import './index';
describe('component vnRoleCard', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('account'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnRoleCard', {$element: null});
}));
describe('reload()', () => {
it('should reload the controller data', () => {
controller.$params.id = 1;
$httpBackend.expectGET('Roles/1').respond('foo');
controller.reload();
$httpBackend.flush();
expect(controller.role).toBe('foo');
});
});
});

View File

@ -0,0 +1,38 @@
<vn-watcher
vn-id="watcher"
url="Shelving"
data="$ctrl.shelving"
insert-mode="true"
form="form">
</vn-watcher>
<form
name="form"
vn-http-submit="$ctrl.onSubmit()"
class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-vertical>
<vn-textfield
label="Name"
ng-model="$ctrl.shelving.code"
rule
vn-focus>
</vn-textfield>
<vn-textfield
label="Description"
ng-model="$ctrl.shelving.description"
rule>
</vn-textfield>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
label="Create">
</vn-submit>
<vn-button
class="cancel"
label="Cancel"
ui-sref="client.shelving">
</vn-button>
</vn-button-bar>
</form>

View File

@ -0,0 +1,15 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
onSubmit() {
return this.$.watcher.submit().then(res =>
this.$state.go('client.shelving.card.basicData', {id: res.data.id})
);
}
}
ngModule.component('vnShelvingCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,42 @@
<vn-descriptor-content
module="client"
base-state="client.shelving"
description="$ctrl.shelving.code">
<slot-menu>
<vn-item
ng-click="deleteShelving.show()"
name="deleteShelving"
translate>
Delete
</vn-item>
</slot-menu>
<slot-body>
<div class="attributes">
<vn-label-value
label="Code"
value="{{$ctrl.shelving.code}}">
</vn-label-value>
<vn-label-value
label="Parking"
value="{{$ctrl.shelving.parking.code}}">
</vn-label-value>
<vn-label-value
label="Worker">
<span
ng-click="workerDescriptor.show($event, $ctrl.shelving.userFk)"
class="link">
{{::$ctrl.shelving.worker.firstName}}
</span>
</vn-label-value>
</div>
</slot-body>
</vn-descriptor-content>
<vn-confirm
vn-id="delete-shelving"
on-accept="$ctrl.onDelete()"
question="Are you sure you want to continue?"
message="Shelving will be removed">
</vn-confirm>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>

View File

@ -0,0 +1,26 @@
import ngModule from '../../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
get shelving() {
return this.entity;
}
set shelving(value) {
this.entity = value;
}
onDelete() {
return this.$http.delete(`Shelvings/${this.shelving.code}`)
.then(() => this.$state.go('client.shelving'))
.then(() => this.vnApp.showSuccess(this.$t('Shelving removed')));
}
}
ngModule.component('vnShelvingDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
shelving: '<'
}
});

View File

@ -0,0 +1,29 @@
import './index';
describe('component vnRoleDescriptor', () => {
let controller;
let $httpBackend;
let role = {id: 1, name: 'foo'};
beforeEach(ngModule('account'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnRoleDescriptor', {$element: null}, {role});
}));
describe('onDelete()', () => {
it('should delete entity and go to index', () => {
controller.$state.go = jest.fn();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectDELETE('Roles/1').respond();
controller.onDelete();
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('account.role');
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
});

View File

@ -0,0 +1,2 @@
Role will be removed: El rol va a ser eliminado
Role removed: Rol eliminado

View File

@ -0,0 +1,8 @@
import './main';
import './index/';
import './summary';
import './card';
import './descriptor';
import './search-panel';
import './create';
import './basic-data';

View File

@ -0,0 +1,43 @@
<vn-auto-search
model="model">
</vn-auto-search>
<vn-data-viewer
model="model"
class="vn-w-sm">
<vn-card>
<div class="vn-list separated">
<a
ng-repeat="shelving in model.data track by shelving.code"
ui-sref="client.shelving.card.summary(::{id: shelving.code})"
ui-sref-opts="{inherit: false}"
translate-attr="{title: 'View shelving'}"
class="vn-item search-result">
<vn-item-section>
<h6>{{::shelving.code}}</h6>
<div>{{::shelving.parking.code}}</div>
<div>{{::shelving.priority}}</div>
</vn-item-section>
<vn-item-section side>
<vn-icon-button
vn-click-stop="$ctrl.preview(shelving)"
vn-tooltip="Preview"
icon="preview">
</vn-icon-button>
</vn-item-section>
</a>
</div>
</vn-card>
</vn-data-viewer>
<vn-popup vn-id="summary">
<vn-shelving-summary shelving="$ctrl.selectedShelving"></vn-shelving-summary>
</vn-popup>
<a ui-sref="client.shelving.create"
ui-sref-opts="{inherit: false}"
vn-tooltip="New shelving"
vn-bind="+"
vn-acl="it"
vn-acl-action="remove"
fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -0,0 +1,14 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
preview(shelving) {
this.selectedShelving = shelving;
this.$.summary.show();
}
}
ngModule.component('vnShelvingIndex', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,2 @@
New role: Nuevo rol
View role: Ver rol

View File

@ -0,0 +1 @@
Subroles: Subroles

View File

@ -0,0 +1,18 @@
<vn-crud-model
vn-id="model"
url="Shelvings"
filter="$ctrl.filter"
limit="20">
</vn-crud-model>
<vn-portal slot="topbar">
<vn-searchbar
info="Search shelving by id or name"
panel="vn-shelving-search-panel"
model="model"
expr-builder="$ctrl.exprBuilder(param, value)"
base-state="client.shelving">
</vn-searchbar>
</vn-portal>
<ui-view>
<vn-shelving-index></vn-shelving-index>
</ui-view>

View File

@ -0,0 +1,29 @@
import ngModule from '../../module';
import ModuleMain from 'salix/components/module-main';
export default class Shelving extends ModuleMain {
constructor($element, $) {
super($element, $);
this.filter = {
include: [
{relation: 'parking'}
],
};
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return {code: {like: `%${value}%`}};
case 'parkingFk':
case 'userFk':
case 'isRecyclable':
return {[param]: value};
}
}
}
ngModule.vnComponent('vnShelving', {
controller: Shelving,
template: require('./index.html')
});

View File

@ -0,0 +1,43 @@
<div class="search-panel">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="General search"
ng-model="filter.search"
info="Search shelvings by code"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
url="Parkings"
label="Parking"
show-field="code"
value-field="id"
ng-model="filter.parkingFk">
</vn-autocomplete>
<vn-autocomplete
vn-one
url="Workers"
label="Worker"
search-function="{or: [{id: $search}, {firstName: {like: $search}}]}"
show-field="firstName"
value-field="id"
ng-model="filter.userFk">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-check
vn-one
label="Recyclable"
ng-model="filter.isRecyclable"
triple-state="true">
</vn-check>
</vn-horizontal>
<vn-horizontal class="vn-mt-lg">
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

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

View File

@ -0,0 +1,38 @@
<vn-card class="summary">
<h5>
<span>{{summary.code}}</span>
</h5>
<vn-horizontal class="vn-pa-md">
<vn-one>
<h4 translate>Basic data</h4>
<vn-label-value
label="Code"
value="{{summary.code}}">
</vn-label-value>
<vn-label-value
label="Parking"
value="{{summary.parking.code}}">
</vn-label-value>
<vn-label-value
label="Priority"
value="{{summary.priority}}">
</vn-label-value>
<vn-label-value
label="Worker">
<span
ng-click="workerDescriptor.show($event, summary.userFk)"
class="link">
{{::summary.worker.firstName}}
</span>
</vn-label-value>
<vn-check
label="Recyclable"
ng-model="summary.isRecyclable"
disabled="true">
</vn-check>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>

View File

@ -0,0 +1,32 @@
import ngModule from '../../module';
import Component from 'core/lib/component';
class Controller extends Component {
set shelving(value) {
console.log(value);
this._shelving = value;
this.$.summary = null;
if (!value) return;
const filter = {
include: [
{relation: 'worker'},
{relation: 'parking'}
]
};
this.$http.get(`Shelvings/${value.code}`, {filter})
.then(res => this.$.summary = res.data);
}
get shelving() {
return this._shelving;
}
}
ngModule.component('vnShelvingSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
shelving: '<'
}
});