2
0
Эх сурвалжийг харах

Fix Swimlane Default title from "key default returned an object instead of string" to translated title of "Default".

Thanks to titho85, hpvb and xet7 !

Fixes #4763,
fixes #4742
Lauri Ojansivu 1 жил өмнө
parent
commit
73a25775e1

+ 3 - 3
client/components/lists/listBody.jade

@@ -79,18 +79,18 @@ template(name="linkCardPopup")
     select.js-select-boards
       option(value="")
       each boards
-        option(value="{{_id}}") {{title}}
+        option(value="{{_id}}") {{isTitleDefault title}}
     input.primary.confirm.js-link-board(type="button" value="{{_ 'link'}}")
 
   label {{_ 'swimlanes'}}:
   select.js-select-swimlanes
     each swimlanes
-      option(value="{{_id}}") {{title}}
+      option(value="{{_id}}") {{isTitleDefault title}}
 
   label {{_ 'lists'}}:
   select.js-select-lists
     each lists
-      option(value="{{_id}}") {{title}}
+      option(value="{{_id}}") {{isTitleDefault title}}
 
   label {{_ 'cards'}}:
   select.js-select-cards

+ 25 - 0
client/components/lists/listBody.js

@@ -593,6 +593,31 @@ BlazeComponent.extendComponent({
   },
 }).register('linkCardPopup');
 
+Template.linkCardPopup.helpers({
+  isTitleDefault(title) {
+    // https://github.com/wekan/wekan/issues/4763
+    // https://github.com/wekan/wekan/issues/4742
+    // Translation text for "default" does not work, it returns an object.
+    // When that happens, try use translation "defaultdefault" that has same content of default, or return text "Default".
+    // This can happen, if swimlane does not have name.
+    // Yes, this is fixing the symptom (Swimlane title does not have title)
+    // instead of fixing the problem (Add Swimlane title when creating swimlane)
+    // because there could be thousands of swimlanes, adding name Default to all of them
+    // would be very slow.
+    if (title.startsWith("key 'default") && title.endsWith('returned an object instead of string.')) {
+      if (`${TAPi18n.__('defaultdefault')}`.startsWith("key 'default") && `${TAPi18n.__('defaultdefault')}`.endsWith('returned an object instead of string.')) {
+        return 'Default';
+      } else  {
+        return `${TAPi18n.__('defaultdefault')}`;
+      }
+    } else if (title === 'Default') {
+      return `${TAPi18n.__('defaultdefault')}`;
+    } else  {
+      return title;
+    }
+  },
+});
+
 BlazeComponent.extendComponent({
   mixins() {
     return [];

+ 4 - 2
client/components/swimlanes/swimlaneHeader.jade

@@ -17,9 +17,11 @@ template(name="swimlaneFixedHeader")
         | {{_ 'list-templates-swimlane'}}
       else if $eq title 'Board Templates'
         | {{_ 'board-templates-swimlane'}}
+      else if $eq title 'Default'
+        | {{_ 'defaultdefault'}}
       else
         +viewer
-          = title
+          | {{isTitleDefault title}}
   .swimlane-header-menu
     unless currentUser.isCommentOnly
       if currentUser.isBoardAdmin
@@ -33,7 +35,7 @@ template(name="swimlaneFixedHeader")
 
 template(name="editSwimlaneTitleForm")
   .list-composer
-    input.list-name-input.full-line(type="text" value=title autofocus)
+    input.list-name-input.full-line(type="text" value="{{isTitleDefault title}}" autofocus)
     .edit-controls.clearfix
       button.primary.confirm(type="submit") {{_ 'save'}}
       a.fa.fa-times-thin.js-close-inlined-form

+ 48 - 0
client/components/swimlanes/swimlaneHeader.js

@@ -1,3 +1,4 @@
+import { TAPi18n } from '/imports/i18n';
 import { ReactiveCache } from '/imports/reactiveCache';
 const { calculateIndexData } = Utils;
 
@@ -33,6 +34,53 @@ Template.swimlaneFixedHeader.helpers({
   isBoardAdmin() {
     return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
+  isTitleDefault(title) {
+    // https://github.com/wekan/wekan/issues/4763
+    // https://github.com/wekan/wekan/issues/4742
+    // Translation text for "default" does not work, it returns an object.
+    // When that happens, try use translation "defaultdefault" that has same content of default, or return text "Default".
+    // This can happen, if swimlane does not have name.
+    // Yes, this is fixing the symptom (Swimlane title does not have title)
+    // instead of fixing the problem (Add Swimlane title when creating swimlane)
+    // because there could be thousands of swimlanes, adding name Default to all of them
+    // would be very slow.
+    if (title.startsWith("key 'default") && title.endsWith('returned an object instead of string.')) {
+      if (`${TAPi18n.__('defaultdefault')}`.startsWith("key 'default") && `${TAPi18n.__('defaultdefault')}`.endsWith('returned an object instead of string.')) {
+        return 'Default';
+      } else  {
+        return `${TAPi18n.__('defaultdefault')}`;
+      }
+    } else if (title === 'Default') {
+      return `${TAPi18n.__('defaultdefault')}`;
+    } else  {
+      return title;
+    }
+  },
+});
+
+Template.editSwimlaneTitleForm.helpers({
+  isTitleDefault(title) {
+    // https://github.com/wekan/wekan/issues/4763
+    // https://github.com/wekan/wekan/issues/4742
+    // Translation text for "default" does not work, it returns an object.
+    // When that happens, try use translation "defaultdefault" that has same content of default, or return text "Default".
+    // This can happen, if swimlane does not have name.
+    // Yes, this is fixing the symptom (Swimlane title does not have title)
+    // instead of fixing the problem (Add Swimlane title when creating swimlane) 
+    // because there could be thousands of swimlanes, adding name Default to all of them
+    // would be very slow.
+    if (title.startsWith("key 'default") && title.endsWith('returned an object instead of string.')) {
+      if (`${TAPi18n.__('defaultdefault')}`.startsWith("key 'default") && `${TAPi18n.__('defaultdefault')}`.endsWith('returned an object instead of string.')) {
+        return 'Default';
+      } else  {
+        return `${TAPi18n.__('defaultdefault')}`;
+      }
+    } else if (title === 'Default') {
+      return `${TAPi18n.__('defaultdefault')}`;
+    } else  {
+      return title;
+    }
+  },
 });
 
 Template.swimlaneActionPopup.events({