Used libraries
core, jsonapi, jsonapi-angular, utils
Library version(s)
"@datx/core": "^2.4.12", "@datx/jsonapi": "^2.4.12", "@datx/jsonapi-angular": "^2.4.12", "@datx/utils": "^2.4.8",
Sample API response (if relevant)
Request objects
{
"data": {
"attributes": {
"created_at": "2023-01-30T13:48:37.000Z"
},
"id": "130",
"type": "order-lines",
"relationships": {
"product": {
"data": {
"id": "166",
"type": "products"
}
}
}
}
}
{
"data": {
"attributes": {
"created_at": "2023-01-30T13:48:37.000Z"
},
"id": "129",
"type": "order-lines",
"relationships": {
"product": {
"data": {
"id": "74",
"type": "products"
}
}
}
}
}
Environments with the issue
Chrome 109.0.5414.74, Ubuntu 22.04.1 LTS
Environments without the issue
No response
Current behavior
public persistOrder(): void {
if (!this.isAbleToPersist()) {
return;
}
const requestOptions = {
queryParams: {
include: 'order-lines.product'
}
} as IRequestOptions;
const order = this.conceptOrder.value;
order.status = OrderStatus.CONCEPT;
order.retrieveAt = this.orderFormGroup.get('retrieveAt').value;
order.reference = this.orderFormGroup.get('reference').value;
this.orderPersistSubscription = order.save(requestOptions).pipe(
mergeMap((persistedOrder: Order) => {
console.log(persistedOrder.orderLines.map((orderLine: OrderLine) => orderLine.position)); // This is line 163
const obs = this.updateOrderLines(persistedOrder);
console.log(persistedOrder.orderLines.map((orderLine: OrderLine) => orderLine.position)); // This is line 165
return combineLatest(obs);
}),
).subscribe(() => {
// this.router.navigate(['/orders/concept/list']);
});
}
private updateOrderLines(order: Order): Observable<OrderLine>[] {
const observables = [];
const orderLineControls = (this.orderLineFormGroup.get('orderLines') as FormArray).controls;
orderLineControls.forEach((orderLineFormGroup: FormGroup) => {
if (orderLineFormGroup.pristine) {
return;
}
const orderLine = order.orderLines.find(
(findOrderLine: OrderLine) => findOrderLine.product?.reference === orderLineFormGroup.get('reference').value);
if (!(orderLine instanceof OrderLine)) {
return;
}
console.log(orderLine.position, orderLine.product.reference); // This is line 190
this.updateOrderLine(orderLine, orderLineFormGroup);
console.log(orderLine.position, orderLine.product.reference); /// This is line 192
observables.push(orderLine.save());
});
return observables;
}
private updateOrderLine(orderLine: OrderLine, formGroup: FormGroup): void {
orderLine.update({amount: formGroup.get('amount').value});
orderLine.update({bigbagType: formGroup.get('bigbagType').value});
orderLine.update({hasPallet: formGroup.get('hasPallet').value});
orderLine.update({position: formGroup.get('position').value});
}
logging
concept-order-create.component.ts:163(2) [false, false]
concept-order-create.component.ts:190 false '100123'
concept-order-create.component.ts:192 true '100123'
concept-order-create.component.ts:190 false '100267'
concept-order-create.component.ts:192 false '100267'
concept-order-create.component.ts:165 (2) [true, false]
I'm searching a little bit with the generation of the patch request towards the API
whereas currently it looks like the changes on the object aren't generated into the body of the request.
weirdly when editing the amount property of the orderLine model it does handle properly.
I don't know for sure if it is a bug or support question.
import {BaseModel} from './base-model';
import {Attribute} from '@datx/core';
import {BigbagType} from '../modules/shared/enums/bigbag-type.enum';
import {Product} from './product';
import * as moment from 'moment/moment';
export class OrderLine extends BaseModel {
static type = 'order-lines';
@Attribute() public amount: number;
@Attribute({map: 'bigbag_type'}) public bigbagType: BigbagType;
@Attribute({
map: 'created_at',
parse: (value: string) => value ? moment(value) : null,
serialize: (value: moment.Moment) => value?.toISOString(),
}) public createdAt?: moment.Moment;
@Attribute({map: 'has_pallet'}) public hasPallet: boolean;
@Attribute() public position: number;
@Attribute({toOne: Product}) public product: Product;
}
Expected behavior
Request objects
{
"data": {
"attributes": {
"created_at": "2023-01-30T13:48:37.000Z",
"has_pallet": true
},
"id": "130",
"type": "order-lines",
"relationships": {
"product": {
"data": {
"id": "166",
"type": "products"
}
}
}
}
}
Reproduction steps
I have send most of my code regarding this issue
Used libraries
core, jsonapi, jsonapi-angular, utils
Library version(s)
Sample API response (if relevant)
Request objects
{ "data": { "attributes": { "created_at": "2023-01-30T13:48:37.000Z" }, "id": "130", "type": "order-lines", "relationships": { "product": { "data": { "id": "166", "type": "products" } } } } }{ "data": { "attributes": { "created_at": "2023-01-30T13:48:37.000Z" }, "id": "129", "type": "order-lines", "relationships": { "product": { "data": { "id": "74", "type": "products" } } } } }Environments with the issue
Chrome 109.0.5414.74, Ubuntu 22.04.1 LTS
Environments without the issue
No response
Current behavior
logging
I'm searching a little bit with the generation of the patch request towards the API
whereas currently it looks like the changes on the object aren't generated into the body of the request.
weirdly when editing the amount property of the orderLine model it does handle properly.
I don't know for sure if it is a bug or support question.
Expected behavior
Request objects
{ "data": { "attributes": { "created_at": "2023-01-30T13:48:37.000Z", "has_pallet": true }, "id": "130", "type": "order-lines", "relationships": { "product": { "data": { "id": "166", "type": "products" } } } } }Reproduction steps