mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Option to add custom field to all cards
This commit is contained in:
parent
0c3b92567e
commit
74d93a6adc
8 changed files with 48 additions and 2 deletions
|
@ -239,7 +239,7 @@ BlazeComponent.extendComponent({
|
||||||
.customFields()
|
.customFields()
|
||||||
.fetch(),
|
.fetch(),
|
||||||
function(field) {
|
function(field) {
|
||||||
if (field.automaticallyOnCard)
|
if (field.automaticallyOnCard || field.alwaysOnCard)
|
||||||
arr.push({ _id: field._id, value: null });
|
arr.push({ _id: field._id, value: null });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -59,6 +59,10 @@ template(name="createCustomFieldPopup")
|
||||||
|
|
||||||
span {{_ 'automatically-field-on-card'}}
|
span {{_ 'automatically-field-on-card'}}
|
||||||
|
|
||||||
|
a.flex.js-field-always-on-card(class="{{#if alwaysOnCard}}is-checked{{/if}}")
|
||||||
|
.materialCheckBox(class="{{#if alwaysOnCard}}is-checked{{/if}}")
|
||||||
|
span {{_ 'always-field-on-card'}}
|
||||||
|
|
||||||
a.flex.js-field-showLabel-on-card(class="{{#if showLabelOnMiniCard}}is-checked{{/if}}")
|
a.flex.js-field-showLabel-on-card(class="{{#if showLabelOnMiniCard}}is-checked{{/if}}")
|
||||||
.materialCheckBox(class="{{#if showLabelOnMiniCard}}is-checked{{/if}}")
|
.materialCheckBox(class="{{#if showLabelOnMiniCard}}is-checked{{/if}}")
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,14 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
|
||||||
$target.find('.materialCheckBox').toggleClass('is-checked');
|
$target.find('.materialCheckBox').toggleClass('is-checked');
|
||||||
$target.toggleClass('is-checked');
|
$target.toggleClass('is-checked');
|
||||||
},
|
},
|
||||||
|
'click .js-field-always-on-card'(evt) {
|
||||||
|
let $target = $(evt.target);
|
||||||
|
if (!$target.hasClass('js-field-always-on-card')) {
|
||||||
|
$target = $target.parent();
|
||||||
|
}
|
||||||
|
$target.find('.materialCheckBox').toggleClass('is-checked');
|
||||||
|
$target.toggleClass('is-checked');
|
||||||
|
},
|
||||||
'click .js-field-showLabel-on-card'(evt) {
|
'click .js-field-showLabel-on-card'(evt) {
|
||||||
let $target = $(evt.target);
|
let $target = $(evt.target);
|
||||||
if (!$target.hasClass('js-field-showLabel-on-card')) {
|
if (!$target.hasClass('js-field-showLabel-on-card')) {
|
||||||
|
@ -194,6 +202,8 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
|
||||||
this.find('.js-field-showLabel-on-card.is-checked') !== null,
|
this.find('.js-field-showLabel-on-card.is-checked') !== null,
|
||||||
automaticallyOnCard:
|
automaticallyOnCard:
|
||||||
this.find('.js-field-automatically-on-card.is-checked') !== null,
|
this.find('.js-field-automatically-on-card.is-checked') !== null,
|
||||||
|
alwaysOnCard:
|
||||||
|
this.find('.js-field-always-on-card.is-checked') !== null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// insert or update
|
// insert or update
|
||||||
|
|
|
@ -601,7 +601,8 @@
|
||||||
"minutes": "minutes",
|
"minutes": "minutes",
|
||||||
"seconds": "seconds",
|
"seconds": "seconds",
|
||||||
"show-field-on-card": "Show this field on card",
|
"show-field-on-card": "Show this field on card",
|
||||||
"automatically-field-on-card": "Auto create field to all cards",
|
"automatically-field-on-card": "Add field to new cards",
|
||||||
|
"always-field-on-card": "Add field to all cards",
|
||||||
"showLabel-field-on-card": "Show field label on minicard",
|
"showLabel-field-on-card": "Show field label on minicard",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
|
|
|
@ -147,6 +147,7 @@ export class CsvCreator {
|
||||||
settings,
|
settings,
|
||||||
showOnCard: false,
|
showOnCard: false,
|
||||||
automaticallyOnCard: false,
|
automaticallyOnCard: false,
|
||||||
|
alwaysOnCard: false,
|
||||||
showLabelOnMiniCard: false,
|
showLabelOnMiniCard: false,
|
||||||
boardIds: [boardId],
|
boardIds: [boardId],
|
||||||
});
|
});
|
||||||
|
|
|
@ -76,6 +76,12 @@ CustomFields.attachSchema(
|
||||||
*/
|
*/
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
alwaysOnCard: {
|
||||||
|
/**
|
||||||
|
* should the custom field be automatically added to all cards?
|
||||||
|
*/
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
showLabelOnMiniCard: {
|
showLabelOnMiniCard: {
|
||||||
/**
|
/**
|
||||||
* should the label of the custom field be shown on minicards?
|
* 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({
|
CustomFields.mutations({
|
||||||
addBoard(boardId) {
|
addBoard(boardId) {
|
||||||
if (boardId) {
|
if (boardId) {
|
||||||
|
@ -198,6 +217,10 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
CustomFields.after.insert((userId, doc) => {
|
CustomFields.after.insert((userId, doc) => {
|
||||||
customFieldCreation(userId, doc);
|
customFieldCreation(userId, doc);
|
||||||
|
|
||||||
|
if (doc.alwaysOnCard) {
|
||||||
|
CustomFields.addToAllCards(doc);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CustomFields.before.update((userId, doc, fieldNames, modifier) => {
|
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) => {
|
CustomFields.before.remove((userId, doc) => {
|
||||||
customFieldDeletion(userId, doc);
|
customFieldDeletion(userId, doc);
|
||||||
Activities.remove({
|
Activities.remove({
|
||||||
|
|
|
@ -243,6 +243,7 @@ export class TrelloCreator {
|
||||||
showOnCard: field.display.cardFront,
|
showOnCard: field.display.cardFront,
|
||||||
showLabelOnMiniCard: field.display.cardFront,
|
showLabelOnMiniCard: field.display.cardFront,
|
||||||
automaticallyOnCard: true,
|
automaticallyOnCard: true,
|
||||||
|
alwaysOnCard: false,
|
||||||
type: field.type,
|
type: field.type,
|
||||||
boardIds: [boardId],
|
boardIds: [boardId],
|
||||||
settings: {},
|
settings: {},
|
||||||
|
|
|
@ -537,6 +537,7 @@ export class WekanCreator {
|
||||||
showOnCard: field.showOnCard,
|
showOnCard: field.showOnCard,
|
||||||
showLabelOnMiniCard: field.showLabelOnMiniCard,
|
showLabelOnMiniCard: field.showLabelOnMiniCard,
|
||||||
automaticallyOnCard: field.automaticallyOnCard,
|
automaticallyOnCard: field.automaticallyOnCard,
|
||||||
|
alwaysOnCard: field.alwaysOnCard,
|
||||||
//use date "now" if now created at date is provided (e.g. for very old boards)
|
//use date "now" if now created at date is provided (e.g. for very old boards)
|
||||||
createdAt: this._now(this.createdAt.customFields[field._id]),
|
createdAt: this._now(this.createdAt.customFields[field._id]),
|
||||||
modifiedAt: field.modifiedAt,
|
modifiedAt: field.modifiedAt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue