mirror of
https://github.com/wekan/wekan.git
synced 2026-01-04 00:28:49 +01:00
add custom field "stringtemplate"
This commit is contained in:
parent
769bb7a55d
commit
b8dc7ff18e
8 changed files with 104 additions and 2 deletions
|
|
@ -119,3 +119,23 @@ template(name="cardCustomField-dropdown")
|
|||
if value
|
||||
+viewer
|
||||
= selectedItem
|
||||
|
||||
template(name="cardCustomField-stringtemplate")
|
||||
if canModifyCard
|
||||
+inlinedForm(classNames="js-card-customfield-stringtemplate")
|
||||
+editor(autofocus=true)
|
||||
= 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
|
||||
if value
|
||||
+viewer
|
||||
= formattedValue
|
||||
else
|
||||
| {{_ 'edit'}}
|
||||
else
|
||||
if value
|
||||
+viewer
|
||||
= formattedValue
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ template(name="minicard")
|
|||
+minicardCustomFieldDate
|
||||
else if $eq definition.type "checkbox"
|
||||
.materialCheckBox(class="{{#if value }}is-checked{{/if}}")
|
||||
else if $eq definition.type "stringtemplate"
|
||||
+viewer
|
||||
= formattedStringtemplateCustomFieldValue(definition)
|
||||
else
|
||||
+viewer
|
||||
= trueValue
|
||||
|
|
|
|||
|
|
@ -21,6 +21,23 @@ BlazeComponent.extendComponent({
|
|||
}).format(customFieldTrueValue);
|
||||
},
|
||||
|
||||
formattedStringtemplateCustomFieldValue(definition) {
|
||||
const customField = this.data()
|
||||
.customFieldsWD()
|
||||
.find(f => f._id === definition._id);
|
||||
|
||||
if(customField && customField.trueValue) {
|
||||
lines = customField.trueValue.replace(/\r\n|\n\r|\n|\r/g, '\n').split('\n');
|
||||
lines = lines.map(line =>
|
||||
definition.settings.stringtemplateFormat.replace(/%\{value\}/gi, line)
|
||||
);
|
||||
|
||||
return lines.join(' ');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue