mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Trello custom field import basically working
This commit is contained in:
parent
c89a0eb694
commit
b793716e85
5 changed files with 59 additions and 23 deletions
|
@ -55,13 +55,21 @@ template(name="cardCustomField-number")
|
|||
template(name="cardCustomField-checkbox")
|
||||
if canModifyCard
|
||||
+inlinedForm(classNames="js-card-customfield-checkbox")
|
||||
input(type="checkbox" value=data.value)
|
||||
input.materialCheckBox(type="checkbox" checked=data.value)
|
||||
.edit-controls.clearfix
|
||||
button.primary(type="submit") {{_ 'save'}}
|
||||
a.fa.fa-times-thin.js-close-inlined-form
|
||||
else
|
||||
a.js-open-inlined-form.checkbox-display
|
||||
if value
|
||||
i.fa.fa-check-square
|
||||
else
|
||||
i.fa.fa-square
|
||||
else
|
||||
if value
|
||||
= value
|
||||
i.fa.fa-check-square
|
||||
else
|
||||
i.fa.fa-square
|
||||
|
||||
template(name="cardCustomField-currency")
|
||||
if canModifyCard
|
||||
|
|
|
@ -78,7 +78,7 @@ CardCustomField.register('cardCustomField');
|
|||
},
|
||||
];
|
||||
}
|
||||
}.register('cardCustomField-checkbox'));
|
||||
}.register('cardCustomField-number'));
|
||||
|
||||
// cardCustomField-checkbox
|
||||
(class extends CardCustomField {
|
||||
|
@ -86,12 +86,16 @@ CardCustomField.register('cardCustomField');
|
|||
super.onCreated();
|
||||
}
|
||||
|
||||
isNull() {
|
||||
return !this.data().value;
|
||||
}
|
||||
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
'submit .js-card-customfield-checkbox'(event) {
|
||||
event.preventDefault();
|
||||
const value = this.find('input').value !== '';
|
||||
const value = this.find('input').checked;
|
||||
this.card.setCustomField(this.customFieldId, value);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -77,6 +77,8 @@ template(name="minicard")
|
|||
if $eq definition.type "currency"
|
||||
+viewer
|
||||
= formattedCurrencyCustomFieldValue(definition)
|
||||
else if $eq definition.type "checkbox"
|
||||
i.fa.fa-check-square
|
||||
else
|
||||
+viewer
|
||||
= trueValue
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -219,19 +219,6 @@ export class TrelloCreator {
|
|||
this.labels[label.id] = labelToCreate._id;
|
||||
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);
|
||||
Boards.direct.update(boardId, { $set: { modifiedAt: this._now() } });
|
||||
// log activity
|
||||
|
@ -248,6 +235,24 @@ 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: {},
|
||||
};
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -326,7 +331,24 @@ export class TrelloCreator {
|
|||
}
|
||||
|
||||
if (card.customFieldItems) {
|
||||
card.customFieldItems.forEach(item => {});
|
||||
cardToCreate.customFields = [];
|
||||
card.customFieldItems.forEach(item => {
|
||||
const custom = {
|
||||
_id: this.customFields[item.idCustomField],
|
||||
};
|
||||
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;
|
||||
} else if (item.value.hasOwnProperty('dropdown')) {
|
||||
custom.value = item.value.dropdown;
|
||||
}
|
||||
cardToCreate.customFields.push(custom);
|
||||
});
|
||||
}
|
||||
|
||||
// insert card
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue