Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
Orders
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Vladimir Trubachoff
Orders
Commits
a1c8b5b1
Commit
a1c8b5b1
authored
Jul 01, 2024
by
Vladimir Trubachoff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix modal add product
parent
053afa15
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
37 deletions
+51
-37
add-product-modal.component.html
...onents/add-product-modal/add-product-modal.component.html
+1
-0
add-product-modal.component.ts
...mponents/add-product-modal/add-product-modal.component.ts
+11
-9
order-line-list.component.html
...components/order-line-list/order-line-list.component.html
+1
-1
order-page.component.ts
...n/webapp/src/app/pages/order-page/order-page.component.ts
+38
-27
No files found.
src/main/webapp/src/app/pages/order-page/components/add-product-modal/add-product-modal.component.html
View file @
a1c8b5b1
...
...
@@ -28,6 +28,7 @@
<td>
<input
type=
"number"
min=
"1"
class=
"w-50 form-control"
[
value
]="
productsCount
(
product
.
id
)"
#
count
...
...
src/main/webapp/src/app/pages/order-page/components/add-product-modal/add-product-modal.component.ts
View file @
a1c8b5b1
import
{
Component
,
EventEmitter
,
Input
,
Output
}
from
'@angular/core'
;
import
{
NgbModal
,
NgbModalRef
}
from
'@ng-bootstrap/ng-bootstrap'
;
import
{
Goods
}
from
'../../../../core/model/goods.model'
;
import
{
AbstractBasicComponent
}
from
'../../../../core/abstract/abstract-component'
;
import
{
takeUntil
}
from
'rxjs'
;
import
{
PagedResponseModel
}
from
'../../../../core/model/paged-response.model'
;
import
{
AbstractBasicComponent
}
from
'../../../../core/abstract/abstract-component'
;
import
{
Goods
}
from
'../../../../core/model/goods.model'
;
import
{
Order
}
from
'../../../../core/model/order.model'
;
import
{
PagedResponseModel
}
from
'../../../../core/model/paged-response.model'
;
import
{
UpdateCount
}
from
'../../order-page.component'
;
@
Component
({
...
...
@@ -30,16 +30,18 @@ export class AddProductModalComponent extends AbstractBasicComponent {
});
}
addOrUpdate
(
goods_id
:
number
,
count
:
number
)
{
this
.
orderLineChange
.
emit
({
goods_id
,
count
,
});
addOrUpdate
(
goodsId
:
number
,
count
:
number
)
{
if
(
count
)
{
this
.
orderLineChange
.
emit
({
goodsId
,
count
,
});
}
}
productsCount
(
productId
:
number
):
number
{
return
(
this
.
order
.
orderLines
.
find
((
ol
)
=>
ol
.
goods
.
id
===
productId
)?.
count
??
0
this
.
order
?
.
orderLines
.
find
((
ol
)
=>
ol
.
goods
.
id
===
productId
)?.
count
??
0
);
}
...
...
src/main/webapp/src/app/pages/order-page/components/order-line-list/order-line-list.component.html
View file @
a1c8b5b1
<h3>
Products
</h3>
<h3>
Order
Products
</h3>
<table
class=
"table table-striped"
>
<thead>
<tr>
...
...
src/main/webapp/src/app/pages/order-page/order-page.component.ts
View file @
a1c8b5b1
...
...
@@ -57,38 +57,46 @@ export class OrderPageComponent
ngOnInit
():
void
{
if
(
!
this
.
isNew
)
{
this
.
getData
(
this
.
id
);
this
.
orderService
.
getOrder
(
this
.
id
).
subscribe
({
next
:
(
order
)
=>
{
this
.
orderSubj$
.
next
(
order
);
this
.
order
=
order
;
},
error
:
(
err
)
=>
{
if
(
DEV
)
{
console
.
dir
(
`Error:
${
err
}
`
);
}
},
});
}
}
deleteLine
(
id
:
number
)
{
this
.
orderLineService
.
delete
(
id
).
subscribe
({
next
:
(
res
)
=>
{
this
.
getData
(
this
.
order
.
id
);
},
error
:
(
err
)
=>
{
if
(
DEV
)
{
console
.
dir
(
`Error:
${
err
}
`
);
}
},
});
}
getData
(
id
:
number
)
{
this
.
orderService
.
getOrder
(
id
).
subscribe
((
order
)
=>
{
this
.
order
=
order
;
this
.
orderSubj$
.
next
(
order
);
});
this
.
orderLineService
.
delete
(
id
)
.
pipe
(
concatMap
(()
=>
this
.
orderService
.
getOrder
(
this
.
id
)))
.
subscribe
({
next
:
(
order
:
Order
)
=>
{
this
.
orderSubj$
.
next
(
order
);
this
.
order
=
order
;
},
error
:
(
err
)
=>
{
if
(
DEV
)
{
console
.
dir
(
`Error:
${
err
}
`
);
}
},
});
}
openAddProductModal
():
void
{
const
orderModalRef
=
this
.
modalService
.
open
(
AddProductModalComponent
,
{
size
:
'xl'
,
});
orderModalRef
.
componentInstance
.
order
=
this
.
order
;
this
.
goodsService
.
get
()
.
subscribe
((
resp
)
=>
(
orderModalRef
.
componentInstance
.
goods
=
resp
));
orderModalRef
.
componentInstance
.
order
=
this
.
order
;
orderModalRef
.
componentInstance
.
pageNumber
.
pipe
(
concatMap
((
page
:
number
)
=>
this
.
goodsService
.
get
(
page
)))
.
subscribe
((
resp
:
PagedResponseModel
<
Goods
>
)
=>
{
...
...
@@ -100,26 +108,29 @@ export class OrderPageComponent
takeUntil
(
this
.
destroy$
),
concatMap
((
v
:
UpdateCount
)
=>
{
const
orderLineId
=
this
.
order
.
orderLines
.
find
(
(
ol
)
=>
ol
.
goods
.
id
===
v
.
goods
_i
d
,
(
ol
)
=>
ol
.
goods
.
id
===
v
.
goods
I
d
,
)?.
id
;
if
(
orderLineId
)
{
return
this
.
orderLineService
.
put
({
id
:
orderLineId
,
order
_i
d
:
this
.
order
.
id
,
goods
_id
:
v
.
goods_i
d
,
order
I
d
:
this
.
order
.
id
,
goods
Id
:
v
.
goodsI
d
,
count
:
v
.
count
,
});
}
return
this
.
orderLineService
.
post
({
order
_i
d
:
this
.
order
.
id
,
goods
_id
:
v
.
goods_i
d
,
order
I
d
:
this
.
order
.
id
,
goods
Id
:
v
.
goodsI
d
,
count
:
v
.
count
,
});
}),
concatMap
(()
=>
this
.
orderService
.
getOrder
(
this
.
id
)),
)
.
subscribe
({
next
:
(
res
:
any
)
=>
{
this
.
getData
(
this
.
order
.
id
);
next
:
(
order
:
Order
)
=>
{
this
.
orderSubj$
.
next
(
order
);
this
.
order
=
order
;
orderModalRef
.
componentInstance
.
order
=
this
.
order
;
},
error
:
(
err
:
any
)
=>
{
if
(
DEV
)
{
...
...
@@ -135,6 +146,6 @@ export class OrderPageComponent
}
export
interface
UpdateCount
{
goods
_i
d
:
number
;
goods
I
d
:
number
;
count
:
number
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment