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.new = "New Column"
|
||||||
projects.column.set_default = "Set Default"
|
projects.column.set_default = "Set Default"
|
||||||
projects.column.set_default_desc = "Set this column as default for uncategorized issues and pulls"
|
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.delete = "Delete Column"
|
||||||
projects.column.deletion_desc = "Deleting a project column moves all related issues to 'Uncategorized'. Continue?"
|
projects.column.deletion_desc = "Deleting a project column moves all related issues to 'Uncategorized'. Continue?"
|
||||||
projects.column.color = "Color"
|
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
|
// MoveIssues moves or keeps issues in a column and sorts them inside that column
|
||||||
func MoveIssues(ctx *context.Context) {
|
func MoveIssues(ctx *context.Context) {
|
||||||
if ctx.Doer == nil {
|
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
|
// MoveIssues moves or keeps issues in a column and sorts them inside that column
|
||||||
func MoveIssues(ctx *context.Context) {
|
func MoveIssues(ctx *context.Context) {
|
||||||
if ctx.Doer == nil {
|
if ctx.Doer == nil {
|
||||||
|
|
|
@ -936,6 +936,7 @@ func RegisterRoutes(m *web.Route) {
|
||||||
m.Put("", web.Bind(forms.EditProjectBoardForm{}), org.EditProjectBoard)
|
m.Put("", web.Bind(forms.EditProjectBoardForm{}), org.EditProjectBoard)
|
||||||
m.Delete("", org.DeleteProjectBoard)
|
m.Delete("", org.DeleteProjectBoard)
|
||||||
m.Post("/default", org.SetDefaultProjectBoard)
|
m.Post("/default", org.SetDefaultProjectBoard)
|
||||||
|
m.Post("/unsetdefault", org.UnsetDefaultProjectBoard)
|
||||||
|
|
||||||
m.Post("/move", org.MoveIssues)
|
m.Post("/move", org.MoveIssues)
|
||||||
})
|
})
|
||||||
|
@ -1292,6 +1293,7 @@ func RegisterRoutes(m *web.Route) {
|
||||||
m.Put("", web.Bind(forms.EditProjectBoardForm{}), repo.EditProjectBoard)
|
m.Put("", web.Bind(forms.EditProjectBoardForm{}), repo.EditProjectBoard)
|
||||||
m.Delete("", repo.DeleteProjectBoard)
|
m.Delete("", repo.DeleteProjectBoard)
|
||||||
m.Post("/default", repo.SetDefaultProjectBoard)
|
m.Post("/default", repo.SetDefaultProjectBoard)
|
||||||
|
m.Post("/unsetdefault", repo.UnSetDefaultProjectBoard)
|
||||||
|
|
||||||
m.Post("/move", repo.MoveIssues)
|
m.Post("/move", repo.MoveIssues)
|
||||||
})
|
})
|
||||||
|
|
|
@ -95,10 +95,25 @@
|
||||||
{{$.locale.Tr "repo.projects.column.edit"}}
|
{{$.locale.Tr "repo.projects.column.edit"}}
|
||||||
</a>
|
</a>
|
||||||
{{if not .Default}}
|
{{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"}}
|
{{svg "octicon-pin"}}
|
||||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
{{$.locale.Tr "repo.projects.column.set_default"}}
|
||||||
</a>
|
</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}}
|
{{end}}
|
||||||
<a class="item show-modal button" data-modal="#delete-board-modal-{{.ID}}">
|
<a class="item show-modal button" data-modal="#delete-board-modal-{{.ID}}">
|
||||||
{{svg "octicon-trash"}}
|
{{svg "octicon-trash"}}
|
||||||
|
@ -134,18 +149,16 @@
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="ui icon header">
|
||||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
<span id="default-project-board-header"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content center">
|
<div class="content center">
|
||||||
<label>
|
<label id="default-project-board-content"></label>
|
||||||
{{$.locale.Tr "repo.projects.column.set_default_desc"}}
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text right actions">
|
<div class="text right actions">
|
||||||
<button class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -99,10 +99,27 @@
|
||||||
{{$.locale.Tr "repo.projects.column.edit"}}
|
{{$.locale.Tr "repo.projects.column.edit"}}
|
||||||
</a>
|
</a>
|
||||||
{{if not .Default}}
|
{{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"}}
|
{{svg "octicon-pin"}}
|
||||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
{{$.locale.Tr "repo.projects.column.set_default"}}
|
||||||
</a>
|
</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}}
|
{{end}}
|
||||||
<a class="item show-modal button" data-modal="#delete-board-modal-{{.ID}}">
|
<a class="item show-modal button" data-modal="#delete-board-modal-{{.ID}}">
|
||||||
{{svg "octicon-trash"}}
|
{{svg "octicon-trash"}}
|
||||||
|
@ -138,18 +155,16 @@
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="ui icon header">
|
||||||
{{$.locale.Tr "repo.projects.column.set_default"}}
|
<span id="default-project-board-header"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content center">
|
<div class="content center">
|
||||||
<label>
|
<label id="default-project-board-content"></label>
|
||||||
{{$.locale.Tr "repo.projects.column.set_default_desc"}}
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text right actions">
|
<div class="text right actions">
|
||||||
<button class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -126,19 +126,30 @@ export function initRepoProject() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.set-default-project-board', async function (e) {
|
$('.default-project-board-modal').each(function () {
|
||||||
e.preventDefault();
|
const boardColumn = $(this).closest('.board-column');
|
||||||
|
const showButton = $(boardColumn).find('.default-project-board-show');
|
||||||
|
const commitButton = $(this).find('.default-project-board-button');
|
||||||
|
|
||||||
await $.ajax({
|
if ($(showButton).data('type') === 'unset_default') {
|
||||||
method: 'POST',
|
$(commitButton).removeClass('primary');
|
||||||
url: $(this).data('url'),
|
$(commitButton).addClass('red');
|
||||||
headers: {
|
}
|
||||||
'X-Csrf-Token': csrfToken,
|
|
||||||
},
|
$(commitButton).on('click', (e) => {
|
||||||
contentType: 'application/json',
|
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 () {
|
$('.delete-project-board').each(function () {
|
||||||
|
|
Loading…
Reference in New Issue