mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Initial work on import of custom fields from Trello
* start adding import functionality * Add checkbox type to customFields
This commit is contained in:
parent
93a3fa9c75
commit
c89a0eb694
4 changed files with 59 additions and 2 deletions
|
|
@ -52,6 +52,17 @@ template(name="cardCustomField-number")
|
||||||
if value
|
if value
|
||||||
= value
|
= value
|
||||||
|
|
||||||
|
template(name="cardCustomField-checkbox")
|
||||||
|
if canModifyCard
|
||||||
|
+inlinedForm(classNames="js-card-customfield-checkbox")
|
||||||
|
input(type="checkbox" value=data.value)
|
||||||
|
.edit-controls.clearfix
|
||||||
|
button.primary(type="submit") {{_ 'save'}}
|
||||||
|
a.fa.fa-times-thin.js-close-inlined-form
|
||||||
|
else
|
||||||
|
if value
|
||||||
|
= value
|
||||||
|
|
||||||
template(name="cardCustomField-currency")
|
template(name="cardCustomField-currency")
|
||||||
if canModifyCard
|
if canModifyCard
|
||||||
+inlinedForm(classNames="js-card-customfield-currency")
|
+inlinedForm(classNames="js-card-customfield-currency")
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,26 @@ CardCustomField.register('cardCustomField');
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}.register('cardCustomField-number'));
|
}.register('cardCustomField-checkbox'));
|
||||||
|
|
||||||
|
// cardCustomField-checkbox
|
||||||
|
(class extends CardCustomField {
|
||||||
|
onCreated() {
|
||||||
|
super.onCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
events() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'submit .js-card-customfield-checkbox'(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const value = this.find('input').value !== '';
|
||||||
|
this.card.setCustomField(this.customFieldId, value);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}.register('cardCustomField-checkbox'));
|
||||||
|
|
||||||
// cardCustomField-currency
|
// cardCustomField-currency
|
||||||
(class extends CardCustomField {
|
(class extends CardCustomField {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,14 @@ CustomFields.attachSchema(
|
||||||
* type of the custom field
|
* type of the custom field
|
||||||
*/
|
*/
|
||||||
type: String,
|
type: String,
|
||||||
allowedValues: ['text', 'number', 'date', 'dropdown', 'currency'],
|
allowedValues: [
|
||||||
|
'text',
|
||||||
|
'number',
|
||||||
|
'date',
|
||||||
|
'dropdown',
|
||||||
|
'checkbox',
|
||||||
|
'currency',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ export class TrelloCreator {
|
||||||
|
|
||||||
// maps a trelloCardId to an array of trelloAttachments
|
// maps a trelloCardId to an array of trelloAttachments
|
||||||
this.attachments = {};
|
this.attachments = {};
|
||||||
|
|
||||||
|
this.customFields = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,6 +163,7 @@ export class TrelloCreator {
|
||||||
// very old boards won't have a creation activity so no creation date
|
// very old boards won't have a creation activity so no creation date
|
||||||
createdAt: this._now(this.createdAt.board),
|
createdAt: this._now(this.createdAt.board),
|
||||||
labels: [],
|
labels: [],
|
||||||
|
customFields: [],
|
||||||
members: [
|
members: [
|
||||||
{
|
{
|
||||||
userId: Meteor.userId(),
|
userId: Meteor.userId(),
|
||||||
|
|
@ -216,6 +219,19 @@ export class TrelloCreator {
|
||||||
this.labels[label.id] = labelToCreate._id;
|
this.labels[label.id] = labelToCreate._id;
|
||||||
boardToCreate.labels.push(labelToCreate);
|
boardToCreate.labels.push(labelToCreate);
|
||||||
});
|
});
|
||||||
|
trelloBoard.customFields.forEach(field => {
|
||||||
|
const fieldToCreate = {
|
||||||
|
_id: Random.id(6),
|
||||||
|
trelloId: field.id,
|
||||||
|
name: field.name,
|
||||||
|
showOnCard: field.display.cardFront,
|
||||||
|
type: field.type,
|
||||||
|
};
|
||||||
|
// We need to remember them by Trello ID, as this is the only ref we have
|
||||||
|
// when importing cards.
|
||||||
|
this.customFields[field.id] = fieldToCreate._id;
|
||||||
|
boardToCreate.customFields.push(fieldToCreate);
|
||||||
|
});
|
||||||
const boardId = Boards.direct.insert(boardToCreate);
|
const boardId = Boards.direct.insert(boardToCreate);
|
||||||
Boards.direct.update(boardId, { $set: { modifiedAt: this._now() } });
|
Boards.direct.update(boardId, { $set: { modifiedAt: this._now() } });
|
||||||
// log activity
|
// log activity
|
||||||
|
|
@ -309,6 +325,10 @@ export class TrelloCreator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (card.customFieldItems) {
|
||||||
|
card.customFieldItems.forEach(item => {});
|
||||||
|
}
|
||||||
|
|
||||||
// insert card
|
// insert card
|
||||||
const cardId = Cards.direct.insert(cardToCreate);
|
const cardId = Cards.direct.insert(cardToCreate);
|
||||||
// keep track of Trello id => Wekan id
|
// keep track of Trello id => Wekan id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue