プラグインハンズオン サンプル » 履歴 » バージョン 4
Haru Iida, 2011/01/22 15:28
1 | 1 | Haru Iida | h1. プラグインハンズオン サンプル |
---|---|---|---|
2 | |||
3 | 4 | Haru Iida | init.rbのサンプル |
4 | <pre> |
||
5 | require 'redmine' |
||
6 | |||
7 | Redmine::Plugin.register :redmine_issue_templates do |
||
8 | name 'Redmine Issue Templates plugin' |
||
9 | author 'Haruyuki Iida' |
||
10 | description 'This is a plugin for Redmine' |
||
11 | version '0.0.1' |
||
12 | url 'http://example.com/path/to/plugin' |
||
13 | author_url 'http://example.com/about' |
||
14 | requires_redmine :version_or_higher => '1.1.0' |
||
15 | |||
16 | # 各アクションの権限定義。ここで定義した権限が管理メニューの「ロールと権限」に表示される。 |
||
17 | project_module :issue_templates do |
||
18 | permission :edit_issue_templates, |
||
19 | {:issue_templates => [:create, :update, :destroy]} |
||
20 | permission :show_issue_templates, |
||
21 | {:issue_templates => [:index, :show, :load]} |
||
22 | end |
||
23 | |||
24 | # プロジェクトメニューに追加するTABの定義 |
||
25 | # TABのキャプション、表示位置、TABをクリックした時に呼ばれるアクションなどを定義 |
||
26 | # ここではissue_templates_controllerのindexを呼ぶ設定。 |
||
27 | menu :project_menu, :issue_templates, |
||
28 | { :controller => 'issue_templates', :action => 'index' }, |
||
29 | :caption => "チケットテンプレート", :after => :issues |
||
30 | |||
31 | end |
||
32 | |||
33 | </pre> |
||
34 | |||
35 | 3 | Haru Iida | index.html.erb のサンプル |
36 | |||
37 | 1 | Haru Iida | <pre> |
38 | 3 | Haru Iida | <h2>IssueTemplates#index</h2> |
39 | 1 | Haru Iida | |
40 | 3 | Haru Iida | <%= link_to '新規作成', :controller => 'issue_templates', |
41 | :action => 'create', :id=>@project %> |
||
42 | </pre> |
||
43 | 1 | Haru Iida | |
44 | create.html.erb のサンプル |
||
45 | 3 | Haru Iida | |
46 | <pre> |
||
47 | |||
48 | <h2>テンプレートの作成</h2> |
||
49 | |||
50 | 1 | Haru Iida | |
51 | <% labelled_tabular_form_for :issue_template, @issue_template, :action => 'update' do |f|%> |
||
52 | <p> |
||
53 | <%= f.text_field :title, :size => 50, :required => true %> |
||
54 | </p> |
||
55 | <p> |
||
56 | <%= f.text_field :note, :size => 80, :label => l(:issue_template_note) %> |
||
57 | </p> |
||
58 | <p><%= f.text_area :description, :rows => 8, :cols=>60, :accesskey => accesskey(:edit), :class => 'wiki-edit' ,:required => true %></p> |
||
59 | <%= submit_tag l(:button_apply) %> |
||
60 | <% end %> |
||
61 | </pre> |