backlogのチケット作成時にカテゴリを選択すると自動でテンプレートが入る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 初期設定 | |
// 発火させたいプロジェクトを記入 | |
var projectName = ""; | |
// テンプレートをbacklogのリポジトリにmarkdown形式で保存。 | |
var template = [ | |
["カテゴリ1", "https://pepope.backlog.com/git/TEST/repo/raw/master/template1.md"], | |
["カテゴリ2", "https://pepope.backlog.com/git/TEST/repo/raw/master/template2.md"] | |
]; | |
// テキストをフォームに入れる関数 | |
function insertText(url) { | |
var syosai = $("#descriptionTextArea"); | |
if (location.pathname == "/add/" + projectName && syosai.val() == "") { | |
// syosai.load(url); // 読み込んだファイルをフォームに書き込めるが、再選択時にうまく動かないため、以下方法にした | |
$.get(url, function (data) { | |
syosai.val(data); | |
}); | |
} | |
} | |
// メイン関数。カテゴリの変更を検知したら発火。 | |
$(function () { | |
$('select[name="issue.componentIds"]').change(function () { | |
var keyword = $('select[name="issue.componentIds"] > option:selected').text(); | |
//console.log("発火検知"); | |
for (var i = 0; i < template.length; i++) { | |
if (template[i][0] == keyword) { | |
//console.log(keyword); | |
insertText(template[i][1]); | |
break; | |
} | |
}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment