# encoding: utf-8 #-- # Copyright (C) 2010 Juho Nieminen # Copyright (C) 2009 Fabio Hideaki Hisamoto # Copyright (C) 2009 Johan Sørensen # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . #++ class GitoriousFormBuilder < ActionView::Helpers::FormBuilder #Creates an option select group out of current repos branches #and a input field for new branch name def current_repos_heads(id, name, current_repo) result = [' ' result << '' result.join("\n") end #Creates an option select group out of current user's projects def current_users_projects(id, name, current_project, users_projects) result = ['' result.join("\n") end # Creates a set of radio buttons for the current_user and a select tag # for any groups he's a member of def current_user_or_group(field, label_title, admin_groups, hint = nil, options = {}) if admin_groups.empty? result = ['
'] else result = ['
'] end result << label(label_title+":") result << "
" result << "Me: " + radio_button("#{field}_type", "User", {:checked => true}) result << select_group_membership(field, admin_groups) result << '
' if options[:hint] result << content_tag(:p, options[:hint], :class => "hint") end result.join("\n") end private def select_group_membership(field, admin_groups) #admin_groups = @template.current_user.groups.select {|g| g.admin? @template.current_user } result = "" result << "Team: " + radio_button("#{field}_type", "Group") result << select("#{field}_id", admin_groups.map{|g| [g.name, g.id] }, {}, :id => "#{object_name}_#{field}_id_group_select") result end end