Move swimlane creation button to board header when using swimlane view mode

This commit is contained in:
Nadav Tasher 2024-12-29 22:54:32 +02:00
parent 989c73f1f1
commit d51e8d1d1d
6 changed files with 60 additions and 74 deletions

View file

@ -2,6 +2,8 @@ import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
import dragscroll from '@wekanteam/dragscroll';
const { calculateIndexData } = Utils;
/*
const DOWNCLS = 'fa-sort-down';
const UPCLS = 'fa-sort-up';
@ -68,6 +70,7 @@ BlazeComponent.extendComponent({
events() {
return [
{
'click .js-open-add-swimlane-menu': Popup.open('swimlaneAdd'),
'click .js-edit-board-title': Popup.open('boardChangeTitle'),
'click .js-star-board'() {
ReactiveCache.getCurrentUser().toggleBoardStar(Session.get('currentBoard'));
@ -128,6 +131,41 @@ BlazeComponent.extendComponent({
},
}).register('boardHeaderBar');
BlazeComponent.extendComponent({
events() {
return [
{
submit(event) {
event.preventDefault();
const currentBoard = Utils.getCurrentBoard();
const titleInput = this.find('.swimlane-name-input');
const title = titleInput.value.trim();
const swimlaneType = currentBoard.isTemplatesBoard()
? 'template-swimlane'
: 'swimlane';
if (title) {
Swimlanes.insert({
title,
boardId: Session.get('currentBoard'),
sort: 0,
type: swimlaneType,
});
titleInput.value = '';
titleInput.focus();
}
// XXX ideally, we should move the popup to the newly
// created swimlane so a user can add more than one swimlane
// with a minimum of interactions
Popup.back();
},
'click .js-swimlane-template': Popup.open('searchElement'),
},
];
},
}).register('swimlaneAddPopup');
Template.boardHeaderBar.helpers({
boardView() {
return Utils.boardView();