操作
プラグインハンズオン サンプル » 履歴 » リビジョン 4
« 前 |
リビジョン 4/20
(差分)
| 次 »
Haru Iida, 2011/01/22 15:28
プラグインハンズオン サンプル¶
init.rbのサンプル
require 'redmine' Redmine::Plugin.register :redmine_issue_templates do name 'Redmine Issue Templates plugin' author 'Haruyuki Iida' description 'This is a plugin for Redmine' version '0.0.1' url 'http://example.com/path/to/plugin' author_url 'http://example.com/about' requires_redmine :version_or_higher => '1.1.0' # 各アクションの権限定義。ここで定義した権限が管理メニューの「ロールと権限」に表示される。 project_module :issue_templates do permission :edit_issue_templates, {:issue_templates => [:create, :update, :destroy]} permission :show_issue_templates, {:issue_templates => [:index, :show, :load]} end # プロジェクトメニューに追加するTABの定義 # TABのキャプション、表示位置、TABをクリックした時に呼ばれるアクションなどを定義 # ここではissue_templates_controllerのindexを呼ぶ設定。 menu :project_menu, :issue_templates, { :controller => 'issue_templates', :action => 'index' }, :caption => "チケットテンプレート", :after => :issues end
index.html.erb のサンプル
<h2>IssueTemplates#index</h2> <%= link_to '新規作成', :controller => 'issue_templates', :action => 'create', :id=>@project %>
create.html.erb のサンプル
<h2>テンプレートの作成</h2> <% labelled_tabular_form_for :issue_template, @issue_template, :action => 'update' do |f|%> <p> <%= f.text_field :title, :size => 50, :required => true %> </p> <p> <%= f.text_field :note, :size => 80, :label => l(:issue_template_note) %> </p> <p><%= f.text_area :description, :rows => 8, :cols=>60, :accesskey => accesskey(:edit), :class => 'wiki-edit' ,:required => true %></p> <%= submit_tag l(:button_apply) %> <% end %>