From 6bed3457e58c240917e46d141af04ae2125fbacb Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Tue, 27 Jul 2021 20:46:18 +0000 Subject: Merged r21085 to 4.1-stable (#35134). git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@21095 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/issues_helper.rb | 5 +++++ test/helpers/issues_helper_test.rb | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 30a2470e9..f2f40654b 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -217,6 +217,11 @@ module IssuesHelper if issue.total_spent_hours == issue.spent_hours link_to(l_hours_short(issue.spent_hours), path) else + # link to global time entries if cross-project subtasks are allowed + # in order to show time entries from not descendents projects + if %w(system tree hierarchy).include?(Setting.cross_project_subtasks) + path = time_entries_path(:issue_id => "~#{issue.id}") + end s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : "" s += " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})" s.html_safe diff --git a/test/helpers/issues_helper_test.rb b/test/helpers/issues_helper_test.rb index 89c9de0ef..991e7fe78 100644 --- a/test/helpers/issues_helper_test.rb +++ b/test/helpers/issues_helper_test.rb @@ -360,4 +360,26 @@ class IssuesHelperTest < Redmine::HelperTest assert_equal '06/06/2019', issue_due_date_details(issue) end end + + def test_issue_spent_hours_details_should_link_to_project_time_entries_depending_on_cross_project_setting + %w(descendants).each do |setting| + with_settings :cross_project_subtasks => setting do + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 3) + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 4) + + assert_match "href=\"/projects/ecookbook/time_entries?issue_id=~1\"", issue_spent_hours_details(Issue.find(1)) + end + end + end + + def test_issue_spent_hours_details_should_link_to_global_time_entries_depending_on_cross_project_setting + %w(system tree hierarchy).each do |setting| + with_settings :cross_project_subtasks => setting do + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 3) + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 4) + + assert_match "href=\"/time_entries?issue_id=~1\"", issue_spent_hours_details(Issue.find(1)) + end + end + end end -- cgit v1.2.3 t-invalid-value Vaadin 6, 7, 8 is a Java framework for modern Java web applications: https://github.com/vaadin/frameworkwww-data
summaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/ui/Image.java
blob: 7474e72443c629d421b77f4123aa1f4e53de18b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Copyright 2000-2018 Vaadin Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.vaadin.ui;

import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.server.Resource;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.image.ImageServerRpc;
import com.vaadin.shared.ui.image.ImageState;

/**
 * Component for embedding images.
 *
 * @author Vaadin Ltd.
 * @since 7.0
 */
@SuppressWarnings("serial")
public class Image extends AbstractEmbedded {

    protected ImageServerRpc rpc = (
            MouseEventDetails mouseDetails) -> fireEvent(
                    new ClickEvent(Image.this, mouseDetails));

    /**
     * Creates a new empty Image.
     */
    public Image() {
        registerRpc(rpc);
    }

    /**
     * Creates a new empty Image with caption.
     *
     * @param caption
     */
    public Image(String caption) {
        this();
        setCaption(caption);
    }

    /**
     * Creates a new Image whose contents is loaded from given resource. The
     * dimensions are assumed if possible. The type is guessed from resource.
     *
     * @param caption
     * @param source
     *            the Source of the embedded object.
     */
    public Image(String caption, Resource source) {
        this(caption);
        setSource(source);
    }

    @Override
    protected ImageState getState() {
        return (ImageState) super.getState();
    }

    @Override
    protected ImageState getState(boolean markAsDirty) {
        return (ImageState) super.getState(markAsDirty);
    }

    /**
     * Add a click listener to the component. The listener is called whenever
     * the user clicks inside the component. Depending on the content the event
     * may be blocked and in that case no event is fired.
     *
     * @see Registration
     *
     * @param listener
     *            The listener to add, not null
     * @return a registration object for removing the listener
     * @since 8.0
     */
    public Registration addClickListener(ClickListener listener) {
        return addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
                listener, ClickListener.clickMethod);
    }

    /**
     * Remove a click listener from the component. The listener should earlier
     * have been added using {@link #addClickListener(ClickListener)}.
     *
     * @param listener
     *            The listener to remove
     *
     * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
     *             registration object returned from
     *             {@link #addClickListener(ClickListener)}.
     */
    @Deprecated
    public void removeClickListener(ClickListener listener) {
        removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
                listener);
    }
}