loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Disable `Create column` button while the column name is empty (#25192)

![Jun-10-2023
18-43-04](https://github.com/go-gitea/gitea/assets/80308335/4796c9be-d161-43a0-a3e3-d9cd6a19cda4)

Fixes #25116

authored by

Punit Inani and committed by
GitHub
2ad2d5a6 22a39bb9

+38 -18
+1 -1
templates/repo/projects/view.tmpl
··· 34 34 35 35 <div class="text right actions"> 36 36 <button class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</button> 37 - <button data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}" class="ui primary button" id="new_board_submit">{{$.locale.Tr "repo.projects.column.new_submit"}}</button> 37 + <button data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}" class="ui primary button disabled" id="new_board_submit">{{$.locale.Tr "repo.projects.column.new_submit"}}</button> 38 38 </div> 39 39 </form> 40 40 </div>
+37 -17
web_src/js/features/repo-projects.js
··· 9 9 parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt; 10 10 } 11 11 12 + function createNewBoard(url, boardTitle, projectColorInput) { 13 + $.ajax({ 14 + url, 15 + data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), 16 + headers: { 17 + 'X-Csrf-Token': csrfToken, 18 + }, 19 + contentType: 'application/json', 20 + method: 'POST', 21 + }).done(() => { 22 + boardTitle.closest('form').removeClass('dirty'); 23 + window.location.reload(); 24 + }); 25 + } 26 + 12 27 function moveIssue({item, from, to, oldIndex}) { 13 28 const columnCards = to.getElementsByClassName('board-card'); 14 29 updateIssueCount(from); ··· 17 32 const columnSorting = { 18 33 issues: Array.from(columnCards, (card, i) => ({ 19 34 issueID: parseInt($(card).attr('data-issue')), 20 - sorting: i 21 - })) 35 + sorting: i, 36 + })), 22 37 }; 23 38 24 39 $.ajax({ ··· 31 46 type: 'POST', 32 47 error: () => { 33 48 from.insertBefore(item, from.children[oldIndex]); 34 - } 49 + }, 35 50 }); 36 51 } 37 52 ··· 168 183 }); 169 184 }); 170 185 171 - $('#new_board_submit').on('click', function (e) { 186 + $('#new_board_submit').on('click', (e) => { 172 187 e.preventDefault(); 188 + const boardTitle = $('#new_board'); 189 + const projectColorInput = $('#new_board_color_picker'); 190 + if (!boardTitle.val()) { 191 + return; 192 + } 193 + const url = $(this).data('url'); 194 + createNewBoard(url, boardTitle, projectColorInput); 195 + }); 173 196 197 + $('.new-board').on('input keyup', (e) => { 174 198 const boardTitle = $('#new_board'); 175 199 const projectColorInput = $('#new_board_color_picker'); 176 - 177 - $.ajax({ 178 - url: $(this).data('url'), 179 - data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}), 180 - headers: { 181 - 'X-Csrf-Token': csrfToken, 182 - }, 183 - contentType: 'application/json', 184 - method: 'POST', 185 - }).done(() => { 186 - boardTitle.closest('form').removeClass('dirty'); 187 - window.location.reload(); 188 - }); 200 + if (!boardTitle.val()) { 201 + $('#new_board_submit').addClass('disabled'); 202 + return; 203 + } 204 + $('#new_board_submit').removeClass('disabled'); 205 + if (e.key === 'Enter') { 206 + const url = $(this).data('url'); 207 + createNewBoard(url, boardTitle, projectColorInput); 208 + } 189 209 }); 190 210 } 191 211