Disable Create column button while the column name is empty  (#25192)
		
	 Fixes #25116
This commit is contained in:
		
					parent
					
						
							
								22a39bb961
							
						
					
				
			
			
				commit
				
					
						2ad2d5a6ce
					
				
			
		
					 2 changed files with 38 additions and 18 deletions
				
			
		| 
						 | 
					@ -34,7 +34,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							<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 data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}" class="ui primary button" id="new_board_submit">{{$.locale.Tr "repo.projects.column.new_submit"}}</button>
 | 
													<button data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}" class="ui primary button disabled" id="new_board_submit">{{$.locale.Tr "repo.projects.column.new_submit"}}</button>
 | 
				
			||||||
							</div>
 | 
												</div>
 | 
				
			||||||
						</form>
 | 
											</form>
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,21 @@ function updateIssueCount(cards) {
 | 
				
			||||||
  parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt;
 | 
					  parent.getElementsByClassName('board-card-cnt')[0].textContent = cnt;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function createNewBoard(url, boardTitle, projectColorInput) {
 | 
				
			||||||
 | 
					  $.ajax({
 | 
				
			||||||
 | 
					    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}) {
 | 
					function moveIssue({item, from, to, oldIndex}) {
 | 
				
			||||||
  const columnCards = to.getElementsByClassName('board-card');
 | 
					  const columnCards = to.getElementsByClassName('board-card');
 | 
				
			||||||
  updateIssueCount(from);
 | 
					  updateIssueCount(from);
 | 
				
			||||||
| 
						 | 
					@ -17,8 +32,8 @@ function moveIssue({item, from, to, oldIndex}) {
 | 
				
			||||||
  const columnSorting = {
 | 
					  const columnSorting = {
 | 
				
			||||||
    issues: Array.from(columnCards, (card, i) => ({
 | 
					    issues: Array.from(columnCards, (card, i) => ({
 | 
				
			||||||
      issueID: parseInt($(card).attr('data-issue')),
 | 
					      issueID: parseInt($(card).attr('data-issue')),
 | 
				
			||||||
      sorting: i
 | 
					      sorting: i,
 | 
				
			||||||
    }))
 | 
					    })),
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  $.ajax({
 | 
					  $.ajax({
 | 
				
			||||||
| 
						 | 
					@ -31,7 +46,7 @@ function moveIssue({item, from, to, oldIndex}) {
 | 
				
			||||||
    type: 'POST',
 | 
					    type: 'POST',
 | 
				
			||||||
    error: () => {
 | 
					    error: () => {
 | 
				
			||||||
      from.insertBefore(item, from.children[oldIndex]);
 | 
					      from.insertBefore(item, from.children[oldIndex]);
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -168,24 +183,29 @@ export function initRepoProject() {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  $('#new_board_submit').on('click', function (e) {
 | 
					  $('#new_board_submit').on('click', (e) => {
 | 
				
			||||||
    e.preventDefault();
 | 
					    e.preventDefault();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    const boardTitle = $('#new_board');
 | 
					    const boardTitle = $('#new_board');
 | 
				
			||||||
    const projectColorInput = $('#new_board_color_picker');
 | 
					    const projectColorInput = $('#new_board_color_picker');
 | 
				
			||||||
 | 
					    if (!boardTitle.val()) {
 | 
				
			||||||
    $.ajax({
 | 
					      return;
 | 
				
			||||||
      url: $(this).data('url'),
 | 
					    }
 | 
				
			||||||
      data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}),
 | 
					    const url = $(this).data('url');
 | 
				
			||||||
      headers: {
 | 
					    createNewBoard(url, boardTitle, projectColorInput);
 | 
				
			||||||
        'X-Csrf-Token': csrfToken,
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      contentType: 'application/json',
 | 
					 | 
				
			||||||
      method: 'POST',
 | 
					 | 
				
			||||||
    }).done(() => {
 | 
					 | 
				
			||||||
      boardTitle.closest('form').removeClass('dirty');
 | 
					 | 
				
			||||||
      window.location.reload();
 | 
					 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $('.new-board').on('input keyup', (e) => {
 | 
				
			||||||
 | 
					    const boardTitle = $('#new_board');
 | 
				
			||||||
 | 
					    const projectColorInput = $('#new_board_color_picker');
 | 
				
			||||||
 | 
					    if (!boardTitle.val()) {
 | 
				
			||||||
 | 
					      $('#new_board_submit').addClass('disabled');
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    $('#new_board_submit').removeClass('disabled');
 | 
				
			||||||
 | 
					    if (e.key === 'Enter') {
 | 
				
			||||||
 | 
					      const url = $(this).data('url');
 | 
				
			||||||
 | 
					      createNewBoard(url, boardTitle, projectColorInput);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue