Merge pull request 'fixes #5235 Error mensaje: Cambios sin guardar' (!1342) from 5235-cambios-sin-guardar into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1342 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
4de49a9155
|
@ -5,10 +5,6 @@ import './style.scss';
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $, vnEmail) {
|
constructor($element, $, vnEmail) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this.clientSample = {
|
|
||||||
clientFk: this.$params.id,
|
|
||||||
companyId: this.vnConfig.companyFk
|
|
||||||
};
|
|
||||||
this.vnEmail = vnEmail;
|
this.vnEmail = vnEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +15,8 @@ class Controller extends Section {
|
||||||
set client(value) {
|
set client(value) {
|
||||||
this._client = value;
|
this._client = value;
|
||||||
|
|
||||||
if (value) {
|
if (value)
|
||||||
this.clientSample.recipient = value.email;
|
this.setClientSample(value);
|
||||||
this.getWorkerEmail();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get companyId() {
|
get companyId() {
|
||||||
|
@ -119,12 +113,17 @@ class Controller extends Section {
|
||||||
.then(() => this.$state.go('client.card.sample.index'));
|
.then(() => this.$state.go('client.card.sample.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
getWorkerEmail() {
|
setClientSample(client) {
|
||||||
const userId = window.localStorage.currentUserWorkerId;
|
const userId = window.localStorage.currentUserWorkerId;
|
||||||
const params = {filter: {where: {userFk: userId}}};
|
const params = {filter: {where: {userFk: userId}}};
|
||||||
this.$http.get('EmailUsers', params).then(res => {
|
this.$http.get('EmailUsers', params).then(res => {
|
||||||
const [worker] = res && res.data;
|
const [worker] = res && res.data;
|
||||||
this.clientSample.replyTo = worker.email;
|
this.clientSample = {
|
||||||
|
clientFk: this.$params.id,
|
||||||
|
companyId: this.vnConfig.companyFk,
|
||||||
|
recipient: client.email,
|
||||||
|
replyTo: worker.email
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,15 +191,19 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getWorkerEmail()', () => {
|
describe('setClientSample()', () => {
|
||||||
it(`should perform a query and then set the replyTo property to the clientSample object`, () => {
|
it(`should perform a query and then set the replyTo property to the clientSample object`, () => {
|
||||||
|
const client = {email: 'test@example.com'};
|
||||||
const expectedEmail = 'batman@arkhamcity.com';
|
const expectedEmail = 'batman@arkhamcity.com';
|
||||||
const serializedParams = $httpParamSerializer({filter: {where: {}}});
|
const serializedParams = $httpParamSerializer({filter: {where: {}}});
|
||||||
$httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]);
|
$httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]);
|
||||||
controller.getWorkerEmail();
|
controller.setClientSample(client);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.clientSample.replyTo).toEqual(expectedEmail);
|
expect(controller.clientSample.replyTo).toEqual(expectedEmail);
|
||||||
|
expect(controller.clientSample.clientFk).toEqual(controller.$params.id);
|
||||||
|
expect(controller.clientSample.recipient).toEqual(client.email);
|
||||||
|
expect(controller.clientSample.companyId).toEqual(controller.vnConfig.companyFk);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue