Pārlūkot izejas kodu

Merge pull request #5491 from mfilser/master

fix empty parentId in cards
Lauri Ojansivu 10 mēneši atpakaļ
vecāks
revīzija
498be2759e
1 mainītis faili ar 12 papildinājumiem un 7 dzēšanām
  1. 12 7
      models/cards.js

+ 12 - 7
models/cards.js

@@ -982,15 +982,16 @@ Cards.helpers({
   },
   },
 
 
   parentCard() {
   parentCard() {
-    if (this.parentId === '') {
-      return null;
+    let ret = null;
+    if (this.parentId) {
+      ret = ReactiveCache.getCard(this.parentId);
     }
     }
-    return ReactiveCache.getCard(this.parentId);
+    return ret;
   },
   },
 
 
   parentCardName() {
   parentCardName() {
     let result = '';
     let result = '';
-    if (this.parentId !== '') {
+    if (this.parentId) {
       const card = ReactiveCache.getCard(this.parentId);
       const card = ReactiveCache.getCard(this.parentId);
       if (card) {
       if (card) {
         result = card.title;
         result = card.title;
@@ -1002,7 +1003,7 @@ Cards.helpers({
   parentListId() {
   parentListId() {
     const result = [];
     const result = [];
     let crtParentId = this.parentId;
     let crtParentId = this.parentId;
-    while (crtParentId !== '') {
+    while (crtParentId) {
       const crt = ReactiveCache.getCard(crtParentId);
       const crt = ReactiveCache.getCard(crtParentId);
       if (crt === null || crt === undefined) {
       if (crt === null || crt === undefined) {
         // maybe it has been deleted
         // maybe it has been deleted
@@ -1022,7 +1023,7 @@ Cards.helpers({
     const resultId = [];
     const resultId = [];
     const result = [];
     const result = [];
     let crtParentId = this.parentId;
     let crtParentId = this.parentId;
-    while (crtParentId !== '') {
+    while (crtParentId) {
       const crt = ReactiveCache.getCard(crtParentId);
       const crt = ReactiveCache.getCard(crtParentId);
       if (crt === null || crt === undefined) {
       if (crt === null || crt === undefined) {
         // maybe it has been deleted
         // maybe it has been deleted
@@ -1048,7 +1049,11 @@ Cards.helpers({
   },
   },
 
 
   isTopLevel() {
   isTopLevel() {
-    return this.parentId === '';
+    let ret = false;
+    if (this.parentId) {
+      ret = true;
+    }
+    return ret;
   },
   },
 
 
   isLinkedCard() {
   isLinkedCard() {