Add unset default project column (#23531)
Close: https://github.com/go-gitea/gitea/issues/23401
This commit is contained in:
parent
e422342eeb
commit
f30cc9faa9
|
@ -1261,6 +1261,8 @@ projects.column.new_submit = "Create Column"
|
|||
projects.column.new = "New Column"
|
||||
projects.column.set_default = "Set Default"
|
||||
projects.column.set_default_desc = "Set this column as default for uncategorized issues and pulls"
|
||||
projects.column.unset_default = "Unset Default"
|
||||
projects.column.unset_default_desc = "Unset this column as default"
|
||||
projects.column.delete = "Delete Column"
|
||||
projects.column.deletion_desc = "Deleting a project column moves all related issues to 'Uncategorized'. Continue?"
|
||||
projects.column.color = "Color"
|
||||
|
|
|
@ -610,6 +610,23 @@ func SetDefaultProjectBoard(ctx *context.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
// UnsetDefaultProjectBoard unset default board for uncategorized issues/pulls
|
||||
func UnsetDefaultProjectBoard(ctx *context.Context) {
|
||||
project, _ := CheckProjectBoardChangePermissions(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
if err := project_model.SetDefaultBoard(project.ID, 0); err != nil {
|
||||
ctx.ServerError("SetDefaultBoard", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
||||
// MoveIssues moves or keeps issues in a column and sorts them inside that column
|
||||
func MoveIssues(ctx *context.Context) {
|
||||
if ctx.Doer == nil {
|
||||
|
|
|
@ -576,6 +576,23 @@ func SetDefaultProjectBoard(ctx *context.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
// UnSetDefaultProjectBoard unset default board for uncategorized issues/pulls
|
||||
func UnSetDefaultProjectBoard(ctx *context.Context) {
|
||||
project, _ := checkProjectBoardChangePermissions(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
if err := project_model.SetDefaultBoard(project.ID, 0); err != nil {
|
||||
ctx.ServerError("SetDefaultBoard", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
||||
// MoveIssues moves or keeps issues in a column and sorts them inside that column
|
||||
func MoveIssues(ctx *context.Context) {
|
||||
if ctx.Doer == nil {
|
||||
|
|
|
@ -936,6 +936,7 @@ func RegisterRoutes(m *web.Route) {
|
|||
m.Put("", web.Bind(forms.EditProjectBoardForm{}), org.EditProjectBoard)
|
||||
m.Delete("", org.DeleteProjectBoard)
|
||||
m.Post("/default", org.SetDefaultProjectBoard)
|
||||
m.Post("/unsetdefault", org.UnsetDefaultProjectBoard)
|
||||
|
||||
m.Post("/move", org.MoveIssues)
|
||||
})
|
||||
|
@ -1292,6 +1293,7 @@ func RegisterRoutes(m *web.Route) {
|
|||
m.Put("", web.Bind(forms.EditProjectBoardForm{}), repo.EditProjectBoard)
|
||||
m.Delete("", repo.DeleteProjectBoard)
|
||||
m.Post("/default", repo.SetDefaultProjectBoard)
|
||||
m.Post("/unsetdefault", repo.UnSetDefaultProjectBoard)
|
||||
|
||||
m.Post("/move", repo.MoveIssues)
|
||||
})
|
||||
|
|
|
@ -95,10 +95,25 @@
|
|||
{{$.locale.Tr "repo.projects.column.edit"}}
|
||||
</a>
|
||||
{{if not .Default}}
|
||||
<a class="item show-modal button" data-modal="#set-default-project-board-modal-{{.ID}}">
|
||||
<a class="item show-modal button default-project-board-show"
|
||||
data-modal="#default-project-board-modal-{{.ID}}"
|
||||
data-modal-default-project-board-header="{{$.locale.Tr "repo.projects.column.set_default"}}"
|
||||
data-modal-default-project-board-content="{{$.locale.Tr "repo.projects.column.set_default_desc"}}"
|
||||
data-modal-default-project-board-submit="{{$.locale.Tr "repo.projects.column.set_default"}}"
|
||||
data-url="{{$.Link}}/{{.ID}}/default">
|
||||
{{svg "octicon-pin"}}
|
||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
||||
</a>
|
||||
{{else}}
|
||||
<a class="item show-modal button default-project-board-show"
|
||||
data-modal="#default-project-board-modal-{{.ID}}"
|
||||
data-modal-default-project-board-header="{{$.locale.Tr "repo.projects.column.unset_default"}}"
|
||||
data-modal-default-project-board-content="{{$.locale.Tr "repo.projects.column.unset_default_desc"}}"
|
||||
data-modal-default-project-board-submit="{{$.locale.Tr "repo.projects.column.unset_default"}}"
|
||||
data-url="{{$.Link}}/{{.ID}}/unsetdefault">
|
||||
{{svg "octicon-pin"}}
|
||||
{{$.locale.Tr "repo.projects.column.unset_default"}}
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="item show-modal button" data-modal="#delete-board-modal-{{.ID}}">
|
||||
{{svg "octicon-trash"}}
|
||||
|
@ -134,18 +149,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui basic modal" id="set-default-project-board-modal-{{.ID}}">
|
||||
<div class="ui basic modal default-project-board-modal" id="default-project-board-modal-{{.ID}}">
|
||||
<div class="ui icon header">
|
||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
||||
<span id="default-project-board-header"></span>
|
||||
</div>
|
||||
<div class="content center">
|
||||
<label>
|
||||
{{$.locale.Tr "repo.projects.column.set_default_desc"}}
|
||||
</label>
|
||||
<label id="default-project-board-content"></label>
|
||||
</div>
|
||||
<div class="text right actions">
|
||||
<button class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</button>
|
||||
<button class="ui primary button set-default-project-board" data-url="{{$.Link}}/{{.ID}}/default">{{$.locale.Tr "repo.projects.column.set_default"}}</button>
|
||||
<button class="ui primary button default-project-board-button" id="default-project-board-submit"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -99,10 +99,27 @@
|
|||
{{$.locale.Tr "repo.projects.column.edit"}}
|
||||
</a>
|
||||
{{if not .Default}}
|
||||
<a class="item show-modal button" data-modal="#set-default-project-board-modal-{{.ID}}">
|
||||
<a class="item show-modal button default-project-board-show"
|
||||
data-modal="#default-project-board-modal-{{.ID}}"
|
||||
data-modal-default-project-board-header="{{$.locale.Tr "repo.projects.column.set_default"}}"
|
||||
data-modal-default-project-board-content="{{$.locale.Tr "repo.projects.column.set_default_desc"}}"
|
||||
data-modal-default-project-board-submit="{{$.locale.Tr "repo.projects.column.set_default"}}"
|
||||
data-type="set_default"
|
||||
data-url="{{$.Link}}/{{.ID}}/default">
|
||||
{{svg "octicon-pin"}}
|
||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
||||
</a>
|
||||
{{else}}
|
||||
<a class="item show-modal button default-project-board-show"
|
||||
data-modal="#default-project-board-modal-{{.ID}}"
|
||||
data-modal-default-project-board-header="{{$.locale.Tr "repo.projects.column.unset_default"}}"
|
||||
data-modal-default-project-board-content="{{$.locale.Tr "repo.projects.column.unset_default_desc"}}"
|
||||
data-modal-default-project-board-submit="{{$.locale.Tr "repo.projects.column.unset_default"}}"
|
||||
data-type="unset_default"
|
||||
data-url="{{$.Link}}/{{.ID}}/unsetdefault">
|
||||
{{svg "octicon-pin"}}
|
||||
{{$.locale.Tr "repo.projects.column.unset_default"}}
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="item show-modal button" data-modal="#delete-board-modal-{{.ID}}">
|
||||
{{svg "octicon-trash"}}
|
||||
|
@ -138,18 +155,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui basic modal" id="set-default-project-board-modal-{{.ID}}">
|
||||
<div class="ui basic modal default-project-board-modal" id="default-project-board-modal-{{.ID}}">
|
||||
<div class="ui icon header">
|
||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
||||
<span id="default-project-board-header"></span>
|
||||
</div>
|
||||
<div class="content center">
|
||||
<label>
|
||||
{{$.locale.Tr "repo.projects.column.set_default_desc"}}
|
||||
</label>
|
||||
<label id="default-project-board-content"></label>
|
||||
</div>
|
||||
<div class="text right actions">
|
||||
<button class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</button>
|
||||
<button class="ui primary button set-default-project-board" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}/default">{{$.locale.Tr "repo.projects.column.set_default"}}</button>
|
||||
<button class="ui primary button default-project-board-button" id="default-project-board-submit"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -126,19 +126,30 @@ export function initRepoProject() {
|
|||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.set-default-project-board', async function (e) {
|
||||
e.preventDefault();
|
||||
$('.default-project-board-modal').each(function () {
|
||||
const boardColumn = $(this).closest('.board-column');
|
||||
const showButton = $(boardColumn).find('.default-project-board-show');
|
||||
const commitButton = $(this).find('.default-project-board-button');
|
||||
|
||||
await $.ajax({
|
||||
method: 'POST',
|
||||
url: $(this).data('url'),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrfToken,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
if ($(showButton).data('type') === 'unset_default') {
|
||||
$(commitButton).removeClass('primary');
|
||||
$(commitButton).addClass('red');
|
||||
}
|
||||
|
||||
$(commitButton).on('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: $(showButton).data('url'),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrfToken,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
}).done(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
$('.delete-project-board').each(function () {
|
||||
|
|
Loading…
Reference in a new issue