Revision 1297:0a574315af3e .svn/pristine/a3
| .svn/pristine/a3/a314ca86d401cd6c66c2c275d0d98bd9585e53c9.svn-base | ||
|---|---|---|
| 1 |
# encoding: utf-8 |
|
| 2 |
# |
|
| 3 |
# Redmine - project management software |
|
| 4 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 5 |
# |
|
| 6 |
# This program is free software; you can redistribute it and/or |
|
| 7 |
# modify it under the terms of the GNU General Public License |
|
| 8 |
# as published by the Free Software Foundation; either version 2 |
|
| 9 |
# of the License, or (at your option) any later version. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License |
|
| 17 |
# along with this program; if not, write to the Free Software |
|
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 19 |
|
|
| 20 |
module ProjectsHelper |
|
| 21 |
def link_to_version(version, options = {})
|
|
| 22 |
return '' unless version && version.is_a?(Version) |
|
| 23 |
link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
|
|
| 24 |
end |
|
| 25 |
|
|
| 26 |
def project_settings_tabs |
|
| 27 |
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
|
| 28 |
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
|
| 29 |
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
|
|
| 30 |
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
|
| 31 |
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
|
| 32 |
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
|
| 33 |
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
|
|
| 34 |
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
|
|
| 35 |
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
|
|
| 36 |
] |
|
| 37 |
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
|
| 38 |
end |
|
| 39 |
|
|
| 40 |
def parent_project_select_tag(project) |
|
| 41 |
selected = project.parent |
|
| 42 |
# retrieve the requested parent project |
|
| 43 |
parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] |
|
| 44 |
if parent_id |
|
| 45 |
selected = (parent_id.blank? ? nil : Project.find(parent_id)) |
|
| 46 |
end |
|
| 47 |
|
|
| 48 |
options = '' |
|
| 49 |
options << "<option value=''></option>" if project.allowed_parents.include?(nil) |
|
| 50 |
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) |
|
| 51 |
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
|
|
| 52 |
end |
|
| 53 |
|
|
| 54 |
# Renders the projects index |
|
| 55 |
def render_project_hierarchy(projects) |
|
| 56 |
render_project_nested_lists(projects) do |project| |
|
| 57 |
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
|
| 58 |
if project.description.present? |
|
| 59 |
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
|
|
| 60 |
end |
|
| 61 |
s |
|
| 62 |
end |
|
| 63 |
end |
|
| 64 |
|
|
| 65 |
# Returns a set of options for a select field, grouped by project. |
|
| 66 |
def version_options_for_select(versions, selected=nil) |
|
| 67 |
grouped = Hash.new {|h,k| h[k] = []}
|
|
| 68 |
versions.each do |version| |
|
| 69 |
grouped[version.project.name] << [version.name, version.id] |
|
| 70 |
end |
|
| 71 |
|
|
| 72 |
if grouped.keys.size > 1 |
|
| 73 |
grouped_options_for_select(grouped, selected && selected.id) |
|
| 74 |
else |
|
| 75 |
options_for_select((grouped.values.first || []), selected && selected.id) |
|
| 76 |
end |
|
| 77 |
end |
|
| 78 |
|
|
| 79 |
def format_version_sharing(sharing) |
|
| 80 |
sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) |
|
| 81 |
l("label_version_sharing_#{sharing}")
|
|
| 82 |
end |
|
| 83 |
end |
|
| .svn/pristine/a3/a3a57388b3ae4f50b030906e001d30172793704b.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class IssueCategoryTest < ActiveSupport::TestCase |
|
| 21 |
fixtures :issue_categories, :issues, :users, :groups_users |
|
| 22 |
|
|
| 23 |
def setup |
|
| 24 |
@category = IssueCategory.find(1) |
|
| 25 |
end |
|
| 26 |
|
|
| 27 |
def test_create |
|
| 28 |
assert IssueCategory.new(:project_id => 2, :name => 'New category').save |
|
| 29 |
category = IssueCategory.first(:order => 'id DESC') |
|
| 30 |
assert_equal 'New category', category.name |
|
| 31 |
end |
|
| 32 |
|
|
| 33 |
def test_create_with_group_assignment |
|
| 34 |
assert IssueCategory.new(:project_id => 2, :name => 'Group assignment', :assigned_to_id => 11).save |
|
| 35 |
category = IssueCategory.first(:order => 'id DESC') |
|
| 36 |
assert_kind_of Group, category.assigned_to |
|
| 37 |
assert_equal Group.find(11), category.assigned_to |
|
| 38 |
end |
|
| 39 |
|
|
| 40 |
def test_destroy |
|
| 41 |
issue = @category.issues.first |
|
| 42 |
@category.destroy |
|
| 43 |
# Make sure the category was nullified on the issue |
|
| 44 |
assert_nil issue.reload.category |
|
| 45 |
end |
|
| 46 |
|
|
| 47 |
def test_destroy_with_reassign |
|
| 48 |
issue = @category.issues.first |
|
| 49 |
reassign_to = IssueCategory.find(2) |
|
| 50 |
@category.destroy(reassign_to) |
|
| 51 |
# Make sure the issue was reassigned |
|
| 52 |
assert_equal reassign_to, issue.reload.category |
|
| 53 |
end |
|
| 54 |
end |
|
| .svn/pristine/a3/a3b49dd1167634bbf9c5460ad4e1ffc52389846f.svn-base | ||
|---|---|---|
| 1 |
<%= form_tag({}) do -%>
|
|
| 2 |
<%= hidden_field_tag 'back_url', url_for(params) %> |
|
| 3 |
<div class="autoscroll"> |
|
| 4 |
<table class="list time-entries"> |
|
| 5 |
<thead> |
|
| 6 |
<tr> |
|
| 7 |
<th class="checkbox hide-when-print"> |
|
| 8 |
<%= link_to image_tag('toggle_check.png'),
|
|
| 9 |
{},
|
|
| 10 |
:onclick => 'toggleIssuesSelection(this); return false;', |
|
| 11 |
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
|
| 12 |
</th> |
|
| 13 |
<%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
|
|
| 14 |
<%= sort_header_tag('user', :caption => l(:label_member)) %>
|
|
| 15 |
<%= sort_header_tag('activity', :caption => l(:label_activity)) %>
|
|
| 16 |
<%= sort_header_tag('project', :caption => l(:label_project)) %>
|
|
| 17 |
<%= sort_header_tag('issue', :caption => l(:label_issue), :default_order => 'desc') %>
|
|
| 18 |
<th><%= l(:field_comments) %></th> |
|
| 19 |
<%= sort_header_tag('hours', :caption => l(:field_hours)) %>
|
|
| 20 |
<th></th> |
|
| 21 |
</tr> |
|
| 22 |
</thead> |
|
| 23 |
<tbody> |
|
| 24 |
<% entries.each do |entry| -%> |
|
| 25 |
<tr class="time-entry <%= cycle("odd", "even") %> hascontextmenu">
|
|
| 26 |
<td class="checkbox hide-when-print"><%= check_box_tag("ids[]", entry.id, false, :id => nil) %></td>
|
|
| 27 |
<td class="spent_on"><%= format_date(entry.spent_on) %></td> |
|
| 28 |
<td class="user"><%= link_to_user(entry.user) %></td> |
|
| 29 |
<td class="activity"><%=h entry.activity %></td> |
|
| 30 |
<td class="project"><%= link_to_project(entry.project) %></td> |
|
| 31 |
<td class="subject"> |
|
| 32 |
<% if entry.issue -%> |
|
| 33 |
<%= entry.issue.visible? ? link_to_issue(entry.issue, :truncate => 50) : "##{entry.issue.id}" -%>
|
|
| 34 |
<% end -%> |
|
| 35 |
</td> |
|
| 36 |
<td class="comments"><%=h entry.comments %></td> |
|
| 37 |
<td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
|
|
| 38 |
<td align="center"> |
|
| 39 |
<% if entry.editable_by?(User.current) -%> |
|
| 40 |
<%= link_to image_tag('edit.png'), edit_time_entry_path(entry),
|
|
| 41 |
:title => l(:button_edit) %> |
|
| 42 |
<%= link_to image_tag('delete.png'), time_entry_path(entry),
|
|
| 43 |
:data => {:confirm => l(:text_are_you_sure)},
|
|
| 44 |
:method => :delete, |
|
| 45 |
:title => l(:button_delete) %> |
|
| 46 |
<% end -%> |
|
| 47 |
</td> |
|
| 48 |
</tr> |
|
| 49 |
<% end -%> |
|
| 50 |
</tbody> |
|
| 51 |
</table> |
|
| 52 |
</div> |
|
| 53 |
<% end -%> |
|
| 54 |
|
|
| 55 |
<%= context_menu time_entries_context_menu_path %> |
|
| .svn/pristine/a3/a3bdc31069cf7b8c2534d8421122408de9806ec5.svn-base | ||
|---|---|---|
| 1 |
#!/usr/bin/env ruby |
|
| 2 |
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. |
|
| 3 |
|
|
| 4 |
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
| 5 |
require File.expand_path('../../config/boot', __FILE__)
|
|
| 6 |
require 'rails/commands' |
|
| .svn/pristine/a3/a3be1d86be827009cae521df133b9bd67e4c3929.svn-base | ||
|---|---|---|
| 1 |
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5); |
|
| 2 |
|
|
| 3 |
function addOption(theSel, theText, theValue) |
|
| 4 |
{
|
|
| 5 |
var newOpt = new Option(theText, theValue); |
|
| 6 |
var selLength = theSel.length; |
|
| 7 |
theSel.options[selLength] = newOpt; |
|
| 8 |
} |
|
| 9 |
|
|
| 10 |
function swapOptions(theSel, index1, index2) |
|
| 11 |
{
|
|
| 12 |
var text, value; |
|
| 13 |
text = theSel.options[index1].text; |
|
| 14 |
value = theSel.options[index1].value; |
|
| 15 |
theSel.options[index1].text = theSel.options[index2].text; |
|
| 16 |
theSel.options[index1].value = theSel.options[index2].value; |
|
| 17 |
theSel.options[index2].text = text; |
|
| 18 |
theSel.options[index2].value = value; |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
function deleteOption(theSel, theIndex) |
|
| 22 |
{
|
|
| 23 |
var selLength = theSel.length; |
|
| 24 |
if(selLength>0) |
|
| 25 |
{
|
|
| 26 |
theSel.options[theIndex] = null; |
|
| 27 |
} |
|
| 28 |
} |
|
| 29 |
|
|
| 30 |
function moveOptions(theSelFrom, theSelTo) |
|
| 31 |
{
|
|
| 32 |
|
|
| 33 |
var selLength = theSelFrom.length; |
|
| 34 |
var selectedText = new Array(); |
|
| 35 |
var selectedValues = new Array(); |
|
| 36 |
var selectedCount = 0; |
|
| 37 |
|
|
| 38 |
var i; |
|
| 39 |
|
|
| 40 |
for(i=selLength-1; i>=0; i--) |
|
| 41 |
{
|
|
| 42 |
if(theSelFrom.options[i].selected) |
|
| 43 |
{
|
|
| 44 |
selectedText[selectedCount] = theSelFrom.options[i].text; |
|
| 45 |
selectedValues[selectedCount] = theSelFrom.options[i].value; |
|
| 46 |
deleteOption(theSelFrom, i); |
|
| 47 |
selectedCount++; |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
for(i=selectedCount-1; i>=0; i--) |
|
| 52 |
{
|
|
| 53 |
addOption(theSelTo, selectedText[i], selectedValues[i]); |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
if(NS4) history.go(0); |
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
function moveOptionUp(theSel) {
|
|
| 60 |
var index = theSel.selectedIndex; |
|
| 61 |
if (index > 0) {
|
|
| 62 |
swapOptions(theSel, index-1, index); |
|
| 63 |
theSel.selectedIndex = index-1; |
|
| 64 |
} |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
function moveOptionDown(theSel) {
|
|
| 68 |
var index = theSel.selectedIndex; |
|
| 69 |
if (index < theSel.length - 1) {
|
|
| 70 |
swapOptions(theSel, index, index+1); |
|
| 71 |
theSel.selectedIndex = index+1; |
|
| 72 |
} |
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
// OK |
|
| 76 |
function selectAllOptions(id) |
|
| 77 |
{
|
|
| 78 |
var select = $('#'+id);/*
|
|
| 79 |
for (var i=0; i<select.options.length; i++) {
|
|
| 80 |
select.options[i].selected = true; |
|
| 81 |
}*/ |
|
| 82 |
select.children('option').attr('selected', true);
|
|
| 83 |
} |
|
Also available in: Unified diff