Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
751c945575
|
@ -45,4 +45,4 @@ import './input-file';
|
||||||
import './treeview';
|
import './treeview';
|
||||||
import './treeview/child';
|
import './treeview/child';
|
||||||
import './calendar';
|
import './calendar';
|
||||||
|
import './scroll-up/scroll-up';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Input from '../../lib/input';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw checkbox with a drop-down and multi options
|
* Multicheck component for checking all form instances at once
|
||||||
* @param {SmallInt} checkAll Primary input-check state: 0 -> uncheck, 1 -> checked
|
* @param {SmallInt} checkAll Primary input-check state: 0 -> uncheck, 1 -> checked
|
||||||
* @param {Array} data List of options shown in drop-down
|
* @param {Array} data List of options shown in drop-down
|
||||||
* @param {Array} models Elements to check / unCheck
|
* @param {Array} models Elements to check / unCheck
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<button class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-js-ripple-effect mdl-button--colored"
|
||||||
|
ng-click="$ctrl.goUp()"
|
||||||
|
vn-tooltip="Go up">
|
||||||
|
<vn-icon icon="keyboard_arrow_up"></vn-icon>
|
||||||
|
</button>
|
|
@ -0,0 +1,35 @@
|
||||||
|
import ngModule from '../../module';
|
||||||
|
import Component from '../../lib/component';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
export default class Controller extends Component {
|
||||||
|
constructor($element, $scope, $window) {
|
||||||
|
super($element, $scope);
|
||||||
|
this.$window = $window;
|
||||||
|
|
||||||
|
$window.addEventListener('scroll', () => {
|
||||||
|
console.log($element[0]);
|
||||||
|
if ($window.scrollY > 0)
|
||||||
|
$element[0].style.display = 'block';
|
||||||
|
else
|
||||||
|
$element[0].style.display = 'none';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
goUp() {
|
||||||
|
this.$window.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$element', '$scope', '$window'];
|
||||||
|
|
||||||
|
ngModule.component('vnScrollUp', {
|
||||||
|
template: require('./scroll-up.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
field: '=?',
|
||||||
|
options: '<?',
|
||||||
|
disabled: '<?',
|
||||||
|
checked: '<?'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,6 @@
|
||||||
|
vn-scroll-up {
|
||||||
|
top: 5em;
|
||||||
|
right: 2.5em;
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
}
|
|
@ -50,4 +50,5 @@ Fields to show: Campos a mostrar
|
||||||
Create new one: Crear nuevo
|
Create new one: Crear nuevo
|
||||||
Toggle: Desplegar/Plegar
|
Toggle: Desplegar/Plegar
|
||||||
Check all: Seleccionar todo
|
Check all: Seleccionar todo
|
||||||
Select a file: Selecciona un fichero
|
Select a file: Selecciona un fichero
|
||||||
|
Go up: Ir arriba
|
|
@ -81,4 +81,5 @@
|
||||||
vn-acl="deliveryBoss"
|
vn-acl="deliveryBoss"
|
||||||
vn-acl-action="remove">
|
vn-acl-action="remove">
|
||||||
</vn-float-button>
|
</vn-float-button>
|
||||||
</a>
|
</a>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -75,4 +75,5 @@
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-claim-summary claim="$ctrl.claimSelected"></vn-claim-summary>
|
<vn-claim-summary claim="$ctrl.claimSelected"></vn-claim-summary>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -66,4 +66,5 @@
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-client-summary client="$ctrl.clientSelected"></vn-client-summary>
|
<vn-client-summary client="$ctrl.clientSelected"></vn-client-summary>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -78,3 +78,4 @@
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
<vn-client-descriptor-popover vn-id="clientDescriptor"></vn-client-descriptor-popover>
|
<vn-client-descriptor-popover vn-id="clientDescriptor"></vn-client-descriptor-popover>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -81,4 +81,6 @@
|
||||||
</vn-ticket-descriptor-popover>
|
</vn-ticket-descriptor-popover>
|
||||||
<vn-client-descriptor-popover
|
<vn-client-descriptor-popover
|
||||||
vn-id="clientDescriptor">
|
vn-id="clientDescriptor">
|
||||||
</vn-client-descriptor-popover>
|
</vn-client-descriptor-popover>
|
||||||
|
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -145,4 +145,5 @@
|
||||||
<vn-worker-descriptor-popover
|
<vn-worker-descriptor-popover
|
||||||
vn-id="workerDescriptor"
|
vn-id="workerDescriptor"
|
||||||
worker-fk="$ctrl.selectedWorker">
|
worker-fk="$ctrl.selectedWorker">
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -90,4 +90,5 @@
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-order-summary order="$ctrl.selectedOrder"></vn-order-summary>
|
<vn-order-summary order="$ctrl.selectedOrder"></vn-order-summary>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -74,4 +74,5 @@
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
<a ui-sref="route.create" vn-tooltip="New route" vn-bind="+" fixed-bottom-right>
|
<a ui-sref="route.create" vn-tooltip="New route" vn-bind="+" fixed-bottom-right>
|
||||||
<vn-float-button icon="add"></vn-float-button>
|
<vn-float-button icon="add"></vn-float-button>
|
||||||
</a>
|
</a>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -160,4 +160,5 @@
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
<vn-client-balance-create
|
<vn-client-balance-create
|
||||||
vn-id="balanceCreateDialog">
|
vn-id="balanceCreateDialog">
|
||||||
</vn-client-balance-create>
|
</vn-client-balance-create>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -3,6 +3,10 @@
|
||||||
url="/api/Tickets/{{$ctrl.$stateParams.id}}/getSales"
|
url="/api/Tickets/{{$ctrl.$stateParams.id}}/getSales"
|
||||||
data="$ctrl.sales">
|
data="$ctrl.sales">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
data="$ctrl.sales">
|
||||||
|
</vn-watcher>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
|
@ -269,17 +273,17 @@
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th number shrink>Id</vn-th>
|
<vn-th number shrink>Id</vn-th>
|
||||||
<vn-th shrink>Item</vn-th>
|
<vn-th>Item</vn-th>
|
||||||
<vn-th number shrink>Quantity</vn-th>
|
<vn-th number shrink>Quantity</vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="sale in $ctrl.transfer.sales">
|
<vn-tr ng-repeat="sale in $ctrl.transfer.sales">
|
||||||
<vn-td number shrink>{{::sale.itemFk | zeroFill:6}}</vn-td>
|
<vn-td number shrink>{{::sale.itemFk | zeroFill:6}}</vn-td>
|
||||||
<vn-td shrink>
|
<vn-td>
|
||||||
<span title="{{::sale.concept}}">{{::sale.concept}}</span>
|
<span title="{{::sale.concept}}">{{::sale.concept}}</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td-editable number>
|
<vn-td-editable number shrink>
|
||||||
<text>{{sale.quantity}}</text>
|
<text>{{sale.quantity}}</text>
|
||||||
<field>
|
<field>
|
||||||
<vn-input-number vn-focus
|
<vn-input-number vn-focus
|
||||||
|
|
|
@ -116,6 +116,18 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns new instances
|
||||||
|
*
|
||||||
|
* @return {Array} New instances
|
||||||
|
*/
|
||||||
|
newInstances() {
|
||||||
|
if (!this.sales) return;
|
||||||
|
|
||||||
|
return this.sales.filter(sale => {
|
||||||
|
return !sale.id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of indexes
|
* Returns an array of indexes
|
||||||
|
@ -151,6 +163,7 @@ class Controller {
|
||||||
return checkedLines.length;
|
return checkedLines.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
removeCheckedLines() {
|
removeCheckedLines() {
|
||||||
const sales = this.checkedLines();
|
const sales = this.checkedLines();
|
||||||
|
|
||||||
|
@ -159,6 +172,9 @@ class Controller {
|
||||||
this.sales.splice(index, 1);
|
this.sales.splice(index, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.newInstances().length === 0)
|
||||||
|
this.$scope.watcher.updateOriginalData();
|
||||||
|
|
||||||
this.refreshTotal();
|
this.refreshTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,8 +311,8 @@ class Controller {
|
||||||
updatePrice() {
|
updatePrice() {
|
||||||
if (this.editedPrice != this.sale.price) {
|
if (this.editedPrice != this.sale.price) {
|
||||||
this.$http.post(`/api/Sales/${this.edit.id}/updatePrice`, {newPrice: this.editedPrice}).then(res => {
|
this.$http.post(`/api/Sales/${this.edit.id}/updatePrice`, {newPrice: this.editedPrice}).then(res => {
|
||||||
if (res.data)
|
this.sale.price = res.data.price;
|
||||||
this.sale.price = res.data.price;
|
this.$scope.watcher.updateOriginalData();
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
|
@ -434,6 +450,8 @@ class Controller {
|
||||||
const data = {quantity: parseInt(sale.quantity)};
|
const data = {quantity: parseInt(sale.quantity)};
|
||||||
const query = `/api/Sales/${sale.id}/updateQuantity`;
|
const query = `/api/Sales/${sale.id}/updateQuantity`;
|
||||||
this.$http.post(query, data).then(() => {
|
this.$http.post(query, data).then(() => {
|
||||||
|
this.$scope.watcher.updateOriginalData();
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.$scope.model.refresh();
|
this.$scope.model.refresh();
|
||||||
|
@ -448,6 +466,8 @@ class Controller {
|
||||||
const data = {concept: sale.concept};
|
const data = {concept: sale.concept};
|
||||||
const query = `/api/Sales/${sale.id}`;
|
const query = `/api/Sales/${sale.id}`;
|
||||||
this.$http.patch(query, data).then(() => {
|
this.$http.patch(query, data).then(() => {
|
||||||
|
this.$scope.watcher.updateOriginalData();
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.$scope.model.refresh();
|
this.$scope.model.refresh();
|
||||||
|
@ -478,6 +498,9 @@ class Controller {
|
||||||
sale.price = newSale.price;
|
sale.price = newSale.price;
|
||||||
sale.item = newSale.item;
|
sale.item = newSale.item;
|
||||||
|
|
||||||
|
if (this.newInstances().length === 0)
|
||||||
|
this.$scope.watcher.updateOriginalData();
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import '../index.js';
|
import '../index.js';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
|
||||||
describe('Ticket', () => {
|
describe('Ticket', () => {
|
||||||
describe('Component vnTicketSale', () => {
|
describe('Component vnTicketSale', () => {
|
||||||
|
@ -42,6 +43,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$scope.ticket = ticket;
|
$scope.ticket = ticket;
|
||||||
|
$scope.watcher = watcher;
|
||||||
|
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpBackend.whenGET(/api\/Tickets\/1\/getSales.*/).respond(sales);
|
$httpBackend.whenGET(/api\/Tickets\/1\/getSales.*/).respond(sales);
|
||||||
|
@ -188,6 +190,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('updateQuantity()', () => {
|
describe('updateQuantity()', () => {
|
||||||
it('should make a POST query saving sale quantity', () => {
|
it('should make a POST query saving sale quantity', () => {
|
||||||
|
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||||
const data = {quantity: 10};
|
const data = {quantity: 10};
|
||||||
const sale = sales[0];
|
const sale = sales[0];
|
||||||
sale.quantity = 10;
|
sale.quantity = 10;
|
||||||
|
@ -196,11 +199,14 @@ describe('Ticket', () => {
|
||||||
$httpBackend.expect('POST', `/api/Sales/1/updateQuantity`, data).respond();
|
$httpBackend.expect('POST', `/api/Sales/1/updateQuantity`, data).respond();
|
||||||
controller.updateQuantity(sale);
|
controller.updateQuantity(sale);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('updateConcept()', () => {
|
describe('updateConcept()', () => {
|
||||||
it('should make a POST query saving sale concept', () => {
|
it('should make a POST query saving sale concept', () => {
|
||||||
|
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||||
const data = {concept: 'My new weapon'};
|
const data = {concept: 'My new weapon'};
|
||||||
const sale = sales[0];
|
const sale = sales[0];
|
||||||
sale.concept = 'My new weapon';
|
sale.concept = 'My new weapon';
|
||||||
|
@ -209,11 +215,14 @@ describe('Ticket', () => {
|
||||||
$httpBackend.expect('PATCH', `/api/Sales/1`, data).respond();
|
$httpBackend.expect('PATCH', `/api/Sales/1`, data).respond();
|
||||||
controller.updateConcept(sale);
|
controller.updateConcept(sale);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addSale()', () => {
|
describe('addSale()', () => {
|
||||||
it('should make a POST query adding a new sale', () => {
|
it('should make a POST query adding a new sale', () => {
|
||||||
|
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||||
const newSale = {itemFk: 4, quantity: 10};
|
const newSale = {itemFk: 4, quantity: 10};
|
||||||
const params = {itemId: 4, quantity: 10};
|
const params = {itemId: 4, quantity: 10};
|
||||||
|
|
||||||
|
@ -233,6 +242,8 @@ describe('Ticket', () => {
|
||||||
$httpBackend.expect('POST', `/api/tickets/1/addSale`, params).respond(expectedResult);
|
$httpBackend.expect('POST', `/api/tickets/1/addSale`, params).respond(expectedResult);
|
||||||
controller.addSale(newSale);
|
controller.addSale(newSale);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,14 @@ vn-ticket-sale {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vn-table, table {
|
vn-table, table {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-table {
|
vn-table {
|
||||||
width: 20em
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: 25em;
|
||||||
|
width: 30em;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
|
|
|
@ -51,4 +51,5 @@
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-pagination model="model"></vn-pagination>
|
<vn-pagination model="model"></vn-pagination>
|
||||||
</div>
|
</div>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
|
@ -72,4 +72,5 @@
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-worker-summary worker="$ctrl.selectedWorker"></vn-worker-summary>
|
<vn-worker-summary worker="$ctrl.selectedWorker"></vn-worker-summary>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
<vn-scroll-up></vn-scroll-up>
|
Loading…
Reference in New Issue