@@ -603,6 +603,7 @@ const handleUndoAction = (action, stages) => (dispatch, getState) => {
603
603
dispatch ( handleCompoundAction ( action , true ) ) ;
604
604
break ;
605
605
case actionType . REPRESENTATION_CHANGED :
606
+ dispatch ( handleChangeRepresentationAction ( action , false , majorView ) ) ;
606
607
break ;
607
608
case actionType . REPRESENTATION_ADDED :
608
609
dispatch ( handleRepresentationAction ( action , false , majorView ) ) ;
@@ -685,6 +686,7 @@ const handleRedoAction = (action, stages) => (dispatch, getState) => {
685
686
dispatch ( handleCompoundAction ( action , false ) ) ;
686
687
break ;
687
688
case actionType . REPRESENTATION_CHANGED :
689
+ dispatch ( handleChangeRepresentationAction ( action , true , majorView ) ) ;
688
690
break ;
689
691
case actionType . REPRESENTATION_ADDED :
690
692
dispatch ( handleRepresentationAction ( action , true , majorView ) ) ;
@@ -728,12 +730,12 @@ const handleCompoundAction = (action, isSelected) => (dispatch, getState) => {
728
730
} ;
729
731
730
732
const handleShoppingCartAction = ( action , isAdd ) => ( dispatch , getState ) => {
731
- const state = getState ( ) ;
732
733
if ( action ) {
734
+ let data = action . item ;
733
735
if ( isAdd ) {
734
- // dispatch(appendToBuyList(data));
736
+ dispatch ( appendToBuyList ( data ) ) ;
735
737
} else {
736
- // dispatch(removeFromToBuyList(data));
738
+ dispatch ( removeFromToBuyList ( data ) ) ;
737
739
}
738
740
}
739
741
} ;
@@ -752,7 +754,6 @@ const addRepresentation = (parentKey, representation, nglView) => (dispatch, get
752
754
const oldRepresentation = representation ;
753
755
const newRepresentationType = oldRepresentation . type ;
754
756
const comp = nglView . stage . getComponentsByName ( parentKey ) . first ;
755
- // add representation to NGL
756
757
const newRepresentation = assignRepresentationToComp (
757
758
newRepresentationType ,
758
759
oldRepresentation . params ,
@@ -762,6 +763,26 @@ const addRepresentation = (parentKey, representation, nglView) => (dispatch, get
762
763
dispatch ( addComponentRepresentation ( parentKey , newRepresentation ) ) ;
763
764
} ;
764
765
766
+ const handleChangeRepresentationAction = ( action , isAdd , nglView ) => ( dispatch , getState ) => {
767
+ if ( action ) {
768
+ dispatch ( changeRepresentation ( isAdd , action . change , action . object_id , action . representation , nglView ) ) ;
769
+ }
770
+ } ;
771
+
772
+ const changeRepresentation = ( isAdd , change , parentKey , representation , nglView ) => ( dispatch , getState ) => {
773
+ const comp = nglView . stage . getComponentsByName ( parentKey ) . first ;
774
+ const r = comp . reprList . find ( rep => rep . uuid === representation . uuid || rep . uuid === representation . lastKnownID ) ;
775
+ if ( r && change ) {
776
+ let key = change . key ;
777
+ let value = isAdd ? change . value : change . oldValue ;
778
+
779
+ r . setParameters ( { [ key ] : value } ) ;
780
+ representation . params [ key ] = value ;
781
+
782
+ dispatch ( updateComponentRepresentation ( parentKey , representation . uuid , representation ) ) ;
783
+ }
784
+ } ;
785
+
765
786
const removeRepresentation = ( parentKey , representation , nglView ) => ( dispatch , getState ) => {
766
787
const comp = nglView . stage . getComponentsByName ( parentKey ) . first ;
767
788
let foundedRepresentation = undefined ;
0 commit comments