update estate without model.refresh()
This commit is contained in:
parent
edea60dd94
commit
4d97357213
|
@ -14,7 +14,7 @@ module.exports = Self => {
|
|||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'string',
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
|
|
@ -6,13 +6,13 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'ticketIds',
|
||||
description: 'the array of ticket ids to set as delivered',
|
||||
type: [],
|
||||
type: ['Number'],
|
||||
required: true,
|
||||
http: {source: 'body'}
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'string',
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -25,7 +25,12 @@ module.exports = Self => {
|
|||
let userId = ctx.req.accessToken.userId;
|
||||
let models = Self.app.models;
|
||||
|
||||
let state = await models.State.findOne({where: {code: 'delivered'}, fields: ['id']});
|
||||
let state = await models.State.findOne({
|
||||
where: {
|
||||
code: 'delivered'
|
||||
},
|
||||
fields: ['id', 'name', 'alertLevel', 'code']
|
||||
});
|
||||
|
||||
let worker = await models.Worker.findOne({where: {userFk: userId}});
|
||||
|
||||
|
@ -38,7 +43,8 @@ module.exports = Self => {
|
|||
});
|
||||
promises.push(promise);
|
||||
}
|
||||
await Promise.all(promises);
|
||||
|
||||
return Promise.all(promises);
|
||||
return state;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -23,18 +23,14 @@ describe('ticket setDelivered()', () => {
|
|||
done();
|
||||
});
|
||||
|
||||
it('should return an array of the tickets states changed to delivered', async() => {
|
||||
it('should return the state which has been applied to the given tickets', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 49}}};
|
||||
let delivered = await app.models.State.findOne({where: {code: 'delivered'}, fields: ['id']});
|
||||
|
||||
let params = [ticketOne.id, ticketTwo.id];
|
||||
let res = await app.models.TicketTracking.setDelivered(ctx, params);
|
||||
let state = await app.models.TicketTracking.setDelivered(ctx, params);
|
||||
|
||||
expect(res[0].ticketFk).toEqual(ticketOne.id);
|
||||
expect(res[0].stateFk).toEqual(delivered.id);
|
||||
|
||||
expect(res[1].ticketFk).toEqual(ticketTwo.id);
|
||||
expect(res[1].stateFk).toEqual(delivered.id);
|
||||
expect(state.id).toEqual(delivered.id);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<vn-td class="expendable">{{::ticket.province}}</vn-td>
|
||||
<vn-td>
|
||||
<span class="chip {{$ctrl.stateColor(ticket)}}">
|
||||
{{::ticket.state}}
|
||||
{{ticket.state}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::ticket.agencyMode}}</vn-td>
|
||||
|
|
|
@ -11,9 +11,15 @@ export default class Controller extends Section {
|
|||
for (let ticket of checkedTickets)
|
||||
ids.push(ticket.id);
|
||||
|
||||
this.$http.post('TicketTrackings/setDelivered', ids).then(() => {
|
||||
this.$http.post('TicketTrackings/setDelivered', ids).then(res => {
|
||||
let state = res.data;
|
||||
for (let ticket of checkedTickets) {
|
||||
ticket.stateFk = state.id;
|
||||
ticket.state = state.name;
|
||||
ticket.alertLevel = state.alertLevel;
|
||||
ticket.alertLevelCode = state.code;
|
||||
}
|
||||
this.openDeliveryNotes(ids);
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue