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

View File

@ -1,4 +1,19 @@
vn-claim-action { 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] { vn-dialog[vn-id=addSales] {
tpl-body { tpl-body {
width: 950px; width: 950px;

View File

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