Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kanban colored boards #16647

Merged
merged 34 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d7ba3cf
#11160 Add colors column for ProjectBoard
romdum Aug 6, 2021
b2c13e0
#11160 Add color input in edit project board form
romdum Aug 6, 2021
19bc8a7
Add label for color
romdum Aug 6, 2021
bfbbbda
Add color picker
romdum Aug 7, 2021
1d4d8e7
Add color input on new board form
romdum Aug 7, 2021
1d0d134
Linter fix
romdum Aug 7, 2021
ad2dc84
Add migration for color project board column
romdum Aug 8, 2021
85b9346
validate project board column
romdum Aug 8, 2021
ca4481a
Correct BoardColorPattern comment
romdum Aug 8, 2021
b182243
Create a generic "color" translation key
romdum Aug 8, 2021
77ed1e3
Add color validation on new project board form
romdum Aug 8, 2021
e64812b
Apply suggestions from code review
6543 Aug 8, 2021
404ab33
Merge branch 'main' into feature/board_color
6543 Aug 8, 2021
3ce6a4c
Merge branch 'main' into feature/board_color
6543 Aug 21, 2021
ec952cd
Change board label color according to background
romdum Aug 23, 2021
153a7fe
Possibility to remove board color
romdum Aug 23, 2021
9f86b27
Merge branch 'main' into feature/board_color
romdum Aug 23, 2021
ff47888
Merge branch main to fix conflicts
romdum Aug 25, 2021
592ac5a
Merge branch 'main' into feature/board_color
6543 Aug 28, 2021
e1ff66a
Use less variable for project board label color
romdum Aug 31, 2021
7918bb7
Add button to remove board colors
romdum Sep 7, 2021
20b4dd6
Add check before update board color
romdum Sep 7, 2021
6a62f90
Linter fix
romdum Sep 7, 2021
1c98c83
Code review
romdum Sep 9, 2021
cc4a33a
Merge branch 'main' into feature/board_color
romdum Sep 9, 2021
037cd56
Merge branch 'main' into feature/board_color
romdum Sep 9, 2021
a86ee3c
Remove btn which remove board color and add precolor
romdum Sep 9, 2021
5e335dc
linter fix
romdum Sep 9, 2021
c39ca47
Add precolor on new project board form
romdum Sep 9, 2021
694bc41
linter fix
romdum Sep 9, 2021
d769196
Board color - Code review
romdum Sep 24, 2021
dc4e4c4
Merge branch 'main'
romdum Sep 24, 2021
3b12e74
Feature Board colored - Code review
romdum Sep 27, 2021
95d7555
Merge branch 'main' into feature/board_color
6543 Sep 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions models/project_board.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ProjectBoard struct {
Title string
Default bool `xorm:"NOT NULL DEFAULT false"` // issues not assigned to a specific board will be assigned to this board
Sorting int8 `xorm:"NOT NULL DEFAULT 0"`
Color string
6543 marked this conversation as resolved.
Show resolved Hide resolved

ProjectID int64 `xorm:"INDEX NOT NULL"`
CreatorID int64 `xorm:"NOT NULL"`
Expand Down Expand Up @@ -173,6 +174,10 @@ func updateProjectBoard(e Engine, board *ProjectBoard) error {
fieldToUpdate = append(fieldToUpdate, "title")
}

if board.Color != "" {
lafriks marked this conversation as resolved.
Show resolved Hide resolved
fieldToUpdate = append(fieldToUpdate, "color")
}

_, err := e.ID(board.ID).Cols(fieldToUpdate...).Update(board)

return err
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ projects.board.set_default = "Set Default"
projects.board.set_default_desc = "Set this board as default for uncategorized issues and pulls"
projects.board.delete = "Delete Board"
projects.board.deletion_desc = "Deleting a project board moves all related issues to 'Uncategorized'. Continue?"
projects.board.edit_color = "Color"
6543 marked this conversation as resolved.
Show resolved Hide resolved
projects.open = Open
projects.close = Close

Expand Down
5 changes: 5 additions & 0 deletions routers/web/repo/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ func AddBoardToProjectPost(ctx *context.Context) {
if err := models.NewProjectBoard(&models.ProjectBoard{
ProjectID: project.ID,
Title: form.Title,
Color: form.Color,
CreatorID: ctx.User.ID,
}); err != nil {
ctx.ServerError("NewProjectBoard", err)
Expand Down Expand Up @@ -511,6 +512,10 @@ func EditProjectBoard(ctx *context.Context) {
board.Title = form.Title
}

if form.Color != "" {
lafriks marked this conversation as resolved.
Show resolved Hide resolved
board.Color = form.Color
}

if form.Sorting != 0 {
board.Sorting = form.Sorting
}
Expand Down
1 change: 1 addition & 0 deletions services/forms/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ type UserCreateProjectForm struct {
type EditProjectBoardForm struct {
Title string `binding:"Required;MaxSize(100)"`
Sorting int8
Color string `binding:"MaxSize(7)"`
6543 marked this conversation as resolved.
Show resolved Hide resolved
}

// _____ .__.__ __
Expand Down
12 changes: 11 additions & 1 deletion templates/repo/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<input class="new-board" id="new_board" name="title" required>
</div>

<div class="field color-field">
<label for="new_board_color">{{$.i18n.Tr "repo.projects.board.edit_color"}}</label>
<input class="color-picker" maxlength="7" placeholder="#c320f6" id="new_board_color_picker" name="color">
</div>

<div class="text right actions">
<div class="ui cancel button">{{$.i18n.Tr "settings.cancel"}}</div>
<button data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}" class="ui green button" id="new_board_submit">{{$.i18n.Tr "repo.projects.board.new_submit"}}</button>
Expand Down Expand Up @@ -69,7 +74,7 @@
<div class="board">
{{ range $board := .Boards }}

<div class="ui segment board-column" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}">
<div class="ui segment board-column" style="background: {{.Color}}!important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}">
<div class="board-column-header df ac sb">
<div class="ui large label board-label py-2">{{.Title}}</div>
{{if and $.CanWriteProjects (not $.Repository.IsArchived) $.PageIsProjects (ne .ID 0)}}
Expand Down Expand Up @@ -104,6 +109,11 @@
<input class="project-board-title" id="new_board_title" name="title" value="{{.Title}}" required>
</div>

<div class="field color-field">
<label for="new_board_color">{{$.i18n.Tr "repo.projects.board.edit_color"}}</label>
<input class="color-picker" maxlength="7" placeholder="#c320f6" id="new_board_color" name="color" value="{{.Color}}">
</div>

<div class="text right actions">
<div class="ui cancel button">{{$.i18n.Tr "settings.cancel"}}</div>
<button data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}" class="ui red button">{{$.i18n.Tr "repo.projects.board.edit"}}</button>
Expand Down
8 changes: 6 additions & 2 deletions web_src/js/features/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export default async function initProject() {
const projectTitleInput = $(this).find(
'.content > .form > .field > .project-board-title',
);
const projectColorInput = $(this).find('.content > .form > .field > #new_board_color');
const boardColumn = $(this).closest('.board-column');

$(this)
.find('.content > .form > .actions > .red')
Expand All @@ -74,7 +76,7 @@ export default async function initProject() {

$.ajax({
url: $(this).data('url'),
data: JSON.stringify({title: projectTitleInput.val()}),
data: JSON.stringify({title: projectTitleInput.val(), color: projectColorInput.val()}),
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
Expand All @@ -84,6 +86,7 @@ export default async function initProject() {
}).done(() => {
projectTitleLabel.text(projectTitleInput.val());
projectTitleInput.closest('form').removeClass('dirty');
boardColumn.attr('style', `background: ${projectColorInput.val()}!important`);
$('.ui.modal').modal('hide');
});
});
Expand Down Expand Up @@ -127,10 +130,11 @@ export default async function initProject() {
e.preventDefault();

const boardTitle = $('#new_board');
const projectColorInput = $('#new_board_color_picker');

$.ajax({
url: $(this).data('url'),
data: JSON.stringify({title: boardTitle.val()}),
data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}),
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
Expand Down
21 changes: 15 additions & 6 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,8 @@ function initLabelEdit() {
$newLabelPanel.hide();
});

createColorPicker($('.color-picker'));
initColorPicker();

$('.precolors .color').on('click', function () {
const color_hex = $(this).data('color-hex');
$('.color-picker').val(color_hex);
$('.minicolors-swatch-color').css('background-color', color_hex);
});
$('.edit-label-button').on('click', function () {
$('.edit-label .color-picker').minicolors('value', $(this).data('color'));
$('#label-modal-id').val($(this).data('id'));
Expand All @@ -182,6 +177,16 @@ function initLabelEdit() {
});
}

function initColorPicker() {
createColorPicker($('.color-picker'));

$('.precolors .color').on('click', function () {
const color_hex = $(this).data('color-hex');
$('.color-picker').val(color_hex);
$('.minicolors-swatch-color').css('background-color', color_hex);
});
}

function updateIssuesMeta(url, action, issueIds, elementId) {
return new Promise(((resolve) => {
$.ajax({
Expand Down Expand Up @@ -2729,6 +2734,10 @@ $(document).ready(async () => {
});
$('.show-modal.button').on('click', function () {
$($(this).data('modal')).modal('show');
const colorPickers = $($(this).data('modal')).find('.color-picker');
if (colorPickers.length > 0) {
initColorPicker();
}
});
$('.delete-post.button').on('click', function () {
const $this = $(this);
Expand Down
13 changes: 13 additions & 0 deletions web_src/less/features/projects.less
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@
.card-ghost * {
opacity: 0;
}

.color-field .minicolors.minicolors-theme-default {
display: block;

.minicolors-input {
height: 38px;
padding-left: 2rem;
}

.minicolors-swatch {
top: 10px;
}
}