diff --git a/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/css/submission.css b/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/css/submission.css index f3b3647f6..dff367088 100644 --- a/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/css/submission.css +++ b/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/css/submission.css @@ -91,6 +91,16 @@ textarea.submission_deny_dialog_reason { margin-bottom: 5px; } +textarea.submission_approve_dialog_message { + width: 460px; + height: 125px; +} + +.submission_approve_dialog_options { + margin-top: 5px; + margin-bottom: 5px; +} + span.patchSelected, div.patchSelected { font-weight: bold; color: #00ff00; diff --git a/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/js/submission.js b/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/js/submission.js index bb5df6bfd..fcbb12731 100644 --- a/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/js/submission.js +++ b/nunaliit2-couch-application/src/main/atlas_couchapp/_attachments/tools/js/submission.js @@ -278,45 +278,128 @@ }); } - ,_approve: function(subDocId, approvedDoc){ + ,_approve: function(subDocId, approvedDoc, approveFn){ var _this = this; - this._getSubmissionDocument({ - subDocId: subDocId - ,onSuccess: function(subDoc){ - subDoc.nunaliit_submission.state = 'approved'; - $n2.couchDocument.adjustDocument(subDoc); - - if( approvedDoc ){ - subDoc.nunaliit_submission.approved_doc = {}; - subDoc.nunaliit_submission.approved_reserved = {}; - for(var key in approvedDoc){ - if( key.length > 0 && key[0] === '_' ) { - var effectiveKey = key.substr(1); - subDoc.nunaliit_submission.approved_reserved[effectiveKey] = - approvedDoc[key]; - } else { - subDoc.nunaliit_submission.approved_doc[key] = - approvedDoc[key]; + collectApprovalMessage(function(message, sendEmail) { + _this._getSubmissionDocument({ + subDocId: subDocId + ,onSuccess: function(subDoc){ + subDoc.nunaliit_submission.state = 'approved'; + $n2.couchDocument.adjustDocument(subDoc); + + if( approvedDoc ){ + + if (message && message !== '') { + subDoc.nunaliit_submission.approval_message = message; + } + + if (sendEmail) { + subDoc.nunaliit_submission.approval_email = { + requested: true + } + } + + subDoc.nunaliit_submission.approved_doc = {}; + subDoc.nunaliit_submission.approved_reserved = {}; + for(var key in approvedDoc){ + if( key.length > 0 && key[0] === '_' ) { + var effectiveKey = key.substr(1); + subDoc.nunaliit_submission.approved_reserved[effectiveKey] = + approvedDoc[key]; + } else { + subDoc.nunaliit_submission.approved_doc[key] = + approvedDoc[key]; + }; }; }; - }; - - _this.submissionDb.updateDocument({ - data: subDoc - ,onSuccess: function(docInfo){ - _this.logger.log( _loc('Submission approved') ); - _this._refreshSubmissions(); - } - ,onError: function(err){ - _this.logger.error( _loc('Unable to update submission document: {err}',{err:err}) ); - } + + _this.submissionDb.updateDocument({ + data: subDoc + ,onSuccess: function(docInfo){ + _this.logger.log( _loc('Submission approved') ); + if( typeof approveFn === 'function' ){ + approveFn(); + }; + _this._refreshSubmissions(); + } + ,onError: function(err){ + _this.logger.error( _loc('Unable to update submission document: {err}',{err:err}) ); + } + }); + } + ,onError: function(err){ + _this.logger.error( _loc('Unable to obtain submission document: {err}',{err:err}) ); + } + }); + }) + + function collectApprovalMessage(callback, sendEmail){ + var diagId = $n2.getUniqueId(); + var $diag = $('