diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 4937525..cc6a851 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -15,10 +15,12 @@ def index private def getStatuses - IssueStatus.sorted().where('is_closed = false').map { |item| { + items = Setting.plugin_dashboard['display_closed_statuses'] ? (IssueStatus.sorted()) : (IssueStatus.sorted().where('is_closed = false')) + items.map { |item| { :id => item.id, :name => item.name, - :color => Setting.plugin_dashboard["status_color_" + item.id.to_s] + :color => Setting.plugin_dashboard["status_color_" + item.id.to_s], + :is_closed => item.is_closed } } end @@ -29,7 +31,7 @@ def getProjects(project_id = -1) items.push({ :id => -1, :name => l(:label_all), - :color => nil + :color => '#4ec7ff' }) Project.visible().where('status = 1').each do |item| diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index b10b30f..5cb8ae7 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -5,17 +5,15 @@ <% end %> - +
<% @statuses.each do |status| %> @@ -23,21 +21,28 @@
<%= status[:name] %>
-
+
"> <% @issues.select {|issue| issue[:status_id] == status[:id] }.each do |issue| %> -
-
- <%= issue[:created_at] %> -
<%= issue[:project].name %>
+ <% project_color = @projects.select {|item| item[:id] == issue[:project].id }[0][:color] %> + <% if status[:is_closed] && Setting.plugin_dashboard['display_minimized_closed_issue_cards'] %> +
+ <%= "#" + issue[:id].to_s %> +
+ <% else %> +
+
+ <%= issue[:created_at] %> +
<%= issue[:project].name %>
+
+ <%= issue[:subject] %> + <%= issue[:author] %> + <% if issue[:executor] == '' || issue[:executor].nil? %> + <%=l :executor_not_set %> + <% else %> + <%= issue[:executor] %> + <% end %>
- <%= issue[:subject] %> - <%= issue[:author] %> - <% if issue[:executor] == '' || issue[:executor].nil? %> - <%=l :executor_not_set %> - <% else %> - <%= issue[:executor] %> - <% end %> -
+ <% end %> <% end %>
diff --git a/app/views/settings/_dashboard_settings.erb b/app/views/settings/_dashboard_settings.erb index 260cb7b..dc442af 100644 --- a/app/views/settings/_dashboard_settings.erb +++ b/app/views/settings/_dashboard_settings.erb @@ -4,15 +4,13 @@ <%=l :settings_header_statuses %> <% IssueStatus.sorted().each do |status| %> - <% if !status.is_closed %> - <% property_name = "status_color_" + status.id.to_s %> - - <%= status.name %> - - - - - <% end %> + <% property_name = "status_color_" + status.id.to_s %> + + <%= status.name %> + + + + <% end %> <%=l :settings_header_projects %> @@ -26,5 +24,20 @@ <% end %> + + <%=l :settings_header_other %> + + + <%=l :settings_display_closed_statuses %> + + <%= check_box_tag "settings[display_closed_statuses]", false, @settings['display_closed_statuses'] %> + + + + <%=l :settings_display_minimized_closed_issue_cards %> + + <%= check_box_tag "settings[display_minimized_closed_issue_cards]", false, @settings['display_minimized_closed_issue_cards'] %> + + \ No newline at end of file diff --git a/assets/javascripts/script.js b/assets/javascripts/script.js index 30aebb6..82dcafb 100644 --- a/assets/javascripts/script.js +++ b/assets/javascripts/script.js @@ -1,6 +1,6 @@ function getUriWithoutDashboard() { - const reg = new RegExp('((?<=.+)\/dashboard.*$|\/$)'); - let baseUri = location.pathname; + const reg = new RegExp('(\/dashboard.*$|\/$)'); + let baseUri = location.href; if (baseUri.match(reg)!= null) { baseUri = baseUri.replace(reg, ''); @@ -11,17 +11,21 @@ function getUriWithoutDashboard() { function goToIssue(id) { const baseUri = getUriWithoutDashboard(); - location.pathname = `${baseUri}/issues/${id}`; + location.href = `${baseUri}/issues/${id}`; } function init() { document.querySelector('#main-menu').remove(); - document.querySelector('[name=project]').addEventListener('change', function(e) { - if (this.value == "-1") { - location.search = ""; - } else { - location.search = `project_id=${this.value}`; - } + document.querySelectorAll('.select_project_item').forEach(item => { + item.addEventListener('click', function() { + if (this.dataset.id == "-1") { + location.search = ""; + } else { + location.search = `project_id=${this.dataset.id}`; + } + }) }); + + document.querySelector("#content").style.overflow = "hidden"; } \ No newline at end of file diff --git a/assets/stylesheets/style.css b/assets/stylesheets/style.css index 6d614d6..f14214e 100644 --- a/assets/stylesheets/style.css +++ b/assets/stylesheets/style.css @@ -35,12 +35,21 @@ flex-direction: column; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; - align-items: center; +} + +.status_column_closed_issues { + display: flex; + width: 100%; + height: 100%; + flex-direction: row; + flex-wrap: wrap; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; } .issue_card { display: flex; - width: 96%; + width: 100%; border-radius: 5px; height: auto; min-height: 50px; @@ -48,6 +57,7 @@ padding-top: 5px; padding-bottom: 5px; background-color: rgb(240, 240, 240); + align-self: center; margin-bottom: 5px; align-items: flex-start; flex-direction: column; @@ -55,6 +65,28 @@ box-shadow: 0px 0px 2px 0px lightgray; } +.minimized_issue_card { + display: inline-flex; + width: min-content; + align-items: center; + justify-content: center; + margin-top: 5px; + margin-bottom: 5px; + height: auto; + border-radius: 5px; + border-bottom: 2px solid; + background-color: rgb(240, 240, 240); +} + +.minimized_issue_card span { + padding: 5px; +} + +.minimized_issue_card:hover { + background-color: rgb(220, 220, 220); + cursor: pointer; +} + .issue_card:hover { background-color: rgb(220, 220, 220); cursor: pointer; @@ -95,10 +127,6 @@ font-size: medium; } -.select_project { - margin-left: 10px; -} - .issue_card_header { display: flex; padding-top: 5px; @@ -110,9 +138,40 @@ margin-left: auto; padding-top: 5px; padding-bottom: 5px; + padding-left: 10px; + padding-right: 10px; + margin-right: 10px; + border-radius: 15px; + color: rgb(255, 255, 255); + font-size: smaller; +} + +.select_project_container { + display: flex; + flex-direction: row; + margin-left: 10px; +} + +.select_project_item { + display: inline-flex; + padding-top: 5px; + padding-bottom: 5px; padding-left: 8px; padding-right: 8px; - margin-right: 10px; border-radius: 15px; + margin-right: 10px; color: white; + opacity: 0.5; + min-width: 50px; + align-items: center; + justify-content: center; +} + +.select_project_item:hover { + opacity: 1; + cursor: pointer; +} + +.select_project_item_selected { + opacity: 1; } \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 821e6e5..d6c29d4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,6 +3,8 @@ en: settings_header_statuses: "Statuses colors" settings_header_projects: "Projects colors" settings_header_other: "Other" + settings_display_closed_statuses: 'Display "closed" statuses' + settings_display_minimized_closed_issue_cards: 'Display minimized "closed" issue cards' settings_enable_drag_and_drop: 'Enable "drag and drop" status changing' executor_not_set: "Not set" label_all: "All" \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 4eb054f..f65b6d8 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -3,6 +3,8 @@ ru: settings_header_statuses: "Цвета статусов" settings_header_projects: "Цвета проектов" settings_header_other: "Разное" + settings_display_closed_statuses: 'Отображать "закрытые" статусы' + settings_display_minimized_closed_issue_cards: 'Отображать свернутые карточки "закрытых" задач' settings_enable_drag_and_drop: 'Включить "drag and drop" изменение статуса' executor_not_set: "Не установлен" label_all: "Все" \ No newline at end of file diff --git a/init.rb b/init.rb index 12e70cc..aa9e553 100644 --- a/init.rb +++ b/init.rb @@ -2,7 +2,7 @@ name 'Dashboard' author "Akpaev E.A." description "Plugin adds an issues dashboard to the application" - version '1.0.5' + version '1.0.6' url 'https://github.com/akpaevj/Dashboard' author_url 'https://github.com/akpaevj' menu :top_menu, :dashboard, { controller: 'dashboard', action: 'index' }, caption: :top_menu_item_title, first: true