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.
95 lines
3.0 KiB
95 lines
3.0 KiB
#-- copyright
|
|
# ReportingEngine
|
|
#
|
|
# Copyright (C) 2010 - 2014 the OpenProject Foundation (OPF)
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# version 3.
|
|
#
|
|
# 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.
|
|
#++
|
|
|
|
class Widget::Controls::SaveAs < Widget::Controls
|
|
def render
|
|
if @subject.new_record?
|
|
link_name = l(:button_save)
|
|
icon = 'icon-save'
|
|
else
|
|
link_name = l(:button_save_as)
|
|
icon = 'icon-save'
|
|
end
|
|
button = link_to(link_name, '#', id: 'query-icon-save-as', class: "button icon-context #{icon}")
|
|
write(button + render_popup)
|
|
end
|
|
|
|
def cache_key
|
|
"#{super}#{@subject.name}"
|
|
end
|
|
|
|
def render_popup_form
|
|
name = content_tag :p,
|
|
class: 'form--field -required -wide-label' do
|
|
label_tag(:query_name,
|
|
class: 'form--label -transparent') do
|
|
Query.human_attribute_name(:name).html_safe
|
|
end +
|
|
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
|
|
end
|
|
if @options[:can_save_as_public]
|
|
box = content_tag :p, class: 'form--field -wide-label' do
|
|
label_tag(:query_is_public,
|
|
Query.human_attribute_name(:is_public),
|
|
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
|
|
end
|
|
name + box
|
|
else
|
|
name
|
|
end
|
|
end
|
|
|
|
def render_popup_buttons
|
|
save = link_to(l(:button_save),
|
|
'#',
|
|
id: 'query-icon-save-button',
|
|
class: 'button -highlight icon-context icon-save',
|
|
:"data-target" => url_for(action: 'create', set_filter: '1'))
|
|
|
|
cancel = link_to(l(:button_cancel),
|
|
'#',
|
|
id: 'query-icon-save-as-cancel',
|
|
class: 'button icon-context icon-cancel')
|
|
save + cancel
|
|
end
|
|
|
|
def render_popup
|
|
content_tag :div, id: 'save_as_form', class: 'button_form', style: 'display:none' do
|
|
render_popup_form + render_popup_buttons
|
|
end
|
|
end
|
|
end
|
|
|