Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yamahigashi/df89a09d6270af05e9e3 to your computer and use it in GitHub Desktop.
Save yamahigashi/df89a09d6270af05e9e3 to your computer and use it in GitHub Desktop.
// Redmine View Customize script // enable on Dashboard Ticket Edit with overlay edit, like trello
// Redmine Dashboard のチケット編集をページ遷移なしに
//
// https://github.com/Gera-IT/Redmine-Fast-Issues-Edit.git
// redmine_overlay_issues_manager
//
// Path pattern: /rdb/taskboard.*
// Type: JavaScript
$(function() {
var overlayTicketEdit = function() {
var a = $('#rdb-board-container>.rdb-groups .rdb-menu-issue>.rdb-container .rdb-list>ul>li:nth-of-type(2)>a');
a.on('click', function(e){
e.preventDefault();
//console.log(e);
_this = $(this);
var exp = /(^|\/([^\/]+))\/projects\/([^\/]+)/;
var match = exp.exec( $('form').first().attr('action') );
var prefix = match[2];
var project_id = match[3];
var url = match[1] + "/render_form.js";
var id = $(this).attr('href').match( /\/issues\/(\d+)/ )[1];
$.ajax({
url: url,
//data: {id: id, project_id: project_id},
data: {id: id},
dataType: 'script',
error: function(XMLHttpRequest, textStatus, errorThrown) {
//window.location = _this.attr('href');
console.log( XMLHttpRequest );
console.log( textStatus );
console.log( errorThrown );
}
})
});
};
var overlayTicketNew = function() {
var get_first_enabled_tracker_id = function() {
var checkboxes = $('.rdb-menu-tracker span.rdb-multicheck > a').filter( "[class$='-enabled']");
return checkboxes.attr( 'href' ).match( /\d+$/ )[0];
};
var get_user_id = function() {
var ua = $( 'a.user.active' );
return ua.attr( 'href' ).match( /\d+$/ )[0];
};
var get_project_id = function( elem ) {
var p_id = elem.attr( 'data-rdb-drop-group' ).match( /\d+$/ );
if( p_id !== null ){
return p_id[0];
} else {
var exp = /(^|\/([^\/]+))\/projects\/([^\/]+)/;
var match = exp.exec( location.href );
return match[3];
}
};
var x = $('.rdb-columns > .rdb-column');
x.dblclick( function( ev ) {
ev.preventDefault();
//console.log( ev );
_this = $( this );
var exp = /(^|\/([^\/]+))\/projects\/([^\/]+)/;
var match = exp.exec( location.href );
var project_id = get_project_id( _this );
var tracker_id = get_first_enabled_tracker_id();
var status_id = _this.attr( 'data-rdb-column-id' ).replace( /^s/, '' );
var url = match[1] + "/render_new_form.js";
var me = get_user_id();
$.ajax({
url: url,
data: {
project_id: project_id,
issue: {
tracker_id: tracker_id,
status_id: status_id,
assigned_to_id: me
}
},
dataType: 'script',
error: function(XMLHttpRequest, textStatus, errorThrown) {
//window.location = _this.attr('href');
console.log( XMLHttpRequest );
console.log( textStatus );
console.log( errorThrown );
}
})
});
}
Rdb.rdbInit(overlayTicketEdit);
Rdb.rdbInit(overlayTicketNew);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment