mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
add custom field "stringtemplate"
This commit is contained in:
parent
769bb7a55d
commit
b8dc7ff18e
8 changed files with 104 additions and 2 deletions
|
|
@ -234,3 +234,33 @@ CardCustomField.register('cardCustomField');
|
|||
];
|
||||
}
|
||||
}.register('cardCustomField-dropdown'));
|
||||
|
||||
// cardCustomField-stringtemplate
|
||||
(class extends CardCustomField {
|
||||
onCreated() {
|
||||
super.onCreated();
|
||||
|
||||
this.stringtemplateFormat = this.data().definition.settings.stringtemplateFormat;
|
||||
}
|
||||
|
||||
formattedValue() {
|
||||
lines = this.data().value.replace(/\r\n|\n\r|\n|\r/g, '\n').split('\n');
|
||||
lines = lines.map(line =>
|
||||
this.stringtemplateFormat.replace(/%\{value\}/gi, line)
|
||||
);
|
||||
|
||||
return lines.join(' ');
|
||||
}
|
||||
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
'submit .js-card-customfield-stringtemplate'(event) {
|
||||
event.preventDefault();
|
||||
const value = this.currentComponent().getValue();
|
||||
this.card.setCustomField(this.customFieldId, value);
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
}.register('cardCustomField-stringtemplate'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue