Merge branch 'dev' into 4124-webp-images
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
d91814473e
|
@ -0,0 +1,58 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('privileges', {
|
||||||
|
description: 'Change role and hasGrant if user has privileges',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The user id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'roleFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The new role for user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'hasGrant',
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Whether to has grant'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: `/:id/privileges`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.privileges = async function(ctx, id, roleFk, hasGrant, options) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const user = await models.Account.findById(userId, null, myOptions);
|
||||||
|
|
||||||
|
if (!user.hasGrant)
|
||||||
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
|
const userToUpdate = await models.Account.findById(id);
|
||||||
|
if (hasGrant != null)
|
||||||
|
return await userToUpdate.updateAttribute('hasGrant', hasGrant, myOptions);
|
||||||
|
if (!roleFk) return;
|
||||||
|
|
||||||
|
const role = await models.Role.findById(roleFk, null, myOptions);
|
||||||
|
const hasRole = await models.Account.hasRole(userId, role.name, myOptions);
|
||||||
|
|
||||||
|
if (!hasRole)
|
||||||
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
|
await userToUpdate.updateAttribute('roleFk', roleFk, myOptions);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,99 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('account privileges()', () => {
|
||||||
|
const employeeId = 1;
|
||||||
|
const developerId = 9;
|
||||||
|
const sysadminId = 66;
|
||||||
|
const bruceWayneId = 1101;
|
||||||
|
|
||||||
|
it('should throw an error when user not has privileges', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: developerId}}};
|
||||||
|
const tx = await models.Account.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await models.Account.privileges(ctx, employeeId, null, true, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toContain(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error when user has privileges but not has the role', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||||
|
const tx = await models.Account.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const root = await models.Role.findOne({
|
||||||
|
where: {
|
||||||
|
name: 'root'
|
||||||
|
}
|
||||||
|
}, options);
|
||||||
|
await models.Account.privileges(ctx, employeeId, root.id, null, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toContain(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change role', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||||
|
const tx = await models.Account.beginTransaction({});
|
||||||
|
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const agency = await models.Role.findOne({
|
||||||
|
where: {
|
||||||
|
name: 'agency'
|
||||||
|
}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
let error;
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
await models.Account.privileges(ctx, bruceWayneId, agency.id, null, options);
|
||||||
|
result = await models.Account.findById(bruceWayneId, null, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).not.toBeDefined();
|
||||||
|
expect(result.roleFk).toEqual(agency.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change hasGrant', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||||
|
const tx = await models.Account.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
await models.Account.privileges(ctx, bruceWayneId, null, true, options);
|
||||||
|
result = await models.Account.findById(bruceWayneId, null, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).not.toBeDefined();
|
||||||
|
expect(result.hasGrant).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -17,14 +17,16 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deleteTrashFiles = async options => {
|
Self.deleteTrashFiles = async options => {
|
||||||
const tx = await Self.beginTransaction({});
|
let tx;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (!myOptions.transaction)
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
myOptions.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (process.env.NODE_ENV == 'test')
|
if (process.env.NODE_ENV == 'test')
|
||||||
|
@ -61,10 +63,9 @@ module.exports = Self => {
|
||||||
const dstFolder = path.join(dmsContainer.client.root, pathHash);
|
const dstFolder = path.join(dmsContainer.client.root, pathHash);
|
||||||
try {
|
try {
|
||||||
await fs.rmdir(dstFolder);
|
await fs.rmdir(dstFolder);
|
||||||
|
} catch (err) {}
|
||||||
|
|
||||||
await dms.destroy(myOptions);
|
await dms.destroy(myOptions);
|
||||||
} catch (err) {
|
|
||||||
await dms.destroy(myOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ module.exports = Self => {
|
||||||
require('../methods/account/change-password')(Self);
|
require('../methods/account/change-password')(Self);
|
||||||
require('../methods/account/set-password')(Self);
|
require('../methods/account/set-password')(Self);
|
||||||
require('../methods/account/validate-token')(Self);
|
require('../methods/account/validate-token')(Self);
|
||||||
|
require('../methods/account/privileges')(Self);
|
||||||
|
|
||||||
// Validations
|
// Validations
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
},
|
},
|
||||||
"image": {
|
"image": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"hasGrant": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL;
|
|
@ -2663,3 +2663,7 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack
|
||||||
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
|
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
|
||||||
VALUES
|
VALUES
|
||||||
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
|
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
UPDATE `account`.`user`
|
||||||
|
SET `hasGrant` = 1
|
||||||
|
WHERE `id` = 66;
|
||||||
|
|
|
@ -51,14 +51,12 @@ export default {
|
||||||
accountDescriptor: {
|
accountDescriptor: {
|
||||||
menuButton: 'vn-user-descriptor vn-icon-button[icon="more_vert"]',
|
menuButton: 'vn-user-descriptor vn-icon-button[icon="more_vert"]',
|
||||||
deleteAccount: '.vn-menu [name="deleteUser"]',
|
deleteAccount: '.vn-menu [name="deleteUser"]',
|
||||||
changeRole: '.vn-menu [name="changeRole"]',
|
|
||||||
setPassword: '.vn-menu [name="setPassword"]',
|
setPassword: '.vn-menu [name="setPassword"]',
|
||||||
activateAccount: '.vn-menu [name="enableAccount"]',
|
activateAccount: '.vn-menu [name="enableAccount"]',
|
||||||
activateUser: '.vn-menu [name="activateUser"]',
|
activateUser: '.vn-menu [name="activateUser"]',
|
||||||
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
||||||
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
||||||
repeatPassword: 'vn-textfield[ng-model="$ctrl.repeatPassword"]',
|
repeatPassword: 'vn-textfield[ng-model="$ctrl.repeatPassword"]',
|
||||||
newRole: 'vn-autocomplete[ng-model="$ctrl.newRole"]',
|
|
||||||
activeAccountIcon: 'vn-icon[icon="contact_mail"]',
|
activeAccountIcon: 'vn-icon[icon="contact_mail"]',
|
||||||
activeUserIcon: 'vn-icon[icon="icon-disabled"]',
|
activeUserIcon: 'vn-icon[icon="icon-disabled"]',
|
||||||
acceptButton: 'button[response="accept"]',
|
acceptButton: 'button[response="accept"]',
|
||||||
|
@ -143,6 +141,11 @@ export default {
|
||||||
verifyCert: 'vn-account-samba vn-check[ng-model="$ctrl.config.verifyCert"]',
|
verifyCert: 'vn-account-samba vn-check[ng-model="$ctrl.config.verifyCert"]',
|
||||||
save: 'vn-account-samba vn-submit'
|
save: 'vn-account-samba vn-submit'
|
||||||
},
|
},
|
||||||
|
accountPrivileges: {
|
||||||
|
checkHasGrant: 'vn-user-privileges vn-check[ng-model="$ctrl.user.hasGrant"]',
|
||||||
|
role: 'vn-user-privileges vn-autocomplete[ng-model="$ctrl.user.roleFk"]',
|
||||||
|
save: 'vn-user-privileges vn-submit'
|
||||||
|
},
|
||||||
clientsIndex: {
|
clientsIndex: {
|
||||||
createClientButton: `vn-float-button`
|
createClientButton: `vn-float-button`
|
||||||
},
|
},
|
||||||
|
@ -1019,8 +1022,8 @@ export default {
|
||||||
},
|
},
|
||||||
travelExtraCommunity: {
|
travelExtraCommunity: {
|
||||||
anySearchResult: 'vn-travel-extra-community > vn-card div > tbody > tr[ng-attr-id="{{::travel.id}}"]',
|
anySearchResult: 'vn-travel-extra-community > vn-card div > tbody > tr[ng-attr-id="{{::travel.id}}"]',
|
||||||
firstTravelReference: 'vn-travel-extra-community tbody:nth-child(2) vn-textfield[ng-model="travel.ref"]',
|
firstTravelReference: 'vn-travel-extra-community tbody:nth-child(2) vn-td-editable[name="reference"]',
|
||||||
firstTravelLockedKg: 'vn-travel-extra-community tbody:nth-child(2) vn-input-number[ng-model="travel.kg"]',
|
firstTravelLockedKg: 'vn-travel-extra-community tbody:nth-child(2) vn-td-editable[name="lockedKg"]',
|
||||||
removeContinentFilter: 'vn-searchbar > form > vn-textfield > div.container > div.prepend > prepend > div > span:nth-child(3) > vn-icon > i'
|
removeContinentFilter: 'vn-searchbar > form > vn-textfield > div.container > div.prepend > prepend > div > span:nth-child(3) > vn-icon > i'
|
||||||
},
|
},
|
||||||
travelBasicData: {
|
travelBasicData: {
|
||||||
|
|
|
@ -19,10 +19,10 @@ describe('Travel extra community path', () => {
|
||||||
it('should edit the travel reference and the locked kilograms', async() => {
|
it('should edit the travel reference and the locked kilograms', async() => {
|
||||||
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
||||||
await page.waitForSpinnerLoad();
|
await page.waitForSpinnerLoad();
|
||||||
await page.clearInput(selectors.travelExtraCommunity.firstTravelReference);
|
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
||||||
await page.write(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
await page.waitForSpinnerLoad();
|
||||||
await page.clearInput(selectors.travelExtraCommunity.firstTravelLockedKg);
|
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500');
|
||||||
await page.write(selectors.travelExtraCommunity.firstTravelLockedKg, '1500');
|
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
expect(message.text).toContain('Data saved!');
|
||||||
|
@ -32,9 +32,9 @@ describe('Travel extra community path', () => {
|
||||||
await page.accessToSection('travel.index');
|
await page.accessToSection('travel.index');
|
||||||
await page.accessToSection('travel.extraCommunity');
|
await page.accessToSection('travel.extraCommunity');
|
||||||
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
||||||
|
await page.waitForTextInElement(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
||||||
const reference = await page.waitToGetProperty(selectors.travelExtraCommunity.firstTravelReference, 'value');
|
const reference = await page.getProperty(selectors.travelExtraCommunity.firstTravelReference, 'innerText');
|
||||||
const lockedKg = await page.waitToGetProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'value');
|
const lockedKg = await page.getProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'innerText');
|
||||||
|
|
||||||
expect(reference).toContain('edited reference');
|
expect(reference).toContain('edited reference');
|
||||||
expect(lockedKg).toContain(1500);
|
expect(lockedKg).toContain(1500);
|
||||||
|
|
|
@ -62,27 +62,6 @@ describe('Account create and basic data path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Descriptor option', () => {
|
describe('Descriptor option', () => {
|
||||||
describe('Edit role', () => {
|
|
||||||
it('should edit the role using the descriptor menu', async() => {
|
|
||||||
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
|
||||||
await page.waitToClick(selectors.accountDescriptor.changeRole);
|
|
||||||
await page.autocompleteSearch(selectors.accountDescriptor.newRole, 'adminBoss');
|
|
||||||
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Role changed succesfully!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the roles section to see now there are more roles', async() => {
|
|
||||||
// when role updates db takes time to return changes, without this timeout the result would have been 3
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
await page.reloadSection('account.card.roles');
|
|
||||||
const rolesCount = await page.countElement(selectors.accountRoles.anyResult);
|
|
||||||
|
|
||||||
expect(rolesCount).toEqual(61);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('activate account', () => {
|
describe('activate account', () => {
|
||||||
it(`should check the active account icon isn't present in the descriptor`, async() => {
|
it(`should check the active account icon isn't present in the descriptor`, async() => {
|
||||||
await page.waitForNumberOfElements(selectors.accountDescriptor.activeAccountIcon, 0);
|
await page.waitForNumberOfElements(selectors.accountDescriptor.activeAccountIcon, 0);
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
import selectors from '../../helpers/selectors.js';
|
||||||
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
|
describe('Account privileges path', () => {
|
||||||
|
let browser;
|
||||||
|
let page;
|
||||||
|
|
||||||
|
beforeAll(async() => {
|
||||||
|
browser = await getBrowser();
|
||||||
|
page = browser.page;
|
||||||
|
await page.loginAndModule('developer', 'account');
|
||||||
|
await page.accessToSearchResult('1101');
|
||||||
|
await page.accessToSection('account.card.privileges');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async() => {
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('as developer', () => {
|
||||||
|
it('should throw error when give privileges', async() => {
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.checkHasGrant);
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.save);
|
||||||
|
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error when change role', async() => {
|
||||||
|
await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee');
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.save);
|
||||||
|
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('as sysadmin', () => {
|
||||||
|
beforeAll(async() => {
|
||||||
|
await page.loginAndModule('sysadmin', 'account');
|
||||||
|
await page.accessToSearchResult('9');
|
||||||
|
await page.accessToSection('account.card.privileges');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should give privileges', async() => {
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.checkHasGrant);
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.save);
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
await page.reloadSection('account.card.privileges');
|
||||||
|
const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant);
|
||||||
|
|
||||||
|
expect(message.text).toContain(`Data saved!`);
|
||||||
|
expect(result).toBe('checked');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change role', async() => {
|
||||||
|
await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee');
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.save);
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
await page.reloadSection('account.card.privileges');
|
||||||
|
const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value');
|
||||||
|
|
||||||
|
expect(message.text).toContain(`Data saved!`);
|
||||||
|
expect(result).toContain('employee');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('as developer again', () => {
|
||||||
|
it('should remove privileges', async() => {
|
||||||
|
await page.accessToSearchResult('9');
|
||||||
|
await page.accessToSection('account.card.privileges');
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.checkHasGrant);
|
||||||
|
await page.waitToClick(selectors.accountPrivileges.save);
|
||||||
|
|
||||||
|
await page.reloadSection('account.card.privileges');
|
||||||
|
const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant);
|
||||||
|
|
||||||
|
expect(result).toBe('unchecked');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -132,5 +132,6 @@
|
||||||
"Descanso diario 9h.": "Daily rest 9h.",
|
"Descanso diario 9h.": "Daily rest 9h.",
|
||||||
"Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.",
|
"Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.",
|
||||||
"Password does not meet requirements": "Password does not meet requirements",
|
"Password does not meet requirements": "Password does not meet requirements",
|
||||||
|
"You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies",
|
||||||
"Not enough privileges to edit a client": "Not enough privileges to edit a client"
|
"Not enough privileges to edit a client": "Not enough privileges to edit a client"
|
||||||
}
|
}
|
|
@ -96,7 +96,7 @@
|
||||||
"This postcode already exists": "Este código postal ya existe",
|
"This postcode already exists": "Este código postal ya existe",
|
||||||
"Concept cannot be blank": "El concepto no puede quedar en blanco",
|
"Concept cannot be blank": "El concepto no puede quedar en blanco",
|
||||||
"File doesn't exists": "El archivo no existe",
|
"File doesn't exists": "El archivo no existe",
|
||||||
"You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias",
|
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias",
|
||||||
"This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
|
"This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
|
||||||
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
|
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
|
||||||
"Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
|
"Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
|
||||||
|
|
|
@ -11,14 +11,6 @@
|
||||||
translate>
|
translate>
|
||||||
Delete
|
Delete
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item
|
|
||||||
ng-click="$ctrl.onChangeRole()"
|
|
||||||
name="changeRole"
|
|
||||||
vn-acl="hr"
|
|
||||||
vn-acl-action="remove"
|
|
||||||
translate>
|
|
||||||
Change role
|
|
||||||
</vn-item>
|
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-if="::$root.user.id == $ctrl.id"
|
ng-if="::$root.user.id == $ctrl.id"
|
||||||
ng-click="$ctrl.onChangePassClick(true)"
|
ng-click="$ctrl.onChangePassClick(true)"
|
||||||
|
@ -128,22 +120,6 @@
|
||||||
question="Are you sure you want to continue?"
|
question="Are you sure you want to continue?"
|
||||||
message="User will be deactivated">
|
message="User will be deactivated">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
||||||
<vn-dialog
|
|
||||||
vn-id="changeRole"
|
|
||||||
on-accept="$ctrl.onChangeRoleAccept()">
|
|
||||||
<tpl-body>
|
|
||||||
<vn-autocomplete
|
|
||||||
label="Role"
|
|
||||||
ng-model="$ctrl.newRole"
|
|
||||||
url="Roles"
|
|
||||||
vn-focus>
|
|
||||||
</vn-autocomplete>
|
|
||||||
</tpl-body>
|
|
||||||
<tpl-buttons>
|
|
||||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
|
||||||
<button response="accept" translate>Accept</button>
|
|
||||||
</tpl-buttons>
|
|
||||||
</vn-dialog>
|
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
vn-id="changePass"
|
vn-id="changePass"
|
||||||
on-accept="$ctrl.onPassChange()"
|
on-accept="$ctrl.onPassChange()"
|
||||||
|
|
|
@ -30,20 +30,6 @@ class Controller extends Descriptor {
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('User removed')));
|
.then(() => this.vnApp.showSuccess(this.$t('User removed')));
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeRole() {
|
|
||||||
this.newRole = this.user.role.id;
|
|
||||||
this.$.changeRole.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
onChangeRoleAccept() {
|
|
||||||
const params = {roleFk: this.newRole};
|
|
||||||
return this.$http.patch(`Accounts/${this.id}`, params)
|
|
||||||
.then(() => {
|
|
||||||
this.emit('change');
|
|
||||||
this.vnApp.showSuccess(this.$t('Role changed succesfully!'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onChangePassClick(askOldPass) {
|
onChangePassClick(askOldPass) {
|
||||||
this.$http.get('UserPasswords/findOne')
|
this.$http.get('UserPasswords/findOne')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
|
@ -30,17 +30,6 @@ describe('component vnUserDescriptor', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onChangeRoleAccept()', () => {
|
|
||||||
it('should call backend method to change role', () => {
|
|
||||||
$httpBackend.expectPATCH('Accounts/1').respond();
|
|
||||||
controller.onChangeRoleAccept();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
||||||
expect(controller.emit).toHaveBeenCalledWith('change');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onPassChange()', () => {
|
describe('onPassChange()', () => {
|
||||||
it('should throw an error when password is empty', () => {
|
it('should throw an error when password is empty', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
|
|
|
@ -18,3 +18,4 @@ import './roles';
|
||||||
import './ldap';
|
import './ldap';
|
||||||
import './samba';
|
import './samba';
|
||||||
import './accounts';
|
import './accounts';
|
||||||
|
import './privileges';
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<mg-ajax path="Accounts/{{post.params.id}}/privileges" options="vnPost"></mg-ajax>
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
url="Accounts"
|
||||||
|
data="$ctrl.user"
|
||||||
|
id-value="$ctrl.$params.id"
|
||||||
|
form="form"
|
||||||
|
save="post">
|
||||||
|
</vn-watcher>
|
||||||
|
<form
|
||||||
|
name="form"
|
||||||
|
ng-submit="watcher.submit()"
|
||||||
|
class="vn-w-md">
|
||||||
|
<vn-card class="vn-pa-lg" vn-focus>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-check
|
||||||
|
label="Has grant"
|
||||||
|
ng-model="$ctrl.user.hasGrant">
|
||||||
|
</vn-check>
|
||||||
|
</vn-vertical>
|
||||||
|
<vn-vertical
|
||||||
|
class="vn-mt-md">
|
||||||
|
<vn-autocomplete
|
||||||
|
label="Role"
|
||||||
|
ng-model="$ctrl.user.roleFk"
|
||||||
|
url="Roles">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit
|
||||||
|
disabled="!watcher.dataChanged()"
|
||||||
|
label="Save">
|
||||||
|
</vn-submit>
|
||||||
|
<vn-button
|
||||||
|
class="cancel"
|
||||||
|
label="Undo changes"
|
||||||
|
disabled="!watcher.dataChanged()"
|
||||||
|
ng-click="watcher.loadOriginalData()">
|
||||||
|
</vn-button>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
|
@ -0,0 +1,9 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
export default class Controller extends Section {}
|
||||||
|
|
||||||
|
ngModule.component('vnUserPrivileges', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1,2 @@
|
||||||
|
Privileges: Privilegios
|
||||||
|
Has grant: Tiene privilegios
|
|
@ -19,7 +19,8 @@
|
||||||
{"state": "account.card.basicData", "icon": "settings"},
|
{"state": "account.card.basicData", "icon": "settings"},
|
||||||
{"state": "account.card.roles", "icon": "group"},
|
{"state": "account.card.roles", "icon": "group"},
|
||||||
{"state": "account.card.mailForwarding", "icon": "forward"},
|
{"state": "account.card.mailForwarding", "icon": "forward"},
|
||||||
{"state": "account.card.aliases", "icon": "email"}
|
{"state": "account.card.aliases", "icon": "email"},
|
||||||
|
{"state": "account.card.privileges", "icon": "badge"}
|
||||||
],
|
],
|
||||||
"role": [
|
"role": [
|
||||||
{"state": "account.role.card.basicData", "icon": "settings"},
|
{"state": "account.role.card.basicData", "icon": "settings"},
|
||||||
|
@ -99,6 +100,13 @@
|
||||||
"description": "Mail aliases",
|
"description": "Mail aliases",
|
||||||
"acl": ["marketing", "hr"]
|
"acl": ["marketing", "hr"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"url": "/privileges",
|
||||||
|
"state": "account.card.privileges",
|
||||||
|
"component": "vn-user-privileges",
|
||||||
|
"description": "Privileges",
|
||||||
|
"acl": ["hr"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"url": "/role?q",
|
"url": "/role?q",
|
||||||
"state": "account.role",
|
"state": "account.role",
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
const {Report, Email, smtp} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('claimPickupEmail', {
|
Self.remoteMethodCtx('claimPickupEmail', {
|
||||||
description: 'Sends the the claim pickup order email with an attached PDF',
|
description: 'Sends the the claim pickup order email with an attached PDF',
|
||||||
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
arg: 'id',
|
arg: 'id',
|
||||||
|
@ -40,7 +41,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.claimPickupEmail = async(ctx, id) => {
|
Self.claimPickupEmail = async ctx => {
|
||||||
const args = Object.assign({}, ctx.args);
|
const args = Object.assign({}, ctx.args);
|
||||||
const params = {
|
const params = {
|
||||||
recipient: args.recipient,
|
recipient: args.recipient,
|
||||||
|
|
|
@ -18,43 +18,43 @@ module.exports = Self => {
|
||||||
Self.consumptionSendQueued = async() => {
|
Self.consumptionSendQueued = async() => {
|
||||||
const queues = await Self.rawSql(`
|
const queues = await Self.rawSql(`
|
||||||
SELECT
|
SELECT
|
||||||
ccq.id,
|
id,
|
||||||
|
params
|
||||||
|
FROM clientConsumptionQueue
|
||||||
|
WHERE status = ''`);
|
||||||
|
|
||||||
|
for (const queue of queues) {
|
||||||
|
try {
|
||||||
|
const params = JSON.parse(queue.params);
|
||||||
|
|
||||||
|
const clients = await Self.rawSql(`
|
||||||
|
SELECT
|
||||||
c.id AS clientFk,
|
c.id AS clientFk,
|
||||||
c.email AS clientEmail,
|
c.email AS clientEmail,
|
||||||
eu.email salesPersonEmail,
|
eu.email salesPersonEmail
|
||||||
REPLACE(json_extract(params, '$.from'), '"', '') AS fromDate,
|
FROM client c
|
||||||
REPLACE(json_extract(params, '$.to'), '"', '') AS toDate
|
|
||||||
FROM clientConsumptionQueue ccq
|
|
||||||
JOIN client c ON (
|
|
||||||
JSON_SEARCH(
|
|
||||||
JSON_ARRAY(
|
|
||||||
json_extract(params, '$.clients')
|
|
||||||
)
|
|
||||||
, 'all', c.id) IS NOT NULL)
|
|
||||||
JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||||
JOIN ticket t ON t.clientFk = c.id
|
JOIN ticket t ON t.clientFk = c.id
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
WHERE status = ''
|
WHERE c.id IN(?)
|
||||||
AND it.isPackaging = FALSE
|
AND it.isPackaging = FALSE
|
||||||
AND DATE(t.shipped) BETWEEN
|
AND DATE(t.shipped) BETWEEN ? AND ?
|
||||||
REPLACE(json_extract(params, '$.from'), '"', '') AND
|
GROUP BY c.id`, [params.clients, params.from, params.to]);
|
||||||
REPLACE(json_extract(params, '$.to'), '"', '')
|
|
||||||
GROUP BY c.id`);
|
|
||||||
|
|
||||||
for (const queue of queues) {
|
for (const client of clients) {
|
||||||
try {
|
|
||||||
const args = {
|
const args = {
|
||||||
id: queue.clientFk,
|
id: client.clientFk,
|
||||||
recipient: queue.clientEmail,
|
recipient: client.clientEmail,
|
||||||
replyTo: queue.salesPersonEmail,
|
replyTo: client.salesPersonEmail,
|
||||||
from: queue.fromDate,
|
from: params.from,
|
||||||
to: queue.toDate
|
to: params.to
|
||||||
};
|
};
|
||||||
|
|
||||||
const email = new Email('campaign-metrics', args);
|
const email = new Email('campaign-metrics', args);
|
||||||
await email.send();
|
await email.send();
|
||||||
|
}
|
||||||
|
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE clientConsumptionQueue
|
UPDATE clientConsumptionQueue
|
||||||
|
@ -69,7 +69,7 @@ module.exports = Self => {
|
||||||
WHERE id = ?`,
|
WHERE id = ?`,
|
||||||
[error.message, queue.id]);
|
[error.message, queue.id]);
|
||||||
|
|
||||||
throw e;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,15 +77,16 @@ export default class Controller extends Section {
|
||||||
|
|
||||||
onSendClientConsumption() {
|
onSendClientConsumption() {
|
||||||
const clientIds = this.checked.map(client => client.id);
|
const clientIds = this.checked.map(client => client.id);
|
||||||
const params = {
|
const data = {
|
||||||
clients: clientIds,
|
clients: clientIds,
|
||||||
from: this.campaign.from,
|
from: this.campaign.from,
|
||||||
to: this.campaign.to
|
to: this.campaign.to
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const params = JSON.stringify(data);
|
||||||
this.$http.post('ClientConsumptionQueues', {params})
|
this.$http.post('ClientConsumptionQueues', {params})
|
||||||
.then(() => this.$.filters.hide())
|
.then(() => this.$.filters.hide())
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('Notifications sent!')));
|
.then(() => this.vnApp.showSuccess(this.$t('Notification sent!')));
|
||||||
}
|
}
|
||||||
|
|
||||||
exprBuilder(param, value) {
|
exprBuilder(param, value) {
|
||||||
|
|
|
@ -69,15 +69,16 @@ describe('Client notification', () => {
|
||||||
data[0].$checked = true;
|
data[0].$checked = true;
|
||||||
data[1].$checked = true;
|
data[1].$checked = true;
|
||||||
|
|
||||||
const params = Object.assign({
|
const args = Object.assign({
|
||||||
clients: [1101, 1102]
|
clients: [1101, 1102]
|
||||||
}, controller.campaign);
|
}, controller.campaign);
|
||||||
|
const params = JSON.stringify(args);
|
||||||
|
|
||||||
$httpBackend.expect('POST', `ClientConsumptionQueues`, {params}).respond(200, params);
|
$httpBackend.expect('POST', `ClientConsumptionQueues`, {params}).respond(200, params);
|
||||||
controller.onSendClientConsumption();
|
controller.onSendClientConsumption();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Notifications sent!');
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Notification sent!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Controller extends Section {
|
||||||
if (this.$params.warehouseFk)
|
if (this.$params.warehouseFk)
|
||||||
this.warehouseFk = this.$params.warehouseFk;
|
this.warehouseFk = this.$params.warehouseFk;
|
||||||
else if (value)
|
else if (value)
|
||||||
this.warehouseFk = value.itemType.warehouseFk;
|
this.warehouseFk = this.vnConfig.warehouseFk;
|
||||||
|
|
||||||
if (this.$params.lineFk)
|
if (this.$params.lineFk)
|
||||||
this.lineFk = this.$params.lineFk;
|
this.lineFk = this.$params.lineFk;
|
||||||
|
|
|
@ -19,7 +19,8 @@ describe('Item', () => {
|
||||||
describe('set item()', () => {
|
describe('set item()', () => {
|
||||||
it('should set warehouseFk property based on itemType warehouseFk', () => {
|
it('should set warehouseFk property based on itemType warehouseFk', () => {
|
||||||
jest.spyOn(controller.$, '$applyAsync');
|
jest.spyOn(controller.$, '$applyAsync');
|
||||||
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
controller.vnConfig = {warehouseFk: 1};
|
||||||
|
controller.item = {id: 1};
|
||||||
|
|
||||||
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
|
@ -211,7 +211,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN province p ON p.id = a.provinceFk
|
LEFT JOIN province p ON p.id = a.provinceFk
|
||||||
LEFT JOIN warehouse w ON w.id = t.warehouseFk
|
LEFT JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||||
STRAIGHT_JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
LEFT JOIN state st ON st.id = ts.stateFk
|
LEFT JOIN state st ON st.id = ts.stateFk
|
||||||
LEFT JOIN client c ON c.id = t.clientFk
|
LEFT JOIN client c ON c.id = t.clientFk
|
||||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||||
|
|
|
@ -3,6 +3,7 @@ const {Email} = require('vn-print');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('driverRouteEmail', {
|
Self.remoteMethodCtx('driverRouteEmail', {
|
||||||
description: 'Sends the driver route email with an attached PDF',
|
description: 'Sends the driver route email with an attached PDF',
|
||||||
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
arg: 'id',
|
arg: 'id',
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('getItemTypeWorker', {
|
||||||
|
description: 'Returns the workers that appear in itemType',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'Object',
|
||||||
|
description: 'Filter defining where and paginated data',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getItemTypeWorker`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getItemTypeWorker = async(ctx, filter, options) => {
|
||||||
|
const myOptions = {};
|
||||||
|
const conn = Self.dataSource.connector;
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const query =
|
||||||
|
`SELECT DISTINCT u.id, u.nickname
|
||||||
|
FROM itemType it
|
||||||
|
JOIN worker w ON w.id = it.workerFk
|
||||||
|
JOIN account.user u ON u.id = w.id`;
|
||||||
|
|
||||||
|
let stmt = new ParameterizedSQL(query);
|
||||||
|
|
||||||
|
if (filter.where) {
|
||||||
|
const value = filter.where.firstName;
|
||||||
|
const myFilter = {
|
||||||
|
where: {or: [
|
||||||
|
{'w.firstName': {like: `%${value}%`}},
|
||||||
|
{'w.lastName': {like: `%${value}%`}},
|
||||||
|
{'u.name': {like: `%${value}%`}},
|
||||||
|
{'u.nickname': {like: `%${value}%`}}
|
||||||
|
]}
|
||||||
|
};
|
||||||
|
|
||||||
|
stmt.merge(conn.makeSuffix(myFilter));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
return conn.executeStmt(stmt);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,21 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('ticket-request getItemTypeWorker()', () => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 18}}};
|
||||||
|
|
||||||
|
it('should return the buyer as result', async() => {
|
||||||
|
const filter = {where: {firstName: 'buyer'}};
|
||||||
|
|
||||||
|
const result = await models.TicketRequest.getItemTypeWorker(ctx, filter);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the workers at itemType as result', async() => {
|
||||||
|
const filter = {};
|
||||||
|
|
||||||
|
const result = await models.TicketRequest.getItemTypeWorker(ctx, filter);
|
||||||
|
|
||||||
|
expect(result.length).toBeGreaterThan(1);
|
||||||
|
});
|
||||||
|
});
|
|
@ -18,6 +18,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.closeAll = async() => {
|
Self.closeAll = async() => {
|
||||||
const toDate = new Date();
|
const toDate = new Date();
|
||||||
|
toDate.setHours(0, 0, 0, 0);
|
||||||
toDate.setDate(toDate.getDate() - 1);
|
toDate.setDate(toDate.getDate() - 1);
|
||||||
|
|
||||||
const todayMinDate = new Date();
|
const todayMinDate = new Date();
|
||||||
|
|
|
@ -101,6 +101,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) {
|
||||||
if (firstOrder == 1) {
|
if (firstOrder == 1) {
|
||||||
const args = {
|
const args = {
|
||||||
id: ticket.clientFk,
|
id: ticket.clientFk,
|
||||||
|
companyId: ticket.companyFk,
|
||||||
recipientId: ticket.clientFk,
|
recipientId: ticket.clientFk,
|
||||||
recipient: ticket.recipient,
|
recipient: ticket.recipient,
|
||||||
replyTo: ticket.salesPersonEmail
|
replyTo: ticket.salesPersonEmail
|
||||||
|
@ -109,7 +110,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) {
|
||||||
const email = new Email('incoterms-authorization', args);
|
const email = new Email('incoterms-authorization', args);
|
||||||
await email.send();
|
await email.send();
|
||||||
|
|
||||||
const sample = await Self.rawSql(
|
const [sample] = await Self.rawSql(
|
||||||
`SELECT id
|
`SELECT id
|
||||||
FROM sample
|
FROM sample
|
||||||
WHERE code = 'incoterms-authorization'
|
WHERE code = 'incoterms-authorization'
|
||||||
|
|
|
@ -126,8 +126,7 @@ module.exports = Self => {
|
||||||
myOptions);
|
myOptions);
|
||||||
|
|
||||||
if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) {
|
if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) {
|
||||||
const error = `You don't have privileges to change the zone or
|
const error = `You don't have privileges to change the zone`;
|
||||||
for these parameters there are more than one shipping options, talk to agencies`;
|
|
||||||
|
|
||||||
throw new UserError(error);
|
throw new UserError(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,7 @@ module.exports = Self => {
|
||||||
myOptions);
|
myOptions);
|
||||||
|
|
||||||
if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) {
|
if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) {
|
||||||
const error = `You don't have privileges to change the zone or
|
const error = `You don't have privileges to change the zone`;
|
||||||
for these parameters there are more than one shipping options, talk to agencies`;
|
|
||||||
|
|
||||||
throw new UserError(error);
|
throw new UserError(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket-request/filter')(Self);
|
require('../methods/ticket-request/filter')(Self);
|
||||||
require('../methods/ticket-request/deny')(Self);
|
require('../methods/ticket-request/deny')(Self);
|
||||||
require('../methods/ticket-request/confirm')(Self);
|
require('../methods/ticket-request/confirm')(Self);
|
||||||
|
require('../methods/ticket-request/getItemTypeWorker')(Self);
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx) {
|
Self.observe('before save', async function(ctx) {
|
||||||
if (ctx.isNewInstance) {
|
if (ctx.isNewInstance) {
|
||||||
|
|
|
@ -18,9 +18,8 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Buyer"
|
label="Buyer"
|
||||||
ng-model="$ctrl.ticketRequest.attenderFk"
|
ng-model="$ctrl.ticketRequest.attenderFk"
|
||||||
url="Workers/activeWithRole"
|
url="TicketRequests/getItemTypeWorker"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
where="{role: {inq: ['logistic', 'buyer']}}"
|
|
||||||
search-function="{firstName: $search}">
|
search-function="{firstName: $search}">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -42,10 +42,10 @@
|
||||||
<th field="id" shrink>
|
<th field="id" shrink>
|
||||||
<span translate>Id</span>
|
<span translate>Id</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="cargoSupplierFk" expand>
|
<th field="cargoSupplierFk">
|
||||||
<span translate>Supplier</span>
|
<span translate>Supplier</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="agencyModeFk" expand>
|
<th field="agencyModeFk">
|
||||||
<span translate>Agency</span>
|
<span translate>Agency</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="ref">
|
<th field="ref">
|
||||||
|
@ -100,37 +100,37 @@
|
||||||
{{::travel.id}}
|
{{::travel.id}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td expand vn-click-stop>
|
<td class="multi-line" vn-click-stop>
|
||||||
<span
|
<span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="supplierDescriptor.show($event, travel.cargoSupplierFk)">
|
ng-click="supplierDescriptor.show($event, travel.cargoSupplierFk)">
|
||||||
{{::travel.cargoSupplierNickname}}
|
{{::travel.cargoSupplierNickname}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td expand>{{::travel.agencyModeName}}</td>
|
<td>{{::travel.agencyModeName}}</td>
|
||||||
<td
|
<td vn-click-stop>
|
||||||
name="reference"
|
<vn-td-editable name="reference" expand>
|
||||||
expand
|
<text>{{travel.ref}}</text>
|
||||||
vn-click-stop>
|
<field>
|
||||||
<vn-textfield
|
<vn-textfield class="dense" vn-focus
|
||||||
class="dense td-editable"
|
|
||||||
ng-model="travel.ref"
|
ng-model="travel.ref"
|
||||||
on-change="$ctrl.save(travel.id, {ref: value})">
|
on-change="$ctrl.save(travel.id, {ref: value})">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-icon>
|
</field>
|
||||||
|
</vn-td-editable>
|
||||||
</td>
|
</td>
|
||||||
<td number>{{::travel.stickers}}</td>
|
<td number>{{::travel.stickers}}</td>
|
||||||
<td
|
<td vn-click-stop>
|
||||||
name="lockedKg"
|
<vn-td-editable name="lockedKg" expand style="text-align: right">
|
||||||
expand
|
<text number>{{travel.kg}}</text>
|
||||||
vn-click-stop>
|
<field>
|
||||||
<vn-input-number
|
<vn-input-number class="dense" vn-focus
|
||||||
number
|
|
||||||
class="td-editable number"
|
|
||||||
ng-model="travel.kg"
|
ng-model="travel.kg"
|
||||||
on-change="$ctrl.save(travel.id, {kg: value})"
|
on-change="$ctrl.save(travel.id, {kg: value})"
|
||||||
min="0">
|
min="0">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
|
</field>
|
||||||
|
</vn-td-editable>
|
||||||
</td>
|
</td>
|
||||||
<td number>{{::travel.loadedKg}}</td>
|
<td number>{{::travel.loadedKg}}</td>
|
||||||
<td number>{{::travel.volumeKg}}</td>
|
<td number>{{::travel.volumeKg}}</td>
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
{{::entry.id}}
|
{{::entry.id}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="multi-line">
|
||||||
<span
|
<span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="supplierDescriptor.show($event, entry.supplierFk)">
|
ng-click="supplierDescriptor.show($event, entry.supplierFk)">
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td expand>{{::entry.ref}}</td>
|
<td class="td-editable">{{::entry.ref}}</td>
|
||||||
<td number>{{::entry.stickers}}</td>
|
<td number>{{::entry.stickers}}</td>
|
||||||
<td number></td>
|
<td number></td>
|
||||||
<td number>{{::entry.loadedkg}}</td>
|
<td number>{{::entry.loadedkg}}</td>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
vn-travel-extra-community {
|
vn-travel-extra-community {
|
||||||
.header {
|
.header {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
font-size: 1.25rem;
|
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
padding-bottom: 7px;
|
padding-bottom: 7px;
|
||||||
|
@ -16,6 +15,10 @@ vn-travel-extra-community {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
.multi-line{
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table[vn-droppable] {
|
table[vn-droppable] {
|
||||||
|
@ -29,10 +32,10 @@ vn-travel-extra-community {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
height: 65px;
|
height: 65px;
|
||||||
pointer-events: fill;
|
pointer-events: fill;
|
||||||
user-select:all;
|
user-select: all;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr[draggable] *::selection{
|
tr[draggable] *::selection {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,16 +46,22 @@ vn-travel-extra-community {
|
||||||
tr[draggable].dragging {
|
tr[draggable].dragging {
|
||||||
background-color: $color-primary-light;
|
background-color: $color-primary-light;
|
||||||
color: $color-font-light;
|
color: $color-font-light;
|
||||||
font-weight:bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.td-editable{
|
|
||||||
input{
|
.multi-line{
|
||||||
font-size: 1.25rem!important;
|
max-width: 200px;
|
||||||
}
|
word-wrap: normal;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.number *{
|
vn-td-editable text {
|
||||||
text-align: right;
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px dashed $color-active;
|
||||||
|
border-radius: 0;
|
||||||
|
color: $color-active
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const leaves = map.get(parentId);
|
const leaves = map.get(parentId);
|
||||||
|
|
||||||
|
const maxNodes = 250;
|
||||||
|
if (res.length <= maxNodes)
|
||||||
setLeaves(leaves);
|
setLeaves(leaves);
|
||||||
|
|
||||||
return leaves || [];
|
return leaves || [];
|
||||||
|
|
Loading…
Reference in New Issue