2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Redmine APIでフィルタに複数の値を指定できるようにする

Posted at

cf_3が整数型のフィールドのとき、

のような感じで複数の値を指定できる方法がないっぽかったので、プラグインで実現してみた。
こういうの既に存在してたら是非教えて下さい。

ソースコード: github.com/miminashi/redmine-multiple-values-filter

注意点

  • いまのところ整数値のカスタムフィールドでしか使えない
  • バリデーションチェックを怠っている

しくみ

  • add_filter_errorをalias_method_chainで書き換えて、filter_typeが:integerの場合でもエラーを出さないようにしている
    • かわりのバリデーションを書かないといけないんだけど書いてない
  • sql_for_field_withをalias_method_chainで書き換えて、IN演算子でSQLを組み立てている

その他

  • Redmineは元々ひとつのフィールドあたり複数個の値を受け取れるようになっているっぽいのでこれを利用してもっと賢そうな感じにできないか
    • APIではなくブラウザからトラッカーなどを複数指定するところなどで使われている
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?