2013-03-19 41 views
0

我正在使用插件來擴展redmine的文件附件功能。控制用戶複選框的可見性

對於我需要添加一個複選框,只有通過用戶與特定角色

可見我對紅寶石完全小白。這是我提到一些其他插件和redmine文檔後提出的。

在插件

/爲myplugin /應用/視圖/附件/ _form.html.erb

<% if view_private_attachment = User.current.allowed_to?(:view_private_attachments, @project) %> 
<%= check_box_tag :private_attachment, true, false %> 
<%= label_tag :private_attachment, 'Private Attachment', :style => 'font-weight:bold;' %> 
    <% end %> 

在插件/爲myplugin /應用/ init.d中

Redmine::Plugin.register :myplugin do 
    name 'myplugin' 
    author 'njan' 
    description 'This is a plugin for Redmine' 
    version '0.0.1' 
    url 'http://example.com/path/to/plugin' 
    author_url 'http://example.com/about' 


project_module :issue_tracking do 
permission :view_private_attachments, { } 

end 
end 

該複選框沒有得到顯示。

回答

0

根據您的情況,您可以使用複選框的禁用和只讀屬性。

<%= f.check_box :private_attachment, :disabled => true, :readonly => true %> 
+0

其實我想限制複選框的「可見性」。即一些具有「查看」權限的用戶可以看到其他人不能查看的複選框。 – born 2013-03-19 07:45:25

+0

如果你想提高能見度,那麼使用條件取決於條件。 – 2013-03-19 07:51:01

+0

哎呀抱歉,我搞砸了「角色和許可」。其實我做的是正確的。浪費至少4小時! Jeeezzzz。 – born 2013-03-19 08:08:31