/* FontAwesome inclusion */ var cssId = 'fontAwesome'; if (!document.getElementById(cssId)) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = cssId; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'; link.media = 'all'; head.appendChild(link); } $(document).on('click', function(e){ $('.issue .attributes .attribute .value').removeClass('edited'); if($(e.target).closest('.value').length) { $(e.target).closest('.value').addClass('edited'); } }); /* Put new dropdown lists in the detailed info block */ if($('#statusListDropdown').length > 0) { var htmlCopy = $('#statusListDropdown').get(0).outerHTML; $('#statusListDropdown').remove(); $('.details .attributes .status.attribute .value').html( '' + $('.details .attributes .status.attribute .value').html() + ' ' + htmlCopy); } if($('#usersListDropdown').length > 0) { var htmlCopy = $('#usersListDropdown').get(0).outerHTML; $('#usersListDropdown').remove(); $('.details .attributes .assigned-to.attribute .value').html( '' + $('.details .attributes .assigned-to.attribute .value').html() + ' ' + htmlCopy); } if($('#prioritiesListDropdown').length > 0) { var htmlCopy = $('#prioritiesListDropdown').get(0).outerHTML; $('#prioritiesListDropdown').remove(); $('.details .attributes .priority.attribute .value').html( '' + $('.details .attributes .priority.attribute .value').html() + ' ' + htmlCopy); } if($('#doneRatioListDropdown').length > 0) { var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML; $('#doneRatioListDropdown').remove(); $('.details .attributes .progress.attribute .value').html('' + $('.details .attributes .progress.attribute .value').html() + ' ' + htmlCopy); } if($('#EstimatedTimeInput').length > 0) { var htmlCopy = $('#EstimatedTimeInput').get(0).outerHTML; $('#EstimatedTimeInput').remove(); $('.details .attributes .estimated-hours.attribute .value').html('' + $('.details .attributes .estimated-hours.attribute .value').html() + ' ' + htmlCopy); } if($('#StartDateInput').length > 0) { var htmlCopy = $('#StartDateInput').get(0).outerHTML; $('#StartDateInput').remove(); $('.details .attributes .start-date.attribute .value').html('' + $('.details .attributes .start-date.attribute .value').html() + ' ' + htmlCopy); } if($('#DueDateInput').length > 0) { var htmlCopy = $('#DueDateInput').get(0).outerHTML; $('#DueDateInput').remove(); $('.details .attributes .due-date.attribute .value').html('' + $('.details .attributes .due-date.attribute .value').html() + ' ' + htmlCopy); } $('body.controller-issues.action-show').on('click', '.btn.close', function(e){ e.preventDefault(); $(e.target).closest('.value').removeClass('edited'); return false; }); function issueDynamicUpdate(field_name, field_value, type, cssClass){ /* hide edit field */ $('.details .attributes .' + cssClass + '.attribute .value').removeClass('edited'); /* add spin notification */ if(type == "progress") { // specific case for progress bar $('.details .attributes .' + cssClass + '.attribute .value').append(' '); } else { $('.details .attributes .' + cssClass + '.attribute .value').append(' '); } /* update value displayed */ $('.details .attributes .' + cssClass + '.attribute .showValue').html(function(){ if(type == "select") { return $('.details .attributes .' + cssClass + '.attribute .value select option:selected').html() } else if (type == "input") { return $('.details .attributes .' + cssClass + '.attribute .value input').val() } else if(type == "date") { return "XXXX/XX/XX"; } }); /* lost focus on element */ if( type != "select") { $('.details .attributes .' + cssClass + '.attribute .value input').blur(); } var token = $("meta[name=csrf-token]").attr('content'); // we prepare the return url which is the updated issue detail page with new values var prepareReturnUrl = encodeURIComponent(_BASE_REDMINE_PATH + '/issues/' + _ISSUE_ID); jQuery.ajax({ type: 'POST', url: _BASE_REDMINE_PATH + '/issues/bulk_update?back_url=' + prepareReturnUrl + '&ids%5B%5D=' + _ISSUE_ID + '&issue%5B' + field_name + '%5D=' + field_value, data: { "authenticity_token" : token }, crossDomain: true, async: false, beforeSend: function(xhr) { xhr.setRequestHeader("authenticity_token", token); }, success: function(msg) { /* get result page content (updated issue detail page with new status) */ var parsed = $.parseHTML(msg); var statusListDropdown = $(parsed).find("#statusListDropdown select"); var prioritiesListDropdown = $(parsed).find('#prioritiesListDropdown select'); /* we update dropdown status with new one from updated page */ $('#statusListDropdown select').html(statusListDropdown.html()); $('#issue_status_id').html(statusListDropdown.html()); $('#prioritiesListDropdown select').html(prioritiesListDropdown.html()); $('#issue_priority_id').html(prioritiesListDropdown.html()); /* we update issue properties edit block */ $('#all_attributes').html($(parsed).find('#all_attributes').html()); /* we update the history list */ $('#history').append($(parsed).find('#history .journal.has-details:last-child')); /* data updated, remove spin and add success icon for 2sec */ setTimeout(function(){ $('.details .attributes .' + cssClass + '.attribute i.fa-spin').removeClass('fa-refresh fa-spin').addClass('fa-check statusOk'); setTimeout(function(){ $('.details .attributes .' + cssClass + '.attribute i.fa-check.statusOk').remove(); }, 2000); }, 500); if(type == "progress") { // specific case for progress bar, we need to update the progress bar view var progressBar = "