Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/issuables_helper.rb90
-rw-r--r--app/helpers/milestones_helper.rb6
2 files changed, 33 insertions, 63 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index ea861bd2fc4..5e277a4c5ed 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -23,23 +23,36 @@ module IssuablesHelper
end
end
- def sidebar_due_date_tooltip_label(issuable)
- if issuable.due_date
- "#{_('Due date')}<br />#{due_date_remaining_days(issuable)}"
+ def sidebar_milestone_tooltip_label(milestone)
+ if milestone && milestone[:due_date]
+ "#{milestone[:title]}<br/>#{sidebar_milestone_remaining_days(milestone)}"
else
- _('Due date')
+ _('Milestone') + (milestone ? "<br/>#{milestone[:title]}" : "")
end
end
- def due_date_remaining_days(issuable)
- remaining_days_in_words = remaining_days_in_words(issuable)
+ def sidebar_milestone_remaining_days(milestone)
+ due_date_remaining_days(due_date: milestone[:due_date], start_date: milestone[:start_date]) if milestone[:due_date]
+ end
+
+ def sidebar_due_date_tooltip_label(due_date)
+ _('Due date') + (due_date ? "<br/>#{due_date_remaining_days(due_date)}" : "")
+ end
+
+ def due_date_remaining_days(due_date, start_date = nil)
+ "#{due_date.to_s(:medium)} (#{remaining_days_in_words(due_date: due_date, start_date: start_date)})"
+ end
+
+ def sidebar_label_filter_path(base_path, label_name)
+ query_params = {label_name: [label_name]}.to_query
- "#{issuable.due_date.to_s(:medium)} (#{remaining_days_in_words})"
+ "#{base_path}?#{query_params}"
end
def multi_label_name(current_labels, default_label)
if current_labels && current_labels.any?
- title = current_labels.first.try(:title)
+ title = current_labels.first.try(:title) || current_labels.first[:title]
+
if current_labels.size > 1
"#{title} +#{current_labels.size - 1} more"
else
@@ -50,13 +63,13 @@ module IssuablesHelper
end
end
- def issuable_json_path(issuable, url_params = {})
+ def issuable_json_path(issuable)
project = issuable.project
if issuable.is_a?(MergeRequest)
- project_merge_request_path(project, issuable.iid, :json, url_params)
+ project_merge_request_path(project, issuable.iid, :json)
else
- project_issue_path(project, issuable.iid, :json, url_params)
+ project_issue_path(project, issuable.iid, :json)
end
end
@@ -197,19 +210,11 @@ module IssuablesHelper
output.join.html_safe
end
- # rubocop: disable CodeReuse/ActiveRecord
- def issuable_todo(issuable)
- if current_user
- current_user.todos.find_by(target: issuable, state: :pending)
- end
- end
- # rubocop: enable CodeReuse/ActiveRecord
-
def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index { |_, i| i < limit }
if labels && labels.any?
- label_names = first.collect(&:name)
+ label_names = first.collect { |l| l[:title] }
label_names << "and #{last.size} more" unless last.empty?
label_names.join(', ')
@@ -356,12 +361,6 @@ module IssuablesHelper
issuable.model_name.human.downcase
end
- def selected_labels
- Array(params[:label_name]).map do |label_name|
- Label.new(title: label_name)
- end
- end
-
def has_filter_bar_param?
finder.class.scalar_params.any? { |p| params[p].present? }
end
@@ -386,22 +385,6 @@ module IssuablesHelper
params[:issuable_template] if issuable_templates(issuable).any? { |template| template[:name] == params[:issuable_template] }
end
- def issuable_todo_button_data(issuable, todo, is_collapsed)
- {
- todo_text: "Add todo",
- mark_text: "Mark todo as done",
- todo_icon: (is_collapsed ? sprite_icon('todo-add') : nil),
- mark_icon: (is_collapsed ? sprite_icon('todo-done', css_class: 'todo-undone') : nil),
- issuable_id: issuable.id,
- issuable_type: issuable.class.name.underscore,
- url: project_todos_path(@project),
- delete_path: (dashboard_todo_path(todo) if todo),
- placement: (is_collapsed ? 'left' : nil),
- container: (is_collapsed ? 'body' : nil),
- boundary: 'viewport'
- }
- end
-
def close_reopen_params(issuable, action)
{
issuable.model_name.to_s.underscore => { state_event: action }
@@ -418,27 +401,20 @@ module IssuablesHelper
end
end
- def issuable_sidebar_options(issuable, can_edit_issuable)
+ def issuable_sidebar_options(sidebar_data)
{
- endpoint: issuable_json_path(issuable, serializer: 'sidebar_extras'),
- toggleSubscriptionEndpoint: toggle_subscription_path(issuable),
- moveIssueEndpoint: move_namespace_project_issue_path(namespace_id: issuable.project.namespace.to_param, project_id: issuable.project, id: issuable),
- projectsAutocompleteEndpoint: autocomplete_projects_path(project_id: @project.id),
- editable: can_edit_issuable,
- currentUser: UserSerializer.new.represent(current_user),
+ endpoint: "#{sidebar_data[:issuable_json_path]}?serializer=sidebar_extras",
+ toggleSubscriptionEndpoint: sidebar_data[:toggle_subscription_path],
+ moveIssueEndpoint: sidebar_data[:move_issue_path],
+ projectsAutocompleteEndpoint: sidebar_data[:projects_autocomplete_path],
+ editable: sidebar_data[:can_edit],
+ currentUser: sidebar_data[:current_user],
rootPath: root_path,
- fullPath: @project.full_path
+ fullPath: sidebar_data[:project_full_path]
}
end
def parent
@project || @group
end
-
- def issuable_milestone_tooltip_title(issuable)
- if issuable.milestone
- milestone_tooltip = milestone_tooltip_title(issuable.milestone)
- _('Milestone') + (milestone_tooltip ? ': ' + milestone_tooltip : '')
- end
- end
end
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb
index 9666080092b..e3dc598e98a 100644
--- a/app/helpers/milestones_helper.rb
+++ b/app/helpers/milestones_helper.rb
@@ -114,12 +114,6 @@ module MilestonesHelper
end
end
- def milestone_tooltip_title(milestone)
- if milestone
- "#{milestone.title}<br />#{milestone_tooltip_due_date(milestone)}"
- end
- end
-
def milestone_time_for(date, date_type)
title = date_type == :start ? "Start date" : "End date"