Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-05-22 11:59:14 +02:00
commit 4c8aa7ff6e
24 changed files with 275 additions and 114 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE `bi`.`tarifa_componentes`
ADD COLUMN `code` VARCHAR(45) NULL DEFAULT NULL AFTER `is_renewable`;

View File

@ -0,0 +1,16 @@
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`componentRate` AS
SELECT
`t`.`Id_Componente` AS `id`,
`t`.`Componente` AS `name`,
`t`.`tarifa_componentes_series_id` AS `componentTypeRate`,
`t`.`tarifa_class` AS `classRate`,
`t`.`tax` AS `tax`,
`t`.`is_renewable` AS `isRenewable`,
`t`.`code` AS `code`
FROM
`bi`.`tarifa_componentes` `t`;

View File

@ -1426,5 +1426,5 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`,`timed`,`manual`)
VALUES VALUES
(106, CONCAT(CURDATE(), ' 07:00'), TRUE), (106, CONCAT(CURDATE(), ' 07:00'), TRUE),
(106, CONCAT(CURDATE(), ' 10:00'), TRUE), (106, CONCAT(CURDATE(), ' 10:00'), TRUE),
(106, CONCAT(CURDATE(), ' 10:10'), TRUE), (106, CONCAT(CURDATE(), ' 10:20'), TRUE),
(106, CONCAT(CURDATE(), ' 15:00'), TRUE); (106, CONCAT(CURDATE(), ' 15:00'), TRUE);

View File

@ -311,9 +311,10 @@ export default {
searchButton: 'vn-ticket-index vn-searchbar vn-icon[icon="search"]', searchButton: 'vn-ticket-index vn-searchbar vn-icon[icon="search"]',
moreMenu: 'vn-ticket-index vn-icon-menu[vn-id="more-button"] > div > vn-icon', moreMenu: 'vn-ticket-index vn-icon-menu[vn-id="more-button"] > div > vn-icon',
moreMenuTurns: 'vn-ticket-index vn-icon-menu vn-drop-down > vn-popover li:nth-child(2)', moreMenuTurns: 'vn-ticket-index vn-icon-menu vn-drop-down > vn-popover li:nth-child(2)',
sixthWeeklyTicketTurn: 'vn-ticket-weekly > form > div > vn-card > div > vn-table > div > vn-tbody > vn-tr:nth-child(6) > vn-td:nth-child(3) > vn-autocomplete > div > div > input', sixthWeeklyTicketTurn: 'vn-ticket-weekly vn-table vn-tr:nth-child(6) vn-autocomplete[field="weekly.weekDay"] input',
weeklyTicket: 'vn-ticket-weekly vn-table > div > vn-tbody > vn-tr', weeklyTicket: 'vn-ticket-weekly vn-table > div > vn-tbody > vn-tr',
sixthWeeklyTicketDeleteIcon: 'vn-ticket-weekly > form vn-tbody > vn-tr:nth-child(6) > vn-td:nth-child(6) > vn-icon-button[icon="delete"]' sixthWeeklyTicketDeleteIcon: 'vn-ticket-weekly vn-tr:nth-child(6) vn-icon-button[icon="delete"]',
acceptDeleteTurn: 'vn-ticket-weekly > vn-confirm[vn-id="deleteWeekly"] button[response="ACCEPT"]'
}, },
createTicketView: { createTicketView: {
clientAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.clientFk"]', clientAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.clientFk"]',

View File

@ -49,7 +49,7 @@ describe('Ticket descriptor path', () => {
expect(url.hash).toContain('/summary'); expect(url.hash).toContain('/summary');
}); });
it('should add the ticket to thirsday turn using the descriptor more menu', async() => { it('should add the ticket to thursday turn using the descriptor more menu', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn) .waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn)
@ -139,9 +139,12 @@ describe('Ticket descriptor path', () => {
expect(result).toEqual('Saturday'); expect(result).toEqual('Saturday');
}); });
// Test #1450 here
it('should delete the weekly ticket 11', async() => { it('should delete the weekly ticket 11', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketsIndex.sixthWeeklyTicketDeleteIcon) .waitToClick(selectors.ticketsIndex.sixthWeeklyTicketDeleteIcon)
.waitToClick(selectors.ticketsIndex.acceptDeleteTurn)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');

View File

@ -113,34 +113,31 @@ vn-table {
&.clickable { &.clickable {
@extend %clickable; @extend %clickable;
} }
& > vn-td > .chip { & > vn-td .chip {
padding: .3em; padding: .3em;
border-radius: .3em; border-radius: .3em;
} }
&.notice,
& > .notice, & > vn-td .chip.notice {
& > vn-td > .notice {
color: $color-font-bg; color: $color-font-bg;
background-color: $color-notice-medium; background-color: $color-notice-medium
} }
&.success,
& > .success, & > vn-td .chip.success {
& > vn-td > .success {
color: $color-font-bg; color: $color-font-bg;
background-color: $color-success-medium; background-color: $color-success-medium
} }
&.warning,
& > .warning, & > vn-td .chip.warning {
& > vn-td > .warning {
color: $color-font-bg; color: $color-font-bg;
background-color: $color-main-medium; background-color: $color-main-medium;
} }
&.alert,
& > .alert, & > vn-td .chip.alert {
& > vn-td > .alert {
color: $color-font-bg; color: $color-font-bg;
background-color: $color-alert-medium; background-color: $color-alert-medium;
} }
& > [actions] { & > [actions] {
width: 1px; width: 1px;

View File

@ -37,6 +37,13 @@ September: Septiembre
October: Octubre October: Octubre
November: Noviembre November: Noviembre
December: Diciembre December: Diciembre
Monday: Lunes
Tuesday: Martes
Wednesday: Miércoles
Thursday: Jueves
Friday: Viernes
Saturday: Sábado
Sunday: Domingo
Has delivery: Hay reparto Has delivery: Hay reparto
Loading: Cargando Loading: Cargando
Fields to show: Campos a mostrar Fields to show: Campos a mostrar

View File

@ -80,9 +80,9 @@
"This client can't be invoiced": "Este cliente no puede ser facturado", "This client can't be invoiced": "Este cliente no puede ser facturado",
"This ticket can't be invoiced": "Este ticket no puede ser facturado", "This ticket can't be invoiced": "Este ticket no puede ser facturado",
"That item is not available on that day": "El item no esta disponible para esa fecha", "That item is not available on that day": "El item no esta disponible para esa fecha",
"That item doesn't exists": "That item doesn't exists", "That item doesn't exists": "No existe el artículo",
"You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado",
"This ticket can not be modified": "Este ticket no puede ser modificado", "This ticket can not be modified": "Este ticket no puede ser modificado",
"The introduced hour already exists": "The introduced hour already exists", "The introduced hour already exists": "Esta hora ya ha sido introducida",
"INFINITE_LOOP": "INFINITE_LOOP" "INFINITE_LOOP": "Existe una dependencia entre dos Jefes"
} }

View File

@ -23,8 +23,16 @@
<vn-tbody> <vn-tbody>
<vn-tr ng-repeat="sample in samples"> <vn-tr ng-repeat="sample in samples">
<vn-td>{{::sample.created | dateTime:'dd/MM/yyyy HH:mm' }}</vn-td> <vn-td>{{::sample.created | dateTime:'dd/MM/yyyy HH:mm' }}</vn-td>
<vn-td>{{::sample.type.description}}</vn-td> <vn-td
<vn-td>{{::sample.worker.user.nickname}}</vn-td> title="{{::sample.type.description}}">
{{::sample.type.description}}
</vn-td>
<vn-td>
<span class="link"
ng-click="$ctrl.showWorkerDescriptor($event, sample.worker.id)">
{{::sample.worker.user.nickname}}
</span>
</vn-td>
<vn-td>{{::sample.company.code}}</vn-td> <vn-td>{{::sample.company.code}}</vn-td>
</vn-tr> </vn-tr>
</vn-tbody> </vn-tbody>
@ -33,6 +41,10 @@
<vn-pagination model="model"></vn-pagination> <vn-pagination model="model"></vn-pagination>
</vn-card> </vn-card>
</vn-vertical> </vn-vertical>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>
<a ui-sref="client.card.sample.create" vn-tooltip="Send sample" <a ui-sref="client.card.sample.create" vn-tooltip="Send sample"
vn-bind="+" fixed-bottom-right> vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button> <vn-float-button icon="add"></vn-float-button>

View File

@ -1,7 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
class Controller { class Controller {
constructor($stateParams) { constructor($scope, $stateParams) {
this.$ = $scope;
this.$stateParams = $stateParams; this.$stateParams = $stateParams;
this.filter = { this.filter = {
include: [ include: [
@ -32,9 +33,19 @@ class Controller {
] ]
}; };
} }
showWorkerDescriptor(event, workerFk) {
if (event.defaultPrevented) return;
event.preventDefault();
event.stopImmediatePropagation();
this.selectedWorker = workerFk;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
} }
Controller.$inject = ['$stateParams']; Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnClientSampleIndex', { ngModule.component('vnClientSampleIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -52,7 +52,7 @@ module.exports = Self => {
request.ticket().warehouseFk, request.ticket().warehouseFk,
false false
]; ];
console.log(params);
let [res] = await Self.rawSql(query, params); let [res] = await Self.rawSql(query, params);
let available = res[0].available; let available = res[0].available;
if (!available) if (!available)

View File

@ -0,0 +1,70 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
module.exports = Self => {
Self.remoteMethodCtx('filter', {
description: 'Find all instances of the model matched by filter from the data source.',
accessType: 'READ',
accepts: [
{
arg: 'filter',
type: 'Object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'}
}, {
arg: 'search',
type: 'String',
description: `If it's and integer searchs by id, otherwise it searchs by client id`,
http: {source: 'query'}
}
],
returns: {
type: ['Object'],
root: true
},
http: {
path: `/filter`,
verb: 'GET'
}
});
Self.filter = async(ctx, filter) => {
let conn = Self.dataSource.connector;
let where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return {or: [
{ticketFk: value},
{clientFk: value}
]};
}
});
filter = mergeFilters(ctx.args.filter, {where});
let stmts = [];
let stmt;
stmt = new ParameterizedSQL(
`SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay,
wh.name AS warehouseName, w.id AS workerFk, u.nickName
FROM ticketWeekly tw
JOIN ticket t ON t.id = tw.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN worker w ON w.id = c.salesPersonFk
JOIN account.user u ON u.id = w.userFk
JOIN warehouse wh ON wh.id = t.warehouseFk`
);
stmt.merge(conn.makeSuffix(filter));
let itemsIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql);
return itemsIndex === 0 ? result : result[itemsIndex];
};
};

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/ticket-weekly/filter')(Self);
};

