Merge pull request '2511-claim_claimManager' (#426) from 2511-claim_claimManager into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #426
Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
Joan Sanchez 2020-10-27 13:57:14 +00:00
commit 8faf7d97fd
21 changed files with 51 additions and 43 deletions

View File

@ -1,3 +1,8 @@
UPDATE `salix`.`ACL` SET `principalId` = 'deliveryBoss' WHERE (`id` = '194');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '97');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '100');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '103');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '202');
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Town', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Province', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');

View File

@ -0,0 +1,3 @@
UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '3');
UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '4');
UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '5');

File diff suppressed because one or more lines are too long

View File

@ -1534,9 +1534,9 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`)
VALUES
( 1, 'pending', 'Pendiente', 1, 1),
( 2, 'managed', 'Gestionado', 1, 5),
( 3, 'resolved', 'Resuelto', 21, 7),
( 4, 'canceled', 'Anulado', 1, 6),
( 5, 'disputed', 'Cuestionado', 21, 3),
( 3, 'resolved', 'Resuelto', 72, 7),
( 4, 'canceled', 'Anulado', 72, 6),
( 5, 'disputed', 'Cuestionado', 72, 3),
( 6, 'mana', 'Mana', 1, 4),
( 7, 'inProgress', 'En Curso', 1, 2);

View File

@ -14,8 +14,8 @@ describe('Claim edit basic data path', () => {
await browser.close();
});
it(`should log in as salesAssistant then reach basic data of the target claim`, async() => {
await page.loginAndModule('salesAssistant', 'claim');
it(`should log in as claimManager then reach basic data of the target claim`, async() => {
await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.basicData');
});
@ -30,7 +30,7 @@ describe('Claim edit basic data path', () => {
expect(message.type).toBe('success');
});
it(`should have been redirected to the next section of claims as the role is salesAssistant`, async() => {
it(`should have been redirected to the next section of claims as the role is claimManager`, async() => {
await page.waitForState('claim.card.detail');
});

View File

@ -8,7 +8,7 @@ describe('Claim development', () => {
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesAssistant', 'claim');
await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.development');
});
@ -31,7 +31,7 @@ describe('Claim development', () => {
expect(message.type).toBe('success');
});
it(`should redirect to the next section of claims as the role is salesAssistant`, async() => {
it(`should redirect to the next section of claims as the role is claimManager`, async() => {
await page.waitForState('claim.card.action');
});

View File

@ -8,7 +8,7 @@ describe('Claim action path', () => {
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'claim');
await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('2');
await page.accessToSection('claim.card.action');
});

View File

@ -26,8 +26,8 @@ describe('claim Descriptor path', () => {
await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true});
});
it(`should log in as salesAssistant and navigate to the target claim`, async() => {
await page.loginAndModule('salesAssistant', 'claim');
it(`should log in as claimManager and navigate to the target claim`, async() => {
await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForState('claim.card.summary');
});

View File

@ -2,13 +2,13 @@ const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
describe('claimBeginning', () => {
const salesAssistantId = 21;
const claimManagerId = 72;
let ticket;
let refundTicketSales;
let salesInsertedInClaimEnd;
const activeCtx = {
accessToken: {userId: salesAssistantId},
accessToken: {userId: claimManagerId},
};
const ctx = {req: activeCtx};

View File

@ -21,10 +21,8 @@ module.exports = Self => {
Self.isEditable = async(ctx, id) => {
const userId = ctx.req.accessToken.userId;
const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
let claim = await Self.app.models.Claim.findById(id, {
const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager');
const claim = await Self.app.models.Claim.findById(id, {
fields: ['claimStateFk'],
include: [{
relation: 'claimState'
@ -33,7 +31,7 @@ module.exports = Self => {
const isClaimResolved = claim && claim.claimState().code == 'resolved';
if (!claim || (isClaimResolved && !isSalesAssistant))
if (!claim || (isClaimResolved && !isClaimManager))
return false;
return true;

View File

@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server');
describe('claim isEditable()', () => {
const salesPerdonId = 18;
const salesAssistantId = 21;
const claimManagerId = 72;
it('should return false if the given claim does not exist', async() => {
let ctx = {req: {accessToken: {userId: salesAssistantId}}};
let ctx = {req: {accessToken: {userId: claimManagerId}}};
let result = await app.models.Claim.isEditable(ctx, 99999);
expect(result).toEqual(false);
@ -17,14 +17,14 @@ describe('claim isEditable()', () => {
expect(result).toEqual(false);
});
it('should be able to edit a resolved claim for a salesAssistant', async() => {
let ctx = {req: {accessToken: {userId: salesAssistantId}}};
it('should be able to edit a resolved claim for a claimManager', async() => {
let ctx = {req: {accessToken: {userId: claimManagerId}}};
let result = await app.models.Claim.isEditable(ctx, 4);
expect(result).toEqual(true);
});
it('should be able to edit a claim for a salesAssistant', async() => {
it('should be able to edit a claim for a claimManager', async() => {
let ctx = {req: {accessToken: {userId: salesPerdonId}}};
let result = await app.models.Claim.isEditable(ctx, 1);

View File

@ -42,17 +42,17 @@ describe('Update Claim', () => {
it(`should success to update the claim within privileges `, async() => {
let newClaim = await app.models.Claim.create(originalData);
const correctState = 4;
const salesPersonId = 18;
const canceledState = 4;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {
userId: salesPersonId
userId: claimManagerId
}
},
args: {
observation: 'valid observation',
claimStateFk: correctState,
claimStateFk: canceledState,
hasToPickUp: false
}
};
@ -66,15 +66,15 @@ describe('Update Claim', () => {
await app.models.Claim.destroyById(newClaim.id);
});
it('should change some sensible fields as salesAssistant', async() => {
it('should change some sensible fields as claimManager', async() => {
let newClaim = await app.models.Claim.create(originalData);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const salesAssistantId = 21;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: salesAssistantId},
accessToken: {userId: claimManagerId},
headers: {origin: 'http://localhost'}
},
args: {

View File

@ -60,9 +60,9 @@ module.exports = Self => {
if (args.claimStateFk) {
const canUpdate = await canChangeState(ctx, claim.claimStateFk);
const hasRights = await canChangeState(ctx, args.claimStateFk);
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant');
const isClaimManager = await models.Account.hasRole(userId, 'claimManager');
if (!canUpdate || !hasRights || changedHasToPickUp && !isSalesAssistant)
if (!canUpdate || !hasRights || changedHasToPickUp && !isClaimManager)
throw new UserError(`You don't have enough privileges to change that field`);
}
delete args.ctx;

View File

@ -56,7 +56,8 @@
class="vn-mr-md"
label="Pick up"
ng-model="$ctrl.claim.hasToPickUp"
vn-acl="salesAssistant">
vn-acl="claimManager"
info="When checked will notify to the salesPerson">
</vn-check>
</vn-horizontal>
</vn-card>

View File

@ -5,7 +5,7 @@ import './style.scss';
class Controller extends Section {
onSubmit() {
this.$.watcher.submit().then(() => {
if (this.aclService.hasAny(['salesAssistant']))
if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.detail');
});
}

View File

@ -4,4 +4,5 @@ Is paid with mana: Cargado al maná
Responsability: Responsabilidad
Company: Empresa
Sales/Client: Comercial/Cliente
Pick up: Recoger
Pick up: Recoger
When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial

View File

@ -13,7 +13,7 @@
Send Pickup order
</vn-item>
<vn-item
vn-acl="salesAssistant"
vn-acl="claimManager"
vn-acl-action="remove"
ng-click="confirmDeleteClaim.show()"
name="deleteClaim"

View File

@ -77,7 +77,7 @@ class Controller extends Section {
this.$.model.refresh();
this.vnApp.showSuccess(this.$t('Data saved!'));
if (this.aclService.hasAny(['salesAssistant']))
if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.development');
});
}
@ -133,7 +133,7 @@ class Controller extends Section {
showEditPopover(event, saleClaimed) {
if (this.isEditable) {
if (!this.aclService.hasAny(['salesAssistant']))
if (!this.aclService.hasAny(['claimManager']))
return this.vnApp.showError(this.$t('Insuficient permisos'));
this.saleClaimed = saleClaimed;

View File

@ -9,7 +9,7 @@ class Controller extends Section {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
if (this.aclService.hasAny(['salesAssistant']))
if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.action');
});
}

View File

@ -70,7 +70,7 @@
"params": {
"claim": "$ctrl.claim"
},
"acl": ["salesAssistant"]
"acl": ["claimManager"]
}, {
"url": "/action",
"state": "claim.card.action",
@ -79,7 +79,7 @@
"params": {
"claim": "$ctrl.claim"
},
"acl": ["salesAssistant"]
"acl": ["claimManager"]
}, {
"url": "/photos",
"state": "claim.card.photos",

View File

@ -42,7 +42,7 @@
max="5"
min="1"
step="1"
vn-acl="salesAssistant">
vn-acl="claimManager">
</vn-range>
</vn-one>
<vn-auto>