Redmine Ticket Preset

Autofill new ticket fields.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name           Redmine Ticket Preset
// @description:en Autofill new ticket fields.
// @version        0.2
// @namespace      http://twitter.com/foldrr/
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @match          http://*/redmine/projects/*/issues/new
// @description Autofill new ticket fields.
// ==/UserScript==

(function(){
    var config = {
        'project1': {
            'private' : true,
            'tracker' : '開発',
            'assigned': 'Steve',
            'version' : 'v1.0.0',
        },
        'project2': {
            'private' : false,
            'tracker' : '開発',
            'assigned': 'Woz',
            'version' : 'v1.1.0',
        },
    };
    var project_name = (location.href.match(/projects\/([^\/]+)/) || [])[1];
    if(! project_name) return;
    if(! config[project_name]) return;
    
    var setCheck = function(id, key){
        var value = config[project_name][key];
        if(! value) return;
        
        $('input[id="' + id + '"]').prop('checked', !!value);
    };
    
    var setSelect = function(id, key){
        var text = config[project_name][key];
        if(! text) return;
        
        value = $('select[id="' + id + '"] option:contains("' + text + '")').val();
        $('select[id="' + id + '"]').val(value);
    };
    
    setCheck ("issue_is_private"      , "private" );
    setSelect("issue_tracker_id"      , "tracker" );
    setSelect("issue_assigned_to_id"  , "assigned");
    setSelect("issue_fixed_version_id", "version" );
})();