View File

@ -181,7 +181,7 @@
"component": "vn-ticket-log", "component": "vn-ticket-log",
"description": "Log" "description": "Log"
}, { }, {
"url" : "/weekly", "url" : "/weekly?q",
"state": "ticket.weekly", "state": "ticket.weekly",
"component": "vn-ticket-weekly", "component": "vn-ticket-weekly",
"description": "Weekly" "description": "Weekly"

View File

@ -16,13 +16,6 @@ You have to allow pop-ups in your web browser to use this functionality:
Disc: Dto Disc: Dto
Available: Disponible Available: Disponible
In which day you want to add the ticket?: ¿A que dia quieres añadir el ticket? In which day you want to add the ticket?: ¿A que dia quieres añadir el ticket?
Monday: Lunes
Tuesday: Martes
Wednesday: Miércoles
Thursday: Jueves
Friday: Viernes
Saturday: Sábado
Sunday: Domingo
Add claim: Crear reclamación Add claim: Crear reclamación
Claim: Reclamación Claim: Reclamación
Transfer lines: Transferir líneas Transfer lines: Transferir líneas

View File

@ -1,14 +1,25 @@
<vn-crud-model auto-load="false" <vn-crud-model auto-load="false"
vn-id="model" vn-id="model"
url="/ticket/api/TicketWeeklies" url="/ticket/api/TicketWeeklies/filter"
filter="::$ctrl.filter" filter="::$ctrl.filter"
limit="20" limit="20"
data="weeklies" data="weeklies"
primary-key="ticketFk" primary-key="ticketFk">
auto-save="true"
on-save="$ctrl.onSave()">
</vn-crud-model> </vn-crud-model>
<form name="form"> <div class="content-block">
<div class="vn-list">
<vn-card pad-medium-h>
<vn-horizontal>
<vn-searchbar
vn-id="turnSearchbar"
style="width: 100%"
on-search="$ctrl.onSearch($params)"
info="Search turns by id or client id"
vn-focus>
</vn-searchbar>
</vn-horizontal>
</vn-card>
</div>
<div margin-medium> <div margin-medium>
<vn-card margin-medium-v pad-medium> <vn-card margin-medium-v pad-medium>
<vn-table model="model"> <vn-table model="model">
@ -30,27 +41,35 @@
</span> </span>
</vn-td> </vn-td>
<vn-td> <vn-td>
<span class="link" ng-click="$ctrl.showClientDescriptor($event, weekly.ticket.client.id)"> <span class="link"
{{::weekly.ticket.client.name}} ng-click="$ctrl.showClientDescriptor($event, weekly.clientFk)"
title ="{{::weekly.clientName}}">
{{::weekly.clientName}}
</span> </span>
</vn-td> </vn-td>
<vn-td ng-click="$ctrl.preventNavigation($event)"> <vn-td ng-click="$ctrl.preventNavigation($event)">
<vn-autocomplete <vn-autocomplete vn-one
vn-one vn-id="weekday"
field="weekly.weekDay" field="weekly.weekDay"
data="$ctrl.weekdays" data="$ctrl.weekdays"
show-field="name" show-field="name"
translate-fields="['name']" translate-fields="['name']"
value-field="id" value-field="id"
on-change="$ctrl.onWeekdayUpdate(weekly.ticketFk, weekday.selection.id)"
order="id"> order="id">
</vn-autocomplete> </vn-autocomplete>
</vn-td> </vn-td>
<vn-td>{{::weekly.ticket.warehouse.name}}</vn-td> <vn-td>{{::weekly.warehouseName}}</vn-td>
<vn-td>{{::weekly.ticket.client.salesPerson.firstName}} {{::weekly.ticket.client.salesPerson.name}}</vn-td> <vn-td>
<span class="link"
ng-click="$ctrl.showWorkerDescriptor($event, weekly.workerFk)">
{{::weekly.nickName}}
</span>
</vn-td>
<vn-td> <vn-td>
<vn-icon-button <vn-icon-button
icon="delete" icon="delete"
ng-click="model.remove($index)" ng-click="$ctrl.deleteWeekly($index)"
vn-tooltip="Delete"> vn-tooltip="Delete">
</vn-icon-button> </vn-icon-button>
</vn-td> </vn-td>
@ -60,14 +79,17 @@
</vn-card> </vn-card>
<vn-pagination model="model"></vn-pagination> <vn-pagination model="model"></vn-pagination>
</div> </div>
</form> </div>
<vn-client-descriptor-popover vn-id="clientDescriptor"></vn-client-descriptor-popover> <vn-client-descriptor-popover vn-id="clientDescriptor"></vn-client-descriptor-popover>
<vn-ticket-descriptor-popover <vn-ticket-descriptor-popover
vn-id="ticketDescriptor"> vn-id="ticketDescriptor">
</vn-ticket-descriptor-popover> </vn-ticket-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
<vn-confirm <vn-confirm
vn-id="deleteWeekly" vn-id="deleteWeekly"
on-response="$ctrl.returnDialog(response)" on-response="$ctrl.returnDialog(response)"
question="Delete weekly" question="You are going to delete this turn"
message="Are you sure you want to delete this weekly?"> message="This turn will be removed! Continue anyway?">
</vn-confirm> </vn-confirm>

View File

@ -2,35 +2,13 @@ import ngModule from '../module';
import './style.scss'; import './style.scss';
export default class Controller { export default class Controller {
constructor($scope, vnApp, $translate) { constructor($scope, vnApp, $translate, $http) {
this.$scope = $scope; this.$ = $scope;
this.vnApp = vnApp; this.vnApp = vnApp;
this._ = $translate; this.$translate = $translate;
this.$http = $http;
this.ticketSelected = null; this.ticketSelected = null;
this.filter = {
include: {
relation: 'ticket',
scope: {
fields: ['id', 'clientFk', 'companyFk', 'warehouseFk'],
include: [
{
relation: 'client',
scope: {
fields: ['salesPersonFk', 'name'],
include: {
relation: 'salesPerson',
scope: {
fields: ['id', 'firstName', 'name']
}
}
}
},
{relation: 'warehouse'}
]
}
}
};
this.weekdays = [ this.weekdays = [
{id: 0, name: 'Monday'}, {id: 0, name: 'Monday'},
@ -43,28 +21,53 @@ export default class Controller {
]; ];
} }
onSave() { onWeekdayUpdate(ticketFk, weekDay) {
this.vnApp.showSuccess(this._.instant('Data saved!')); const params = {ticketFk, weekDay};
this.$http.patch('/ticket/api/TicketWeeklies/', params).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
} }
deleteWeekly(index) {
this.ticketIndex = index;
this.$.deleteWeekly.show();
event.stopImmediatePropagation();
}
onSearch(params) {
if (params)
this.$.model.applyFilter(null, params);
else
this.$.model.clear();
}
showClientDescriptor(event, clientFk) { showClientDescriptor(event, clientFk) {
this.$scope.clientDescriptor.clientFk = clientFk; this.$.clientDescriptor.clientFk = clientFk;
this.$scope.clientDescriptor.parent = event.target; this.$.clientDescriptor.parent = event.target;
this.$scope.clientDescriptor.show(); this.$.clientDescriptor.show();
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
showTicketDescriptor(event, ticketFk) { showTicketDescriptor(event, ticketFk) {
this.$scope.ticketDescriptor.ticketFk = ticketFk; this.$.ticketDescriptor.ticketFk = ticketFk;
this.$scope.ticketDescriptor.parent = event.target; this.$.ticketDescriptor.parent = event.target;
this.$scope.ticketDescriptor.show(); this.$.ticketDescriptor.show();
event.preventDefault();
event.stopImmediatePropagation();
}
showWorkerDescriptor(event, workerFk) {
this.$.workerDescriptor.workerFk = workerFk;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
onDescriptorLoad() { onDescriptorLoad() {
this.$scope.popover.relocate(); this.$.popover.relocate();
} }
preventNavigation(event) { preventNavigation(event) {
@ -72,13 +75,19 @@ export default class Controller {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
deleteWeekly(expedition) { returnDialog(response) {
this.expeditionId = expedition.id; const ticket = this.$.model.data[this.ticketIndex];
this.$scope.deleteWeekly.show(); if (response === 'ACCEPT') {
this.$http.delete(`/ticket/api/TicketWeeklies/${ticket.ticketFk}`).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.$.model.remove(this.ticketIndex);
});
}
} }
} }
Controller.$inject = ['$scope', 'vnApp', '$translate'];
Controller.$inject = ['$scope', 'vnApp', '$translate', '$http'];
ngModule.component('vnTicketWeekly', { ngModule.component('vnTicketWeekly', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,2 +1,6 @@
Turn: Turno Turn: Turno
Ticket ID: ID Ticket Ticket ID: ID Ticket
Weekly: Turnos
You are going to delete this turn: Vas a eliminar este turno
This turn will be removed! Continue anyway?: Se eliminará este turno! ¿Continuar de todas formas?
Search turns by id or client id: Busca turnos por el identificador o el identificador del cliente

View File

@ -12,27 +12,30 @@
<vn-tr> <vn-tr>
<vn-td ng-repeat="weekday in $ctrl.weekDays" center> <vn-td ng-repeat="weekday in $ctrl.weekDays" center>
<div translate>{{::$ctrl.weekdayNames[$index].name}}</div> <div translate>{{::$ctrl.weekdayNames[$index].name}}</div>
{{::weekday.dated | date: 'dd/MM/yyyy'}} <span>{{::weekday.dated | date: 'dd'}}</span>
<span title="{{::weekday.dated | date: 'MMMM' | translate}}" translate>
{{::weekday.dated | date: 'MMMM'}}
</span>
</vn-td> </vn-td>
</vn-tr> </vn-tr>
</vn-thead> </vn-thead>
<vn-tbody> <vn-tbody>
<vn-tr> <vn-tr>
<vn-td ng-repeat="weekday in $ctrl.weekDays" class="hours" pad-none center> <vn-td ng-repeat="weekday in $ctrl.weekDays" class="hours" pad-none center>
<vn-label-value ng-repeat="hour in weekday.hours" <section ng-repeat="hour in weekday.hours" center>
label="{{($index % 2) == 0 ? 'In' : 'Out'}}" <vn-icon
value="{{hour.timed | dateTime: 'HH:mm'}}"> icon="arrow_{{($index % 2) == 0 ? 'forward' : 'back'}}"
</vn-label-value> title="{{(($index % 2) == 0 ? 'In' : 'Out') | translate}}">
</vn-icon>
<span class="chip notice">{{hour.timed | dateTime: 'HH:mm'}}</span>
</section>
</vn-td> </vn-td>
</vn-tr> </vn-tr>
</vn-tbody> </vn-tbody>
<vn-tfoot> <vn-tfoot>
<vn-tr> <vn-tr>
<vn-td center ng-repeat="weekday in $ctrl.weekDays"> <vn-td center ng-repeat="weekday in $ctrl.weekDays">
<vn-label-value {{$ctrl.getWeekdayTotalHours(weekday)}} h.
label="Total"
value="{{$ctrl.getWeekdayTotalHours(weekday)}} h.">
</vn-label-value>
</vn-td> </vn-td>
</vn-tr> </vn-tr>
<vn-tr> <vn-tr>
@ -74,7 +77,7 @@
<h5 style="text-align: center"> <h5 style="text-align: center">
<span translate>Add time</span> <span translate>Add time</span>
</h5> </h5>
<vn-input-time vn-one model="$ctrl.newTime" label="Hour"></vn-input-time> <vn-input-time vn-one model="$ctrl.newTime" label="Hour" vn-focus></vn-input-time>
</div> </div>
</tpl-body> </tpl-body>
<tpl-buttons> <tpl-buttons>

View File

@ -2,10 +2,11 @@ import ngModule from '../module';
import './style.scss'; import './style.scss';
class Controller { class Controller {
constructor($scope, $http, $stateParams) { constructor($scope, $http, $stateParams, $element) {
this.$stateParams = $stateParams; this.$stateParams = $stateParams;
this.$ = $scope; this.$ = $scope;
this.$http = $http; this.$http = $http;
this.$element = $element;
this.defaultDate = new Date(); this.defaultDate = new Date();
this.currentWeek = []; this.currentWeek = [];
this.weekDays = []; this.weekDays = [];
@ -209,14 +210,18 @@ class Controller {
showAddTimeDialog(weekday) { showAddTimeDialog(weekday) {
const timed = new Date(weekday.dated); const timed = new Date(weekday.dated);
const now = new Date(); const now = new Date();
now.setHours(now.getHours(), now.getMinutes(), 0, 0); now.setHours(now.getHours(), now.getMinutes(), 0, 0);
now.setMonth(timed.getMonth()); now.setMonth(timed.getMonth());
now.setDate(timed.getDate()); now.setDate(timed.getDate());
this.newTime = now; this.newTime = now;
this.selectedWeekday = weekday; this.selectedWeekday = weekday;
this.$.addTimeDialog.show(); this.$.addTimeDialog.show();
const selector = 'vn-dialog[vn-id="addTimeDialog"] input[type="time"]';
const input = this.$element[0].querySelector(selector);
input.focus();
} }
addTime(response) { addTime(response) {
@ -230,7 +235,7 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$http', '$stateParams']; Controller.$inject = ['$scope', '$http', '$stateParams', '$element'];
ngModule.component('vnWorkerTimeControl', { ngModule.component('vnWorkerTimeControl', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -4,12 +4,14 @@ describe('Worker', () => {
describe('Component vnWorkerTimeControl', () => { describe('Component vnWorkerTimeControl', () => {
let $scope; let $scope;
let controller; let controller;
let $element;
beforeEach(ngModule('worker')); beforeEach(ngModule('worker'));
beforeEach(angular.mock.inject(($componentController, $rootScope) => { beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new(); $scope = $rootScope.$new();
controller = $componentController('vnWorkerTimeControl', {$scope}); $element = angular.element('<vn-worker-time-control></vn-worker-time-control>');
controller = $componentController('vnWorkerTimeControl', {$scope, $element});
})); }));
describe('worker() setter', () => { describe('worker() setter', () => {

View File

@ -1,12 +1,5 @@
In: Entrada In: Entrada
Out: Salida Out: Salida
Monday: Lunes
Tuesday: Martes
Wednesday: Miércoles
Thursday: Jueves
Friday: Viernes
Saturday: Sábado
Sunday: Domingo
Hour: Hora Hour: Hora
Hours: Horas Hours: Horas
Add time: Añadir hora Add time: Añadir hora

View File

@ -9,8 +9,16 @@ vn-worker-time-control {
vn-td.hours { vn-td.hours {
vertical-align: top; vertical-align: top;
vn-label-value { & > section {
padding: .6em .5em position: relative;
padding: .6em 0;
& > vn-icon {
position: absolute;
margin-left: -1.3em;
margin-top: -3px;
color: $color-font-secondary;
}
} }
} }

BIN
print/report/printer-setup/assets/files/model.ezp Executable file → Normal file

Binary file not shown.