Bläddra i källkod

add configuration field for separator

tod31 4 år sedan
förälder
incheckning
3778a9ebcf

+ 2 - 1
client/components/cards/cardCustomFields.js

@@ -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() {

+ 1 - 1
client/components/cards/minicard.js

@@ -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() {

+ 4 - 1
client/components/sidebar/sidebarCustomFields.jade

@@ -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}}")

+ 18 - 1
client/components/sidebar/sidebarCustomFields.js

@@ -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')) {

+ 2 - 1
i18n/en.i18n.json

@@ -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)"
 }

+ 4 - 0
models/customFields.js

@@ -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