Allow link to default dashboard in dashboard breadcrumb and fix pie chart overlay
This commit is contained in:
parent
858f87e57f
commit
df8dd2110e
@ -1,9 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module AdditionalsProjectsHelper
|
||||
def project_overview_name(_project, dashboard = nil)
|
||||
def project_overview_name(project, dashboard = nil)
|
||||
name = [l(:label_overview)]
|
||||
name << dashboard.name if dashboard.present? && (dashboard.always_expose? || !dashboard.system_default)
|
||||
|
||||
if dashboard.present? && (dashboard.always_expose? || !dashboard.system_default)
|
||||
default_dashboard = Dashboard.default DashboardContentProject::TYPE_NAME, project, User.current, ''
|
||||
name = [dashboard_link(default_dashboard, project, name: l(:label_overview))] if default_dashboard&.id != dashboard.id
|
||||
name << dashboard.name if dashboard.present? && (dashboard.always_expose? || !dashboard.system_default)
|
||||
end
|
||||
|
||||
safe_join name, Additionals::LIST_SEPARATOR
|
||||
end
|
||||
|
@ -22,7 +22,12 @@ module DashboardsHelper
|
||||
|
||||
def welcome_overview_name(dashboard = nil)
|
||||
name = [l(:label_home)]
|
||||
name << dashboard.name if dashboard&.always_expose? || dashboard.present? && !dashboard.system_default?
|
||||
|
||||
if dashboard&.always_expose? || dashboard.present? && !dashboard.system_default?
|
||||
default_dashboard = Dashboard.default DashboardContentWelcome::TYPE_NAME, nil, User.current, ''
|
||||
name = [dashboard_link(default_dashboard, nil, name: l(:label_home))] if default_dashboard&.id != dashboard.id
|
||||
name << dashboard.name
|
||||
end
|
||||
|
||||
safe_join name, Additionals::LIST_SEPARATOR
|
||||
end
|
||||
|
@ -19,6 +19,7 @@ class AdditionalsChart
|
||||
# build return value
|
||||
def build_chart_data(datasets, **options)
|
||||
cached_labels = labels
|
||||
|
||||
data = { datasets: datasets.to_json,
|
||||
labels: cached_labels.keys,
|
||||
label_ids: cached_labels.values }
|
||||
@ -31,6 +32,9 @@ class AdditionalsChart
|
||||
data[:value_link_method] = '_project_issues_path' unless options.key? :value_link_method
|
||||
data[:color_schema] = color_schema
|
||||
|
||||
data_values = Array(datasets).first[:data]
|
||||
data[:data_sum] = data_values.present? ? data_values.sum : 0
|
||||
|
||||
data.merge options
|
||||
end
|
||||
|
||||
|
@ -76,8 +76,8 @@ class Dashboard < ActiveRecord::Base
|
||||
.try(:id)
|
||||
end
|
||||
|
||||
def default(dashboard_type, project = nil, user = User.current)
|
||||
recently_id = User.current.pref.recently_used_dashboard dashboard_type, project
|
||||
def default(dashboard_type, project = nil, user = User.current, recently_id = nil)
|
||||
recently_id ||= User.current.pref.recently_used_dashboard dashboard_type, project
|
||||
|
||||
scope = where dashboard_type: dashboard_type
|
||||
scope = scope.where(project_id: project.id).or(scope.where(project_id: nil)) if project.present?
|
||||
|
@ -12,7 +12,8 @@ javascript:
|
||||
data: {
|
||||
label_ids: #{raw json_escape(@chart[:label_ids])},
|
||||
labels: #{raw json_escape(@chart[:labels])},
|
||||
datasets: #{raw json_escape(@chart[:datasets])}
|
||||
datasets: #{raw json_escape(@chart[:datasets])},
|
||||
data_sum: #{raw @chart[:data_sum]},
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
@ -29,27 +30,20 @@ javascript:
|
||||
scheme: "#{@chart[:color_schema]}",
|
||||
fillAlpha: 0.8,
|
||||
},
|
||||
datalabels: {
|
||||
formatter: (value, ctx) => {
|
||||
let sum = 0;
|
||||
let dataArr = ctx.chart.data.datasets[0].data;
|
||||
dataArr.map(data => {
|
||||
sum += data;
|
||||
});
|
||||
let percentage = (value*100 / sum).toFixed(0)+"%";
|
||||
return percentage;
|
||||
},
|
||||
display: function(ctx) {
|
||||
if (ctx.dataset.data[ctx.dataIndex] > 1){
|
||||
return "auto";
|
||||
tooltip: {
|
||||
displayColors: false,
|
||||
callbacks: {
|
||||
title(context) {
|
||||
return context[0].label;
|
||||
},
|
||||
label(context) {
|
||||
const v = context.dataset.data[context.dataIndex];
|
||||
const sum = context.chart.data.data_sum;
|
||||
const percentage = (v*100 / sum).toFixed(0)+"%";
|
||||
return ['#{l :label_quantity}: ' + v, '#{l :label_percentage}: ' + percentage];
|
||||
}
|
||||
else{
|
||||
return ctx.dataset.data[ctx.dataIndex] > 1;
|
||||
}
|
||||
},
|
||||
color: '#000',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [ChartDataLabels]
|
||||
}
|
||||
});
|
||||
|
@ -141,9 +141,11 @@ cs:
|
||||
label_open_in_new_windows: "Otevřít v nových oknech"
|
||||
label_optional: "volitelný"
|
||||
label_pdf_wiki_settings: "PDF Wiki nastavení"
|
||||
label_percentage: "Procento"
|
||||
label_project_information: "Informace o projektu"
|
||||
label_project_list: "Seznam projektů"
|
||||
label_project_setting: "Projekt"
|
||||
label_quantity: "Množství"
|
||||
label_query_delete: "Smazat dotaz"
|
||||
label_query_edit: "Upravit dotaz"
|
||||
label_query_name_search: "Hledejte jméno"
|
||||
|
@ -141,9 +141,11 @@ de:
|
||||
label_open_in_new_windows: In neuen Fenster öffnen
|
||||
label_optional: optional
|
||||
label_pdf_wiki_settings: PDF Wiki Einstellungen
|
||||
label_percentage: Anteil
|
||||
label_project_information: Projektinformation
|
||||
label_project_list: Projektliste
|
||||
label_project_setting: Projekt
|
||||
label_quantity: Anzahl
|
||||
label_query_delete: Abfrage löschen
|
||||
label_query_edit: Abfrage bearbeiten
|
||||
label_query_name_search: Nach Name suchen
|
||||
|
@ -141,9 +141,11 @@ en:
|
||||
label_open_in_new_windows: Open in new windows
|
||||
label_optional: "optional"
|
||||
label_pdf_wiki_settings: PDF Wiki settings
|
||||
label_percentage: Percentage
|
||||
label_project_information: "Project information"
|
||||
label_project_list: "Project list"
|
||||
label_project_setting: Project
|
||||
label_quantity: "Quantity"
|
||||
label_query_delete: Delete query
|
||||
label_query_edit: Edit query
|
||||
label_query_name_search: Search for name
|
||||
|
@ -141,9 +141,11 @@ es:
|
||||
label_open_in_new_windows: Abrir en una nueva ventana
|
||||
label_optional: "opcional"
|
||||
label_pdf_wiki_settings: Configuración de la Wiki en PDF
|
||||
label_percentage: Porcentaje
|
||||
label_project_information: "Información del proyecto"
|
||||
label_project_list: "Lista de proyectos"
|
||||
label_project_setting: "Proyecto"
|
||||
label_quantity: "Ctd."
|
||||
label_query_delete: Eliminar consulta
|
||||
label_query_edit: Editar Consulta
|
||||
label_query_name_search: Buscar por nombre
|
||||
|
@ -141,9 +141,11 @@ fr:
|
||||
label_open_in_new_windows: Ouvrir dans une nouvelle fenêtre
|
||||
label_optional: "optionnel"
|
||||
label_pdf_wiki_settings: paramètres d'édition PDF d'une page Wiki
|
||||
label_percentage: Percentage
|
||||
label_project_information: "Informations sur le projet"
|
||||
label_project_list: "liste des projets"
|
||||
label_project_setting: "Projet"
|
||||
label_quantity: "Quantité"
|
||||
label_query_delete: Annuler la requête
|
||||
label_query_edit: Modifier la requête
|
||||
label_query_name_search: Rechercher un nom
|
||||
|
@ -141,9 +141,11 @@ it:
|
||||
label_open_in_new_windows: "Apri in nuove finestre"
|
||||
label_optional: "opzionale"
|
||||
label_pdf_wiki_settings: PDF Wiki settings
|
||||
label_percentage: Percentage
|
||||
label_project_information: "Informazioni sul progetto"
|
||||
label_project_list: "Elenco dei progetti"
|
||||
label_project_setting: "Progetto"
|
||||
label_quantity: "Numero"
|
||||
label_query_delete: Elimina query
|
||||
label_query_edit: Modifica query
|
||||
label_query_name_search: Ricerca per nome
|
||||
|
@ -141,9 +141,11 @@ ja:
|
||||
label_open_in_new_windows: "新しいウィンドウで開く"
|
||||
label_optional: "任意"
|
||||
label_pdf_wiki_settings: PDF Wiki settings
|
||||
label_percentage: "割合"
|
||||
label_project_information: "プロジェクト情報"
|
||||
label_project_list: "プロジェクト一覧"
|
||||
label_project_setting: "プロジェクト"
|
||||
label_quantity: "数量"
|
||||
label_query_delete: Delete query
|
||||
label_query_edit: Edit query
|
||||
label_query_name_search: "名前を検索"
|
||||
|
@ -141,9 +141,11 @@ ko:
|
||||
label_open_in_new_windows: 새 창에서 열기
|
||||
label_optional: "선택"
|
||||
label_pdf_wiki_settings: PDF Wiki settings
|
||||
label_percentage: "백분율"
|
||||
label_project_information: "프로젝트 정보"
|
||||
label_project_list: "프로젝트 목록"
|
||||
label_project_setting: "계획"
|
||||
label_quantity: "수량"
|
||||
label_query_delete: 검색어 삭제
|
||||
label_query_edit: 검색어 수정
|
||||
label_query_name_search: 이름 검색
|
||||
|
@ -141,9 +141,11 @@ pl:
|
||||
label_open_in_new_windows: "Otwieranie w nowych oknach"
|
||||
label_optional: "fakultatywny"
|
||||
label_pdf_wiki_settings: "PDF Wiki nastawy"
|
||||
label_percentage: Procent
|
||||
label_project_information: "Informacja o projekcie"
|
||||
label_project_list: "Lista projektów"
|
||||
label_project_setting: "Projekt"
|
||||
label_quantity: "Ilość"
|
||||
label_query_delete: "Usuń query"
|
||||
label_query_edit: "Edycja query"
|
||||
label_query_name_search: "Wyszukaj nazwę"
|
||||
|
@ -141,9 +141,11 @@ pt-BR:
|
||||
label_open_in_new_windows: "Abrir em novas janelas"
|
||||
label_optional: "opcional"
|
||||
label_pdf_wiki_settings: "Configurações do Wiki em PDF"
|
||||
label_percentage: "Percentagem"
|
||||
label_project_information: "Informações sobre o projeto"
|
||||
label_project_list: "Lista de projetos"
|
||||
label_project_setting: "Projeto"
|
||||
label_quantity: "Quantidade"
|
||||
label_query_delete: "Eliminar consulta"
|
||||
label_query_edit: "Editar consulta"
|
||||
label_query_name_search: "Busca por nome"
|
||||
|
@ -141,9 +141,11 @@ ru:
|
||||
label_open_in_new_windows: "Открыть в новом окне"
|
||||
label_optional: "необязательный"
|
||||
label_pdf_wiki_settings: PDF Wiki settings
|
||||
label_percentage: "Процент"
|
||||
label_project_information: "Информация о проекте"
|
||||
label_project_list: "Список проектов"
|
||||
label_project_setting: "Проект"
|
||||
label_quantity: "Количество"
|
||||
label_query_delete: "Удалить query"
|
||||
label_query_edit: "Редактировать query"
|
||||
label_query_name_search: "Поиск имени"
|
||||
|
@ -141,9 +141,11 @@
|
||||
label_open_in_new_windows: Open in new windows
|
||||
label_optional: "選擇性"
|
||||
label_pdf_wiki_settings: "PDF Wiki 設定"
|
||||
label_percentage: Percentage
|
||||
label_project_information: "项目信息"
|
||||
label_project_list: "專案清單"
|
||||
label_project_setting: "项目"
|
||||
label_quantity: "Quantity"
|
||||
label_query_delete: 刪除查詢
|
||||
label_query_edit: 編輯查詢
|
||||
label_query_name_search: "搜索名字"
|
||||
|
@ -141,9 +141,11 @@ zh:
|
||||
label_open_in_new_windows: 在新窗口打开
|
||||
label_optional: "可选项"
|
||||
label_pdf_wiki_settings: Wiki PDF 导出设置
|
||||
label_percentage: Percentage
|
||||
label_project_information: "项目信息"
|
||||
label_project_list: "项目列表"
|
||||
label_project_setting: "项目"
|
||||
label_quantity: "Quantity"
|
||||
label_query_delete: 删除查询
|
||||
label_query_edit: 编辑查询
|
||||
label_query_name_search: "搜索名字"
|
||||
|
@ -52,17 +52,6 @@ module Additionals
|
||||
end
|
||||
end
|
||||
|
||||
def add_autowatcher(user)
|
||||
return if user.nil? ||
|
||||
!user.is_a?(User) ||
|
||||
user.anonymous? ||
|
||||
!user.active? ||
|
||||
watched_by?(user) ||
|
||||
watchers.detect { |watcher| watcher.user_id == user.id }
|
||||
|
||||
add_watcher user
|
||||
end
|
||||
|
||||
def log_time_allowed?(user = User.current)
|
||||
!status_was.is_closed || user.allowed_to?(:log_time_on_closed_issues, project)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user