mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Use the copyBoard method to duplicate a board
* Use `copyBoard` instead of `cloneBoard` to duplicate a board * Give duplicated boards a unique title by appending number
This commit is contained in:
parent
ff8a36653a
commit
b249fcbb2e
3 changed files with 28 additions and 3 deletions
|
|
@ -124,9 +124,13 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
'click .js-clone-board'(evt) {
|
'click .js-clone-board'(evt) {
|
||||||
Meteor.call(
|
Meteor.call(
|
||||||
'cloneBoard',
|
'copyBoard',
|
||||||
this.currentData()._id,
|
this.currentData()._id,
|
||||||
Session.get('fromBoard'),
|
{
|
||||||
|
sort: Boards.find({ archived: false }).count(),
|
||||||
|
type: 'board',
|
||||||
|
title: Boards.findOne(this.currentData()._id).copyTitle(),
|
||||||
|
},
|
||||||
(err, res) => {
|
(err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.setError(err.error);
|
this.setError(err.error);
|
||||||
|
|
|
||||||
|
|
@ -687,7 +687,6 @@ BlazeComponent.extendComponent({
|
||||||
_id = data;
|
_id = data;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// _id = board.copy();
|
|
||||||
}
|
}
|
||||||
Popup.close();
|
Popup.close();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -562,6 +562,28 @@ Boards.helpers({
|
||||||
Rules.insert(rule);
|
Rules.insert(rule);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Return a unique title based on the current title
|
||||||
|
*
|
||||||
|
* @returns {string|null}
|
||||||
|
*/
|
||||||
|
copyTitle() {
|
||||||
|
const m = this.title.match(/^(?<title>.*?)\s*(\[(?<num>\d+)]\s*$|\s*$)/);
|
||||||
|
const title = m.groups.title;
|
||||||
|
let num = 0;
|
||||||
|
Boards.find({ title: new RegExp(`^${title}\\s*\\[\\d+]\\s*$`) }).forEach(
|
||||||
|
board => {
|
||||||
|
const m = board.title.match(/^(?<title>.*?)\s*\[(?<num>\d+)]\s*$/);
|
||||||
|
if (m) {
|
||||||
|
const n = parseInt(m.groups.num, 10);
|
||||||
|
num = num < n ? n : num;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return `${title} [${num + 1}]`;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is supplied user authorized to view this board?
|
* Is supplied user authorized to view this board?
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue