partially fixed Github issue #12 : Read only attributes can't be edited anymore. Dynamic refresh for read only attributes when status changes
This commit is contained in:
parent
7f5d6e6858
commit
f314d1a472
@ -18,6 +18,8 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/)
|
|||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
* **v 0.4.3** : partially fixed Github issue #12 : Read only attributes can't be edited anymore. Dynamic refresh for read only attributes when status changes
|
||||||
|
* **v 0.4.2** : fixed Github issue #10 : History list updated after modification
|
||||||
* **v 0.4.1** : fixed Github issue #7 : update status list to follow Redmine workflow
|
* **v 0.4.1** : fixed Github issue #7 : update status list to follow Redmine workflow
|
||||||
* **v 0.4.0** : fixed Github issues #2, #4, #9. Edited dropdown display
|
* **v 0.4.0** : fixed Github issues #2, #4, #9. Edited dropdown display
|
||||||
* **v 0.3.0** : start date, due date, ratio and estimated time fields are now dynamically editable. Translation files added (en, fr). Log added in console when AJAX fails
|
* **v 0.3.0** : start date, due date, ratio and estimated time fields are now dynamically editable. Translation files added (en, fr). Log added in console when AJAX fails
|
||||||
|
|||||||
@ -18,63 +18,69 @@ $(document).on('click', function(e){
|
|||||||
$(e.target).closest('.value').addClass('edited');
|
$(e.target).closest('.value').addClass('edited');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Put new dropdown lists in the detailed info block */
|
function initEditFields()
|
||||||
if($('#statusListDropdown').length > 0) {
|
{
|
||||||
var htmlCopy = $('#statusListDropdown').get(0).outerHTML;
|
/* Put new dropdown lists in the detailed info block */
|
||||||
$('#statusListDropdown').remove();
|
if($('#statusListDropdown').length > 0) {
|
||||||
$('.details .attributes .status.attribute .value').html( '<span class="showValue">' +
|
var htmlCopy = $('#statusListDropdown').get(0).outerHTML;
|
||||||
$('.details .attributes .status.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
$('#statusListDropdown').remove();
|
||||||
htmlCopy);
|
$('.details .attributes .status.attribute .value').html( '<span class="showValue">' +
|
||||||
}
|
$('.details .attributes .status.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
if($('#usersListDropdown').length > 0) {
|
}
|
||||||
var htmlCopy = $('#usersListDropdown').get(0).outerHTML;
|
|
||||||
$('#usersListDropdown').remove();
|
if($('#usersListDropdown').length > 0) {
|
||||||
$('.details .attributes .assigned-to.attribute .value').html( '<span class="showValue">' +
|
var htmlCopy = $('#usersListDropdown').get(0).outerHTML;
|
||||||
$('.details .attributes .assigned-to.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
$('#usersListDropdown').remove();
|
||||||
htmlCopy);
|
$('.details .attributes .assigned-to.attribute .value').html( '<span class="showValue">' +
|
||||||
}
|
$('.details .attributes .assigned-to.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
if($('#prioritiesListDropdown').length > 0) {
|
}
|
||||||
var htmlCopy = $('#prioritiesListDropdown').get(0).outerHTML;
|
|
||||||
$('#prioritiesListDropdown').remove();
|
if($('#prioritiesListDropdown').length > 0) {
|
||||||
$('.details .attributes .priority.attribute .value').html( '<span class="showValue">' +
|
var htmlCopy = $('#prioritiesListDropdown').get(0).outerHTML;
|
||||||
$('.details .attributes .priority.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
$('#prioritiesListDropdown').remove();
|
||||||
htmlCopy);
|
$('.details .attributes .priority.attribute .value').html( '<span class="showValue">' +
|
||||||
|
$('.details .attributes .priority.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('#doneRatioListDropdown').length > 0) {
|
||||||
|
var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML;
|
||||||
|
$('#doneRatioListDropdown').remove();
|
||||||
|
$('.details .attributes .progress.attribute .value').html('<span class="showValue">' +
|
||||||
|
$('.details .attributes .progress.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('#EstimatedTimeInput').length > 0) {
|
||||||
|
var htmlCopy = $('#EstimatedTimeInput').get(0).outerHTML;
|
||||||
|
$('#EstimatedTimeInput').remove();
|
||||||
|
$('.details .attributes .estimated-hours.attribute .value').html('<span class="showValue">' +
|
||||||
|
$('.details .attributes .estimated-hours.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('#StartDateInput').length > 0) {
|
||||||
|
var htmlCopy = $('#StartDateInput').get(0).outerHTML;
|
||||||
|
$('#StartDateInput').remove();
|
||||||
|
$('.details .attributes .start-date.attribute .value').html('<span class="showValue">' +
|
||||||
|
$('.details .attributes .start-date.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('#DueDateInput').length > 0) {
|
||||||
|
var htmlCopy = $('#DueDateInput').get(0).outerHTML;
|
||||||
|
$('#DueDateInput').remove();
|
||||||
|
$('.details .attributes .due-date.attribute .value').html('<span class="showValue">' +
|
||||||
|
$('.details .attributes .due-date.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
|
htmlCopy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#doneRatioListDropdown').length > 0) {
|
initEditFields();
|
||||||
var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML;
|
|
||||||
$('#doneRatioListDropdown').remove();
|
|
||||||
$('.details .attributes .progress.attribute .value').html('<span class="showValue">' +
|
|
||||||
$('.details .attributes .progress.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
|
||||||
htmlCopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($('#EstimatedTimeInput').length > 0) {
|
|
||||||
var htmlCopy = $('#EstimatedTimeInput').get(0).outerHTML;
|
|
||||||
$('#EstimatedTimeInput').remove();
|
|
||||||
$('.details .attributes .estimated-hours.attribute .value').html('<span class="showValue">' +
|
|
||||||
$('.details .attributes .estimated-hours.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
|
||||||
htmlCopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($('#StartDateInput').length > 0) {
|
|
||||||
var htmlCopy = $('#StartDateInput').get(0).outerHTML;
|
|
||||||
$('#StartDateInput').remove();
|
|
||||||
$('.details .attributes .start-date.attribute .value').html('<span class="showValue">' +
|
|
||||||
$('.details .attributes .start-date.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
|
||||||
htmlCopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($('#DueDateInput').length > 0) {
|
|
||||||
var htmlCopy = $('#DueDateInput').get(0).outerHTML;
|
|
||||||
$('#DueDateInput').remove();
|
|
||||||
$('.details .attributes .due-date.attribute .value').html('<span class="showValue">' +
|
|
||||||
$('.details .attributes .due-date.attribute .value').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
|
||||||
htmlCopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('body.controller-issues.action-show').on('click', '.btn.close', function(e){
|
$('body.controller-issues.action-show').on('click', '.btn.close', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -130,14 +136,12 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
|
|||||||
/* get result page content (updated issue detail page with new status) */
|
/* get result page content (updated issue detail page with new status) */
|
||||||
var parsed = $.parseHTML(msg);
|
var parsed = $.parseHTML(msg);
|
||||||
|
|
||||||
var statusListDropdown = $(parsed).find("#statusListDropdown select");
|
/* we update the details block */
|
||||||
var prioritiesListDropdown = $(parsed).find('#prioritiesListDropdown select');
|
$('div.issue.details').html($(parsed).find('div.issue.details').html());
|
||||||
/* we update dropdown status with new one from updated page */
|
/* we init edit fields */
|
||||||
$('#statusListDropdown select').html(statusListDropdown.html());
|
initEditFields();
|
||||||
$('#issue_status_id').html(statusListDropdown.html());
|
initEditFieldListeners();
|
||||||
$('#prioritiesListDropdown select').html(prioritiesListDropdown.html());
|
|
||||||
$('#issue_priority_id').html(prioritiesListDropdown.html());
|
|
||||||
|
|
||||||
/* we update issue properties edit block */
|
/* we update issue properties edit block */
|
||||||
$('#all_attributes').html($(parsed).find('#all_attributes').html());
|
$('#all_attributes').html($(parsed).find('#all_attributes').html());
|
||||||
|
|
||||||
@ -151,35 +155,11 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
|
|||||||
$('.details .attributes .' + cssClass + '.attribute i.fa-check.statusOk').remove();
|
$('.details .attributes .' + cssClass + '.attribute i.fa-check.statusOk').remove();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
if(type == "progress") { // specific case for progress bar, we need to update the progress bar view
|
|
||||||
var progressBar = "<tbody><tr>";
|
|
||||||
var percentTodo = 100 - parseInt(field_value);
|
|
||||||
if(field_value != 0) { progressBar += "<td style='width: " + field_value + "%;' class='closed' title='" + field_value + "%'></td>"; }
|
|
||||||
if(percentTodo != 0) { progressBar += "<td style='width: " + percentTodo + "%;' class='todo'></td>"; }
|
|
||||||
progressBar += "</tr></tbody>";
|
|
||||||
$('.details .attributes .' + cssClass + '.attribute table.progress').attr('class', 'progress progress-' + field_value).html(progressBar);
|
|
||||||
$('.details .attributes .' + cssClass + ' .percent').html(field_value + "%");
|
|
||||||
} else if( type == "date") { // specific case for start date and due date, we have to update min and max date allowed
|
|
||||||
if(field_name == "start_date")
|
|
||||||
{
|
|
||||||
$('body').find('#DueDateInput input').attr('min', field_value);
|
|
||||||
} else if (field_name == "due_date")
|
|
||||||
{
|
|
||||||
$('body').find('#StartDateInput input').attr('max', field_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update other fields to avoid conflict
|
// update other fields to avoid conflict
|
||||||
$('#issue_lock_version').val(parseInt($('#issue_lock_version').val()) + 1 );
|
$('#issue_lock_version').val(parseInt($('#issue_lock_version').val()) + 1 );
|
||||||
$('#last_journal_id').val(parseInt($('#last_journal_id').val()) + 1 );
|
$('#last_journal_id').val(parseInt($('#last_journal_id').val()) + 1 );
|
||||||
if(type == "select")
|
|
||||||
{
|
|
||||||
$('#issue_' + field_name + ' option').removeAttr('selected').filter('[value=' + field_value + ']').prop('selected', true);
|
|
||||||
} else if (type == "input" || type == "date")
|
|
||||||
{
|
|
||||||
$('#issue_' + field_name).val(field_value);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: function(xhr, msg, error) {
|
error: function(xhr, msg, error) {
|
||||||
/* error and no update, info logged into console */
|
/* error and no update, info logged into console */
|
||||||
@ -200,100 +180,104 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Listeners foreach attribute */
|
/* Listeners foreach attribute */
|
||||||
|
function initEditFieldListeners()
|
||||||
var domSelectStatus = $('body').find('#statusListDropdown select');
|
{
|
||||||
domSelectStatus.on('change', function(e){
|
var domSelectStatus = $('body').find('#statusListDropdown select');
|
||||||
issueDynamicUpdate('status_id', domSelectStatus.val(), 'select', 'status');
|
domSelectStatus.on('change', function(e){
|
||||||
|
issueDynamicUpdate('status_id', domSelectStatus.val(), 'select', 'status');
|
||||||
|
|
||||||
/* update the classes status from */
|
/* update the classes status from */
|
||||||
$("#content > div.issue").removeClass(function (index, className) {
|
$("#content > div.issue").removeClass(function (index, className) {
|
||||||
return (className.match (/(^|\s)status-\S+/g) || []).join(' ');
|
return (className.match (/(^|\s)status-\S+/g) || []).join(' ');
|
||||||
}).addClass('status-' + domSelectStatus.val());
|
}).addClass('status-' + domSelectStatus.val());
|
||||||
}); /* end on change domSelectStatus */
|
}); /* end on change domSelectStatus */
|
||||||
|
|
||||||
var domSelectPriorities = $('body').find('#prioritiesListDropdown select');
|
var domSelectPriorities = $('body').find('#prioritiesListDropdown select');
|
||||||
domSelectPriorities.on('change', function(e){
|
domSelectPriorities.on('change', function(e){
|
||||||
issueDynamicUpdate('priority_id', domSelectPriorities.val(), 'select', 'priority');
|
issueDynamicUpdate('priority_id', domSelectPriorities.val(), 'select', 'priority');
|
||||||
|
|
||||||
/* update the classes priority from */
|
/* update the classes priority from */
|
||||||
$("#content > div.issue").removeClass(function (index, className) {
|
$("#content > div.issue").removeClass(function (index, className) {
|
||||||
return (className.match (/(^|\s)priority-\S+/g) || []).join(' ');
|
return (className.match (/(^|\s)priority-\S+/g) || []).join(' ');
|
||||||
}).addClass('priority-' + domSelectStatus.val());
|
}).addClass('priority-' + domSelectStatus.val());
|
||||||
}); /* end on change domSelectPriorities */
|
}); /* end on change domSelectPriorities */
|
||||||
|
|
||||||
var domSelectUsers = $('body').find('#usersListDropdown select');
|
var domSelectUsers = $('body').find('#usersListDropdown select');
|
||||||
domSelectUsers.on('change', function(e){
|
domSelectUsers.on('change', function(e){
|
||||||
issueDynamicUpdate('assigned_to_id', domSelectUsers.val(), 'select', 'assigned-to');
|
issueDynamicUpdate('assigned_to_id', domSelectUsers.val(), 'select', 'assigned-to');
|
||||||
}); /* end on change domSelectUsers */
|
}); /* end on change domSelectUsers */
|
||||||
|
|
||||||
var domSelectRatio = $('body').find('#doneRatioListDropdown select');
|
var domSelectRatio = $('body').find('#doneRatioListDropdown select');
|
||||||
domSelectRatio.on('change', function(e){
|
domSelectRatio.on('change', function(e){
|
||||||
issueDynamicUpdate('done_ratio', domSelectRatio.val(), 'progress', 'progress');
|
issueDynamicUpdate('done_ratio', domSelectRatio.val(), 'progress', 'progress');
|
||||||
}); /* end on change domSelectRatio */
|
}); /* end on change domSelectRatio */
|
||||||
|
|
||||||
var domInputEstimatedTime = $('body').find('#EstimatedTimeInput input');
|
var domInputEstimatedTime = $('body').find('#EstimatedTimeInput input');
|
||||||
$('#EstimatedTimeInput a.btn.validate').on('click', function(e)
|
$('#EstimatedTimeInput a.btn.validate').on('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.estimated-hours .value .error').remove();
|
$('.estimated-hours .value .error').remove();
|
||||||
var estimatedTime = parseFloat(domInputEstimatedTime.val());
|
var estimatedTime = parseFloat(domInputEstimatedTime.val());
|
||||||
if(estimatedTime >= 0)
|
if(estimatedTime >= 0)
|
||||||
{
|
{
|
||||||
issueDynamicUpdate('estimated_hours', estimatedTime, 'input', 'estimated-hours');
|
issueDynamicUpdate('estimated_hours', estimatedTime, 'input', 'estimated-hours');
|
||||||
} else {
|
} else {
|
||||||
/* estimated time must be > 0 */
|
/* estimated time must be > 0 */
|
||||||
$('.estimated-hours .value').append('<span class="error"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + _TXT_ERROR_POSITIVE_NUMBER + '</span>');
|
$('.estimated-hours .value').append('<span class="error"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + _TXT_ERROR_POSITIVE_NUMBER + '</span>');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
domInputEstimatedTime.on('keyup', function(e){
|
domInputEstimatedTime.on('keyup', function(e){
|
||||||
$('.details .attributes .estimated-hours.attribute .selectedValue span').html(
|
$('.details .attributes .estimated-hours.attribute .selectedValue span').html(
|
||||||
$('.details .attributes .estimated-hours.attribute .value input').val()
|
$('.details .attributes .estimated-hours.attribute .value input').val()
|
||||||
);
|
);
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode == 13) {
|
||||||
$('#EstimatedTimeInput a.btn.validate').click();
|
$('#EstimatedTimeInput a.btn.validate').click();
|
||||||
}
|
}
|
||||||
});/* end EstimatedTime */
|
});/* end EstimatedTime */
|
||||||
|
|
||||||
var domInputStartDate = $('body').find('#StartDateInput input');
|
var domInputStartDate = $('body').find('#StartDateInput input');
|
||||||
$('#StartDateInput a.btn.validate').on('click', function(e)
|
$('#StartDateInput a.btn.validate').on('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.start-date .value .error').remove();
|
$('.start-date .value .error').remove();
|
||||||
if(new Date(domInputStartDate.val()).getTime() <= new Date($('body').find('#DueDateInput input').val()).getTime())
|
if(new Date(domInputStartDate.val()).getTime() <= new Date($('body').find('#DueDateInput input').val()).getTime())
|
||||||
{
|
{
|
||||||
issueDynamicUpdate('start_date', domInputStartDate.val(), 'date', 'start-date');
|
issueDynamicUpdate('start_date', domInputStartDate.val(), 'date', 'start-date');
|
||||||
} else {
|
} else {
|
||||||
/* start date must be < due date */
|
/* start date must be < due date */
|
||||||
$('.start-date .value').append('<span class="error"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + _TXT_ERROR_START_DATE + '</span>');
|
$('.start-date .value').append('<span class="error"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + _TXT_ERROR_START_DATE + '</span>');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
domInputStartDate.on('keyup', function(e){
|
domInputStartDate.on('keyup', function(e){
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode == 13) {
|
||||||
$('#StartDateInput a.btn.validate').click();
|
$('#StartDateInput a.btn.validate').click();
|
||||||
}
|
}
|
||||||
});/* end StartDate */
|
});/* end StartDate */
|
||||||
|
|
||||||
var domInputDueDate = $('body').find('#DueDateInput input');
|
var domInputDueDate = $('body').find('#DueDateInput input');
|
||||||
$('#DueDateInput a.btn.validate').on('click', function(e)
|
$('#DueDateInput a.btn.validate').on('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.due-date .value .error').remove();
|
$('.due-date .value .error').remove();
|
||||||
if(new Date($('body').find('#StartDateInput input').val()).getTime() <= new Date(domInputDueDate.val()).getTime())
|
if(new Date($('body').find('#StartDateInput input').val()).getTime() <= new Date(domInputDueDate.val()).getTime())
|
||||||
{
|
{
|
||||||
issueDynamicUpdate('due_date', domInputDueDate.val(), 'date', 'due-date');
|
issueDynamicUpdate('due_date', domInputDueDate.val(), 'date', 'due-date');
|
||||||
} else {
|
} else {
|
||||||
/* start date must be < due date */
|
/* start date must be < due date */
|
||||||
$('.due-date .value').append('<span class="error"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + _TXT_ERROR_DUE_DATE + '</span>');
|
$('.due-date .value').append('<span class="error"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + _TXT_ERROR_DUE_DATE + '</span>');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
domInputDueDate.on('keyup', function(e){
|
domInputDueDate.on('keyup', function(e){
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode == 13) {
|
||||||
$('#DueDateInput a.btn.validate').click();
|
$('#DueDateInput a.btn.validate').click();
|
||||||
}
|
}
|
||||||
});/* end StartDate */
|
});/* end StartDate */
|
||||||
|
}
|
||||||
|
|
||||||
|
initEditFieldListeners();
|
||||||
2
init.rb
2
init.rb
@ -6,7 +6,7 @@ Redmine::Plugin.register :redmine_issue_dynamic_edit do
|
|||||||
name 'Redmine Dynamic edit Issue plugin'
|
name 'Redmine Dynamic edit Issue plugin'
|
||||||
author 'Hugo Zilliox'
|
author 'Hugo Zilliox'
|
||||||
description 'Allows users to dynamically update issue attributes in detailed view'
|
description 'Allows users to dynamically update issue attributes in detailed view'
|
||||||
version '0.4.2'
|
version '0.4.3'
|
||||||
url 'https://github.com/ilogeek/redmine_issue_dynamic_edit'
|
url 'https://github.com/ilogeek/redmine_issue_dynamic_edit'
|
||||||
author_url 'https://hzilliox.fr'
|
author_url 'https://hzilliox.fr'
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,6 +22,9 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
if (issue_id)
|
if (issue_id)
|
||||||
issue = Issue.find(issue_id)
|
issue = Issue.find(issue_id)
|
||||||
|
readOnlyAttributes = issue.read_only_attribute_names(User.current)
|
||||||
|
# o << issue.required_attribute_names(User.current).to_json
|
||||||
|
|
||||||
if (issue)
|
if (issue)
|
||||||
if (User.current.allowed_to?(:edit_issues, project))
|
if (User.current.allowed_to?(:edit_issues, project))
|
||||||
|
|
||||||
@ -30,7 +33,7 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
# Status dropdown
|
# Status dropdown
|
||||||
statuses = issue.new_statuses_allowed_to(User.current)
|
statuses = issue.new_statuses_allowed_to(User.current)
|
||||||
if (!statuses.empty?)
|
if (!statuses.empty? && !(readOnlyAttributes.include? 'status_id'))
|
||||||
o << "<span class='dynamicEdit' id='statusListDropdown'>"
|
o << "<span class='dynamicEdit' id='statusListDropdown'>"
|
||||||
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
||||||
statuses.each do |s|
|
statuses.each do |s|
|
||||||
@ -45,8 +48,7 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
# Users dropdown
|
# Users dropdown
|
||||||
assignables = project.assignable_users
|
assignables = project.assignable_users
|
||||||
o << assignables.to_json
|
if (!assignables.empty? && !(readOnlyAttributes.include? 'assigned_to_id'))
|
||||||
if (!assignables.empty?)
|
|
||||||
o << "<span class='dynamicEdit' id='usersListDropdown'>"
|
o << "<span class='dynamicEdit' id='usersListDropdown'>"
|
||||||
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
||||||
assignables.each do |u|
|
assignables.each do |u|
|
||||||
@ -61,7 +63,7 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
# Priorities dropdown
|
# Priorities dropdown
|
||||||
priorities = IssuePriority.all
|
priorities = IssuePriority.all
|
||||||
if(!priorities.empty?)
|
if(!priorities.empty? && !(readOnlyAttributes.include? 'priority_id'))
|
||||||
o << "<span class='dynamicEdit' id='prioritiesListDropdown'>"
|
o << "<span class='dynamicEdit' id='prioritiesListDropdown'>"
|
||||||
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
||||||
priorities.each do |p|
|
priorities.each do |p|
|
||||||
@ -75,52 +77,60 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
|
|||||||
end
|
end
|
||||||
|
|
||||||
# %done dropdown
|
# %done dropdown
|
||||||
percent = 0
|
if(!(readOnlyAttributes.include? 'done_ratio'))
|
||||||
o << "<span class='dynamicEdit' id='doneRatioListDropdown'>"
|
percent = 0
|
||||||
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
o << "<span class='dynamicEdit' id='doneRatioListDropdown'>"
|
||||||
loop do
|
o << "<select data-issue='#{issue_id}'><option disabled='disabled' selected> </option>"
|
||||||
if (percent == issue.done_ratio)
|
loop do
|
||||||
o << "<option value='#{percent}' selected>#{percent}%</option>"
|
if (percent == issue.done_ratio)
|
||||||
else
|
o << "<option value='#{percent}' selected>#{percent}%</option>"
|
||||||
o << "<option value='#{percent}'>#{percent}%</option>"
|
else
|
||||||
|
o << "<option value='#{percent}'>#{percent}%</option>"
|
||||||
|
end
|
||||||
|
percent += 10
|
||||||
|
if percent == 110
|
||||||
|
break
|
||||||
end
|
end
|
||||||
percent += 10
|
end
|
||||||
if percent == 110
|
o << "</select> <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a></span>"
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
o << "</select> <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a></span>"
|
|
||||||
|
|
||||||
# Estimated_time dropdown
|
# Estimated_time dropdown
|
||||||
o << "<span class='dynamicEdit' id='EstimatedTimeInput'>"
|
if(!(readOnlyAttributes.include? 'estimated_hours'))
|
||||||
o << " <input type='text' value='#{issue.estimated_hours}' size='6'/>"
|
o << "<span class='dynamicEdit' id='EstimatedTimeInput'>"
|
||||||
o << "<a href='#' class='btn btn-primary validate' aria-label='" + l(:ide_txt_validation_btn) + "'><i class='fa fa-check fa-fw' aria-hidden='true'></i></a>"
|
o << " <input type='text' value='#{issue.estimated_hours}' size='6'/>"
|
||||||
o << " <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a>"
|
o << "<a href='#' class='btn btn-primary validate' aria-label='" + l(:ide_txt_validation_btn) + "'><i class='fa fa-check fa-fw' aria-hidden='true'></i></a>"
|
||||||
o << "</span>"
|
o << " <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a>"
|
||||||
|
o << "</span>"
|
||||||
|
end
|
||||||
|
|
||||||
# Start date
|
# Start date
|
||||||
o << "<span class='dynamicEdit' id='StartDateInput'>"
|
if(!(readOnlyAttributes.include? 'start_date'))
|
||||||
o << " <input size=\"10\" value=\"#{issue.start_date}\" type=\"date\" max=\"#{issue.due_date}\">"
|
o << "<span class='dynamicEdit' id='StartDateInput'>"
|
||||||
o << " <a href='#' class='btn btn-primary validate' aria-label='" + l(:ide_txt_validation_btn) + "'><i class='fa fa-check fa-fw' aria-hidden='true'></i></a>"
|
o << " <input size=\"10\" value=\"#{issue.start_date}\" type=\"date\" max=\"#{issue.due_date}\">"
|
||||||
o << " <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a>"
|
o << " <a href='#' class='btn btn-primary validate' aria-label='" + l(:ide_txt_validation_btn) + "'><i class='fa fa-check fa-fw' aria-hidden='true'></i></a>"
|
||||||
o << "</span>"
|
o << " <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a>"
|
||||||
o << "<script>"
|
o << "</span>"
|
||||||
o << "//<![CDATA[\n"
|
o << "<script>"
|
||||||
o << " $(function() { $('#StartDateInput input').addClass('date').datepickerFallback(datepickerOptions); });\n"
|
o << "//<![CDATA[\n"
|
||||||
o << "//]]>\n"
|
o << " $(function() { $('#StartDateInput input').addClass('date').datepickerFallback(datepickerOptions); });\n"
|
||||||
o << "</script>"
|
o << "//]]>\n"
|
||||||
|
o << "</script>"
|
||||||
|
end
|
||||||
|
|
||||||
# Due date
|
# Due date
|
||||||
o << "<span class='dynamicEdit' id='DueDateInput'>"
|
if(!(readOnlyAttributes.include? 'due_date'))
|
||||||
o << " <input size=\"10\" value=\"#{issue.due_date}\" type=\"date\" min=\"#{issue.start_date}\">"
|
o << "<span class='dynamicEdit' id='DueDateInput'>"
|
||||||
o << " <a href='#' class='btn btn-primary validate' aria-label='" + l(:ide_txt_validation_btn) + "'><i class='fa fa-check fa-fw' aria-hidden='true'></i></a>"
|
o << " <input size=\"10\" value=\"#{issue.due_date}\" type=\"date\" min=\"#{issue.start_date}\">"
|
||||||
o << " <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a>"
|
o << " <a href='#' class='btn btn-primary validate' aria-label='" + l(:ide_txt_validation_btn) + "'><i class='fa fa-check fa-fw' aria-hidden='true'></i></a>"
|
||||||
o << "</span>"
|
o << " <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a>"
|
||||||
o << "<script>"
|
o << "</span>"
|
||||||
o << "//<![CDATA[\n"
|
o << "<script>"
|
||||||
o << " $(function() { $('#DueDateInput input').addClass('date').datepickerFallback(datepickerOptions); });\n"
|
o << "//<![CDATA[\n"
|
||||||
o << "//]]>\n"
|
o << " $(function() { $('#DueDateInput input').addClass('date').datepickerFallback(datepickerOptions); });\n"
|
||||||
o << "</script>"
|
o << "//]]>\n"
|
||||||
|
o << "</script>"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user