Merge branch 'jrsupplee-trello-import'

This commit is contained in:
Lauri Ojansivu 2021-01-19 16:59:58 +02:00
commit 3a96f71b91
8 changed files with 2479 additions and 7 deletions

View file

@ -52,6 +52,14 @@ template(name="cardCustomField-number")
if value
= value
template(name="cardCustomField-checkbox")
.js-checklist-item.checklist-item(class="{{#if data.value }}is-checked{{/if}}")
if canModifyCard
.check-box-container
.check-box.materialCheckBox(class="{{#if data.value }}is-checked{{/if}}")
else
.materialCheckBox(class="{{#if data.value }}is-checked{{/if}}")
template(name="cardCustomField-currency")
if canModifyCard
+inlinedForm(classNames="js-card-customfield-currency")

View file

@ -80,6 +80,25 @@ CardCustomField.register('cardCustomField');
}
}.register('cardCustomField-number'));
// cardCustomField-checkbox
(class extends CardCustomField {
onCreated() {
super.onCreated();
}
toggleItem() {
this.card.setCustomField(this.customFieldId, !this.data().value);
}
events() {
return [
{
'click .js-checklist-item .check-box-container': this.toggleItem,
},
];
}
}.register('cardCustomField-checkbox'));
// cardCustomField-currency
(class extends CardCustomField {
onCreated() {

View file

@ -7,4 +7,3 @@ template(name="dateBadge")
a.card-date(title="{{showTitle}}" class="{{classes}}")
time(datetime="{{showISODate}}")
| {{showDate}}

View file

@ -77,6 +77,8 @@ template(name="minicard")
if $eq definition.type "currency"
+viewer
= formattedCurrencyCustomFieldValue(definition)
else if $eq definition.type "checkbox"
.materialCheckBox(class="{{#if value }}is-checked{{/if}}")
else
+viewer
= trueValue

View file

@ -242,11 +242,11 @@ textarea
margin: 3px 4px
// Material Design checkboxes
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked
position: absolute
left: -9999px
visibility: hidden
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked
position: absolute
left: -9999px
visibility: hidden
.materialCheckBox
position: relative

View file

@ -22,7 +22,14 @@ CustomFields.attachSchema(
* type of the custom field
*/
type: String,
allowedValues: ['text', 'number', 'date', 'dropdown', 'currency'],
allowedValues: [
'text',
'number',
'date',
'dropdown',
'checkbox',
'currency',
],
},
settings: {
/**

View file

@ -40,6 +40,8 @@ export class TrelloCreator {
// maps a trelloCardId to an array of trelloAttachments
this.attachments = {};
this.customFields = {};
}
/**
@ -161,6 +163,7 @@ export class TrelloCreator {
// very old boards won't have a creation activity so no creation date
createdAt: this._now(this.createdAt.board),
labels: [],
customFields: [],
members: [
{
userId: Meteor.userId(),
@ -232,6 +235,36 @@ export class TrelloCreator {
// not the author from the original object.
userId: this._user(),
});
if (trelloBoard.customFields) {
trelloBoard.customFields.forEach(field => {
const fieldToCreate = {
// trelloId: field.id,
name: field.name,
showOnCard: field.display.cardFront,
showLabelOnMiniCard: field.display.cardFront,
automaticallyOnCard: true,
type: field.type,
boardIds: [boardId],
settings: {},
};
if (field.type === 'list') {
fieldToCreate.type = 'dropdown';
fieldToCreate.settings = {
dropdownItems: field.options.map(opt => {
return {
_id: opt.id,
name: opt.value.text,
};
}),
};
}
// We need to remember them by Trello ID, as this is the only ref we have
// when importing cards.
this.customFields[field.id] = CustomFields.direct.insert(fieldToCreate);
});
}
return boardId;
}
@ -309,6 +342,27 @@ export class TrelloCreator {
}
}
if (card.customFieldItems) {
cardToCreate.customFields = [];
card.customFieldItems.forEach(item => {
const custom = {
_id: this.customFields[item.idCustomField],
};
if (item.idValue) {
custom.value = item.idValue;
} else if (item.value.hasOwnProperty('checked')) {
custom.value = item.value.checked === 'true';
} else if (item.value.hasOwnProperty('text')) {
custom.value = item.value.text;
} else if (item.value.hasOwnProperty('date')) {
custom.value = item.value.date;
} else if (item.value.hasOwnProperty('number')) {
custom.value = item.value.number;
}
cardToCreate.customFields.push(custom);
});
}
// insert card
const cardId = Cards.direct.insert(cardToCreate);
// keep track of Trello id => Wekan id

File diff suppressed because it is too large Load diff