@@ -120,6 +120,7 @@ export default {
120
120
...mapState ( useUiStateStore , [
121
121
'runDigestSelected' ,
122
122
'worksetNameSelected' ,
123
+ 'paramViewWorksetUpdatedCount' ,
123
124
'uiLang'
124
125
] )
125
126
} ,
@@ -284,16 +285,20 @@ export default {
284
285
onWorksetReadonlyToggle ( ) {
285
286
this . $emit ( 'set-update-readonly' , this . digest , this . worksetNameSelected , ! this . worksetCurrent . IsReadonly )
286
287
} ,
287
- // return true if any ticked workset is read only
288
- isReadOnlyTicked ( ) {
288
+ // return true if any ticked workset is has unsaved parameter
289
+ isUnsavedTicked ( ) {
289
290
if ( ! this . wsTreeTicked ?. length ) return false // no selection, nothing is ticked
290
291
291
292
const wsTop = this . wsTreeData [ 0 ]
292
293
for ( const ws of wsTop . children ) {
293
294
if ( ! ws . label || ws . children . length > 0 ) continue // it is not a workset
294
295
295
296
if ( this . wsTreeTicked . findIndex ( ( wsKey ) => { return wsKey === ws . key } ) >= 0 ) { // workset is ticked
296
- if ( ws . isReadonly ) return true
297
+ if ( ws . isReadonly ) continue // workset is readonly
298
+
299
+ // if there are any edited and unsaved parameters for this workset
300
+ const n = this . paramViewWorksetUpdatedCount ( { digest : this . digest , worksetName : ws . label } )
301
+ if ( n > 0 ) return true // unable to delete because workset have unsaved parameter(s)
297
302
}
298
303
}
299
304
return false // all ticked worksets are unlocked for delete
@@ -412,7 +417,7 @@ export default {
412
417
}
413
418
} ,
414
419
415
- // delete multiple worksets worksets
420
+ // delete multiple worksets
416
421
async doWsDeleteMultiple ( nameLst ) {
417
422
if ( ! nameLst || ! Array . isArray ( nameLst ) || ! nameLst ?. length ) {
418
423
console . warn ( 'Unable to delete: invalid (or empty) list of names, length:' , nameLst ?. length )
@@ -422,7 +427,44 @@ export default {
422
427
this . $q . notify ( { type : 'info' , message : this . $t ( 'Deleting multiple input scenarios' ) + ': [ ' + nLen . toString ( ) + ' ]' } )
423
428
this . loadWsMultipletDelete = true
424
429
425
- let isOk = false
430
+ // if any workset is readonly then make it read-write
431
+ let isOk = true
432
+ let nUpd = 0
433
+
434
+ for ( const name of nameLst ) {
435
+ if ( this . worksetTextList . findIndex ( wt => wt . Name === name && wt . IsReadonly ) < 0 ) continue
436
+
437
+ // workset is readonly: make it read-write
438
+ isOk = false
439
+
440
+ const u = this . omsUrl +
441
+ '/api/model/' + encodeURIComponent ( this . digest ) +
442
+ '/workset/' + encodeURIComponent ( name ) +
443
+ '/readonly/false'
444
+ try {
445
+ await this . $axios . post ( u ) // ignore response on success
446
+ isOk = true
447
+ nUpd ++
448
+ } catch ( e ) {
449
+ let em = ''
450
+ try {
451
+ if ( e . response ) em = e . response . data || ''
452
+ } finally { }
453
+ console . warn ( 'Server offline or input scenario not found.' , em )
454
+ this . $q . notify ( { type : 'negative' , message : this . $t ( 'Server offline or input scenario not found: ' ) + name } )
455
+ }
456
+ if ( ! isOk ) break
457
+ }
458
+ // exit on error and refersh workset list if required
459
+ if ( ! isOk ) {
460
+ this . loadWsMultipletDelete = false
461
+ if ( nUpd > 0 ) this . $emit ( 'set-list-refresh' )
462
+ return
463
+ }
464
+
465
+ // delete multiple worksets
466
+ isOk = false
467
+
426
468
const u = this . omsUrl + '/api/model/' + encodeURIComponent ( this . digest ) + '/delete-worksets'
427
469
try {
428
470
await this . $axios . post ( u , nameLst ) // ignore response on success
0 commit comments