diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-14 06:10:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-14 06:10:47 +0300 |
commit | 04698e448a10aedea2f3ed37ffd0327e9b91426e (patch) | |
tree | 8804a89c577dc005d3135d830e28de572f80f05d /app/helpers/issuables_helper.rb | |
parent | e7cc427bc63dccac50cc3ccda2976befcea1ecf5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/issuables_helper.rb')
-rw-r--r-- | app/helpers/issuables_helper.rb | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index de5cae2e9e2..da142cbed0e 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -2,7 +2,6 @@ module IssuablesHelper include GitlabRoutingHelper - include IssuablesDescriptionTemplatesHelper def sidebar_gutter_toggle_icon content_tag(:span, class: 'js-sidebar-toggle-container', data: { is_expanded: !sidebar_gutter_collapsed? }) do @@ -76,6 +75,28 @@ module IssuablesHelper .to_json end + def template_dropdown_tag(issuable, &block) + title = selected_template(issuable) || "Choose a template" + options = { + toggle_class: 'js-issuable-selector', + title: title, + filter: true, + placeholder: 'Filter', + footer_content: true, + data: { + data: issuable_templates(issuable), + field_name: 'issuable_template', + selected: selected_template(issuable), + project_path: ref_project.path, + namespace_path: ref_project.namespace.full_path + } + } + + dropdown_tag(title, options: options) do + capture(&block) + end + end + def users_dropdown_label(selected_users) case selected_users.length when 0 @@ -273,7 +294,6 @@ module IssuablesHelper { projectPath: ref_project.path, - projectId: ref_project.id, projectNamespace: ref_project.namespace.full_path } end @@ -349,6 +369,24 @@ module IssuablesHelper cookies[:collapsed_gutter] == 'true' end + def issuable_templates(issuable) + @issuable_templates ||= + case issuable + when Issue + ref_project.repository.issue_template_names + when MergeRequest + ref_project.repository.merge_request_template_names + end + end + + def issuable_templates_names(issuable) + issuable_templates(issuable).map { |template| template[:name] } + end + + def selected_template(issuable) + params[:issuable_template] if issuable_templates(issuable).any? { |template| template[:name] == params[:issuable_template] } + end + def issuable_todo_button_data(issuable, is_collapsed) { todo_text: _('Add a to do'), @@ -386,6 +424,12 @@ module IssuablesHelper end end + def template_names_path(parent, issuable) + return '' unless parent.is_a?(Project) + + project_template_names_path(parent, template_type: issuable.class.name.underscore) + end + def issuable_sidebar_options(issuable) { endpoint: "#{issuable[:issuable_json_path]}?serializer=sidebar_extras", |