Merge pull request '3069-client.shelving' (#1029) from 3069-client.shelving into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1029 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
cabc30ef87
|
@ -18,6 +18,7 @@
|
|||
"modules/supplier/front/**/*",
|
||||
"modules/ticket/front/**/*",
|
||||
"modules/travel/front/**/*",
|
||||
"modules/shelving/front/**/*",
|
||||
"modules/worker/front/**/*",
|
||||
"modules/zone/front/**/*"
|
||||
]
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES
|
||||
('ShelvingLog','*','READ','ALLOW','ROLE','employee');
|
|
@ -0,0 +1,18 @@
|
|||
ALTER TABLE `vn`.`itemShelving` DROP FOREIGN KEY itemShelving_fk2;
|
||||
ALTER TABLE `vn`.`shelvingLog` DROP FOREIGN KEY shelvingLog_FK_ibfk_1;
|
||||
ALTER TABLE `vn`.`smartTag` DROP FOREIGN KEY smartTag_shelving_fk;
|
||||
ALTER TABLE `vn`.`workerShelving` DROP FOREIGN KEY workerShelving_shelving_fk;
|
||||
|
||||
ALTER TABLE `vn`.`shelving` DROP PRIMARY KEY;
|
||||
ALTER TABLE `vn`.`shelving` ADD id INT auto_increment PRIMARY KEY NULL;
|
||||
ALTER TABLE `vn`.`shelving` CHANGE id id int(11) auto_increment NOT NULL FIRST;
|
||||
ALTER TABLE `vn`.`shelving` ADD CONSTRAINT shelving_UN UNIQUE KEY (code);
|
||||
|
||||
ALTER TABLE `vn`.`itemShelving` ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`shelvingLog` ADD CONSTRAINT shelvingLog_FK_ibfk_1 FOREIGN KEY (originFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`smartTag` ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`workerShelving` ADD CONSTRAINT workerShelving_FK_1 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.shelvingLog DROP FOREIGN KEY shelvingLog_FK_ibfk_1;
|
||||
ALTER TABLE vn.shelvingLog MODIFY COLUMN originFk INT NOT NULL;
|
||||
ALTER TABLE vn.shelvingLog ADD CONSTRAINT shelvingLog_FK FOREIGN KEY (originFk) REFERENCES vn.shelving(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Parking','*','*','ALLOW','ROLE','employee')
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Shelving','*','*','ALLOW','ROLE','employee')
|
|
@ -155,14 +155,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`, `daysInFuture`)
|
||||
VALUES
|
||||
|
@ -1137,6 +1152,9 @@ INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
|
|||
(3, 2, NULL),
|
||||
(23, 1, NULL);
|
||||
|
||||
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `level`)
|
||||
VALUES
|
||||
(1, 1, 1);
|
||||
INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
||||
VALUES
|
||||
('100', '01', 1, '100-01', 1);
|
||||
|
|
|
@ -21,6 +21,7 @@ export default function moduleImport(moduleName) {
|
|||
case 'entry' : return import('entry/front');
|
||||
case 'account' : return import('account/front');
|
||||
case 'supplier' : return import('supplier/front');
|
||||
case 'shelving' : return import('shelving/front');
|
||||
case 'monitor' : return import('monitor/front');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import './modules/route/front/module.js';
|
|||
import './modules/ticket/front/module.js';
|
||||
import './modules/travel/front/module.js';
|
||||
import './modules/worker/front/module.js';
|
||||
import './modules/shelving/front/module.js';
|
||||
|
||||
core.run(vnInterceptor => {
|
||||
vnInterceptor.setApiPath(null);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
{"state": "client.card.unpaid", "icon": "icon-defaulter"}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
{"key": "c", "state": "client.index"}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getSummary', {
|
||||
description: 'Returns the shelving summary',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'code',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The shelving code',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:code/getSummary`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
Self.getSummary = async code => {
|
||||
let filter = {
|
||||
where: {code: code},
|
||||
fields: [
|
||||
'code',
|
||||
'parkingFk',
|
||||
'priority',
|
||||
'userFk',
|
||||
'isRecyclable'
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'parking'
|
||||
},
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['id', 'userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['id', 'nickname']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return Self.app.models.Shelving.findOne(filter);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"Parking": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Shelving": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ShelvingLog": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "ShelvingLog",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "shelvingLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/shelving/getSummary')(Self);
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "Shelving",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "ShelvingLog",
|
||||
"showField": "id"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "shelving"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"code": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"parkingFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isPrinted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"priority": {
|
||||
"type": "number"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isRecyclable": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"parking": {
|
||||
"type": "belongsTo",
|
||||
"model": "Parking",
|
||||
"foreignKey": "parkingFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<mg-ajax path="Shelvings/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.shelving"
|
||||
form="form"
|
||||
save="patch">
|
||||
</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-input-number vn-one
|
||||
label="Priority"
|
||||
ng-model="$ctrl.shelving.priority"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<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>
|
|
@ -0,0 +1,10 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
ngModule.vnComponent('vnShelvingBasicData', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
bindings: {
|
||||
shelving: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-shelving-descriptor
|
||||
shelving="$ctrl.shelving"
|
||||
on-change="$ctrl.reload()">
|
||||
</vn-shelving-descriptor>
|
||||
<vn-left-menu source="card"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -0,0 +1,29 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleCard from 'salix/components/module-card';
|
||||
|
||||
class Controller extends ModuleCard {
|
||||
reload() {
|
||||
const filter = {
|
||||
include: [
|
||||
{relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
}
|
||||
}
|
||||
}},
|
||||
{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
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
import './index';
|
||||
|
||||
describe('component vnShelvingCard', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
const data = {id: 1, code: 'AAA'};
|
||||
|
||||
beforeEach(ngModule('shelving'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
|
||||
let $element = angular.element('<div></div>');
|
||||
controller = $componentController('vnShelvingCard', {$element});
|
||||
|
||||
$stateParams.id = data.id;
|
||||
$httpBackend.whenRoute('GET', 'Shelvings/:id').respond(data);
|
||||
}));
|
||||
|
||||
it('should reload the controller data', () => {
|
||||
controller.reload();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.shelving).toEqual(data);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,51 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="Shelvings"
|
||||
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-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-input-number vn-one
|
||||
label="Priority"
|
||||
ng-model="$ctrl.shelving.priority"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<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="Create">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Cancel"
|
||||
ui-sref="shelving.index">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -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('shelving.card.basicData', {id: res.data.id})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnShelvingCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,38 @@
|
|||
import './index';
|
||||
|
||||
describe('Shelving', () => {
|
||||
describe('Component vnShelvingCreate', () => {
|
||||
let $scope;
|
||||
let $state;
|
||||
let controller;
|
||||
|
||||
beforeEach(ngModule('shelving'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$scope.watcher = {
|
||||
submit: () => {
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 1}});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
const $element = angular.element('<vn-shelving-create></vn-shelving-create>');
|
||||
controller = $componentController('vnShelvingCreate', {$element, $scope});
|
||||
controller.$params = {};
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it(`should redirect to basic data by calling the $state.go function`, () => {
|
||||
jest.spyOn(controller.$state, 'go');
|
||||
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,45 @@
|
|||
<vn-descriptor-content
|
||||
module="shelving"
|
||||
description="$ctrl.shelving.code"
|
||||
summary="$ctrl.$.summary">
|
||||
<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.user.nickname}}
|
||||
</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-popup vn-id="summary">
|
||||
<vn-shelving-summary shelving="$ctrl.shelving"></vn-shelving-summary>
|
||||
</vn-popup>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -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.id}`)
|
||||
.then(() => this.$state.go('shelving.index'))
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Shelving removed')));
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnShelvingDescriptor', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
shelving: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,29 @@
|
|||
import './index.js';
|
||||
|
||||
describe('component vnShelvingDescriptor', () => {
|
||||
let $httpBackend;
|
||||
let controller;
|
||||
|
||||
const shelving = {id: 1, code: 'AA6'};
|
||||
|
||||
beforeEach(ngModule('shelving'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnShelvingDescriptor', {$element: null}, {shelving});
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
}));
|
||||
|
||||
describe('onDelete()', () => {
|
||||
it('should delete entity and go to index', () => {
|
||||
controller.$state.go = jest.fn();
|
||||
|
||||
$httpBackend.expectDELETE('Shelvings/1').respond();
|
||||
controller.onDelete();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('shelving.index');
|
||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,11 @@
|
|||
export * from './module';
|
||||
|
||||
import './basic-data';
|
||||
import './card';
|
||||
import './create';
|
||||
import './descriptor';
|
||||
import './index/';
|
||||
import './main';
|
||||
import './search-panel';
|
||||
import './summary';
|
||||
import './log';
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
<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.id"
|
||||
ui-sref="shelving.card.summary(::{id: shelving.id})"
|
||||
translate-attr="{title: 'View shelving'}"
|
||||
class="vn-item search-result">
|
||||
<vn-item-section>
|
||||
<h6>{{::shelving.code}}</h6>
|
||||
<vn-label-value label="Parking"
|
||||
value="{{::shelving.parking.code}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Priority"
|
||||
value="{{::shelving.priority}}">
|
||||
</vn-label-value>
|
||||
</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="shelving.create"
|
||||
vn-tooltip="New shelving"
|
||||
vn-bind="+"
|
||||
vn-acl-action="remove"
|
||||
fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
|
@ -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.vnComponent('vnShelvingIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
import './index.js';
|
||||
describe('Component vnShelvingIndex', () => {
|
||||
let controller;
|
||||
let $window;
|
||||
let shelvings = [{
|
||||
id: 1,
|
||||
code: 'AAA'
|
||||
}, {
|
||||
id: 2,
|
||||
code: 'AA1'
|
||||
}, {
|
||||
id: 3,
|
||||
code: 'AA2'
|
||||
}];
|
||||
|
||||
beforeEach(ngModule('shelving'));
|
||||
|
||||
beforeEach(inject(($componentController, _$window_) => {
|
||||
$window = _$window_;
|
||||
const $element = angular.element('<vn-shelving-index></vn-shelving-index>');
|
||||
controller = $componentController('vnShelvingIndex', {$element});
|
||||
}));
|
||||
|
||||
describe('preview()', () => {
|
||||
it('should show the dialog summary', () => {
|
||||
controller.$.summary = {show: () => {}};
|
||||
jest.spyOn(controller.$.summary, 'show');
|
||||
|
||||
let event = new MouseEvent('click', {
|
||||
view: $window,
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
controller.preview(event, shelvings[0]);
|
||||
|
||||
expect(controller.$.summary.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
Parking: Parking
|
||||
Priority: Prioridad
|
|
@ -0,0 +1 @@
|
|||
<vn-log url="ShelvingLogs" origin-id="$ctrl.$params.id"></vn-log>
|
|
@ -0,0 +1,7 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
ngModule.vnComponent('vnShelvingLog', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Changed by: Cambiado por
|
|
@ -0,0 +1,19 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Shelvings"
|
||||
filter="$ctrl.filter"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
panel="vn-shelving-search-panel"
|
||||
info="Search shelving by code, parking or worker"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
<vn-left-menu></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -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')
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
import './index';
|
||||
|
||||
describe('component vnShelving', () => {
|
||||
let controller;
|
||||
|
||||
beforeEach(ngModule('shelving'));
|
||||
|
||||
beforeEach(inject($componentController => {
|
||||
controller = $componentController('vnShelving', {$element: null});
|
||||
}));
|
||||
|
||||
describe('exprBuilder()', () => {
|
||||
it('should search by code', () => {
|
||||
let expr = controller.exprBuilder('search', 'UXN');
|
||||
|
||||
expect(expr).toEqual({code: {like: '%UXN%'}},);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Search shelving by code, parking or worker: Busca carros por código, parking o trabajador
|
|
@ -0,0 +1,3 @@
|
|||
import {ng} from 'core/vendor';
|
||||
|
||||
export default ng.module('shelving', ['salix']);
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"module": "shelving",
|
||||
"name": "Shelvings",
|
||||
"icon" : "contact_support",
|
||||
"dependencies": ["worker"],
|
||||
"validations" : true,
|
||||
"menus": {
|
||||
"main": [
|
||||
{"state": "shelving.index", "icon": "contact_support"}
|
||||
],
|
||||
"card": [
|
||||
{"state": "shelving.card.basicData", "icon": "settings"},
|
||||
{"state": "shelving.card.log", "icon": "history"}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
{"key": "s", "state": "shelving.index"}
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"url": "/shelving",
|
||||
"state": "shelving",
|
||||
"abstract": true,
|
||||
"component": "vn-shelving",
|
||||
"description": "Shelvings"
|
||||
},
|
||||
{
|
||||
"url": "/index?q",
|
||||
"state": "shelving.index",
|
||||
"component": "vn-shelving-index",
|
||||
"description": "Shelvings"
|
||||
},
|
||||
{
|
||||
"url": "/create",
|
||||
"state": "shelving.create",
|
||||
"component": "vn-shelving-create",
|
||||
"description": "New shelving"
|
||||
},
|
||||
{
|
||||
"url": "/:id",
|
||||
"state": "shelving.card",
|
||||
"abstract": true,
|
||||
"component": "vn-shelving-card"
|
||||
},
|
||||
{
|
||||
"url": "/summary",
|
||||
"state": "shelving.card.summary",
|
||||
"component": "vn-shelving-summary",
|
||||
"description": "Summary",
|
||||
"params": {
|
||||
"shelving": "$ctrl.shelving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/basic-data",
|
||||
"state": "shelving.card.basicData",
|
||||
"component": "vn-shelving-basic-data",
|
||||
"description": "Basic data",
|
||||
"params": {
|
||||
"shelving": "$ctrl.shelving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url" : "/log",
|
||||
"state": "shelving.card.log",
|
||||
"component": "vn-shelving-log",
|
||||
"description": "Log"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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>
|
|
@ -0,0 +1,7 @@
|
|||
import ngModule from '../module';
|
||||
import SearchPanel from 'core/components/searchbar/search-panel';
|
||||
|
||||
ngModule.vnComponent('vnShelvingSearchPanel', {
|
||||
template: require('./index.html'),
|
||||
controller: SearchPanel
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Search shelvings by code: Busca carros por código
|
|
@ -0,0 +1,51 @@
|
|||
<vn-card class="summary">
|
||||
<h5>
|
||||
<a ng-if="::$ctrl.summary.code"
|
||||
vn-tooltip="Go to the shelving"
|
||||
ui-sref="shelving.card.summary({id: {{::$ctrl.summary.code}}})"
|
||||
name="goToSummary">
|
||||
<vn-icon-button icon="launch"></vn-icon-button>
|
||||
</a>
|
||||
<span>{{::$ctrl.summary.code}}</span>
|
||||
</h5>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<h4>
|
||||
<a
|
||||
ui-sref="shelving.card.basicData({id: $ctrl.summary.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Basic data</span>
|
||||
</a>
|
||||
</h4>
|
||||
<vn-vertical>
|
||||
<vn-label-value
|
||||
label="Code"
|
||||
value="{{::$ctrl.summary.code}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Parking"
|
||||
value="{{::$ctrl.summary.parking.code}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Priority"
|
||||
value="{{::$ctrl.summary.priority}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Worker">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.worker.user.id)"
|
||||
class="link">
|
||||
{{$ctrl.summary.worker.user.nickname}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-check
|
||||
label="Recyclable"
|
||||
ng-model="$ctrl.summary.isRecyclable"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-vertical>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -0,0 +1,41 @@
|
|||
import ngModule from '../module';
|
||||
import Summary from 'salix/components/summary';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Summary {
|
||||
set shelving(value) {
|
||||
this._shelving = value;
|
||||
this.summary = null;
|
||||
if (!value) return;
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
}
|
||||
}
|
||||
}},
|
||||
{relation: 'parking'}
|
||||
]
|
||||
};
|
||||
this.$http.get(`Shelvings/${value.id}`, {filter})
|
||||
.then(res => this.summary = res.data);
|
||||
}
|
||||
|
||||
get shelving() {
|
||||
return this._shelving;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnShelvingSummary', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
shelving: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
Code: Código
|
||||
Parking: Parking
|
||||
Priority: Prioridad
|
||||
Worker: Trabajador
|
||||
Recyclable: Reciclable
|
|
@ -0,0 +1,7 @@
|
|||
@import "variables";
|
||||
|
||||
vn-client-summary {
|
||||
.alert span {
|
||||
color: $color-alert
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue