add configuration field for separator

This commit is contained in:
tod31 2021-04-09 11:28:32 +02:00
parent 880d94e220
commit 3778a9ebcf
6 changed files with 31 additions and 5 deletions

View file

@ -241,6 +241,7 @@ CardCustomField.register('cardCustomField');
super.onCreated();
this.stringtemplateFormat = this.data().definition.settings.stringtemplateFormat;
this.stringtemplateSeparator = this.data().definition.settings.stringtemplateSeparator;
}
formattedValue() {
@ -249,7 +250,7 @@ CardCustomField.register('cardCustomField');
.split('\n')
.filter(value => value.trim() !== '')
.map(value => this.stringtemplateFormat.replace(/%\{value\}/gi, value))
.join(' ');
.join(this.stringtemplateSeparator ?? '');
}
events() {

View file

@ -34,7 +34,7 @@ BlazeComponent.extendComponent({
.split('\n')
.filter(value => value.trim() !== '')
.map(value => definition.settings.stringtemplateFormat.replace(/%\{value\}/gi, value))
.join(' ');
.join(definition.settings.stringtemplateSeparator ?? '');
},
events() {

View file

@ -54,7 +54,10 @@ template(name="createCustomFieldPopup")
div.js-field-settings.js-field-settings-stringtemplate(class="{{#if isTypeNotSelected 'stringtemplate'}}hide{{/if}}")
label
| {{_ 'custom-field-stringtemplate-format'}}
input.js-field-stringtemplate(type="text" value=getStringtemplateFormat)
input.js-field-stringtemplate-format(type="text" value=getStringtemplateFormat)
label
| {{_ 'custom-field-stringtemplate-separator'}}
input.js-field-stringtemplate-separator(type="text" value=getStringtemplateSeparator)
a.flex.js-field-show-on-card(class="{{#if showOnCard}}is-checked{{/if}}")
.materialCheckBox(class="{{#if showOnCard}}is-checked{{/if}}")

View file

@ -91,6 +91,12 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
? this.data().settings.stringtemplateFormat
: '',
);
this.stringtemplateSeparator = new ReactiveVar(
this.data().settings && this.data().settings.stringtemplateSeparator
? this.data().settings.stringtemplateSeparator
: '',
);
},
types() {
@ -139,6 +145,10 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
return this.stringtemplateFormat.get();
},
getStringtemplateSeparator() {
return this.stringtemplateSeparator.get();
},
getSettings() {
const settings = {};
switch (this.type.get()) {
@ -157,6 +167,9 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
case 'stringtemplate': {
const stringtemplateFormat = this.stringtemplateFormat.get();
settings.stringtemplateFormat = stringtemplateFormat;
const stringtemplateSeparator = this.stringtemplateSeparator.get();
settings.stringtemplateSeparator = stringtemplateSeparator;
break;
}
}
@ -181,10 +194,14 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
evt.target.value = '';
}
},
'input .js-field-stringtemplate'(evt) {
'input .js-field-stringtemplate-format'(evt) {
const value = evt.target.value;
this.stringtemplateFormat.set(value);
},
'input .js-field-stringtemplate-separator'(evt) {
const value = evt.target.value;
this.stringtemplateSeparator.set(value);
},
'click .js-field-show-on-card'(evt) {
let $target = $(evt.target);
if (!$target.hasClass('js-field-show-on-card')) {

View file

@ -990,5 +990,6 @@
"move-swimlane": "Move Swimlane",
"moveSwimlanePopup-title": "Move Swimlane",
"custom-field-stringtemplate": "String Template",
"custom-field-stringtemplate-format": "Format (use %{value} as placeholder)"
"custom-field-stringtemplate-format": "Format (use %{value} as placeholder)",
"custom-field-stringtemplate-separator": "Separator (use   or   for a space)"
}

View file

@ -69,6 +69,10 @@ CustomFields.attachSchema(
type: String,
optional: true,
},
'settings.stringtemplateSeparator': {
type: String,
optional: true,
},
showOnCard: {
/**
* should we show on the cards this custom field