Skip to content
Snippets Groups Projects
Verified Commit 649e5cb8 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Pridane pluginy

parent f22110a7
No related branches found
No related tags found
No related merge requests found
Showing
with 1818 additions and 0 deletions
...@@ -6,3 +6,4 @@ RUN apt-get update && \ ...@@ -6,3 +6,4 @@ RUN apt-get update && \
build-essential build-essential
COPY ./themes/ /usr/src/redmine/public/themes/ COPY ./themes/ /usr/src/redmine/public/themes/
COPY ./plugins/ /usr/src/redmine/plugins/
gem 'redmine_extensions' unless Dir.exist?(File.expand_path('../../easyproject', __FILE__))
LICENCE
All Easy Redmine Extensions are distributed under GNU/GPL 2 license (see below).
If not otherwise stated, all images, cascading style sheets, and included JavaScript are NOT GPL, and are released under the Easy Redmine Commercial Use License (see below).
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
EASY REDMINE COMMERCIAL USE LICENSE
The Easy Redmine Commercial Use License is a GPL compatible license that pertains only to the images, cascading style sheets and JavaScript elements of Easy Redmine Themes and Styles produced by Easy Software Ltd. As stated by the GPL version 2.0 license, these elements of product that are not compiled together but are sent independently of GPL code, and combined in a client's browser, do not have to be GPL themselves. These images, cascading style sheets and JavaScript elements are copyright Easy Software Ltd. and can be used and manipulated for your own or if you have signed Easy Redmine Partner Agreement for your clients purposes. You cannot redistribute these files as your own, or include them in any package or extension of your own without prior consent of Easy Software Ltd.
Unauthorised distribution or making it accessible to a third party without prior Easy Software Ltd. consent, authorizes Easy Software Ltd. to invoice contractual penalty in the amount of 10 000 EUR for any breach of the this License.
# Easy Gantt
For documentation and requirements, go to https://www.easyredmine.com/redmine-gantt-plugin
easy_extensions = Redmine::Plugin.installed?(:easy_extensions)
app_dir = File.join(File.dirname(__FILE__), 'app')
lib_dir = File.join(File.dirname(__FILE__), 'lib', 'easy_gantt')
# Redmine patches
patch_path = File.join(lib_dir, 'redmine_patch', '**', '*.rb')
Dir.glob(patch_path).each do |file|
require file
end
ActiveSupport::Dependencies.autoload_paths << File.join(app_dir, 'models', 'queries')
if easy_extensions
ActiveSupport::Dependencies.autoload_paths << File.join(app_dir, 'models', 'easy_queries')
EasyQuery.register(EasyGanttEasyIssueQuery)
EasyQuery.register(EasyGanttEasyProjectQuery)
# RedmineExtensions::QueryOutput.whitelist_outputs_for_query 'EasyGanttEasyIssueQuery', 'list'
# RedmineExtensions::QueryOutput.whitelist_outputs_for_query 'EasyGanttEasyProjectQuery', 'list'
Rails.application.configure do
config.assets.precompile.concat [
proc { |logical_path, filename|
if logical_path.start_with?('easy_gantt/')
basename = File.basename(logical_path)
if basename.start_with?('_')
false
else
true
end
end
}
]
end
end
# this block is called every time rails are reloading code
# in development it means after each change in observed file
# in production it means once just after server has started
# in this block should be used require_dependency, but only if necessary.
# better is to place a class in file named by rails naming convency and let it be loaded automatically
# Here goes query registering, custom fields registering and so on
ActionDispatch::Reloader.to_prepare do
require 'easy_gantt/easy_gantt'
require 'easy_gantt/hooks'
RedmineExtensions::EasySettingPresenter.boolean_keys << :easy_gantt_show_holidays << :easy_gantt_show_project_progress << :easy_gantt_show_lowest_progress_tasks << :easy_gantt_show_task_soonest_start << :easy_gantt_relation_delay_in_workdays << :easy_gantt_fixed_delay
end
#Redmine::MenuManager.map :top_menu do |menu|
# menu.push(:easy_gantt, { controller: 'easy_gantt', action: 'index', set_filter: 0 },
# caption: :label_easy_gantt,
# after: :documents,
# html: { class: 'icon icon-stats' },
# if: proc { User.current.allowed_to_globally?(:view_global_easy_gantt) })
#end
Redmine::MenuManager.map :project_menu do |menu|
menu.push(:easy_gantt, { controller: 'easy_gantt', action: 'index' },
param: :project_id,
caption: :button_project_menu_easy_gantt,
if: proc { |p| User.current.allowed_to?(:view_easy_gantt, p) })
end
Redmine::MenuManager.map :easy_gantt_tools do |menu|
menu.push(:back, 'javascript:void(0)',
param: :project_id,
caption: :button_back,
html: { icon: 'icon-back' })
menu.push(:task_control, 'javascript:void(0)',
param: :project_id,
caption: :button_edit,
html: { icon: 'icon-edit' })
menu.push(:add_task, 'javascript:void(0)',
param: :project_id,
caption: :label_new,
html: { trial: true, icon: 'icon-add' },
if: proc { |p| p.present? })
menu.push(:critical, 'javascript:void(0)',
param: :project_id,
caption: :'easy_gantt.button.critical_path',
html: { trial: true, icon: 'icon-summary' },
if: proc { |p| p.present? })
menu.push(:baseline, 'javascript:void(0)',
param: :project_id,
caption: :'easy_gantt.button.create_baseline',
html: { trial: true, icon: 'icon-projects icon-project' },
if: proc { |p| p.present? })
menu.push(:resource, proc { |project| defined?(EasyUserAllocations) ? { controller: 'user_allocation_gantt', project_id: project } : nil },
param: :project_id,
caption: :'easy_gantt.button.resource_management',
html: { trial: true, icon: 'icon-stats', easy_text: defined?(EasyExtensions) },
if: proc { |p| p.present? })
end
# this block is executed once just after Redmine is started
# means after all plugins are initialized
# it is place for plain requires, not require_dependency
# it should contain hooks, permissions - base class in Redmine is required thus is not reloaded
ActiveSupport.on_load(:easyproject, yield: true) do
if easy_extensions
Redmine::MenuManager.map :projects_easy_page_layout_service_box do |menu|
menu.push(:project_easy_gantt, :easy_gantt_path,
caption: :label_easy_gantt,
html: { class: 'icon icon-stats button button-2' },
if: proc { User.current.allowed_to_globally?(:view_global_easy_gantt) })
end
Redmine::MenuManager.map :easy_quick_top_menu do |menu|
menu.push(:project_easy_gantt, { controller: 'easy_gantt', action: 'index', id: nil, set_filter: 0 },
caption: :label_easy_gantt,
parent: :projects,
html: { class: 'icon icon-stats' },
if: proc { User.current.allowed_to_globally?(:view_global_easy_gantt) })
menu.push(:issues_easy_gantt, { controller: 'easy_gantt', action: 'index', id: nil, set_filter: 0 },
caption: :label_easy_gantt,
parent: :issues,
html: { class: 'icon icon-stats project-gantt' },
if: proc { User.current.allowed_to_globally?(:view_global_easy_gantt) })
end
end
end
ActionDispatch::Reloader.to_prepare do
Redmine::AccessControl.map do |map|
map.project_module :easy_gantt do |pmap|
# View project level
pmap.permission(:view_easy_gantt, {
easy_gantt: [:index, :issues, :projects],
easy_gantt_pro: [:lowest_progress_tasks, :cashflow_data],
easy_gantt_resources: [:index, :project_data, :users_sums, :projects_sums, :allocated_issues],
easy_resource_limits: [:index]
}, read: true)
# Edit project level
pmap.permission(:edit_easy_gantt, {
easy_gantt: [:change_issue_relation_delay, :reschedule_project],
easy_gantt_resources: [:bulk_update_or_create],
easy_resource_limits: [:new, :create, :edit, :update, :destroy]
}, require: :member)
# View global level
pmap.permission(:view_global_easy_gantt, {
easy_gantt: [:index, :issues, :projects, :project_issues],
easy_gantt_pro: [:lowest_progress_tasks, :cashflow_data],
easy_gantt_resources: [:index, :project_data, :global_data, :projects_sums, :allocated_issues],
easy_resource_limits: [:index]
}, global: true, read: true)
# Edit global level
pmap.permission(:edit_global_easy_gantt, {
easy_gantt_resources: [:bulk_update_or_create],
easy_resource_limits: [:new, :create, :edit, :update, :destroy]
}, global: true, require: :loggedin)
# View personal level
pmap.permission(:view_personal_easy_gantt, {
easy_gantt_resources: [:global_data],
easy_resource_limits: [:index]
}, global: true, read: true)
# Edit personal level
pmap.permission(:edit_personal_easy_gantt, {
easy_gantt_resources: [:bulk_update_or_create],
easy_resource_limits: [:new, :create, :edit, :update, :destroy]
}, global: true, require: :loggedin)
end
end
end
class EasyGanttController < ApplicationController
accept_api_auth :index, :issues, :projects, :project_issues, :change_issue_relation_delay, :reschedule_project
menu_item :easy_gantt
RELATION_TYPES_TO_LOAD = ['relates', 'blocks', 'blocked', 'precedes', 'follows', 'start_to_start', 'finish_to_finish', 'start_to_finish']
before_action :find_optional_project, except: [:reschedule_project, :project_issues]
before_action :find_opened_project, except: [:reschedule_project]
before_action :authorize, if: proc { @project.present? }
before_action :authorize_global, if: proc { @project.nil? }
before_action :check_rest_api_enabled, only: [:index]
before_action :find_relation, only: [:change_issue_relation_delay]
include_query_helpers
helper :custom_fields
def index
retrieve_query
end
# Data retrieve method
def issues
retrieve_query
load_projects
load_issues
load_versions
load_relations
build_dates @issues, :start_date, :due_date
end
# Data retrieve method
def projects
retrieve_query
load_projects
build_dates @projects, :gantt_start_date, :gantt_due_date
@projects_issues_counts = Issue.visible.gantt_opened.where(project_id: @projects).group(:project_id).count(:id)
end
def project_issues
# TODO: Global route to skip rights
@issues = Issue.visible.gantt_opened.where(project_id: params[:project_id]).order(:start_date)
@issue_ids = @issues.map(&:id)
load_relations
version_ids = @issues.map(&:fixed_version_id).uniq.compact
@versions = Version.open.where('id IN (?) OR project_id = ?', version_ids, params[:project_id]).sorted
end
def change_issue_relation_delay
if !User.current.allowed_to?(:manage_issue_relations, @project)
return render_403
end
@relation.update_column(:delay, params[:delay].to_i)
respond_to do |format|
format.api { render_api_ok }
end
end
# You cannot use issue.reschedule_on because it will
# also set start_date which is not desirable !!!
def reschedule_project
begin
# Do not used callback `find_project` because it will test access rights
# to project context. Method wont work if project does not have gantt enabled.
project = Project.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
return
end
project.gantt_reschedule(params[:days].to_i)
respond_to do |format|
format.api { render_api_ok }
end
end
def current_menu_item
@current_menu_item ||= if params[:gantt_type] == 'rm'
:resource
else
:easy_gantt
end
end
private
def check_rest_api_enabled
if Setting.rest_api_enabled != '1'
render_error message: l('easy_gantt.errors.no_rest_api')
return false
end
end
def find_relation
@relation = IssueRelation.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
def query_class
if EasyGantt.easy_extensions?
@project ? EasyGanttEasyIssueQuery : EasyGanttEasyProjectQuery
else
@project ? EasyGantt::EasyGanttIssueQuery : EasyGanttProjectQuery
end
end
def retrieve_query
if params[:query_id].present?
cond = 'project_id IS NULL'
if @project
cond << " OR project_id = #{@project.id}"
# In Easy Project query can be defined for subprojects
if !@project.root? && EasyGantt.easy_extensions?
ancestors = @project.ancestors.select(:id).to_sql
cond << " OR (is_for_subprojects = #{Project.connection.quoted_true} AND project_id IN (#{ancestors}))"
end
end
@query = query_class.where(cond).find_by(id: params[:query_id])
raise ActiveRecord::RecordNotFound if @query.nil?
raise Unauthorized unless @query.visible?
@query.project = @project
sort_clear
else
@query = query_class.new(name: '_')
@query.project = @project
@query.from_params(params)
end
if @opened_project
@query.opened_project = @opened_project
end
end
# Load version from loaded task and from opened projects
# TO_CONSIDER: Send versions if there is no tasks?
def load_versions
version_ids = @issues.map(&:fixed_version_id).uniq.compact
@versions = Version.open.where("id IN (?) OR project_id = ?", version_ids, @opened_project.id).sorted
end
# Load subproject of opened project which contains filtered tasks
#
# Project 1
# |-- Project 1.1
# | `-- Project 1.1.1
# | |-- Task 1
# | `-- Task 2
# `-- Project 1.2
#
# If Project 1 is opened, Project 1.1 must be send even if there is no task
#
# TO_CONSIDER: Send full tree and load only opened_project's issues
#
def load_projects
p_table = Project.table_name
@projects = []
# Project gantt is opened, normally only subprojects will be sent
# but there is not any root project yet
if @project && @opened_project == @project
@projects << @project
end
projects = @query.without_opened_project { |q|
scope = q.create_entity_scope
# Not necessary, will take only subprojects
if @opened_project
scope = scope.where("#{p_table}.lft >= ? AND #{p_table}.rgt <= ?", @opened_project.lft, @opened_project.rgt)
end
scope.distinct.pluck("#{p_table}.lft, #{p_table}.rgt, #{p_table}.parent_id")
}
if projects.blank?
return
end
# All ancestors conditions
tree_conditions = []
projects.each do |lft, rgt|
tree_conditions << "(lft <= #{lft} AND rgt >= #{rgt})"
end
tree_conditions = tree_conditions.join(' OR ')
@parent_ids = projects.map(&:last)
# From ancestors take only current opened level
@projects.concat Project.where(tree_conditions).where(parent_id: @opened_project.try(:id)).to_a
Project.load_gantt_dates(@projects)
if EasySetting.value(:easy_gantt_show_project_progress)
Project.load_gantt_completed_percent(@projects)
end
end
# Only between loaded tasks
def load_relations
if @issue_ids.empty?
@relations = []
else
@relations = IssueRelation.where('issue_from_id IN (?) OR issue_to_id IN (?)', @issue_ids, @issue_ids).
where(relation_type: RELATION_TYPES_TO_LOAD)
end
end
def load_issues
preloads = [:project, :author, :assigned_to, :relations_to]
if EasySetting.value(:easy_gantt_show_task_soonest_start)
preloads << :parent
preloads << { relations_to: :issue_from }
else
preloads << :relations_to
end
@issues = @query.entities(
includes: [:project, :status, :assigned_to, :fixed_version, :tracker, :priority, :custom_values],
preload: preloads,
order: "#{Issue.table_name}.start_date, #{Issue.table_name}.id"
)
@issue_ids = @issues.map(&:id)
end
def build_dates(data, starts, ends)
starts = data.map(&starts).compact
ends = data.map(&ends).compact
@start_date = (starts.min || ends.min || Date.today) - 1.day
@end_date = (ends.max || starts.max || Date.today) + 1.day
end
def find_optional_project
# Easy query workaround
if params[:set_filter] == '1' && params[:project_id].present? && params[:project_id].start_with?('=', '!*', '*')
return
end
super
end
def find_opened_project
if params[:opened_project_id].present?
@opened_project = Project.find(params[:opened_project_id])
else
@opened_project = @project
end
rescue ActiveRecord::RecordNotFound
render_404
end
end
module EasyGanttHelper
def easy_gantt_include_js(*javascripts, from_plugin: 'easy_gantt')
plugin = (EasyGantt.easy_extensions? ? nil : from_plugin)
result = ''
javascripts.flatten!
javascripts.compact!
javascripts.each do |javascript|
result << javascript_include_tag("#{from_plugin}/#{javascript}", plugin: plugin)
end
result.html_safe
end
def easy_gantt_include_css(*stylesheets, media: 'screen', from_plugin: 'easy_gantt')
plugin = (EasyGantt.easy_extensions? ? nil : from_plugin)
result = ''
stylesheets.flatten!
stylesheets.compact!
stylesheets.each do |stylesheet|
result << stylesheet_link_tag("#{from_plugin}/#{stylesheet}", plugin: plugin, media: media)
end
result.html_safe
end
def easy_gantt_js_button(text, options={})
if text.is_a?(Symbol)
lang_key = text
text = l(lang_key, scope: [:easy_gantt, :button])
options[:title] ||= l(lang_key, scope: [:easy_gantt, :title], default: text)
end
options[:class] = "gantt-menu-button #{options[:class]}"
options[:class] << ' button' unless options.delete(:no_button)
if (icon = options.delete(:icon))
options[:class] << " icon #{icon}"
end
link_to(text, options[:url] || 'javascript:void(0)', options)
end
def easy_gantt_help_button(*args)
options = args.extract_options!
feature = args.shift
text = args.shift
options[:class] = "gantt-menu-help-button #{options[:class]}"
options[:icon] ||= 'icon-help'
options[:id] = 'button_' + feature.to_s + '_help'
help_text = raw l(options.delete(:easy_text) ? :easy_text : :text, scope: [:easy_gantt, :popup, feature])
easy_gantt_js_button(text || '&#8203;'.html_safe, options) + %Q(
<div id="#{feature}_help_modal" style="display:none">
<h3 class="title">#{raw l(:heading, scope: [:easy_gantt, :popup, feature]) }</h3>
<p>#{help_text}</p>
</div>
).html_safe
end
def api_render_versions(api, versions)
return if versions.blank?
api.array :versions do
versions.each do |version|
api.version do
api.id version.id
api.name version.name
api.start_date version.effective_date
api.project_id version.project_id
api.permissions do
api.editable version.gantt_editable?
end
end
end
end
end
def api_render_columns(api, query)
api.array :columns do
query.columns.each do |c|
api.column do
api.name c.name
api.title c.caption
end
end
end
end
def api_render_scheme(api, table)
if table.is_a?(Symbol)
if Object.const_defined?(table)
table = Object.const_get(table)
else
return
end
end
return unless table.column_names.include?('easy_color_scheme')
col = table.arel_table[:easy_color_scheme]
records = table.where(col.not_eq(nil).and(col.not_eq(''))).pluck(:id, :easy_color_scheme)
api.array table.to_s do
records.each do |id, scheme|
api.entity do
api.id id
api.scheme scheme
end
end
end
end
def api_render_holidays(api, startdt, enddt)
wc = User.current.try(:current_working_time_calendar)
return if wc.nil?
api.array :holidays do
startdt.upto(enddt) do |date|
api.date date if wc.holiday?(date)
end
end
end
def api_render_issues(api, issues, with_columns: false)
api.array :issues do
issues.each do |issue|
api.issue do
api.id issue.id
api.name issue.subject
api.start_date issue.start_date
api.due_date issue.due_date
api.estimated_hours issue.estimated_hours
api.done_ratio issue.done_ratio
api.closed issue.closed?
api.fixed_version_id issue.fixed_version_id
api.overdue issue.overdue?
api.parent_issue_id issue.parent_id
api.project_id issue.project_id
api.tracker_id issue.tracker_id
api.priority_id issue.priority_id
api.status_id issue.status_id
api.assigned_to_id issue.assigned_to_id
if EasySetting.value(:easy_gantt_show_task_soonest_start) && @project.nil?
api.soonest_start issue.soonest_start
end
if EasySetting.value(:easy_gantt_show_task_latest_due) && @project.nil?
api.latest_due issue.latest_due
end
api.is_planned !!issue.project.try(:is_planned)
api.permissions do
api.editable issue.gantt_editable?
end
if with_columns
api.array :columns do
@query.columns.each do |c|
api.column do
api.name c.name
api.value gantt_format_column(issue, c, c.value(issue))
end
end
end
end
end
end
end
end
def api_render_relations(api, relations)
api.array :relations do
relations.each do |rel|
api.relation do
api.id rel.id
api.source_id rel.issue_from_id
api.target_id rel.issue_to_id
api.type rel.relation_type
api.delay rel.delay.to_i
end
end
end
end
def api_render_projects(api, projects, with_columns: false)
api.array :projects do
projects.each do |project|
api.project do
api.id project.id
api.name project.name
api.start_date project.gantt_start_date || Date.today
api.due_date project.gantt_due_date || Date.today
api.parent_id project.parent_id
api.is_baseline project.try(:easy_baseline_for_id?)
# Schema
api.status_id project.status
api.priority_id project.try(:easy_priority_id)
api.permissions do
api.editable project.gantt_editable?
end
if EasySetting.value(:easy_gantt_show_project_progress)
api.done_ratio project.gantt_completed_percent
end
if @projects_issues_counts && @projects_issues_counts.has_key?(project.id)
api.issues_count @projects_issues_counts[project.id]
end
if @parent_ids && @parent_ids.include?(project.id)
api.has_subprojects true
end
if with_columns
api.array :columns do
@query.columns.each do |c|
api.column do
api.name c.name
api.value gantt_format_column(project, c, c.value(project))
end
end
end
end
end
end
end
end
# This method exist because
# 1. EntityAttributeHelper is for complex html formating
# 2. Redmine doest not have it
# Gantt should show light and non-html values
def gantt_format_column(entity, column, value)
if entity.is_a?(Project) && column.name == :status && respond_to?(:format_project_attribute)
format_project_attribute(Project, column, value)
elsif value.is_a?(Float)
locale = User.current.language.presence || ::I18n.locale
number_with_precision(value, locale: locale).to_s
elsif value.is_a?(Array)
value.join(', ')
else
value.to_s
end
end
def prepare_test_includes(tests)
includes = []
tests.each do |test_file|
plugin = 'easy_gantt'
if test_file.include?('/')
split = test_file.split('/')
plugin = split[0]
test_file = split[1]
end
includes << [test_file, plugin]
end
includes
end
end
module EasyGantt
class EasyGanttIssueQuery < IssueQuery
attr_accessor :entity_scope
attr_accessor :opened_project
def default_columns_names
[:subject, :priority, :assigned_to]
end
def entity
Issue
end
def from_params(params)
build_from_params(params)
end
def to_params
params = { set_filter: 1, type: self.class.name, f: [], op: {}, v: {} }
filters.each do |filter_name, opts|
params[:f] << filter_name
params[:op][filter_name] = opts[:operator]
params[:v][filter_name] = opts[:values]
end
params[:c] = column_names
params
end
def to_partial_path
'easy_gantt/easy_queries/show'
end
def initialize_available_filters
super
@available_filters.delete('subproject_id')
end
def entity_scope
@entity_scope ||= begin
scope = Issue.visible
if Project.column_names.include? 'easy_baseline_for_id'
scope = scope.where(Project.table_name => {easy_baseline_for_id: nil})
end
scope
end
end
def create_entity_scope(options={})
entity_scope.includes(options[:includes]).
references(options[:includes]).
preload(options[:preload]).
where(statement).
where(options[:conditions])
end
def entities(options={})
create_entity_scope(options).order(options[:order])
end
def project_statement
p_table = Project.table_name
conditions = "#{p_table}.status = #{Project::STATUS_ACTIVE}"
if opened_project
conditions = "#{conditions} AND #{Project.table_name}.id = #{opened_project.id}"
end
conditions
end
def without_opened_project
_opened_project = opened_project
self.opened_project = nil
yield self
ensure
self.opened_project = _opened_project
end
end
end
class EasyGanttEasyIssueQuery < EasyIssueQuery
KEEP_AVAILABLE_COLUMNS = [
# Issues
:id, :project, :parent, :status, :tracker, :priority, :fixed_version, :subject, :start_date, :due_date, :created_on, :updated_on, :easy_status_updated_on, :open_duration_in_hours, :easy_last_updated_by, :done_ratio, :easy_due_date_time_remaining, :closed_on, :easy_closed_by, :is_private, :category, :assigned_to, :author, :estimated_hours, :total_estimated_hours, :spent_hours, :total_spent_hours, :remaining_timeentries, :total_remaining_timeentries, :spent_estimated_timeentries, :total_spent_estimated_timeentries,
# Projects
:"projects.name", :"projects.parent", :"projects.root", :"projects.status", :"projects.start_date", :"projects.due_date", :"projects.created_on", :"projects.updated_on", :"projects.easy_indicator", :"projects.identifier", :"projects.completed_percent", :"projects.priority", :"projects.sum_estimated_hours", :"projects.total_sum_estimated_hours", :"projects.sum_of_timeentries", :"projects.remaining_timeentries", :"projects.total_remaining_timeentries", :"projects.total_spent_hours", :"projects.author"
]
attr_accessor :opened_project
def query_after_initialize
super
self.display_filter_group_by_on_index = false
self.display_filter_sort_on_index = false
self.display_filter_settings_on_index = false
self.display_filter_group_by_on_edit = false
self.display_filter_sort_on_edit = false
self.display_filter_settings_on_edit = false
self.display_show_sum_row = false
self.display_load_groups_opened = false
self.export_formats = {}
self.is_tagged = true if new_record?
end
def available_outputs
[]
end
def groupable_columns
[]
end
def available_outputs
['list']
end
def default_list_columns
super.presence || ['subject', 'assigned_to']
end
def easy_query_entity_controller
'easy_gantt'
end
def easy_query_entity_action
'index'
end
def column_groups_ordering
[
l(:label_most_used),
l("label_filter_group_#{class_name_underscored}"),
EasyQuery.column_filter_group_name(nil),
l(:label_filter_group_easy_time_entry_query),
l(:label_filter_group_status_time),
l(:label_filter_group_status_count),
l(:label_filter_group_easy_project_query),
EasyQuery.column_filter_group_name(:project),
l(:label_user_plural)
]
end
def entity_easy_query_path(**options)
project = options[:project] || project
if project
easy_gantt_path(project, options)
end
end
# Delete these filters because of project_scope
def initialize_available_filters
super
@available_filters.delete('subproject_id')
end
def initialize_available_columns
super
add_associated_columns EasyProjectQuery
@available_columns.keep_if { |column|
KEEP_AVAILABLE_COLUMNS.include?(column.name) ||
column.name.to_s.start_with?('cf_') ||
column.name.to_s.start_with?('projects.cf_')
}
end
def project_scope
# Except closed and archived
scope = Project.active_and_planned
# Templates should be included only on template context
if project.nil? || !project.easy_is_easy_template?
scope = scope.non_templates
end
if opened_project
scope = scope.where(id: opened_project.id)
end
if has_filter?('is_planned')
op = value_for('is_planned') == '1' ? '=' : '<>'
scope = scope.where("#{Project.table_name}.status #{op} ?", Project::STATUS_PLANNED)
end
scope
end
def without_opened_project
_opened_project = opened_project
self.opened_project = nil
self.additional_scope = nil
yield self
ensure
self.opened_project = _opened_project
self.additional_scope = nil
end
def self.chart_support?
false
end
end
class EasyGanttEasyProjectQuery < EasyProjectQuery
attr_accessor :opened_project
def query_after_initialize
super
self.display_filter_group_by_on_index = false
self.display_filter_sort_on_index = false
self.display_filter_settings_on_index = false
self.display_filter_group_by_on_edit = false
self.display_filter_sort_on_edit = false
self.display_filter_settings_on_edit = false
self.display_show_sum_row = false
self.display_load_groups_opened = false
self.export_formats = {}
self.is_tagged = true if new_record?
end
def groupable_columns
[]
end
def available_outputs
['list']
end
def default_list_columns
super.presence || ['name']
end
def filter_groups_ordering
[
l(:label_most_used),
l(:label_filter_group_easy_project_query),
EasyQuery.column_filter_group_name(nil)
]
end
def column_groups_ordering
[
l(:label_most_used),
l(:label_filter_group_easy_project_query),
EasyQuery.column_filter_group_name(nil),
l(:label_filter_group_easy_time_entry_query),
l(:label_user_plural)
]
end
def easy_query_entity_controller
'easy_gantt'
end
def easy_query_entity_action
'index'
end
def entity_easy_query_path(**options)
easy_gantt_path(options)
end
def additional_scope
if opened_project
Project.where(id: opened_project.id)
else
nil
end
end
def without_opened_project
_opened_project = opened_project
self.opened_project = nil
self.additional_scope = nil
yield self
ensure
self.opened_project = _opened_project
self.additional_scope = nil
end
def self.chart_support?
false
end
end
class EasyGanttProjectQuery < Query
attr_accessor :opened_project
self.queried_class = Project
self.available_columns = [
QueryColumn.new(:name, sortable: "#{Project.table_name}.name"),
QueryColumn.new(:created_on, sortable: "#{Project.table_name}.created_on"),
QueryColumn.new(:updated_on, sortable: "#{Project.table_name}.updated_on"),
]
def initialize(*args)
super
self.filters ||= {}
end
def default_columns_names
[:name]
end
def initialize_available_filters
add_available_filter 'name', type: :text
add_available_filter 'created_on', type: :date_past
add_available_filter 'updated_on', type: :date_past
end
def from_params(params)
build_from_params(params)
end
def to_params
params = { set_filter: 1, type: self.class.name, f: [], op: {}, v: {} }
filters.each do |filter_name, opts|
params[:f] << filter_name
params[:op][filter_name] = opts[:operator]
params[:v][filter_name] = opts[:values]
end
params[:c] = column_names
params
end
def to_partial_path
'easy_gantt/easy_queries/show'
end
def entities(options={})
scope = Project.active.visible
if Project.column_names.include?('easy_baseline_for_id')
scope = scope.where(Project.table_name => { easy_baseline_for_id: nil })
end
scope = scope.includes(options[:includes]).
references(options[:includes]).
preload(options[:preload]).
where(statement).
where(options[:conditions]).
order(options[:order])
if opened_project
scope = scope(projects: { id: opened_project.id })
end
scope.to_a
end
def entity_scope
Project.visible
end
def create_entity_scope(options={})
entity_scope.includes(options[:includes]).
references(options[:includes]).
preload(options[:preload]).
where(statement).
where(options[:conditions])
end
def without_opened_project
_opened_project = opened_project
self.opened_project = nil
yield self
ensure
self.opened_project = _opened_project
end
end
<p class="error">
<%= l(:error_epm_easy_gantt_already_active) %>
</p>
<%
heads_for_wiki_formatter
if EasyGantt.easy_extensions?
main_css = 'easy_gantt'
else
main_css = 'generated/easy_gantt'
end
%>
<%= content_for :header_tags do %>
<%= easy_gantt_include_css(main_css, media: 'all') %>
<% if EasyGantt.combine_by_pipeline?(params) %>
<%= javascript_include_tag('easy_gantt/easy_gantt') %>
<% else %>
<%= easy_gantt_include_js(
'utils',
'dhtmlxgantt',
'dhtmlxgantt_marker',
'main',
'data',
'loader',
'saver',
'logger',
'widget',
'panel_widget',
'gantt_widget',
'view',
'history',
'dhtml_modif',
'dhtml_addons',
'dhtml_rewrite',
('dhtml_relations' if EasySetting.value(:easy_gantt_fixed_delay)),
'background',
'pro_manager',
'storage',
'tooltip',
'toolpanel',
'print',
'left_grid',
'sumrow',
'bars',
'problem_finder',
'collapsor',
'libs/libs',
'libs/svg.min',
) %>
<% end %>
<%= easy_gantt_include_js(
('sample' unless EasyGantt.easy_gantt_pro?),
('libs/moment' unless EasyGantt.easy_extensions?)
) %>
<script type="application/javascript">
$(ysy.initGantt);
</script>
<% end %>
<%= content_for :header_tags do %>
<script type="text/javascript">
window.ysy = window.ysy || {};
ysy.settings = ysy.settings || {};
$.extend(true, ysy.settings, <%= {
platform: EasyGantt.platform,
easyRedmine: EasyGantt.easy_extensions?,
isGantt: (params[:controller] == 'easy_gantt'),
language: I18n.locale.to_s,
project: ({ id: @project.id, name: @project.name } if @project),
dateFormat: (Setting.date_format.presence || I18n.t('date.formats.default')),
nonWorkingWeekDays: EasyGantt.non_working_week_days,
holidays: [],
milestonePush: ((EasyGantt.easy_extensions? && !EasySetting.value('milestone_effective_date_from_issue_due_date')) ? true : false),
workDayDelays: EasySetting.value(:easy_gantt_relation_delay_in_workdays),
fixedRelations: EasySetting.value(:easy_gantt_fixed_delay),
defaultZoom: EasySetting.value(:easy_gantt_default_zoom),
paths: {
rootPath: home_path
},
labels: {
buttons: {
button_delete: l(:button_delete),
button_submit: l(:button_submit),
button_yes: l(:general_text_Yes),
button_no: l(:general_text_No),
button_cancel: l(:button_cancel),
button_reload: l('easy_gantt.button.reload'),
button_save: l(:button_save)
},
sample_text: l('easy_gantt.sample.text').html_safe,
sample_global_free_text: l('easy_gantt.sample_global_free.text').html_safe,
date: {
month_full: Array(l('date.month_names')).compact,
month_short: Array(l('date.abbr_month_names')).compact,
day_full: Array(l('date.day_names')).compact,
day_short: Array(l('date.abbr_day_names')).compact
},
types: {
project: l(:field_project),
issue: l(:field_issue),
milestone: l(:field_version),
relation: l(:field_relation)
},
errors: Array(l('activerecord.errors.messages')).compact,
errors2: {
unsaved_parent: l('easy_gantt.errors.unsaved_parent')
},
problems: {
overMilestone: l('easy_gantt.errors.overmile'),
too_short: l('easy_gantt.errors.too_short'),
overdue: l('easy_gantt.errors.overdue'),
progressDateOverdue: l('easy_gantt.errors.progress_date_overdue'),
shortDelay: l('easy_gantt.errors.short_delay')
},
gateway: {
sendFailed: l('easy_gantt.gateway.send_failed'),
entitySaveFailed: l('easy_gantt.gateway.entity_save_failed'),
allSended: l(:notice_successful_update)
},
titles: {
easyGantt: l(:heading_easy_gantts_issues)
}
},
styles: {
backgrounds:{
selected: '#fff3a1',
line: 'rgba(200,200,200,0.5)',
line_month: '#aaaaff'
}
}
}.to_json.html_safe %>)
ysy.view = ysy.view || {};
ysy.view.templates = $.extend(ysy.view.templates, <%= {
TaskTooltip: %{
<h3 class="gantt-tooltip-header">{{name}}</h3>
{{#start_date}}
<div class="gantt-tooltip-start_date"><span class="gantt-tooltip-label">#{l(:field_start_date)}:</span> {{start_date}}</div>
{{/start_date}}
{{#end_date}}
<div class="gantt-tooltip-end_date"><span class="gantt-tooltip-label">#{l(:field_due_date)}:</span> {{end_date}}</div>
{{/end_date}}
{{#milestone}}
<div class="gantt-tooltip-milestone"><span class="gantt-tooltip-label">#{l(:field_version)}:</span> {{milestone.name}}</div>
{{/milestone}}
{{#columns}}
<div class="gantt-tooltip-column-{{name}}"><span class="gantt-tooltip-label">{{label}}:</span> {{value}}</div>
{{/columns}}
{{#problems}}
<div class="gantt-tooltip-problem">{{.}}</div>
{{/problems}}
},
Button: %{
<span class="button {{active}}" title="{{title}}">
<a id="{{elid}}_button_in" class="gantt_button{{icon}}" href="javascript:void(0)">{{name}}</a>
</span>
},
LinkButton: %{
<a class="{{css}}" title="{{title}}" href="javascript:void(0)">{{name}}</a>
},
SuperPanel: %{},
# reloadModal: %{
# <h3 class="title">#{l('easy_gantt.reload_modal.title')}</h3>
# <h4>#{l('easy_gantt.reload_modal.label_errors')}:</h4>
# <ul class="gantt-reload-modal-errors">
# {{#errors}}
# <li class="gantt-reload-model-error">{{.}}</li>
# {{/errors}}
# </ul>
# <p>#{l('easy_gantt.reload_modal.text_reload_appeal')}</p>
# },
preBlocker: %{
<div style="left:{{pos_x}}px" class="gantt_task_relation_stop gantt_task_relation_stop_left" title="#{l('easy_gantt.text_blocker_move_pre')}">
</div>
},
endBlocker: %{
<div style="left:{{pos_x}}px" class="gantt_task_relation_stop gantt_task_relation_stop_right" title="#{l('easy_gantt.text_blocker_move_end')}">
</div>
},
ProblemFinder: %{
#{l('easy_gantt.button.problem_finder')}:
<span class="gantt-menu-problems-count{{#count}} gantt-with-problems{{/count}}">{{count}}</span>
},
ProblemFinderList: %{
<ol>
{{#entities}}
<li>
<a href="javascript:ysy.pro.problemFinder.scrollToEntity('{{entityId}}')">
{{#isProject}}#{l(:field_project)}{{/isProject}}{{^isProject}}#{l(:field_issue)}{{/isProject}}: <strong>{{name}}</strong>
<br>
<span class="gantt-menu-problems-reason">{{text}}</span>
</a>
</li>
{{/entities}}
{{#relations}}
<li>
<a href="javascript:ysy.pro.problemFinder.scrollToEntity('{{entityId}}')">
#{l(:field_relation)}: <strong>{{sourceName}}</strong> - <strong>{{targetName}}</strong>
<br>
<span class="gantt-menu-problems-reason">{{text}}</span>
</a>
</li>
{{/relations}}
</ol>
}
}.to_json.html_safe %>)
</script>
<% end %>
<%
unless defined?(show_menu_items)
show_menu_items = true
end
zooms = { 'day' => 'calendar-day', 'week' => 'calendar-week', 'month' => 'calendar-month' }
%>
<span id="close_all_something">
<a id="button_close_all_projects" title="<%= l(:close_all, scope: [:easy_gantt, :button])+' '+l(:label_project_plural) %>" class="gantt-button-symbol icon-folder" href="javascript:void(0)"></a>
<a id="button_close_all_milestones" title="<%= l(:close_all, scope: [:easy_gantt, :button])+' '+l(:label_version_plural) %>" class="gantt-button-symbol gantt-icon-milestone" href="javascript:void(0)"></a>
<a id="button_close_all_parent_issues" title="<%= l(:close_all, scope: [:easy_gantt, :button])+' '+l(:label_parent_issue_plural) %>" class="gantt-button-symbol gantt-icon-parent-issue" href="javascript:void(0)"></a>
</span>
<div id="supertop_panel" class="gantt-supertop-panel easy-gantt__supertop-panel clear"></div>
<div id="easy_gantt_menu" class="easy-gantt__menu clear">
<div class="push-left">
<% if Rails.env.development? %>
<%= easy_gantt_js_button l(:button_test), id: 'button_test' %>
<% end %>
<%= easy_gantt_js_button('&#8203;'.html_safe, id: 'button_jump_today', title: l(:jump_today, scope: [:easy_gantt, :title]), icon: 'icon-calendar') %>
<% zooms.each do |name, icon| %>
<%= easy_gantt_js_button(:"#{name}_zoom", id: "button_#{name}_zoom", icon: "icon-#{icon}") %>
<% end %>
</div>
<div class="push-right">
<% if show_menu_items %>
<%= easy_gantt_js_button(:problem_finder, {
url: 'javascript:void(0)',
id: 'button_problem_finder',
class: 'problem-finder',
no_button: true
}) %>
<div class="easy-gantt__menu-group easy-gantt__menu-group--tooltiped easy-gantt__menu-tools">
<a href="javascript:void(0)" class="button gantt-menu-button icon icon-settings easy-gantt__menu-tools-button"><%= l(:tool_panel, :scope => [:easy_gantt, :button]) %></a>
<ul id="easy_gantt_tool_panel" class="easy-gantt__menu-item">
<% menu_items_for(:easy_gantt_tools, @project) do |node| %>
<li>
<%
opts = node.html_options.dup
opts[:url] = (node.url.is_a?(Proc) ? node.url.call(@project) : node.url)
opts[:id] = "button_#{node.name}"
opts[:no_button] = 'true'
caption = opts[:caption].is_a?(Proc) ? opts[:caption].call(params[:gantt_type]) : node.caption
%>
<% if opts.delete(:trial) %>
<%= easy_gantt_help_button(node.name, caption, opts) %>
<% else %>
<%= easy_gantt_js_button(caption, opts) %>
<% end %>
</li>
<% end %>
</ul>
</div>
<%= easy_gantt_js_button(l(:button_save), {
url: 'javascript:void(0)',
id: 'button_save',
no_button: true,
class: 'button-positive button-1 icon icon-save'
}) %>
<% end %>
</div>
<%= call_hook(:view_easy_gantts_issues_toolbars, project: @project) %>
</div>
<!-- This is container for gantt -->
<div id="gantt_cont" style="width: 100%;" class="clear"></div>
<!-- End container for gantt -->
<%=
easy_gantt_include_js(
# test framework
'jasmine/helpers/test',
'jasmine/jasmine_lib/jasmine',
'jasmine/jasmine_lib/jasmine-html',
'jasmine/jasmine_lib/boot',
# common tests
'jasmine/main',
'jasmine/loader',
'jasmine/working_helper',
'jasmine/working_helper_add',
'jasmine/pos_date',
'jasmine/history',
'jasmine/model_relations',
'jasmine/load_reorder'
)
%>
<% extra_test_names = params[:run_jasmine_tests]
if extra_test_names != 'true'
if extra_test_names.is_a?(String)
extra_tests = prepare_test_includes([extra_test_names])
elsif extra_test_names.is_a?(Array)
extra_tests = prepare_test_includes(extra_test_names)
else
extra_tests = []
end
extra_tests.each do |test, plugin| %>
<%= easy_gantt_include_js("jasmine/#{test}", from_plugin: plugin) %>
<% end %>
<% end %>
<%= easy_gantt_include_css('jasmine', media: 'all') %>
<%
unless defined?(form_options)
form_options = {}
end
query ||= @query
form_path ||= easy_gantt_path(@project)
form_options[:additional_elements_to_serialize] ||= 'null'
%>
<div class="content-title"><%= title(easy_query_name) %></div>
<%= form_tag(form_path, method: :get, id: 'query_form') do %>
<div id="query_form_with_buttons" class="hide-when-print">
<%= hidden_field_tag 'set_filter', '1' %>
<div id="query_form_content">
<fieldset id="filters" class="collapsible collapsed">
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
<div style="display: none;">
<%= render 'queries/filters', query: query %>
</div>
</fieldset>
<fieldset class="collapsible collapsed">
<legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
<div style="display: none;">
<table>
<tr>
<td><%= l(:field_column_names) %></td>
<td><%= render_query_columns_selection(query) %></td>
</tr>
</table>
</div>
</fieldset>
</div>
<p class="buttons">
<%= link_to_function l(:button_apply), 'applyEasyGanttQuery()', class: 'icon icon-checked' %>
<%= link_to l(:button_clear), { set_filter: 1, project_id: @project }, class: 'icon icon-reload' %>
</p>
</div>
<% end %>
<script>
var additionalElementsToSerialize;
$(document).ready(function(){
additionalElementsToSerialize = <%=raw form_options[:additional_elements_to_serialize] %>;
});
function applyEasyGanttQuery(){
if (additionalElementsToSerialize) {
var data = additionalElementsToSerialize.serializeArray()[0];
if (data) {
var newInput = $("<input />").attr("type", "hidden")
.attr("name", data.name)
.attr("value", data.value);
newInput.appendTo("#query_form");
}
}
$("#query_form").submit();
}
</script>
<%
plugin = Redmine::Plugin.find('easy_gantt')
easy_extensions = EasyGantt.easy_extensions?
query ||= @query
main_gantt_params = query.to_params.merge(key: User.current.api_key, format: 'json')
main_gantt_path = if @project
issues_easy_gantt_path(@project, main_gantt_params)
else
projects_easy_gantt_path(main_gantt_params)
end
unless defined?(show_query)
show_query = true
end
if EasyGantt.easy_gantt_pro?
sample_path = ''
# elsif easy_extensions
# sample_path = "#{home_path}assets/easy_gantt/sample_{{version}}.json"
else
sample_path = "#{home_path}plugin_assets/easy_gantt/data/sample_{{version}}.json"
end
back_url = URI.unescape(request.fullpath)
%>
<div id="easy_gantt" class="<%= easy_extensions ? 'easy' : 'redmine' %> gantt clear">
<% if show_query %>
<% if User.current.admin? && @project.nil? %>
<div class="contextual settings">
<% # Easy is called URI.escape before redirect to back
# So a%7Cb" is transformed into "a%257Cb" (original "a|b") %>
<%= link_to '', plugin_settings_path(plugin, back_url: back_url), class: 'icon icon-settings', title: l(:label_easy_gantt_settings)%>
</div>
<% end %>
<%= render query, easy_query_name: l(:heading_easy_gantts_issues),
wrapper_class: '',
form_options: { additional_elements_to_serialize: '$("input#easy_gantt_type")' },
options: { show_free_search: false,
show_custom_formatting: false,
additional_tagged_url_options: { gantt_type: params[:gantt_type] } } %>
<% end %>
<%= hidden_field_tag 'gantt_type', '', id: 'easy_gantt_type' %>
<%= render 'easy_gantt/menu_graph' %>
<div id="easy_gantt_footer" class="gantt-footer">
<div id="easy_gantt_footer_legend" class="gantt-footer-legend"></div>
<div id="gantt_footer_buttons" class="gantt-footer-menu">
<% # Print doesn't work on RM but be carefull of page modules %>
<% if EasyGantt.easy_printable_templates? && !params[:gantt_type].present? %>
<%
# Prepare options for selection
# - easy_gantt category should be first
# - select first option on easy_gantt category if this category contains only one option
gantt_category = EasyPrintableTemplate.category_caption('easy_gantt')
options = { gantt_category => [] }
print_template_url = preview_easy_printable_template_path(':id', entity_type: 'Project', entity_id: @project.try(:id), back_url: back_url);
templates = EasyPrintableTemplate.pluck(:name, :category, :id)
templates.each do |name, category, id|
key = EasyPrintableTemplate.category_caption(category)
options[key] ||= []
options[key] << [name, id]
end
if options[gantt_category].size == 1
selected_key = options[gantt_category].first
prompt = false
else
prompt = true
end
%>
<%= select_tag :print, grouped_options_for_select(options, selected_key, prompt: prompt), id: 'easy-printable-templates', style: 'width: auto' %>
<%= link_to_function l(:button_print), 'printableTemplatePrint()', class: 'button button-2 icon icon-print' %>
<label title="<%= l('easy_gantt.title.print_fit') %>">
<%= l('easy_gantt.button.print_fit') %>
<input type="checkbox" id="easy_gantt_print_fit_checkbox" checked>
</label>
<% else %>
<%= easy_gantt_js_button(l(:button_print), icon: 'icon-print', id: 'button_print') %>
<% end %>
<% unless EasyGantt.easy_gantt_pro? %>
<%= easy_gantt_js_button(:load_sample_data, id: 'button_sample') %>
<% end %>
</div>
<% unless EasyGantt.easy_extensions? %>
<p><%= link_to l(:text_easy_gantt_footer), l(:link_easy_gantt_plugin), target: '_blank' %></p>
<% end %>
</div>
</div>
<%= render 'easy_gantt/includes' %>
<%= render 'easy_gantt/test_includes' if params[:run_jasmine_tests] || params[:spec] %>
<%= render 'easy_gantt/js_prepare' %>
<%= content_for :header_tags do %>
<script type="text/javascript">
window.ysy = window.ysy || {};
ysy.settings = ysy.settings || {};
ysy.view = ysy.view || {};
$.extend(true, ysy.settings, <%= {
hoursPerDay: 8,
parentIssueDates: (Setting.parent_issue_dates == 'derived'),
schemeBy: (@project ? EasySetting.value('issue_color_scheme_for') : 'project_priority'),
paths: {
mainGantt: main_gantt_path.html_safe,
issuePOST: issues_path(format: 'json', key: User.current.api_key),
issuePUT: issue_path(':issueID', format: 'json', key: User.current.api_key),
issueDELETE: issue_path(':issueID', format: 'json', key: User.current.api_key),
relationPOST: issue_relations_path(':issueID', format: 'json', key: User.current.api_key),
relationPUT: relation_easy_gantt_path(':projectID', ':relaID', format: 'json', key: User.current.api_key),
relationDELETE: relation_path(':relaID', format: 'json', key: User.current.api_key),
versionPOST: project_versions_path(':projectID', format: 'json', key: User.current.api_key),
versionPUT: version_path(':versionID', format: 'json', key: User.current.api_key),
sample_data: sample_path
},
labels: {
links: {
start_to_start: l(:label_start_to_start),
start_to_finish: l(:label_start_to_finish),
finish_to_finish: l(:label_finish_to_finish),
precedes: l(:label_precedes),
relates: l(:label_relates_to),
copied_to: l(:label_copied_to),
blocks: l(:label_blocks),
duplicates: l(:label_duplicates)
},
errors2:{
loop_link: l('easy_gantt.errors.loop_link'),
link_target_new: l('easy_gantt.errors.link_target_new'),
link_target_readonly: l('easy_gantt.errors.link_target_readonly'),
unsupported_link_type: l('easy_gantt.errors.unsupported_link_type'),
duplicate_link: l('easy_gantt.errors.duplicate_link')
}
}
}.to_json.html_safe %>);
ysy.view.templates = $.extend(ysy.view.templates, <%= {
LinkConfigPopup: %{
<h3 class='title'>#{l(:heading_delay_popup)}</h3>
<label for='link_delay_input'>#{l(:field_delay)}:</label>
<span style="width:100px;display:inline-block;"></span>
<input id='link_delay_input' type='number' min='{{minimal}}' value='{{delay}}' size='3'>
<!--<a id='link_fix_actual' class='button icon icon-link' href='javascript:void(0)'>#{l(:button_use_actual_delay)}</a>-->
<!--<a id='link_remove_delay' class='button icon icon-link' href='javascript:void(0)' >#{l('easy_gantt.button.remove_delay')}</a>-->
<div id='link_popup_button_cont' >
<hr>
<a id='link_delete' class='icon icon-unlink button' href='javascript:void(0)'>#{l(:button_delete)}</a>
<a id='link_close' class='icon icon-save button-positive' href='javascript:void(0)' style='float:right'>#{l(:button_submit)}</a>
</div>
},
SuperPanel: %{
{{#sample}}
<div id="sample_cont" class="flash notice gantt-sample-flash">
<h2 id="sample_label">#{l('easy_gantt.sample.header')}</h2>
<p>{{{text}}}</p>
<p class="" style="text-align:center">
<a id="sample_video_button" class="icon icon-youtube" href="javascript:void(0)">#{l('easy_gantt.sample.video_label')}</a>
{{^global_free}}
<a id="sample_close_button" class="gantt-sample-close-button button button-important" href="javascript:void(0)" title="#{l('easy_gantt.sample.close_label')}">#{l('easy_gantt.sample.close_label')}</a>
{{/global_free}}
{{#global_free}}
<a id="sample_upgrade_button" class="button button-positive" href="#{l(:link_easy_gantt_plugin)}" target="_blank" title="#{l('easy_gantt.label_pro_upgrade')}">#{l('easy_gantt.label_pro_upgrade')}</a>
{{/global_free}}
</p>
<div class="clear"></div>
</div>
{{/sample}}
},
easy_unimplemented: %{
<h3 class="title">{{modal.title}}</h3><span>{{{modal.text}}}</span>
},
video_modal: %{
<h3 class="title">#{l('easy_gantt.sample.video.title')}</h3>
<iframe class="gantt-modal-video" width="800" height="450" src="//www.youtube.com/embed/#{l('easy_gantt.sample.video.video_id')}?autoplay=1">
</iframe>
<p>#{l('easy_gantt.sample.video.text')}</p>
},
video_modal_global: %{
<h3 class="title">#{l('easy_gantt.sample_global_free.video.title')}</h3>
<iframe class="gantt-modal-video" width="800" height="450" src="//www.youtube.com/embed/#{l('easy_gantt.sample_global_free.video.video_id')}?autoplay=1">
</iframe>
<p>#{l('easy_gantt.sample_global_free.video.text')}</p>
},
legend: %{
{{text}}
},
linkDragModal: %{
{{#errorReason}}
<b>{{errorReason}}</b>
{{/errorReason}}
{{^errorReason}}
#{l(:label_relation_new)}{{#type}} <b>{{type}}</b>{{/type}}<br>
<b>{{from}}</b> #{l('easy_gantt.link_dir.link_end')}<br>
{{#to}}<b>{{to}}</b> #{l('easy_gantt.link_dir.link_start')}{{/to}}
{{/errorReason}}
},
printIncludes: %{
#{easy_gantt_include_css('dhtmlxgantt', media: 'all')}
#{easy_gantt_include_css('easy_gantt', media: 'all')}
}
}.to_json.html_safe %>);
function printableTemplatePrint(){
var $select = $("#easy-printable-templates");
var value = $select.val();
if (value === "") {
// $select.css({border: "1px solid red"})
return false
}
var url = "<%= print_template_url %>";
url = url.replace(":id", value);
easyModel.print.preview({href: url})
}
</script>
<% end %>
<%= call_hook(:view_easy_gantt_index_bottom, project: @project, query: query) %>
<% content_for :sidebar do %>
<%= call_hook(:view_easy_gantt_index_sidebar, project: @project, query: query, gantt_type: params[:gantt_type]) %>
<% # DEPRECATED %>
<%= call_hook(:view_easy_gantts_issues_sidebar, project: @project, query: query) %>
<% end %>
api.easy_gantt_data do
api.start_date @start_date
api.end_date @end_date
api_render_columns(api, @query)
api_render_projects(api, @projects)
api_render_issues(api, @issues, with_columns: true)
api_render_relations(api, @relations)
api_render_versions(api, @versions)
if EasySetting.value(:easy_gantt_show_holidays) && params[:subproject_loading].blank?
api_render_holidays(api, @start_date - 1.month, @end_date + 1.month)
end
# Load only on first request
if params[:subproject_loading].nil?
api.schemes do
api_render_scheme(api, IssuePriority)
api_render_scheme(api, IssueStatus)
api_render_scheme(api, Tracker)
end
end
end
<tr>
<td colspan="2"><%= l(:label_easy_gantt) %>:</td>
</tr>
<tr>
<td>
<%= easy_printable_template_link_to_add_token('%easy_gantt_current%', f, l(:label_easy_gantt)) %>
</td>
<td>
<%= l(:text_easy_gantt_print_easy_gantt_current) %>
</td>
</tr>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment