From bf1cc3ebd6633c9747aec5da9fe31dd6be300daa Mon Sep 17 00:00:00 2001 From: puni9869 Date: Sat, 10 Jun 2023 18:45:56 +0530 Subject: [PATCH 1/6] #25116 After the name of the new kanban in the projects, press Enter will not create the kanban --- templates/repo/projects/view.tmpl | 4 +-- web_src/js/features/repo-projects.js | 43 +++++++++++++++++++--------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index f249854b159cb..61bc7e1e35233 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -33,8 +33,8 @@
- - + +
diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index b8cb651f69df8..dff978f5493f6 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -9,6 +9,20 @@ function updateIssueCount(cards) { parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt; } +function createNewBoard(boardTitle, projectColorInput) { + $.ajax({ + url: $(this).data('url'), + data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), + headers: { + 'X-Csrf-Token': csrfToken, + }, + contentType: 'application/json', + method: 'POST', + }).done(() => { + boardTitle.closest('form').removeClass('dirty'); + window.location.reload(); + }); +} function moveIssue({item, from, to, oldIndex}) { const columnCards = to.getElementsByClassName('board-card'); updateIssueCount(from); @@ -170,22 +184,25 @@ export function initRepoProject() { $('#new_board_submit').on('click', function (e) { e.preventDefault(); - const boardTitle = $('#new_board'); const projectColorInput = $('#new_board_color_picker'); + if (boardTitle.val().length < 1) { + return false; + } + createNewBoard(boardTitle, projectColorInput); + }); - $.ajax({ - url: $(this).data('url'), - data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), - headers: { - 'X-Csrf-Token': csrfToken, - }, - contentType: 'application/json', - method: 'POST', - }).done(() => { - boardTitle.closest('form').removeClass('dirty'); - window.location.reload(); - }); + $('.new-board').on('keyup', function(e) { + const boardTitle = $('#new_board'); + const projectColorInput = $('#new_board_color_picker'); + if (boardTitle.val().length < 1) { + $('#new_board_submit').addClass('disabled'); + return false; + } + $(`#new_board_submit`).removeClass('disabled'); + if (e.key === 'Enter' || e.keyCode === 13) { + createNewBoard(boardTitle, projectColorInput); + } }); } From 50d618943331ec2658af783a5997d986b1b89196 Mon Sep 17 00:00:00 2001 From: puni9869 Date: Sat, 10 Jun 2023 19:01:08 +0530 Subject: [PATCH 2/6] Reverting --- templates/repo/projects/view.tmpl | 4 +-- web_src/js/features/repo-projects.js | 43 +++++++++------------------- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index 61bc7e1e35233..f249854b159cb 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -33,8 +33,8 @@
- - + +
diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index dff978f5493f6..b8cb651f69df8 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -9,20 +9,6 @@ function updateIssueCount(cards) { parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt; } -function createNewBoard(boardTitle, projectColorInput) { - $.ajax({ - url: $(this).data('url'), - data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), - headers: { - 'X-Csrf-Token': csrfToken, - }, - contentType: 'application/json', - method: 'POST', - }).done(() => { - boardTitle.closest('form').removeClass('dirty'); - window.location.reload(); - }); -} function moveIssue({item, from, to, oldIndex}) { const columnCards = to.getElementsByClassName('board-card'); updateIssueCount(from); @@ -184,25 +170,22 @@ export function initRepoProject() { $('#new_board_submit').on('click', function (e) { e.preventDefault(); - const boardTitle = $('#new_board'); - const projectColorInput = $('#new_board_color_picker'); - if (boardTitle.val().length < 1) { - return false; - } - createNewBoard(boardTitle, projectColorInput); - }); - $('.new-board').on('keyup', function(e) { const boardTitle = $('#new_board'); const projectColorInput = $('#new_board_color_picker'); - if (boardTitle.val().length < 1) { - $('#new_board_submit').addClass('disabled'); - return false; - } - $(`#new_board_submit`).removeClass('disabled'); - if (e.key === 'Enter' || e.keyCode === 13) { - createNewBoard(boardTitle, projectColorInput); - } + + $.ajax({ + url: $(this).data('url'), + data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), + headers: { + 'X-Csrf-Token': csrfToken, + }, + contentType: 'application/json', + method: 'POST', + }).done(() => { + boardTitle.closest('form').removeClass('dirty'); + window.location.reload(); + }); }); } From 38e4e092936ee3db324e078ddfd90cb3d47f4826 Mon Sep 17 00:00:00 2001 From: puni9869 Date: Sat, 10 Jun 2023 19:10:16 +0530 Subject: [PATCH 3/6] #25116 After the name of the new kanban in the projects, press Enter will not create the kanban --- templates/repo/projects/view.tmpl | 4 +-- web_src/js/features/repo-projects.js | 45 +++++++++++++++++++--------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index f249854b159cb..61bc7e1e35233 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -33,8 +33,8 @@
- - + +
diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index b8cb651f69df8..ae0ac33754341 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -9,6 +9,20 @@ function updateIssueCount(cards) { parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt; } +function createNewBoard(boardTitle, projectColorInput) { + $.ajax({ + url: $(this).data('url'), + data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), + headers: { + 'X-Csrf-Token': csrfToken, + }, + contentType: 'application/json', + method: 'POST', + }).done(() => { + boardTitle.closest('form').removeClass('dirty'); + window.location.reload(); + }); +} function moveIssue({item, from, to, oldIndex}) { const columnCards = to.getElementsByClassName('board-card'); updateIssueCount(from); @@ -168,24 +182,27 @@ export function initRepoProject() { }); }); - $('#new_board_submit').on('click', function (e) { + $('#new_board_submit').on('click', (e) => { e.preventDefault(); - const boardTitle = $('#new_board'); const projectColorInput = $('#new_board_color_picker'); + if (boardTitle.val().length < 1) { + return false; + } + createNewBoard(boardTitle, projectColorInput); + }); - $.ajax({ - url: $(this).data('url'), - data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), - headers: { - 'X-Csrf-Token': csrfToken, - }, - contentType: 'application/json', - method: 'POST', - }).done(() => { - boardTitle.closest('form').removeClass('dirty'); - window.location.reload(); - }); + $('.new-board').on('keyup', (e) => { + const boardTitle = $('#new_board'); + const projectColorInput = $('#new_board_color_picker'); + if (boardTitle.val().length < 1) { + $('#new_board_submit').addClass('disabled'); + return false; + } + $(`#new_board_submit`).removeClass('disabled'); + if (e.key === 'Enter' || e.keyCode === 13) { + createNewBoard(boardTitle, projectColorInput); + } }); } From 8cd07d1d7040b1e9a689f16e083158602cd4f853 Mon Sep 17 00:00:00 2001 From: puni9869 Date: Tue, 13 Jun 2023 02:37:33 +0530 Subject: [PATCH 4/6] Reverting view.tmpl changes and fixed suggestions. --- templates/repo/projects/view.tmpl | 4 ++-- web_src/js/features/repo-projects.js | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index 61bc7e1e35233..068c42838a571 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -33,8 +33,8 @@
- - + +
diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index ae0ac33754341..9dde055bf1985 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -9,9 +9,9 @@ function updateIssueCount(cards) { parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt; } -function createNewBoard(boardTitle, projectColorInput) { +function createNewBoard(url, boardTitle, projectColorInput) { $.ajax({ - url: $(this).data('url'), + url, data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), headers: { 'X-Csrf-Token': csrfToken, @@ -23,6 +23,7 @@ function createNewBoard(boardTitle, projectColorInput) { window.location.reload(); }); } + function moveIssue({item, from, to, oldIndex}) { const columnCards = to.getElementsByClassName('board-card'); updateIssueCount(from); @@ -31,8 +32,8 @@ function moveIssue({item, from, to, oldIndex}) { const columnSorting = { issues: Array.from(columnCards, (card, i) => ({ issueID: parseInt($(card).attr('data-issue')), - sorting: i - })) + sorting: i, + })), }; $.ajax({ @@ -45,7 +46,7 @@ function moveIssue({item, from, to, oldIndex}) { type: 'POST', error: () => { from.insertBefore(item, from.children[oldIndex]); - } + }, }); } @@ -186,22 +187,24 @@ export function initRepoProject() { e.preventDefault(); const boardTitle = $('#new_board'); const projectColorInput = $('#new_board_color_picker'); - if (boardTitle.val().length < 1) { - return false; + if (!boardTitle.val()) { + return; } - createNewBoard(boardTitle, projectColorInput); + const url = $(this).data('url'); + createNewBoard(url, boardTitle, projectColorInput); }); $('.new-board').on('keyup', (e) => { const boardTitle = $('#new_board'); const projectColorInput = $('#new_board_color_picker'); - if (boardTitle.val().length < 1) { + if (!boardTitle.val()) { $('#new_board_submit').addClass('disabled'); return false; } - $(`#new_board_submit`).removeClass('disabled'); - if (e.key === 'Enter' || e.keyCode === 13) { - createNewBoard(boardTitle, projectColorInput); + $('#new_board_submit').removeClass('disabled'); + if (e.key === 'Enter') { + const url = $(this).data('url'); + createNewBoard(url, boardTitle, projectColorInput); } }); } From 75d457f1dea3209d6f99dbaa60bba7bda831c824 Mon Sep 17 00:00:00 2001 From: puni9869 Date: Tue, 13 Jun 2023 02:44:26 +0530 Subject: [PATCH 5/6] Removing the false in return. --- web_src/js/features/repo-projects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index 9dde055bf1985..3e67535423350 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -199,7 +199,7 @@ export function initRepoProject() { const projectColorInput = $('#new_board_color_picker'); if (!boardTitle.val()) { $('#new_board_submit').addClass('disabled'); - return false; + return; } $('#new_board_submit').removeClass('disabled'); if (e.key === 'Enter') { From 8649ce7fac241f78fd791dcd2e65a3a34ba49854 Mon Sep 17 00:00:00 2001 From: puni9869 Date: Tue, 13 Jun 2023 10:49:14 +0530 Subject: [PATCH 6/6] Adding input event as well --- web_src/js/features/repo-projects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index 3e67535423350..82814ec8b6b0a 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -194,7 +194,7 @@ export function initRepoProject() { createNewBoard(url, boardTitle, projectColorInput); }); - $('.new-board').on('keyup', (e) => { + $('.new-board').on('input keyup', (e) => { const boardTitle = $('#new_board'); const projectColorInput = $('#new_board_color_picker'); if (!boardTitle.val()) {