@@ -125,7 +125,7 @@ import {
125
125
setInspirationMoleculeDataList
126
126
} from '../../components/datasets/redux/actions' ;
127
127
import { selectVectorAndResetCompounds } from '../../../js/reducers/selection/dispatchActions' ;
128
- import { ActionCreators as UndoActionCreators } from '../../undoredo/actions'
128
+ import { ActionCreators as UndoActionCreators } from '../../undoredo/actions' ;
129
129
130
130
export const addCurrentActionsListToSnapshot = ( snapshot , project , nglViewList ) => async ( dispatch , getState ) => {
131
131
let projectID = project && project . projectID ;
@@ -148,103 +148,6 @@ export const saveCurrentActionsList = (snapshot, project, nglViewList, all = fal
148
148
149
149
const saveActionsList = ( project , snapshot , actionList , nglViewList ) => async ( dispatch , getState ) => {
150
150
const state = getState ( ) ;
151
-
152
- const currentTargetOn = state . apiReducers . target_on ;
153
- const currentSites = state . selectionReducers . mol_group_selection ;
154
- const currentLigands = state . selectionReducers . fragmentDisplayList ;
155
- const currentProteins = state . selectionReducers . proteinList ;
156
- const currentComplexes = state . selectionReducers . complexList ;
157
- const currentSelectionAll = state . selectionReducers . moleculeAllSelection ;
158
-
159
- const currentDatasetLigands = state . datasetsReducers . ligandLists ;
160
- const currentDatasetProteins = state . datasetsReducers . proteinLists ;
161
- const currentDatasetComplexes = state . datasetsReducers . complexLists ;
162
- const currentDatasetSelectionAll = state . datasetsReducers . moleculeAllSelection ;
163
-
164
- const currentTargets = ( currentTargetOn && [ currentTargetOn ] ) || [ ] ;
165
-
166
- let orderedActionList = actionList . reverse ( ( a , b ) => a . timestamp - b . timestamp ) ;
167
-
168
- let currentActions = [ ] ;
169
-
170
- getCurrentActionList ( orderedActionList , actionType . TARGET_LOADED , getCollection ( currentTargets ) , currentActions ) ;
171
- getCurrentActionList ( orderedActionList , actionType . SITE_TURNED_ON , getCollection ( currentSites ) , currentActions ) ;
172
- getCurrentActionList ( orderedActionList , actionType . LIGAND_TURNED_ON , getCollection ( currentLigands ) , currentActions ) ;
173
-
174
- getCurrentActionListOfAllSelection (
175
- orderedActionList ,
176
- actionType . ALL_TURNED_ON ,
177
- getCollection ( currentSelectionAll ) ,
178
- currentActions ,
179
- getCollection ( currentLigands ) ,
180
- getCollection ( currentProteins ) ,
181
- getCollection ( currentComplexes )
182
- ) ;
183
-
184
- getCurrentActionListOfAllSelectionByType (
185
- orderedActionList ,
186
- actionType . ALL_TURNED_ON_BY_TYPE ,
187
- 'ligand' ,
188
- getCollection ( currentLigands ) ,
189
- currentActions
190
- ) ;
191
-
192
- getCurrentActionListOfAllSelectionByType (
193
- orderedActionList ,
194
- actionType . ALL_TURNED_ON_BY_TYPE ,
195
- 'protein' ,
196
- getCollection ( currentProteins ) ,
197
- currentActions
198
- ) ;
199
-
200
- getCurrentActionListOfAllSelectionByType (
201
- orderedActionList ,
202
- actionType . ALL_TURNED_ON_BY_TYPE ,
203
- 'complex' ,
204
- getCollection ( currentComplexes ) ,
205
- currentActions
206
- ) ;
207
-
208
- getCurrentActionListOfAllSelectionByTypeOfDataset (
209
- orderedActionList ,
210
- actionType . ALL_TURNED_ON_BY_TYPE ,
211
- 'ligand' ,
212
- getCollectionOfDataset ( currentDatasetLigands ) ,
213
- currentActions
214
- ) ;
215
-
216
- getCurrentActionListOfAllSelectionByTypeOfDataset (
217
- orderedActionList ,
218
- actionType . ALL_TURNED_ON_BY_TYPE ,
219
- 'protein' ,
220
- getCollectionOfDataset ( currentDatasetProteins ) ,
221
- currentActions
222
- ) ;
223
-
224
- getCurrentActionListOfAllSelectionByTypeOfDataset (
225
- orderedActionList ,
226
- actionType . ALL_TURNED_ON_BY_TYPE ,
227
- 'complex' ,
228
- getCollectionOfDataset ( currentDatasetComplexes ) ,
229
- currentActions
230
- ) ;
231
-
232
- getCurrentActionListOfAllSelection (
233
- orderedActionList ,
234
- actionType . ALL_TURNED_ON ,
235
- getCollectionOfDataset ( currentDatasetSelectionAll ) ,
236
- currentActions ,
237
- getCollectionOfDataset ( currentDatasetLigands ) ,
238
- getCollectionOfDataset ( currentDatasetProteins ) ,
239
- getCollectionOfDataset ( currentDatasetComplexes )
240
- ) ;
241
-
242
- getCurrentActionList (
243
- orderedActionList ,
244
- actionType . SIDECHAINS_TURNED_ON ,
245
- getCollection ( currentProteins ) ,
246
- currentActions
247
- ) ;
248
151
const snapshotID = snapshot && snapshot . id ;
249
152
if ( snapshotID ) {
250
153
const currentTargetOn = state . apiReducers . target_on ;
@@ -264,6 +167,7 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
264
167
const currentDatasetSurfaces = state . datasetsReducers . surfaceLists ;
265
168
const currentDatasetSelectionAll = state . datasetsReducers . moleculeAllSelection ;
266
169
170
+ const showedCompoundList = state . previewReducers . compounds . showedCompoundList ;
267
171
const currentDatasetBuyList = state . datasetsReducers . compoundsToBuyDatasetMap ;
268
172
const currentobjectsInView = state . nglReducers . objectsInView ;
269
173
@@ -278,17 +182,72 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
278
182
getCurrentActionList ( orderedActionList , actionType . SITE_TURNED_ON , getCollection ( currentSites ) , currentActions ) ;
279
183
getCurrentActionList ( orderedActionList , actionType . LIGAND_TURNED_ON , getCollection ( currentLigands ) , currentActions ) ;
280
184
281
- getCurrentActionList (
185
+ getCurrentActionListOfAllSelection (
282
186
orderedActionList ,
283
187
actionType . ALL_TURNED_ON ,
284
188
getCollection ( currentSelectionAll ) ,
189
+ currentActions ,
190
+ getCollection ( currentLigands ) ,
191
+ getCollection ( currentProteins ) ,
192
+ getCollection ( currentComplexes )
193
+ ) ;
194
+
195
+ getCurrentActionListOfAllSelectionByType (
196
+ orderedActionList ,
197
+ actionType . ALL_TURNED_ON_BY_TYPE ,
198
+ 'ligand' ,
199
+ getCollection ( currentLigands ) ,
285
200
currentActions
286
201
) ;
287
- getCurrentActionList (
202
+
203
+ getCurrentActionListOfAllSelectionByType (
204
+ orderedActionList ,
205
+ actionType . ALL_TURNED_ON_BY_TYPE ,
206
+ 'protein' ,
207
+ getCollection ( currentProteins ) ,
208
+ currentActions
209
+ ) ;
210
+
211
+ getCurrentActionListOfAllSelectionByType (
212
+ orderedActionList ,
213
+ actionType . ALL_TURNED_ON_BY_TYPE ,
214
+ 'complex' ,
215
+ getCollection ( currentComplexes ) ,
216
+ currentActions
217
+ ) ;
218
+
219
+ getCurrentActionListOfAllSelectionByTypeOfDataset (
220
+ orderedActionList ,
221
+ actionType . ALL_TURNED_ON_BY_TYPE ,
222
+ 'ligand' ,
223
+ getCollectionOfDataset ( currentDatasetLigands ) ,
224
+ currentActions
225
+ ) ;
226
+
227
+ getCurrentActionListOfAllSelectionByTypeOfDataset (
228
+ orderedActionList ,
229
+ actionType . ALL_TURNED_ON_BY_TYPE ,
230
+ 'protein' ,
231
+ getCollectionOfDataset ( currentDatasetProteins ) ,
232
+ currentActions
233
+ ) ;
234
+
235
+ getCurrentActionListOfAllSelectionByTypeOfDataset (
236
+ orderedActionList ,
237
+ actionType . ALL_TURNED_ON_BY_TYPE ,
238
+ 'complex' ,
239
+ getCollectionOfDataset ( currentDatasetComplexes ) ,
240
+ currentActions
241
+ ) ;
242
+
243
+ getCurrentActionListOfAllSelection (
288
244
orderedActionList ,
289
245
actionType . ALL_TURNED_ON ,
290
246
getCollectionOfDataset ( currentDatasetSelectionAll ) ,
291
- currentActions
247
+ currentActions ,
248
+ getCollectionOfDataset ( currentDatasetLigands ) ,
249
+ getCollectionOfDataset ( currentDatasetProteins ) ,
250
+ getCollectionOfDataset ( currentDatasetComplexes )
292
251
) ;
293
252
294
253
getCurrentActionList (
@@ -323,13 +282,27 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
323
282
currentActions
324
283
) ;
325
284
285
+ getCurrentActionList (
286
+ orderedActionList ,
287
+ actionType . VECTOR_COUMPOUND_ADDED ,
288
+ getCollection ( showedCompoundList ) ,
289
+ currentActions
290
+ ) ;
291
+
326
292
getCurrentActionList (
327
293
orderedActionList ,
328
294
actionType . MOLECULE_ADDED_TO_SHOPPING_CART ,
329
295
getCollectionOfShoppingCart ( currentBuyList ) ,
330
296
currentActions
331
297
) ;
332
298
299
+ getCurrentActionListOfAllShopingCart (
300
+ orderedActionList ,
301
+ actionType . MOLECULE_ADDED_TO_SHOPPING_CART_ALL ,
302
+ getCollectionOfShoppingCart ( currentBuyList ) ,
303
+ currentActions
304
+ ) ;
305
+
333
306
getCurrentActionList (
334
307
orderedActionList ,
335
308
actionType . LIGAND_TURNED_ON ,
@@ -379,6 +352,9 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
379
352
currentActions
380
353
) ;
381
354
355
+ getCommonLastActionByType ( orderedActionList , actionType . CLASS_SELECTED , currentActions ) ;
356
+ getCommonLastActionByType ( orderedActionList , actionType . CLASS_UPDATED , currentActions ) ;
357
+
382
358
if ( nglViewList ) {
383
359
let nglStateList = nglViewList . map ( nglView => {
384
360
return { id : nglView . id , orientation : nglView . stage . viewerControls . getOrientation ( ) } ;
@@ -488,6 +464,13 @@ const getCurrentActionList = (orderedActionList, type, collection, currentAction
488
464
}
489
465
} ;
490
466
467
+ const getCommonLastActionByType = ( orderedActionList , type , currentActions ) => {
468
+ let action = orderedActionList . find ( action => action . type === type ) ;
469
+ if ( action ) {
470
+ currentActions . push ( Object . assign ( { ...action } ) ) ;
471
+ }
472
+ } ;
473
+
491
474
const getCurrentActionListOfAllSelection = (
492
475
orderedActionList ,
493
476
type ,
@@ -573,6 +556,22 @@ const getCurrentActionListOfAllSelectionByTypeOfDataset = (
573
556
}
574
557
} ;
575
558
559
+ const getCurrentActionListOfAllShopingCart = ( orderedActionList , type , collection , currentActions ) => {
560
+ let action = orderedActionList . find ( action => action . type === type ) ;
561
+ if ( action && collection ) {
562
+ let actionItems = action . items ;
563
+ let items = [ ] ;
564
+ collection . forEach ( data => {
565
+ let item = actionItems . find ( action => action . id === data . id && action . dataset_id === data . datasetId ) ;
566
+ if ( item ) {
567
+ items . push ( item ) ;
568
+ }
569
+ } ) ;
570
+
571
+ currentActions . push ( Object . assign ( { ...action , items : items } ) ) ;
572
+ }
573
+ } ;
574
+
576
575
const getCollection = dataList => {
577
576
let list = [ ] ;
578
577
if ( dataList ) {
@@ -887,27 +886,62 @@ const restoreMoleculesActions = (orderedActionList, stage) => (dispatch, getStat
887
886
888
887
let vectorAction = orderedActionList . find ( action => action . type === actionType . VECTOR_SELECTED ) ;
889
888
if ( vectorAction ) {
890
- dispatch ( setCurrentVector ( vectorAction . object_name ) ) ;
889
+ dispatch ( selectVectorAndResetCompounds ( vectorAction . object_name ) ) ;
891
890
}
892
891
893
- dispatch ( restoreCartActions ( moleculesAction ) ) ;
892
+ dispatch ( restoreCartActions ( moleculesAction , stage ) ) ;
894
893
dispatch ( restoreAllSelectionActions ( orderedActionList , stage , true ) ) ;
895
894
dispatch ( restoreAllSelectionByTypeActions ( orderedActionList , stage , true ) ) ;
896
895
dispatch ( setIsTrackingMoleculesRestoring ( false ) ) ;
897
896
} ;
898
897
899
- const restoreCartActions = moleculesAction => ( dispatch , getState ) => {
898
+ const restoreCartActions = ( moleculesAction , majorViewStage ) => ( dispatch , getState ) => {
899
+ let shoppingCartAllaction = moleculesAction . find (
900
+ action => action . type === actionType . MOLECULE_ADDED_TO_SHOPPING_CART_ALL
901
+ ) ;
902
+ if ( shoppingCartAllaction ) {
903
+ dispatch (
904
+ handleBuyListAll ( { isSelected : true , items : shoppingCartAllaction . items , majorViewStage : majorViewStage } )
905
+ ) ;
906
+ }
907
+
900
908
let shoppingCartActions = moleculesAction . filter (
901
909
action => action . type === actionType . MOLECULE_ADDED_TO_SHOPPING_CART
902
910
) ;
903
911
if ( shoppingCartActions ) {
904
912
shoppingCartActions . forEach ( action => {
905
913
let data = action . item ;
914
+ let compoundId = action . compoundId ;
915
+
906
916
if ( data ) {
907
- dispatch ( appendToBuyList ( data ) ) ;
917
+ dispatch ( handleBuyList ( { isSelected : true , data, compoundId } ) ) ;
908
918
}
909
919
} ) ;
910
920
}
921
+
922
+ let classSelectedAction = moleculesAction . find ( action => action . type === actionType . CLASS_SELECTED ) ;
923
+ if ( classSelectedAction ) {
924
+ dispatch ( setCurrentCompoundClass ( classSelectedAction . value , classSelectedAction . oldValue ) ) ;
925
+ }
926
+
927
+ let classUpdatedAction = moleculesAction . find ( action => action . type === actionType . CLASS_UPDATED ) ;
928
+ if ( classUpdatedAction ) {
929
+ let id = classUpdatedAction . object_id ;
930
+ let newValue = classUpdatedAction . newCompoundClasses ;
931
+ let oldValue = classUpdatedAction . oldCompoundClasses ;
932
+ let value = classUpdatedAction . object_name ;
933
+ value = value !== undefined ? value : '' ;
934
+ dispatch ( setCompoundClasses ( newValue , oldValue , value , id ) ) ;
935
+ }
936
+
937
+ let vectorCompoundActions = moleculesAction . filter ( action => action . type === actionType . VECTOR_COUMPOUND_ADDED ) ;
938
+ if ( vectorCompoundActions ) {
939
+ vectorCompoundActions . forEach ( action => {
940
+ let data = action . item ;
941
+ let compoundId = action . compoundId ;
942
+ dispatch ( handleShowVectorCompound ( { isSelected : true , data, index : compoundId , majorViewStage : majorViewStage } ) ) ;
943
+ } ) ;
944
+ }
911
945
} ;
912
946
913
947
const restoreAllSelectionActions = ( moleculesAction , stage , isSelection ) => ( dispatch , getState ) => {
@@ -2271,9 +2305,9 @@ export const mergeActions = (trackAction, list) => {
2271
2305
} else {
2272
2306
newList . push ( trackAction ) ;
2273
2307
}
2274
- return { merged : merged , list : newList } ;
2308
+ return { merged : merged , list : newList } ;
2275
2309
} else {
2276
- return { merged : merged , list : [ ...list , trackAction ] } ;
2310
+ return { merged : merged , list : [ ...list , trackAction ] } ;
2277
2311
}
2278
2312
// return {merged: merged, list: [...list, trackAction]};
2279
2313
} ;
0 commit comments