css fixes + back unit tests
gitea/salix/1757-drag_and_drop_department This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-10-17 13:27:50 +02:00
parent 4ca001d98e
commit b2b76b05d8
7 changed files with 187 additions and 121 deletions

View File

@ -72,7 +72,7 @@ describe('Component vnTreeview', () => {
describe('fetch()', () => {
it(`should call the fetchFunc() method`, () => {
spyOn(controller, 'fetchFunc').and.returnValue(
new Promise(resolve => resolve())
new Promise(resolve => resolve([{name: 'My item'}]))
);
controller.fetch().then(() => {
expect(controller.data).toBeDefined();

View File

@ -1,123 +1,116 @@
<vn-crud-model auto-load="false"
<vn-crud-model auto-load="true"
vn-id="model"
url="claim/api/ClaimEnds"
filter="$ctrl.filter"
data="$ctrl.salesClaimed">
</vn-crud-model>
<vn-vertical compact>
<vn-card class="vn-pa-lg">
<vn-vertical>
<vn-horizontal>
<div class="totalBox" ng-show="$ctrl.salesClaimed.length > 0">
<vn-label-value label="Total claimed"
value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
</vn-label-value>
</div>
</vn-horizontal>
<vn-horizontal>
<vn-tool-bar class="vn-mb-md">
<vn-button
label="Import claim"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
vn-http-click="$ctrl.importToNewRefundTicket()"p
vn-tooltip="Imports claim details">
</vn-button>
<vn-button
label="Import ticket"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
ng-click="$ctrl.showLastTickets($event)"
vn-tooltip="Imports ticket lines">
</vn-button>
<vn-input-range
vn-one
label="Responsability"
value="$ctrl.claim.responsibility"
max="$ctrl.maxResponsibility"
min="1"
step="1"
vn-acl="salesAssistant"
on-change="$ctrl.saveResponsibility(value)">
</vn-input-range>
</vn-tool-bar>
<vn-one
style = "text-align:right">
<vn-check
vn-one
label="Is paid with mana"
ng-model="$ctrl.claim.isChargedToMana"
vn-acl="salesAssistant"
on-change="$ctrl.saveMana(value)">
</vn-check>
</vn-one>
</vn-horizontal>
<vn-data-viewer model="model">
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th number>Ticket</vn-th>
<vn-th>Destination</vn-th>
<vn-th>Landed</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th>Description</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Disc.</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr
ng-repeat="saleClaimed in $ctrl.salesClaimed"
vn-repeat-last on-last="$ctrl.focusLastInput()">
<vn-td number>
<span
ng-click="$ctrl.showDescriptor($event, saleClaimed.sale.itemFk)"
class="link">
{{saleClaimed.sale.itemFk | zeroFill:6}}
</span>
</vn-td>
<vn-td number>
<span
class="link"
ng-click="$ctrl.showTicketDescriptor($event, saleClaimed.sale.ticketFk)">
{{::saleClaimed.sale.ticketFk}}
<vn-card class="vn-mb-md vn-pa-lg vn-w-lg" style="text-align: right"
ng-if="$ctrl.salesClaimed.length > 0">
<vn-label-value label="Total claimed"
value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
</vn-label-value>
</vn-card>
<vn-card class="vn-pa-lg vn-w-lg">
<section class="header">
<vn-tool-bar class="vn-mb-md">
<vn-button
label="Import claim"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
vn-http-click="$ctrl.importToNewRefundTicket()"p
translate-attr="{title: 'Imports claim details'}">
</vn-button>
<vn-button
label="Import ticket"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
ng-click="$ctrl.showLastTickets($event)"
translate-attr="{title: 'Imports ticket lines'}">
</vn-button>
<vn-input-range vn-none
label="Responsability"
value="$ctrl.claim.responsibility"
max="$ctrl.maxResponsibility"
min="1"
step="1"
vn-acl="salesAssistant"
on-change="$ctrl.saveResponsibility(value)">
</vn-input-range>
</vn-tool-bar>
<vn-check vn-one
label="Is paid with mana"
ng-model="$ctrl.claim.isChargedToMana"
vn-acl="salesAssistant"
on-change="$ctrl.saveMana(value)">
</vn-check>
</section>
<vn-data-viewer model="model">
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th number>Ticket</vn-th>
<vn-th>Destination</vn-th>
<vn-th>Landed</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th>Description</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Disc.</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr
ng-repeat="saleClaimed in $ctrl.salesClaimed"
vn-repeat-last on-last="$ctrl.focusLastInput()">
<vn-td number>
<span
ng-click="$ctrl.showDescriptor($event, saleClaimed.sale.itemFk)"
class="link">
{{::saleClaimed.sale.itemFk | zeroFill:6}}
</span>
</vn-td>
<vn-td>
<vn-autocomplete
vn-one
id="claimDestinationFk"
ng-model="saleClaimed.claimDestinationFk"
url="/claim/api/ClaimDestinations"
fields="['id','description']"
value-field="id"
show-field="description"
on-change="$ctrl.setClaimDestination(saleClaimed.id, value)">
</vn-autocomplete>
</vn-td>
<vn-td>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
<vn-td expand>{{saleClaimed.sale.concept}}</vn-td>
<vn-td number>{{saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
<vn-td number>{{saleClaimed.sale.discount}} %</vn-td>
<vn-td number>
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
</vn-td>
<vn-td shrink>
<vn-icon-button
vn-tooltip="Remove line"
icon="delete"
ng-click="$ctrl.deleteClaimedSale(saleClaimed.id)"
tabindex="-1">
</vn-icon-button>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-data-viewer>
</vn-vertical>
</vn-card>
</vn-td>
<vn-td number>
<span
class="link"
ng-click="$ctrl.showTicketDescriptor($event, saleClaimed.sale.ticketFk)">
{{::saleClaimed.sale.ticketFk}}
</span>
</vn-td>
<vn-td>
<vn-autocomplete vn-one
id="claimDestinationFk"
ng-model="saleClaimed.claimDestinationFk"
url="/claim/api/ClaimDestinations"
fields="['id','description']"
value-field="id"
show-field="description"
on-change="$ctrl.setClaimDestination(saleClaimed.id, value)">
</vn-autocomplete>
</vn-td>
<vn-td>{{::saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td number>{{::saleClaimed.sale.quantity}}</vn-td>
<vn-td expand>{{::saleClaimed.sale.concept}}</vn-td>
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
<vn-td number>{{::saleClaimed.sale.discount}} %</vn-td>
<vn-td number>
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
</vn-td>
<vn-td shrink>
<vn-icon-button
vn-tooltip="Remove line"
icon="delete"
ng-click="$ctrl.deleteClaimedSale(saleClaimed.id)"
tabindex="-1">
</vn-icon-button>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-data-viewer>
<vn-button-bar>
<vn-button
label="Regularize"
@ -125,11 +118,7 @@
vn-http-click="$ctrl.regularize()">
</vn-button>
</vn-button-bar>
<!-- WIP
<a ng-click="$ctrl.openAddSalesDialog()" vn-tooltip="New item" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>
-->
</vn-card>
<!-- Add Lines Dialog -->
<vn-dialog vn-id="addSales">

View File

@ -1,4 +1,19 @@
vn-claim-action {
.header {
display: flex;
justify-content: space-between;
align-items: center;
align-content: center;
vn-tool-bar {
flex: 1
}
vn-check {
flex: none;
}
}
vn-dialog[vn-id=addSales] {
tpl-body {
width: 950px;

View File

@ -1,6 +1,6 @@
import './index.js';
fdescribe('Ticket component vnTicketService', () => {
describe('Ticket component vnTicketService', () => {
let controller;
let $httpBackend;
let $httpParamSerializer;

View File

@ -0,0 +1,18 @@
const app = require('vn-loopback/server/server');
describe('department createChild()', () => {
let createdChild;
afterAll(async done => {
await createdChild.destroy();
done();
});
it('should create a new child', async() => {
const parentId = null;
createdChild = await app.models.Department.createChild(parentId, 'My new department');
expect(createdChild.name).toEqual('My new department');
expect(createdChild.parentFk).toBeNull();
});
});

View File

@ -0,0 +1,23 @@
const app = require('vn-loopback/server/server');
describe('department moveChild()', () => {
let updatedChild;
afterAll(async done => {
const child = await app.models.Department.findById(updatedChild.id);
await child.updateAttribute('parentFk', null);
done();
});
it('should move a child department to a new parent', async() => {
const childId = 22;
const parentId = 1;
const child = await app.models.Department.findById(childId);
expect(child.parentFk).toBeNull();
updatedChild = await app.models.Department.moveChild(childId, parentId);
expect(updatedChild.parentFk).toEqual(1);
});
});

View File

@ -0,0 +1,21 @@
const app = require('vn-loopback/server/server');
describe('department removeChild()', () => {
let removedChild;
afterAll(async done => {
await app.models.Department.create(removedChild);
done();
});
it('should remove a child department', async() => {
const childId = 1;
removedChild = await app.models.Department.findById(childId);
const result = await app.models.Department.removeChild(childId);
const existsChild = await app.models.Department.findById(childId);
expect(result.count).toEqual(1);
expect(existsChild).toBeNull();
});
});