Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7165-fixEmptySheet
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-05-03 09:14:59 +02:00
commit 3b46f67b9d
34 changed files with 9 additions and 698 deletions

View File

@ -179,7 +179,7 @@ BEGIN
LEFT JOIN alertLevel a ON a.id = t.alertLevel;
ELSE
SELECT SUM(`in`) - SUM(`out`) INTO @a
SELECT IFNULL(SUM(IFNULL(`in`, 0)) - SUM(IFNULL(`out`, 0)), 0) INTO @a
FROM tItemDiary
WHERE shipped < vDate;

View File

@ -277,7 +277,7 @@
"Collection does not exist": "La colección no existe",
"Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo",
"Insert a date range": "Inserte un rango de fechas",
"Added observation": "{{user}} añadió esta observacion: {{text}}",
"Added observation": "{{user}} añadió esta observacion: {{text}} {{defaulterId}} ({{{defaulterUrl}}})",
"Comment added to client": "Observación añadida al cliente {{clientFk}}",
"Invalid auth code": "Código de verificación incorrecto",
"Invalid or expired verification code": "Código de verificación incorrecto o expirado",

View File

@ -29,6 +29,7 @@ module.exports = Self => {
const $t = ctx.req.__; // $translate
const myOptions = {};
const userId = ctx.req.accessToken.userId;
const url = await Self.app.models.Url.getUrl();
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -38,7 +39,9 @@ module.exports = Self => {
const body = $t('Added observation', {
user: user.name,
text: observation
text: observation,
defaulterId: defaulter.clientFk,
defaulterUrl: `${url}client/${defaulter.clientFk}/summary`
});
await models.Mail.create({

View File

@ -1,52 +0,0 @@
<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>

View File

@ -1,10 +0,0 @@
import ngModule from '../module';
import Section from 'salix/components/section';
ngModule.vnComponent('vnShelvingBasicData', {
template: require('./index.html'),
controller: Section,
bindings: {
shelving: '<'
}
});

View File

@ -1,8 +0,0 @@
<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>

View File

@ -1,29 +0,0 @@
import ngModule from '../module';
import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
const filter = {
include: [
{relation: 'worker',
scope: {
fields: ['id'],
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
});

View File

@ -1,26 +0,0 @@
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);
});
});

View File

@ -1,51 +0,0 @@
<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>

View File

@ -1,15 +0,0 @@
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
});

View File

@ -1,38 +0,0 @@
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});
});
});
});
});

View File

@ -1,45 +0,0 @@
<vn-descriptor-content
module="shelving"
description="$ctrl.shelving.code"
summary="$ctrl.$.summary">
<slot-menu>
<vn-item
ng-click="deleteShelving.show()"
name="deleteShelving"
translate>
Delete shelving
</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="deleteShelving"
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>

View File

@ -1,26 +0,0 @@
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: '<'
}
});

View File

@ -1,29 +0,0 @@
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();
});
});
});

View File

@ -1,3 +0,0 @@
Delete shelving: Eliminar carro
Shelving will be removed: El carro será eliminado
Shelving removed: Carro eliminado

View File

@ -1,11 +1,3 @@
export * from './module';
import './basic-data';
import './card';
import './create';
import './descriptor';
import './index/';
import './main';
import './search-panel';
import './summary';
import './log';

View File

@ -1,47 +0,0 @@
<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>

View File

@ -1,14 +0,0 @@
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
});

View File

@ -1,39 +0,0 @@
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();
});
});
});

View File

@ -1,2 +0,0 @@
Parking: Parking
Priority: Prioridad

View File

@ -1 +0,0 @@
<vn-log url="ShelvingLogs" origin-id="$ctrl.$params.id"></vn-log>

View File

@ -1,7 +0,0 @@
import ngModule from '../module';
import Section from 'salix/components/section';
ngModule.vnComponent('vnShelvingLog', {
template: require('./index.html'),
controller: Section,
});

View File

@ -1 +0,0 @@
Changed by: Cambiado por

View File

@ -1,19 +0,0 @@
<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>

View File

@ -4,22 +4,10 @@ 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};
}
async $onInit() {
this.$state.go('home');
window.location.href = await this.vnApp.getUrl(`shelving/`);
}
}

View File

@ -1,19 +0,0 @@
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%'}},);
});
});
});

View File

@ -26,42 +26,6 @@
"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"
}
]
}

View File

@ -1,43 +0,0 @@
<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

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

View File

@ -1 +0,0 @@
Search shelvings by code: Busca carros por código

View File

@ -1,51 +0,0 @@
<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>

View File

@ -1,41 +0,0 @@
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: ['id'],
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: '<'
}
});

View File

@ -1,5 +0,0 @@
Code: Código
Parking: Parking
Priority: Prioridad
Worker: Trabajador
Recyclable: Reciclable

View File

@ -1,7 +0,0 @@
@import "variables";
vn-client-summary {
.alert span {
color: $color-alert
}
}