@@ -30,16 +30,9 @@ import { DialogsId } from '../../utils/UIconstants';
30
30
import {
31
31
createFilter ,
32
32
deleteElements ,
33
- duplicateCase ,
34
- duplicateContingencyList ,
35
- duplicateFilter ,
36
- duplicateModification ,
37
- duplicateParameter ,
38
- duplicateStudy ,
33
+ duplicateElement ,
39
34
elementExists ,
40
35
fetchAppsAndUrls ,
41
- fetchElementsInfos ,
42
- getNameCandidate ,
43
36
moveElementsToDirectory ,
44
37
newScriptFromFilter ,
45
38
newScriptFromFiltersContingencyList ,
@@ -114,7 +107,8 @@ const ContentContextualMenu = (props) => {
114
107
nameItem ,
115
108
descriptionItem ,
116
109
sourceItemUuid ,
117
- parentDirectoryUuid
110
+ parentDirectoryUuid ,
111
+ specificType
118
112
) => {
119
113
dispatch (
120
114
setSelectionForCopy ( {
@@ -123,6 +117,7 @@ const ContentContextualMenu = (props) => {
123
117
nameItem : nameItem ,
124
118
descriptionItem : descriptionItem ,
125
119
parentDirectoryUuid : parentDirectoryUuid ,
120
+ specificType,
126
121
} )
127
122
) ;
128
123
} ,
@@ -134,21 +129,24 @@ const ContentContextualMenu = (props) => {
134
129
nameItem ,
135
130
descriptionItem ,
136
131
sourceItemUuid ,
137
- parentDirectoryUuid
132
+ parentDirectoryUuid ,
133
+ sprecificTypeItem
138
134
) {
139
135
dispatchSelectionForCopy (
140
136
typeItem ,
141
137
nameItem ,
142
138
descriptionItem ,
143
139
sourceItemUuid ,
144
- parentDirectoryUuid
140
+ parentDirectoryUuid ,
141
+ sprecificTypeItem
145
142
) ;
146
143
broadcastChannel . postMessage ( {
147
144
typeItem : typeItem ,
148
145
nameItem : nameItem ,
149
146
descriptionItem : descriptionItem ,
150
147
sourceItemUuid : sourceItemUuid ,
151
148
parentDirectoryUuid : parentDirectoryUuid ,
149
+ specificTypeItem : sprecificTypeItem ,
152
150
} ) ;
153
151
154
152
handleCloseDialog ( ) ;
@@ -177,7 +175,6 @@ const ContentContextualMenu = (props) => {
177
175
case ElementType . SECURITY_ANALYSIS_PARAMETERS :
178
176
case ElementType . SENSITIVITY_PARAMETERS :
179
177
case ElementType . LOADFLOW_PARAMETERS :
180
- case ElementType . CONTINGENCY_LIST :
181
178
console . info (
182
179
activeElement . type +
183
180
' with uuid ' +
@@ -194,6 +191,24 @@ const ContentContextualMenu = (props) => {
194
191
selectedDirectory . elementUuid
195
192
) ;
196
193
break ;
194
+ case ElementType . CONTINGENCY_LIST :
195
+ console . info (
196
+ activeElement . type +
197
+ ' with uuid ' +
198
+ activeElement . elementUuid +
199
+ ' from directory ' +
200
+ selectedDirectory . elementUuid +
201
+ ' selected for copy'
202
+ ) ;
203
+ copyElement (
204
+ activeElement . type ,
205
+ activeElement . elementName ,
206
+ activeElement . description ,
207
+ activeElement . elementUuid ,
208
+ selectedDirectory . elementUuid ,
209
+ activeElement . specificMetadata . type
210
+ ) ;
211
+ break ;
197
212
198
213
default :
199
214
handleLastError (
@@ -204,96 +219,51 @@ const ContentContextualMenu = (props) => {
204
219
} ;
205
220
const duplicateItem = ( ) => {
206
221
if ( activeElement ) {
207
- getNameCandidate (
208
- selectedDirectory . elementUuid ,
209
- activeElement . elementName ,
210
- activeElement . type
211
- )
212
- . then ( ( newItemName ) => {
213
- switch ( activeElement . type ) {
214
- case ElementType . CASE :
215
- duplicateCase (
216
- newItemName ,
217
- activeElement . description ,
218
- activeElement . elementUuid ,
219
- selectedDirectory . elementUuid
220
- ) . catch ( ( error ) => {
221
- handleDuplicateError ( error . message ) ;
222
- } ) ;
223
- break ;
224
- case ElementType . CONTINGENCY_LIST :
225
- fetchElementsInfos ( [ activeElement . elementUuid ] )
226
- . then ( ( res ) => {
227
- duplicateContingencyList (
228
- res [ 0 ] . specificMetadata . type ,
229
- newItemName ,
230
- activeElement . description ,
231
- activeElement . elementUuid ,
232
- selectedDirectory . elementUuid
233
- ) . catch ( ( error ) => {
234
- handleDuplicateError ( error . message ) ;
235
- } ) ;
236
- } )
237
- . catch ( ( error ) => {
238
- handleLastError ( error . message ) ;
239
- } ) ;
240
- break ;
241
- case ElementType . STUDY :
242
- duplicateStudy (
243
- newItemName ,
244
- activeElement . description ,
245
- activeElement . elementUuid ,
246
- selectedDirectory . elementUuid
247
- ) . catch ( ( error ) => {
248
- handleDuplicateError ( error . message ) ;
249
- } ) ;
250
- break ;
251
- case ElementType . FILTER :
252
- duplicateFilter (
253
- newItemName ,
254
- activeElement . description ,
255
- activeElement . elementUuid ,
256
- selectedDirectory . elementUuid
257
- ) . catch ( ( error ) => {
258
- handleDuplicateError ( error . message ) ;
259
- } ) ;
260
- break ;
261
- case ElementType . MODIFICATION :
262
- duplicateModification (
263
- newItemName ,
264
- activeElement . description ,
265
- activeElement . elementUuid ,
266
- selectedDirectory . elementUuid
267
- ) . catch ( ( error ) => {
268
- handleDuplicateError ( error . message ) ;
269
- } ) ;
270
- break ;
271
- case ElementType . VOLTAGE_INIT_PARAMETERS :
272
- case ElementType . SENSITIVITY_PARAMETERS :
273
- case ElementType . SECURITY_ANALYSIS_PARAMETERS :
274
- case ElementType . LOADFLOW_PARAMETERS :
275
- duplicateParameter (
276
- newItemName ,
277
- activeElement . type ,
278
- activeElement . elementUuid ,
279
- selectedDirectory . elementUuid ,
280
- activeElement . description
281
- ) . catch ( ( error ) => {
282
- handleDuplicateError ( error . message ) ;
283
- } ) ;
284
- break ;
285
- default :
286
- handleLastError (
287
- intl . formatMessage ( {
288
- id : 'unsupportedItem' ,
289
- } )
290
- ) ;
291
- }
292
- } )
293
- . catch ( ( error ) => {
294
- handleDuplicateError ( error . message ) ;
295
- } )
296
- . finally ( ( ) => handleCloseDialog ( ) ) ;
222
+ switch ( activeElement . type ) {
223
+ case ElementType . CASE :
224
+ case ElementType . STUDY :
225
+ case ElementType . FILTER :
226
+ case ElementType . MODIFICATION :
227
+ duplicateElement (
228
+ activeElement . elementUuid ,
229
+ undefined ,
230
+ activeElement . type
231
+ ) . catch ( ( error ) => {
232
+ handleDuplicateError ( error . message ) ;
233
+ } ) ;
234
+ break ;
235
+ case ElementType . CONTINGENCY_LIST :
236
+ duplicateElement (
237
+ activeElement . elementUuid ,
238
+ undefined ,
239
+ activeElement . type ,
240
+ selectedElements [ 0 ] . specificMetadata . type
241
+ ) . catch ( ( error ) => {
242
+ handleDuplicateError ( error . message ) ;
243
+ } ) ;
244
+ break ;
245
+ case ElementType . VOLTAGE_INIT_PARAMETERS :
246
+ case ElementType . SENSITIVITY_PARAMETERS :
247
+ case ElementType . SECURITY_ANALYSIS_PARAMETERS :
248
+ case ElementType . LOADFLOW_PARAMETERS :
249
+ duplicateElement (
250
+ activeElement . elementUuid ,
251
+ undefined ,
252
+ ElementType . PARAMETERS ,
253
+ activeElement . type
254
+ ) . catch ( ( error ) => {
255
+ handleDuplicateError ( error . message ) ;
256
+ } ) ;
257
+ break ;
258
+ default : {
259
+ handleLastError (
260
+ intl . formatMessage ( {
261
+ id : 'unsupportedItem' ,
262
+ } )
263
+ ) ;
264
+ }
265
+ }
266
+ handleCloseDialog ( ) ;
297
267
}
298
268
} ;
299
269
0 commit comments