mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 07:31:47 +01:00
Merge branch 'master' of https://github.com/wekan/wekan into new-search
This commit is contained in:
commit
9d2bb505ae
78 changed files with 788 additions and 3439 deletions
|
|
@ -508,6 +508,7 @@ Boards.helpers({
|
|||
copy() {
|
||||
const oldId = this._id;
|
||||
delete this._id;
|
||||
delete this.slug;
|
||||
const _id = Boards.insert(this);
|
||||
|
||||
// Copy all swimlanes in board
|
||||
|
|
@ -537,7 +538,52 @@ Boards.helpers({
|
|||
},
|
||||
});
|
||||
});
|
||||
|
||||
// copy rules, actions, and triggers
|
||||
const actionsMap = {};
|
||||
Actions.find({ boardId: oldId }).forEach(action => {
|
||||
const id = action._id;
|
||||
delete action._id;
|
||||
action.boardId = _id;
|
||||
actionsMap[id] = Actions.insert(action);
|
||||
});
|
||||
const triggersMap = {};
|
||||
Triggers.find({ boardId: oldId }).forEach(trigger => {
|
||||
const id = trigger._id;
|
||||
delete trigger._id;
|
||||
trigger.boardId = _id;
|
||||
triggersMap[id] = Triggers.insert(trigger);
|
||||
});
|
||||
Rules.find({ boardId: oldId }).forEach(rule => {
|
||||
delete rule._id;
|
||||
rule.boardId = _id;
|
||||
rule.actionId = actionsMap[rule.actionId];
|
||||
rule.triggerId = triggersMap[rule.triggerId];
|
||||
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?
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2151,7 +2151,7 @@ Cards.globalSearch = queryParams => {
|
|||
const cards = Cards.find(selector, projection);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('count:', cards.count());
|
||||
//console.log('count:', cards.count());
|
||||
|
||||
return { cards, errors };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ export class CsvCreator {
|
|||
settings,
|
||||
showOnCard: false,
|
||||
automaticallyOnCard: false,
|
||||
alwaysOnCard: false,
|
||||
showLabelOnMiniCard: false,
|
||||
boardIds: [boardId],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -76,6 +76,12 @@ CustomFields.attachSchema(
|
|||
*/
|
||||
type: Boolean,
|
||||
},
|
||||
alwaysOnCard: {
|
||||
/**
|
||||
* should the custom field be automatically added to all cards?
|
||||
*/
|
||||
type: Boolean,
|
||||
},
|
||||
showLabelOnMiniCard: {
|
||||
/**
|
||||
* should the label of the custom field be shown on minicards?
|
||||
|
|
@ -111,6 +117,19 @@ CustomFields.attachSchema(
|
|||
}),
|
||||
);
|
||||
|
||||
CustomFields.addToAllCards = cf => {
|
||||
Cards.update(
|
||||
{
|
||||
boardId: { $in: cf.boardIds },
|
||||
customFields: { $not: { $elemMatch: { _id: cf._id } } },
|
||||
},
|
||||
{
|
||||
$push: { customFields: { _id: cf._id, value: null } },
|
||||
},
|
||||
{ multi: true },
|
||||
);
|
||||
};
|
||||
|
||||
CustomFields.mutations({
|
||||
addBoard(boardId) {
|
||||
if (boardId) {
|
||||
|
|
@ -198,6 +217,10 @@ if (Meteor.isServer) {
|
|||
|
||||
CustomFields.after.insert((userId, doc) => {
|
||||
customFieldCreation(userId, doc);
|
||||
|
||||
if (doc.alwaysOnCard) {
|
||||
CustomFields.addToAllCards(doc);
|
||||
}
|
||||
});
|
||||
|
||||
CustomFields.before.update((userId, doc, fieldNames, modifier) => {
|
||||
|
|
@ -224,6 +247,11 @@ if (Meteor.isServer) {
|
|||
}
|
||||
});
|
||||
|
||||
CustomFields.after.update((userId, doc) => {
|
||||
if (doc.alwaysOnCard) {
|
||||
CustomFields.addToAllCards(doc);
|
||||
}
|
||||
});
|
||||
CustomFields.before.remove((userId, doc) => {
|
||||
customFieldDeletion(userId, doc);
|
||||
Activities.remove({
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ export class TrelloCreator {
|
|||
showOnCard: field.display.cardFront,
|
||||
showLabelOnMiniCard: field.display.cardFront,
|
||||
automaticallyOnCard: true,
|
||||
alwaysOnCard: false,
|
||||
type: field.type,
|
||||
boardIds: [boardId],
|
||||
settings: {},
|
||||
|
|
|
|||
|
|
@ -537,6 +537,7 @@ export class WekanCreator {
|
|||
showOnCard: field.showOnCard,
|
||||
showLabelOnMiniCard: field.showLabelOnMiniCard,
|
||||
automaticallyOnCard: field.automaticallyOnCard,
|
||||
alwaysOnCard: field.alwaysOnCard,
|
||||
//use date "now" if now created at date is provided (e.g. for very old boards)
|
||||
createdAt: this._now(this.createdAt.customFields[field._id]),
|
||||
modifiedAt: field.modifiedAt,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue