Last active
May 1, 2025 07:57
-
-
Save furu-nob/d8067811a9b41a0e94a01eb46d16ca3a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Redmine view-customize Plugin | |
# 選択したテンプレートよって、custom_fieldを自動的に切り替える、マッピング定義版 | |
# パスのパターン なし → 「/projects/some_project/issues/new」選択したプロジェクトから新しいチケットを作る想定空欄でもいいかも | |
# プロジェクトのパターン「some_project」(プロジェクトを選択) | |
# 挿入位置 「全ページのヘッダ」 | |
# 種別 「JavaScript」 | |
$(function() { | |
const templateMapping = { | |
'1': 'AAA', | |
'2': 'AAA', | |
'3': 'BBB', | |
'4': 'CCC', | |
'5': 'DDD', | |
'6': 'EEE', | |
'7': 'BBB', | |
'8': 'CCC', | |
'9': 'DDD', | |
'10': 'EEE', | |
// 必要に応じて他のテンプレートIDも追加 | |
}; | |
function updateCustomFieldsBasedOnTemplate() { | |
var templateId = $('#issue_template').val(); // テンプレートIDを取得 | |
console.log('Template ID:', templateId); | |
var value = templateMapping[templateId] || ''; // マッピングにない場合は空文字 | |
$('[name="issue[custom_field_values][3]"]').val(value); | |
} | |
// 初回呼び出し | |
updateCustomFieldsBasedOnTemplate(); | |
// テンプレート選択時にも実行 | |
$('#issue_template').on('change', updateCustomFieldsBasedOnTemplate); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment