Configuration file added (https settings, target and action listener choices, field exclusion) (#30 #35 #41)
This commit is contained in:
parent
3ef47ab625
commit
1fb2a0519c
@ -1,8 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* OPTIONS DEFINED FROM CONFIGURATION FILE
|
||||||
|
*/
|
||||||
|
var _CONF_FORCE_HTTPS = _CONF_FORCE_HTTPS || false;
|
||||||
|
var _CONF_LISTENER_TYPE = _CONF_LISTENER_TYPE || "click";
|
||||||
|
var _CONF_LISTENER_TARGET = _CONF_LISTENER_TARGET || "value";
|
||||||
|
var _CONF_EXCLUDED_FIELD_ID = _CONF_EXCLUDED_FIELD_ID || [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allow inclusion from other page
|
* Allow inclusion from other page
|
||||||
* See https://github.com/Ilogeek/redmine_issue_dynamic_edit/commit/26684a2dd9b12dcc7377afd79e9fe5c142d26ebd for more info
|
* See https://github.com/Ilogeek/redmine_issue_dynamic_edit/commit/26684a2dd9b12dcc7377afd79e9fe5c142d26ebd for more info
|
||||||
*/
|
*/
|
||||||
var LOCATION_HREF = typeof custom_location_href !== 'undefined' ? custom_location_href : window.location.href;
|
var LOCATION_HREF = typeof custom_location_href !== 'undefined' ? custom_location_href : window.location.href;
|
||||||
|
if(_CONF_FORCE_HTTPS) { LOCATION_HREF = LOCATION_HREF.replace(/^http:\/\//i, 'https://'); }
|
||||||
|
|
||||||
/* FontAwesome inclusion */
|
/* FontAwesome inclusion */
|
||||||
var cssId = 'fontAwesome';
|
var cssId = 'fontAwesome';
|
||||||
@ -18,18 +27,32 @@ var cssId = 'fontAwesome';
|
|||||||
head.appendChild(link);
|
head.appendChild(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', function(e){
|
$(document).on(_CONF_LISTENER_TYPE, function(e){
|
||||||
$('.issue .attributes .attribute .value').removeClass('edited');
|
$('.issue .attributes .attribute .value').removeClass('edited');
|
||||||
if($(e.target).closest('a').length){ return; }
|
if($(e.target).closest('a').length){ return; }
|
||||||
if($(e.target).closest('.value').length) {
|
if($(e.target).closest('.' + _CONF_LISTENER_TARGET).length) {
|
||||||
|
// avoid text selection if dblclick
|
||||||
|
var sel = window.getSelection ? window.getSelection() : document.selection;
|
||||||
|
if (sel) {
|
||||||
|
if (sel.removeAllRanges) {
|
||||||
|
sel.removeAllRanges();
|
||||||
|
} else if (sel.empty) {
|
||||||
|
sel.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// we show the edit box
|
||||||
$(e.target).closest('.value').addClass('edited');
|
$(e.target).closest('.value').addClass('edited');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isExcluded(elmt_id) {
|
||||||
|
return _CONF_EXCLUDED_FIELD_ID.indexOf(elmt_id) > -1;
|
||||||
|
}
|
||||||
|
|
||||||
function initEditFields()
|
function initEditFields()
|
||||||
{
|
{
|
||||||
/* Put new dropdown lists in the detailed info block */
|
/* Put new dropdown lists in the detailed info block */
|
||||||
if($('#statusListDropdown').length > 0) {
|
if($('#statusListDropdown').length > 0 && !isExcluded('statusListDropdown')) {
|
||||||
var htmlCopy = $('#statusListDropdown').get(0).outerHTML;
|
var htmlCopy = $('#statusListDropdown').get(0).outerHTML;
|
||||||
$('#statusListDropdown').remove();
|
$('#statusListDropdown').remove();
|
||||||
$('.details .attributes .status.attribute .value').html( '<span class="showValue">' +
|
$('.details .attributes .status.attribute .value').html( '<span class="showValue">' +
|
||||||
@ -37,7 +60,7 @@ function initEditFields()
|
|||||||
htmlCopy);
|
htmlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#prioritiesListDropdown').length > 0) {
|
if($('#prioritiesListDropdown').length > 0 && !isExcluded('prioritiesListDropdown')) {
|
||||||
var htmlCopy = $('#prioritiesListDropdown').get(0).outerHTML;
|
var htmlCopy = $('#prioritiesListDropdown').get(0).outerHTML;
|
||||||
$('#prioritiesListDropdown').remove();
|
$('#prioritiesListDropdown').remove();
|
||||||
$('.details .attributes .priority.attribute .value').html( '<span class="showValue">' +
|
$('.details .attributes .priority.attribute .value').html( '<span class="showValue">' +
|
||||||
@ -45,7 +68,7 @@ function initEditFields()
|
|||||||
htmlCopy);
|
htmlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#doneRatioListDropdown').length > 0) {
|
if($('#doneRatioListDropdown').length > 0 && !isExcluded('doneRatioListDropdown')) {
|
||||||
var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML;
|
var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML;
|
||||||
$('#doneRatioListDropdown').remove();
|
$('#doneRatioListDropdown').remove();
|
||||||
$('.details .attributes .progress.attribute .value').html('<span class="showValue">' +
|
$('.details .attributes .progress.attribute .value').html('<span class="showValue">' +
|
||||||
@ -53,7 +76,7 @@ function initEditFields()
|
|||||||
htmlCopy);
|
htmlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#EstimatedTimeInput').length > 0) {
|
if($('#EstimatedTimeInput').length > 0 && !isExcluded('EstimatedTimeInput')) {
|
||||||
var htmlCopy = $('#EstimatedTimeInput').get(0).outerHTML;
|
var htmlCopy = $('#EstimatedTimeInput').get(0).outerHTML;
|
||||||
$('#EstimatedTimeInput').remove();
|
$('#EstimatedTimeInput').remove();
|
||||||
$('.details .attributes .estimated-hours.attribute .value').html('<span class="showValue">' +
|
$('.details .attributes .estimated-hours.attribute .value').html('<span class="showValue">' +
|
||||||
@ -61,7 +84,7 @@ function initEditFields()
|
|||||||
htmlCopy);
|
htmlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#StartDateInput').length > 0) {
|
if($('#StartDateInput').length > 0 && !isExcluded('StartDateInput')) {
|
||||||
var htmlCopy = $('#StartDateInput').get(0).outerHTML;
|
var htmlCopy = $('#StartDateInput').get(0).outerHTML;
|
||||||
$('#StartDateInput').remove();
|
$('#StartDateInput').remove();
|
||||||
$('.details .attributes .start-date.attribute .value').html('<span class="showValue">' +
|
$('.details .attributes .start-date.attribute .value').html('<span class="showValue">' +
|
||||||
@ -69,7 +92,7 @@ function initEditFields()
|
|||||||
htmlCopy);
|
htmlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#DueDateInput').length > 0) {
|
if($('#DueDateInput').length > 0 && !isExcluded('DueDateInput')) {
|
||||||
var htmlCopy = $('#DueDateInput').get(0).outerHTML;
|
var htmlCopy = $('#DueDateInput').get(0).outerHTML;
|
||||||
$('#DueDateInput').remove();
|
$('#DueDateInput').remove();
|
||||||
$('.details .attributes .due-date.attribute .value').html('<span class="showValue">' +
|
$('.details .attributes .due-date.attribute .value').html('<span class="showValue">' +
|
||||||
@ -77,21 +100,21 @@ function initEditFields()
|
|||||||
htmlCopy);
|
htmlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#TitleInput').length > 0) {
|
if($('#TitleInput').length > 0 && !isExcluded('TitleInput')) {
|
||||||
var htmlCopy = $('#TitleInput').get(0).outerHTML;
|
var htmlCopy = $('#TitleInput').get(0).outerHTML;
|
||||||
$('#TitleInput').remove();
|
$('#TitleInput').remove();
|
||||||
$('.subject h3').html('<span class="showValue">' + $('.subject h3').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
$('.subject h3').html('<span class="showValue">' + $('.subject h3').html() + '</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
|
||||||
htmlCopy).addClass('value');
|
htmlCopy).addClass('value');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#DescriptionInput').length > 0) {
|
if($('#DescriptionInput').length > 0 && !isExcluded('DescriptionInput')) {
|
||||||
var htmlCopy = $('#DescriptionInput').get(0).outerHTML;
|
var htmlCopy = $('#DescriptionInput').get(0).outerHTML;
|
||||||
$('#DescriptionInput').remove();
|
$('#DescriptionInput').remove();
|
||||||
$('div.description .wiki').html(' <i class="fa fa-pencil fa-fw" aria-hidden="true" style="float:right;"></i><span class="showValue">' + $('div.description .wiki').html() + '</span>' +
|
$('div.description .wiki').html(' <i class="fa fa-pencil fa-fw" aria-hidden="true" style="float:right;"></i><span class="showValue">' + $('div.description .wiki').html() + '</span>' +
|
||||||
htmlCopy).addClass('value');
|
htmlCopy).addClass('value');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('select#issue_assigned_to_id').length > 0)
|
if($('select#issue_assigned_to_id').length > 0 && !isExcluded('issue_assigned_to_id'))
|
||||||
{
|
{
|
||||||
var htmlCopy = $('select#issue_assigned_to_id').get(0).outerHTML;
|
var htmlCopy = $('select#issue_assigned_to_id').get(0).outerHTML;
|
||||||
// 2 technics with simple or double quote (safety first)
|
// 2 technics with simple or double quote (safety first)
|
||||||
@ -107,7 +130,7 @@ function initEditFields()
|
|||||||
editHTML);
|
editHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('select#issue_fixed_version_id').length > 0)
|
if($('select#issue_fixed_version_id').length > 0 && !isExcluded('issue_fixed_version_id'))
|
||||||
{
|
{
|
||||||
var htmlCopy = $('select#issue_fixed_version_id').get(0).outerHTML;
|
var htmlCopy = $('select#issue_fixed_version_id').get(0).outerHTML;
|
||||||
// 2 technics with simple or double quote (safety first)
|
// 2 technics with simple or double quote (safety first)
|
||||||
@ -127,7 +150,7 @@ function initEditFields()
|
|||||||
{
|
{
|
||||||
var info = CF_VALUE_JSON[i].custom_field;
|
var info = CF_VALUE_JSON[i].custom_field;
|
||||||
var value = CF_VALUE_JSON[i].value;
|
var value = CF_VALUE_JSON[i].value;
|
||||||
if(info.visible && info.editable)
|
if(info.visible && info.editable && !isExcluded("issue_custom_field_values_" + info.id))
|
||||||
{
|
{
|
||||||
if($('.details .attributes .cf_' + info.id + '.attribute .value').length
|
if($('.details .attributes .cf_' + info.id + '.attribute .value').length
|
||||||
&& $('#issue_custom_field_values_' + info.id).length )
|
&& $('#issue_custom_field_values_' + info.id).length )
|
||||||
|
|||||||
35
assets/javascripts/issue_dynamic_edit_configuration_file.js
Normal file
35
assets/javascripts/issue_dynamic_edit_configuration_file.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* CONFIGURATION FILE
|
||||||
|
* More info on https://github.com/Ilogeek/redmine_issue_dynamic_edit
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* _CONF_FORCE_HTTPS (boolean)
|
||||||
|
* Will force AJAX call performed by the plugin to be done with https protocol
|
||||||
|
* Use this value if you encounter some difficulties with "Mixed content" issues
|
||||||
|
* Allowed values : false (default), true
|
||||||
|
*/
|
||||||
|
var _CONF_FORCE_HTTPS = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* _CONF_LISTENER_TYPE (string)
|
||||||
|
* Choose which action will trigger the apparition of the edition block
|
||||||
|
* Allowed values : click (default), dblclick
|
||||||
|
*/
|
||||||
|
var _CONF_LISTENER_TYPE = "click";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* _CONF_LISTENER_TARGET (string)
|
||||||
|
* Choose which area will trigger the apparition of the edition block
|
||||||
|
* "value" will target the whole line, "fa-pencil" will only target the pencil icon
|
||||||
|
* Allowed values : value (default), fa-pencil
|
||||||
|
*/
|
||||||
|
var _CONF_LISTENER_TARGET = "value";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* _CONF_EXCLUDED_FIELD_ID (string array)
|
||||||
|
* Choose which fields to exclude. They won't have the edit block and pencil
|
||||||
|
* Custom fields have an unique ID and this ID must be prefixed by "issue_custom_field_values_". Eg : "issue_custom_field_values_4" is an allowed value
|
||||||
|
* Allowed values : array of any ID selector (css). Eg : ["statusListDropdown", "StartDateInput", "TitleInput", "issue_custom_field_values_4"]
|
||||||
|
*/
|
||||||
|
var _CONF_EXCLUDED_FIELD_ID = [];
|
||||||
@ -17,7 +17,7 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
def view_layouts_base_body_bottom(context)
|
def view_layouts_base_body_bottom(context)
|
||||||
if current_is_detail_page(context)
|
if current_is_detail_page(context)
|
||||||
javascript_include_tag('issue_dynamic_edit.js', :plugin => :redmine_issue_dynamic_edit)
|
javascript_include_tag('issue_dynamic_edit_configuration_file.js', 'issue_dynamic_edit.js', :plugin => :redmine_issue_dynamic_edit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user