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

Notes for Project-Board-Columns #29045

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cfa01d6
feat(board-notes): add, edit and delete of BoardNotes
zokkis Feb 3, 2024
79f5d58
feat(board-notes): styles for card-content and modals
zokkis Feb 3, 2024
c668d8e
feat(board-notes): move notes like issues
zokkis Feb 3, 2024
90d0b60
feat(board-notes): set boardID to 0 on when board gets deleted
zokkis Feb 3, 2024
a9924b6
feat(board-notes): add projectID to BoardNote
zokkis Feb 3, 2024
423404c
feat(board-notes): better styles for large cards
zokkis Feb 3, 2024
c369889
fix: update note content on frontend and backend
zokkis Feb 3, 2024
962ea45
enhance: don't reload page to remove deleted column and cards
zokkis Feb 3, 2024
ac79a31
fix: max-width for cards and attachments (fixes: #29029)
zokkis Feb 3, 2024
bff8dc6
enhance: can add notes to 'Uncategorized'-Column
zokkis Feb 3, 2024
2c63ee1
enhance: don't reload page after moving note
zokkis Feb 3, 2024
696a632
enhance: new sort-order -> newest BoardNote on top
zokkis Feb 4, 2024
a29422f
refactor: use form-fetch-action instead of own $.ajax
zokkis Feb 4, 2024
0f4b806
enhance: content of BoardNotes with MD support
zokkis Feb 4, 2024
12f8cda
fix: whole project-column has cursor grab
zokkis Feb 4, 2024
51c8e09
enhance: smaller cards and view-modal
zokkis Feb 4, 2024
4e17cf2
enhance: create issue from board-note
zokkis Feb 4, 2024
0d8f8a2
i18n: translations for board-notes
zokkis Feb 4, 2024
965f70d
fix: edit the column-title don't remove the count-div (fixes: #29031)
zokkis Feb 4, 2024
762f2ce
fix: v1.21 to main
zokkis Feb 4, 2024
76b90eb
chore: lint
zokkis Feb 4, 2024
4815e7a
fix: required changes from CI and Bot
zokkis Feb 4, 2024
410b286
enhance: show amount of tasks in board-notes card
zokkis Feb 4, 2024
5084134
enhance: board-notes can now be pinned
zokkis Feb 4, 2024
abb5152
chore: rename BoardNote to ProjectBoardNote
zokkis Feb 6, 2024
1c12d87
refactor: LoadAttributes function
zokkis Feb 6, 2024
7b28107
fix: missed translations for form
zokkis Feb 7, 2024
f3ce631
fix: projectBoardNote delete
zokkis Feb 7, 2024
99cf2d1
enhance: add tags to project-board-notes
zokkis Feb 7, 2024
1bd15a4
fix: init markdownEditor on pinned notes
zokkis Feb 7, 2024
dd7cb77
enhance: select labels while creating note
zokkis Feb 7, 2024
0c77014
fix: unique note_label
zokkis Feb 7, 2024
313016e
style: break note card title
zokkis Feb 7, 2024
c87b630
fix: issue content was set with old data
zokkis Feb 7, 2024
be88ded
enhance: link milestone to note
zokkis Feb 8, 2024
1f1c997
permissions: only admin and creator can edit notes
zokkis Feb 8, 2024
67e5a86
fix: cursor-grap only on columns and cards if column-id != 0 and use …
zokkis Feb 8, 2024
1c50683
fix: moving pinned cards need permissions
zokkis Feb 8, 2024
f1387ca
enhance: show pinned note in list
zokkis Feb 8, 2024
0aa0c5c
fix: show milestone in view-modal of note
zokkis Feb 8, 2024
50e8545
enhance: notes are now available in orgs
zokkis Feb 9, 2024
2f4631a
enhance: milestone and label selectors with search
zokkis Feb 9, 2024
6222c42
chore: add migration
zokkis Feb 9, 2024
98cb5c0
i18n: translations for milestone
zokkis Feb 9, 2024
0f74de6
chore: fmt and lint
zokkis Feb 9, 2024
afcd5d8
fix: prefill of issue form is now from pinned notes possible
zokkis Feb 9, 2024
7e470d9
Merge branch 'main' into feature/project-board-notes
6543 Feb 25, 2024
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
11 changes: 3 additions & 8 deletions models/issues/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package issues
import (
"context"
"fmt"
"regexp"
"slices"

"code.gitea.io/gitea/models/db"
Expand All @@ -16,6 +15,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
Expand Down Expand Up @@ -141,11 +141,6 @@ type Issue struct {
ShowRole RoleDescriptor `xorm:"-"`
}

var (
issueTasksPat = regexp.MustCompile(`(^\s*[-*]\s\[[\sxX]\]\s.)|(\n\s*[-*]\s\[[\sxX]\]\s.)`)
issueTasksDonePat = regexp.MustCompile(`(^\s*[-*]\s\[[xX]\]\s.)|(\n\s*[-*]\s\[[xX]\]\s.)`)
)

// IssueIndex represents the issue index table
type IssueIndex db.ResourceIndex

Expand Down Expand Up @@ -443,12 +438,12 @@ func (issue *Issue) IsPoster(uid int64) bool {

// GetTasks returns the amount of tasks in the issues content
func (issue *Issue) GetTasks() int {
return len(issueTasksPat.FindAllStringIndex(issue.Content, -1))
return len(markdown.MarkdownTasksRegex.FindAllStringIndex(issue.Content, -1))
}

// GetTasksDone returns the amount of completed tasks in the issues content
func (issue *Issue) GetTasksDone() int {
return len(issueTasksDonePat.FindAllStringIndex(issue.Content, -1))
return len(markdown.MarkdownTasksDoneRegex.FindAllStringIndex(issue.Content, -1))
}

// GetLastEventTimestamp returns the last user visible event timestamp, either the creation of this issue or the close.
Expand Down
51 changes: 51 additions & 0 deletions models/migrations/v1_22/v287.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_22 //nolint

import (
"code.gitea.io/gitea/modules/timeutil"

"xorm.io/xorm"
)

type BoardNote struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Board has been renamed to Column, this should be ColumnNote now.

ID int64 `xorm:"pk autoincr"`
Title string `xorm:"TEXT NOT NULL"`
Content string `xorm:"LONGTEXT"`
Sorting int64 `xorm:"NOT NULL DEFAULT 0"`
PinOrder int64 `xorm:"NOT NULL DEFAULT 0"`
MilestoneID int64 `xorm:"INDEX"`

ProjectID int64 `xorm:"INDEX NOT NULL"`
BoardID int64 `xorm:"INDEX NOT NULL"`
CreatorID int64 `xorm:"NOT NULL"`

CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

// TableName xorm will read the table name from this method
func (BoardNote) TableName() string {
return "project_board_note"
}

type BoardNoteLabel struct {
ID int64 `xorm:"pk autoincr"`
BoardNoteID int64 `xorm:"UNIQUE(s) NOT NULL"`
LabelID int64 `xorm:"UNIQUE(s) NOT NULL"`
}

// TableName xorm will read the table name from this method
func (BoardNoteLabel) TableName() string {
return "project_board_note_label"
}

func CreateTablesForBoardNotes(x *xorm.Engine) error {
err := x.Sync(new(BoardNote))
if err != nil {
return err
}

return x.Sync(new(BoardNoteLabel))
}
25 changes: 25 additions & 0 deletions models/project/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ func (b *Board) NumIssues(ctx context.Context) int {
return int(c)
}

// NumBoardNotes return counter of all notes assigned to the board
func (b *Board) NumBoardNotes(ctx context.Context) int {
c, err := db.GetEngine(ctx).Table("project_board_note").
Where("project_id=?", b.ProjectID).
And("board_id=?", b.ID).
GroupBy("id").
Cols("id").
Count()
if err != nil {
return 0
}
return int(c)
}

// NumIssuesAndNotes return counter of all issues and notes assigned to the board
func (b *Board) NumIssuesAndNotes(ctx context.Context) int {
numIssues := b.NumIssues(ctx)
numBoardNotes := b.NumBoardNotes(ctx)
return numIssues + numBoardNotes
}

func init() {
db.RegisterModel(new(Board))
}
Expand Down Expand Up @@ -180,6 +201,10 @@ func deleteBoardByID(ctx context.Context, boardID int64) error {
return err
}

if err = board.removeBoardNotes(ctx); err != nil {
return err
}

if _, err := db.GetEngine(ctx).ID(board.ID).NoAutoCondition().Delete(board); err != nil {
return err
}
Expand Down
Loading
Loading