@@ -1219,6 +1219,9 @@ async function addReview( params ) {
12191219 assetId : leaf . assetId
12201220 } )
12211221
1222+ // Track whether a review exists in the database
1223+ attachmentsGrid . reviewExists = false
1224+
12221225 /******************************************************/
12231226 // END Attachments Panel
12241227 /******************************************************/
@@ -1388,11 +1391,6 @@ async function addReview( params ) {
13881391 projection : [ 'detail' , 'ccis' , 'check' , 'fix' ]
13891392 }
13901393 } ) ,
1391- Ext . Ajax . requestPromise ( {
1392- responseType : 'json' ,
1393- url : `${ STIGMAN . Env . apiBase } /collections/${ collectionId } /reviews/${ assetId } /${ groupGridRecord . data . ruleId } ` ,
1394- method : 'GET' ,
1395- } ) ,
13961394 Ext . Ajax . requestPromise ( {
13971395 responseType : 'json' ,
13981396 url : `${ STIGMAN . Env . apiBase } /collections/${ collectionId } /reviews/${ assetId } /${ groupGridRecord . data . ruleId } ` ,
@@ -1403,7 +1401,7 @@ async function addReview( params ) {
14031401 } )
14041402 ]
14051403
1406- const [ content , review , reviewProjected ] = await Promise . all ( requests )
1404+ const [ content , reviewProjected ] = await Promise . all ( requests )
14071405
14081406 // CONTENT
14091407 reviewTab . contentPanel . update ( content )
@@ -1418,8 +1416,13 @@ async function addReview( params ) {
14181416
14191417 // Display the review
14201418 reviewForm . groupGridRecord = groupGridRecord
1421- reviewForm . loadValues ( review )
1419+ reviewForm . loadValues ( reviewProjected )
14221420 reviewForm . isLoaded = true
1421+
1422+ // Check if review exists in database and update attachment button accordingly
1423+ attachmentsGrid . reviewExists = ! ! reviewProjected
1424+ attachmentsGrid . updateAttachmentButtonState ( attachmentsGrid . reviewExists , reviewForm . defaultAccess === 'rw' )
1425+
14231426 reviewForm . setReviewFormItemStates ( )
14241427
14251428 if ( ! reviewProjected ) {
@@ -1674,6 +1677,11 @@ async function addReview( params ) {
16741677 saveParams . sm . selectRow ( saveParams . index ) ;
16751678 return
16761679 }
1680+
1681+ // After successful save, review now exists in database
1682+ attachmentsGrid . reviewExists = true
1683+ attachmentsGrid . updateAttachmentButtonState ( true , reviewForm . defaultAccess === 'rw' )
1684+
16771685 reviewForm . setReviewFormItemStates ( reviewForm )
16781686 }
16791687 catch ( e ) {
0 commit comments