kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.6 KiB
108 lines
3.6 KiB
11 years ago
|
#-- copyright
|
||
5 years ago
|
# OpenProject is an open source project management software.
|
||
|
# Copyright (C) 2012-2020 the OpenProject GmbH
|
||
11 years ago
|
#
|
||
5 years ago
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
5 years ago
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
11 years ago
|
#
|
||
|
# 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 General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
5 years ago
|
#
|
||
|
# See docs/COPYRIGHT.rdoc for more details.
|
||
11 years ago
|
#++
|
||
|
|
||
13 years ago
|
class Widget::Controls::SaveAs < Widget::Controls
|
||
|
def render
|
||
|
if @subject.new_record?
|
||
4 years ago
|
link_name = I18n.t(:button_save)
|
||
9 years ago
|
icon = 'icon-save'
|
||
13 years ago
|
else
|
||
4 years ago
|
link_name = I18n.t(:button_save_as)
|
||
9 years ago
|
icon = 'icon-save'
|
||
13 years ago
|
end
|
||
10 years ago
|
button = link_to(link_name, '#', id: 'query-icon-save-as', class: "button icon-context #{icon}")
|
||
13 years ago
|
write(button + render_popup)
|
||
|
end
|
||
|
|
||
|
def cache_key
|
||
|
"#{super}#{@subject.name}"
|
||
|
end
|
||
|
|
||
|
def render_popup_form
|
||
8 years ago
|
name = content_tag :p,
|
||
6 years ago
|
class: 'form--field -required -wide-label' do
|
||
10 years ago
|
label_tag(:query_name,
|
||
6 years ago
|
class: 'form--label -transparent') do
|
||
|
Query.human_attribute_name(:name).html_safe
|
||
|
end +
|
||
8 years ago
|
content_tag(:span,
|
||
|
class: 'form--field-container') do
|
||
|
content_tag(:span,
|
||
|
class: 'form--text-field-container') do
|
||
|
text_field_tag(:query_name,
|
||
|
@subject.name,
|
||
|
required: true)
|
||
|
end
|
||
|
end
|
||
13 years ago
|
end
|
||
|
if @options[:can_save_as_public]
|
||
7 years ago
|
box = content_tag :p, class: 'form--field -wide-label' do
|
||
10 years ago
|
label_tag(:query_is_public,
|
||
|
Query.human_attribute_name(:is_public),
|
||
8 years ago
|
class: 'form--label -transparent') +
|
||
|
content_tag(:span,
|
||
|
class: 'form--field-container') do
|
||
|
content_tag(:span,
|
||
|
class: 'form--check-box-container') do
|
||
|
check_box_tag(:query_is_public,
|
||
|
1,
|
||
|
false,
|
||
|
class: 'form--check-box')
|
||
|
end
|
||
|
end
|
||
13 years ago
|
end
|
||
|
name + box
|
||
|
else
|
||
|
name
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def render_popup_buttons
|
||
4 years ago
|
save_url_params = { action: 'create', set_filter: '1' }
|
||
|
save_url_params[:project_id] = @subject.project.id if @subject.project
|
||
|
|
||
4 years ago
|
save = link_to(I18n.t(:button_save),
|
||
10 years ago
|
'#',
|
||
|
id: 'query-icon-save-button',
|
||
9 years ago
|
class: 'button -highlight icon-context icon-save',
|
||
4 years ago
|
:"data-target" => url_for(**save_url_params))
|
||
11 years ago
|
|
||
4 years ago
|
cancel = link_to(I18n.t(:button_cancel),
|
||
10 years ago
|
'#',
|
||
|
id: 'query-icon-save-as-cancel',
|
||
|
class: 'button icon-context icon-cancel')
|
||
|
save + cancel
|
||
13 years ago
|
end
|
||
|
|
||
|
def render_popup
|
||
10 years ago
|
content_tag :div, id: 'save_as_form', class: 'button_form', style: 'display:none' do
|
||
13 years ago
|
render_popup_form + render_popup_buttons
|
||
|
end
|
||
|
end
|
||
|
end
|