Redmine Ticket Preset

Autofill new ticket fields.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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" );
})();