Redmine でチケット更新時にフォームの値からウォッチャーを追加
対象
- Redmine : 3.3.1
- クライアント : Linux, Firefox 50.1.0
やりたいこと
ユーザー選択のフィールドを持つチケットを更新するときに、選択したユーザーをついでにウォッチャーに追加したい場合がある。
ウォッチャーの追加を自動にしたい。
方法
View Customize Plugin (https://github.com/onozaty/redmine-view-customize) を使う。
/issues/\d+$
$(document).on("submit", "#issue-form", function() {
var trackerId = "1";
var statusId = "1";
var userFieldIds = [
"issue_custom_field_values_1",
"issue_custom_field_values_2"
];
if ($("#issue_tracker_id").length > 0) {
if ($("#issue_tracker_id").val() !== trackerId) {
return;
}
} else {
if (!$("#content > div.issue").hasClass("tracker-" + trackerId)) {
return;
}
}
if ($("#issue_status_id").val() !== statusId) {
return;
}
var userIds = [];
for (var i = 0; i < userFieldIds.length; i++) {
$("#" + userFieldIds[i]).each(function() {
var $this = $(this);
if ($this.is("select")) {
if ($this.prop("multiple")) {
userIds = userIds.concat($this.val() || []);
} else {
userIds.push($this.val());
}
} else if ($this.is("input")) {
$("input[name='" + $this.attr("name") + "'][value!='']:checked").each(function() {
userIds.push($(this).val());
});
}
});
}
if (!userIds) {
return;
}
$.post(location.href + "/watchers", { "watcher": { "user_ids": userIds } });
});
Author And Source
この問題について(Redmine でチケット更新時にフォームの値からウォッチャーを追加), 我々は、より多くの情報をここで見つけました https://qiita.com/ayweak/items/e8ede6d45859b1f608fd著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .