Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
akpaevj committed May 21, 2021
2 parents b8193d5 + e9ae2bc commit eca34a5
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 22 deletions.
9 changes: 1 addition & 8 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def index
@selected_project_id = params[:project_id].nil? ? -1 : params[:project_id].to_i
show_sub_tasks = Setting.plugin_dashboard['display_child_projects_tasks']
@show_project_badge = @selected_project_id == -1 || @selected_project_id != -1 && show_sub_tasks
@use_drag_and_drop = Setting.plugin_dashboard['enable_drag_and_drop']
@display_minimized_closed_issue_cards = Setting.plugin_dashboard['display_closed_statuses'] ? Setting.plugin_dashboard['display_minimized_closed_issue_cards'] : false
@statuses = get_statuses
@projects = get_projects
Expand Down Expand Up @@ -43,14 +44,6 @@ def get_statuses
data
end

def get_random_dark_color
'hsl(' + Random.new.rand(0..360).to_s + ', 60%, 75%)'
end

def get_random_light_color
'hsl(' + Random.new.rand(0..360).to_s + ', 100%, 50%)'
end

def get_projects
data = {-1 => {
:name => l(:label_all),
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@

<script>
$(function() {
init();
init(<%= @use_drag_and_drop %>);
})
</script>
15 changes: 15 additions & 0 deletions app/views/settings/_dashboard_settings.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<% content_for :header_tags do %>
<%= javascript_include_tag 'settings', plugin: 'dashboard' %>
<% end %>

<table>
<tbody>
<tr>
Expand All @@ -24,9 +28,20 @@
</td>
</tr>
<% end %>
<tr>
<td colspan="2">
<button type="button" onclick="generateColors()"><%=l :settings_generate_colors %></button>
<td>
</tr>
<tr>
<th colspan="2"> <%=l :settings_header_other %> </td>
</tr>
<tr>
<td> <%=l :settings_enable_drag_and_drop %> </th>
<td>
<%= check_box_tag "settings[enable_drag_and_drop]", true, @settings['enable_drag_and_drop'] %>
</td>
</tr>
<tr>
<td> <%=l :settings_use_drop_down_menu %> </th>
<td>
Expand Down
28 changes: 15 additions & 13 deletions assets/javascripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function setIssueStatus(issueId, statusId, item, oldContainer, oldIndex) {
}
}

function init() {
function init(useDragAndDrop) {
document.querySelector('#main-menu').remove();

document.querySelectorAll('.select_project_item').forEach(item => {
Expand All @@ -52,17 +52,19 @@ function init() {

document.querySelector("#content").style.overflow = "hidden";

document.querySelectorAll('.status_column_closed_issues, .status_column_issues').forEach(item => {
new Sortable(item, {
group: 'issues',
animation: 150,
draggable: '.issue_card',
onEnd: async function(evt) {
const newStatus = evt.to.closest('.status_column').dataset.id;
const issueId = evt.item.dataset.id;

await setIssueStatus(issueId, newStatus, evt.item, evt.from, evt.oldIndex);
}
if (useDragAndDrop) {
document.querySelectorAll('.status_column_closed_issues, .status_column_issues').forEach(item => {
new Sortable(item, {
group: 'issues',
animation: 150,
draggable: '.issue_card',
onEnd: async function(evt) {
const newStatus = evt.to.closest('.status_column').dataset.id;
const issueId = evt.item.dataset.id;

await setIssueStatus(issueId, newStatus, evt.item, evt.from, evt.oldIndex);
}
})
})
})
}
}
22 changes: 22 additions & 0 deletions assets/javascripts/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function hslToHex(h, s, l) {
l /= 100;
const a = s * Math.min(l, 1 - l) / 100;
const f = n => {
const k = (n + h / 30) % 12;
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
return Math.round(255 * color).toString(16).padStart(2, '0');
};
return `#${f(0)}${f(8)}${f(4)}`;
}

function getRandomColor() {
return hslToHex(Math.random() * 360, 100, 45);
}

function generateColors() {
document.querySelectorAll('input[type=color]').forEach(function(item) {
if (item.value == '#000000') {
item.value = getRandomColor();
}
});
}
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ en:
settings_display_child_projects_tasks: 'Display child projects tasks'
settings_display_minimized_closed_issue_cards: 'Display minimized "closed" issue cards'
settings_enable_drag_and_drop: '"Drag and drop" status changing'
settings_generate_colors: "Generate colors"
executor_not_set: "Not set"
label_all: "All"
1 change: 1 addition & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ ru:
settings_display_child_projects_tasks: 'Отображать задачи дочерних проектов'
settings_display_minimized_closed_issue_cards: 'Отображать свернутые карточки "закрытых" задач'
settings_enable_drag_and_drop: '"Drag and drop" изменение статуса'
settings_generate_colors: "Сгенерировать цвета"
executor_not_set: "Не установлен"
label_all: "Все"

0 comments on commit eca34a5

Please sign in to comment.