File tree Expand file tree Collapse file tree 8 files changed +88
-22
lines changed
Expand file tree Collapse file tree 8 files changed +88
-22
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,10 @@ class Menu extends React.Component {
4646
4747
4848 < IndexLink to = { Uris . SELL_INVENTORY_TRACK . CREATE } activeClassName = "active"
49- className = "list-group-item" > Sell Inventory Relation</ IndexLink >
49+ className = "list-group-item" > Create Sell Inventory Relation</ IndexLink >
50+
51+ < IndexLink to = { Uris . SELL_INVENTORY_TRACK . BASE } activeClassName = "active"
52+ className = "list-group-item" > Sell Inventory Relations</ IndexLink >
5053
5154 </ div >
5255
Original file line number Diff line number Diff line change @@ -146,8 +146,6 @@ var AddRemoveEditProducts = React.createClass({
146146
147147 < TableHeaderColumn dataField = "name" dataFormat = { $this . formatName } > Name</ TableHeaderColumn >
148148 < TableHeaderColumn dataField = "quantity" > Quantity</ TableHeaderColumn >
149- < TableHeaderColumn dataField = "added" > Added</ TableHeaderColumn >
150- < TableHeaderColumn dataField = "removed" > Removed</ TableHeaderColumn >
151149 < TableHeaderColumn dataField = "unitId" dataFormat = { $this . formatUnit } > Unit</ TableHeaderColumn >
152150 < TableHeaderColumn dataField = "action" dataFormat = { $this . formatAction } > Action</ TableHeaderColumn >
153151 </ BootstrapTable >
Original file line number Diff line number Diff line change @@ -113,12 +113,6 @@ module.exports = ListInventories = React.createClass({
113113 Add/Remove/Edit Products
114114 </ a >
115115
116- < a href = { Uris . toAbsoluteUri ( Uris . INVENTORY . VIEW , { id : inventory . id } ) }
117- className = "btn btn-success"
118- style = { { marginRight : '5px' } } title = "View this inventory." >
119- View
120- </ a >
121-
122116 {
123117 auth . currentUser ( ) . username != "admin" ? null : (
124118 < span className = "btn btn-danger" title = "Delete this inventory."
Original file line number Diff line number Diff line change @@ -37,9 +37,7 @@ module.exports = ProductList = React.createClass({
3737 < TableHeaderColumn dataField = "forSale"
3838 dataFormat = { forSale => ! ! forSale ? 'Yes' : 'No' } >
3939 For Sale</ TableHeaderColumn >
40-
41- < TableHeaderColumn dataField = "inventories" dataFormat = { $this . formatInventories } >
42- Inventory</ TableHeaderColumn >
40+
4341 < TableHeaderColumn dataField = "sku" > SKU</ TableHeaderColumn >
4442 < TableHeaderColumn dataField = "remarks" > Remarks</ TableHeaderColumn >
4543 < TableHeaderColumn dataField = "action" dataFormat = { $this . formatAction } > Action</ TableHeaderColumn >
Original file line number Diff line number Diff line change 22
33import React from 'react' ;
44var ProductDependencyList = require ( './ProductDependencyList' ) ;
5+ var trkSv = require ( './TrackService' ) ;
6+ var productService = require ( '../product/ProductService' ) ;
7+ var Promise = require ( 'bluebird' ) ;
58
69class ListTrack extends React . Component {
710 constructor ( props ) {
@@ -12,6 +15,58 @@ class ListTrack extends React.Component {
1215 products : [ ] ,
1316 productsById : { } ,
1417 } ;
18+ this . componentDidMount . bind ( this ) ;
19+ }
20+
21+ componentDidMount ( ) {
22+ var $this = this ;
23+
24+ var arr = [ ] ;
25+
26+ arr . push (
27+ trkSv . findAll ( )
28+ . then ( rsp => {
29+ return {
30+ tracks : rsp . data ,
31+ tracksByProductId : rsp . data
32+ . reduce ( ( map , track ) => {
33+
34+ var kk = map [ track . productId ] || [ ] ;
35+
36+ kk . push ( track ) ;
37+
38+ map [ track . productId ] = kk ;
39+
40+ return map ;
41+ } , { } )
42+ } ;
43+ } ) )
44+ ;
45+
46+ arr . push (
47+ productService . findAllDecomposed ( )
48+ . then ( rsp => {
49+ return {
50+ products : rsp . data ,
51+ productsById : rsp . data . reduce ( ( map , product ) => {
52+ map [ product . id ] = product ;
53+ return map ;
54+ } , { } )
55+ } ;
56+ } )
57+ )
58+
59+ Promise . all ( arr )
60+ . then ( states => {
61+ return states . reduce ( ( map , state ) => {
62+ for ( var x in state ) {
63+ map [ x ] = state [ x ] ;
64+ }
65+ return map ;
66+ } , { } ) ;
67+ } )
68+ . then ( state => $this . setState ( state ) )
69+ ;
1570 }
1671
1772 render ( ) {
Original file line number Diff line number Diff line change 22var Stream = require ( 'streamjs' ) ;
33
44import React from 'react' ;
5+ var Uris = require ( '../Uris' ) ;
56
67class ProductDependencyList extends React . Component {
78 constructor ( props ) {
@@ -15,7 +16,7 @@ class ProductDependencyList extends React.Component {
1516 var products = $this . props . products ;
1617 return (
1718
18- < table class = "table table-condensed" >
19+ < table className = "table table-condensed" >
1920 < thead >
2021 < tr >
2122 < th >
@@ -35,17 +36,22 @@ class ProductDependencyList extends React.Component {
3536 product : productsById [ p . id ] || { }
3637 } ;
3738 } )
39+ . peek ( p => console . log ( "product" , p . name ) )
3840 . filter ( e => ! ! e . tracks . length )
3941 . map ( e => {
4042 const { tracks, product} = e ;
4143 return (
42- < tr >
43- < td > { product . name } </ td >
44+ < tr key = { Math . random ( ) } >
45+ < td >
46+ < a href = { Uris . toAbsoluteUri ( Uris . SELL_INVENTORY_TRACK . UPDATE , { productId : product . id } ) } > { product . name } </ a >
47+ </ td >
4448 < td >
4549 {
4650 tracks . map ( ( tk , idx ) => {
4751 return (
48- tk . name
52+ < span key = { Math . random ( ) } >
53+ { productsById [ tk . inventoryProductId ] . name + ( ( idx === ( tracks . length - 1 ) ) ? '' : ', ' ) }
54+ </ span >
4955 ) ;
5056 } )
5157 }
Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ class TrackService {
4141 create ( tracks ) {
4242 return new Promise ( function ( resolve , reject ) {
4343
44- tracks . forEach ( tk => tk . productId = tk . id ) ;
44+ tracks . forEach ( tk => {
45+ tk . productId = tk . id
46+ delete tk . id ;
47+ } ) ;
4548
4649 console . log ( "SEND." + ServerEvents . CREATE_TRACK , JSON . stringify ( tracks ) ) ;
4750
@@ -64,7 +67,10 @@ class TrackService {
6467
6568 update ( productId , tracks ) {
6669
67- tracks = tracks . forEach ( tk => tk . productId = tk . id ) ;
70+ tracks . forEach ( tk => {
71+ tk . productId = tk . productId || tk . id ;
72+ delete tk . id ;
73+ } ) ;
6874
6975 return new Promise ( function ( resolve , reject ) {
7076
Original file line number Diff line number Diff line change @@ -123,10 +123,16 @@ module.exports = TrackEdit = React.createClass({
123123 ;
124124
125125 arr . push (
126- trkSv . find ( { productId : $this . props . params . productId } )
127- . then ( trks => {
128- return { tracks : trks , productId : $this . props . params . productId } ;
129- } ) )
126+ trkSv . findAll ( { productId : $this . props . params . productId } )
127+ . then ( rsp => {
128+ return {
129+ tracks : rsp . data . map ( tk => {
130+ tk . no = Math . random ( ) ;
131+ tk . id = tk . productId ;
132+ return tk ;
133+ } ) , productId : $this . props . params . productId
134+ } ;
135+ } ) ) ;
130136
131137 Promise . all ( arr )
132138 . then ( list => {
You can’t perform that action at this time.
0 commit comments