Skip to content

Commit

Permalink
Sync the class change of Edit Column Button to JS code (#23400)
Browse files Browse the repository at this point in the history
In #22767, we changed the class of `Edit Column` button from `red` to
`primary`
But `red` is used to find this button in js.....

---------

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: zeripath <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2023
1 parent c6f5029 commit e72290f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion templates/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

<div class="text right actions">
<div class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</div>
<button data-url="{{$.Link}}/{{.ID}}" class="ui primary button">{{$.locale.Tr "repo.projects.column.edit"}}</button>
<button data-url="{{$.Link}}/{{.ID}}" class="ui primary button edit-column-button">{{$.locale.Tr "repo.projects.column.edit"}}</button>
</div>
</form>
</div>
Expand Down
48 changes: 22 additions & 26 deletions web_src/js/features/repo-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,39 +95,35 @@ export function initRepoProject() {
$('.edit-project-board').each(function () {
const projectHeader = $(this).closest('.board-column-header');
const projectTitleLabel = projectHeader.find('.board-label');
const projectTitleInput = $(this).find(
'.content > .form > .field > .project-board-title',
);
const projectColorInput = $(this).find('.content > .form > .field #new_board_color');
const projectTitleInput = $(this).find('.project-board-title');
const projectColorInput = $(this).find('#new_board_color');
const boardColumn = $(this).closest('.board-column');

if (boardColumn.css('backgroundColor')) {
setLabelColor(projectHeader, rgbToHex(boardColumn.css('backgroundColor')));
}

$(this)
.find('.content > .form > .actions > .red')
.on('click', function (e) {
e.preventDefault();

$.ajax({
url: $(this).data('url'),
data: JSON.stringify({title: projectTitleInput.val(), color: projectColorInput.val()}),
headers: {
'X-Csrf-Token': csrfToken,
},
contentType: 'application/json',
method: 'PUT',
}).done(() => {
projectTitleLabel.text(projectTitleInput.val());
projectTitleInput.closest('form').removeClass('dirty');
if (projectColorInput.val()) {
setLabelColor(projectHeader, projectColorInput.val());
}
boardColumn.attr('style', `background: ${projectColorInput.val()}!important`);
$('.ui.modal').modal('hide');
});
$(this).find('.edit-column-button').on('click', function (e) {
e.preventDefault();

$.ajax({
url: $(this).data('url'),
data: JSON.stringify({title: projectTitleInput.val(), color: projectColorInput.val()}),
headers: {
'X-Csrf-Token': csrfToken,
},
contentType: 'application/json',
method: 'PUT',
}).done(() => {
projectTitleLabel.text(projectTitleInput.val());
projectTitleInput.closest('form').removeClass('dirty');
if (projectColorInput.val()) {
setLabelColor(projectHeader, projectColorInput.val());
}
boardColumn.attr('style', `background: ${projectColorInput.val()}!important`);
$('.ui.modal').modal('hide');
});
});
});

$(document).on('click', '.set-default-project-board', async function (e) {
Expand Down

0 comments on commit e72290f

Please sign in to comment.