Sfoglia il codice sorgente

Move every Swimlanes.findOne(idOrFirstObjectSelector, options) to the ReactiveCache

Martin Filser 2 anni fa
parent
commit
48ba81eb3d

+ 2 - 2
client/components/cards/subtasks.js

@@ -13,12 +13,12 @@ BlazeComponent.extendComponent({
     const listId = targetBoard.getDefaultSubtasksListId();
 
     //Get the full swimlane data for the parent task.
-    const parentSwimlane = Swimlanes.findOne({
+    const parentSwimlane = ReactiveCache.getSwimlane({
       boardId: crtBoard._id,
       _id: card.swimlaneId,
     });
     //find the swimlane of the same name in the target board.
-    const targetSwimlane = Swimlanes.findOne({
+    const targetSwimlane = ReactiveCache.getSwimlane({
       boardId: targetBoard._id,
       title: parentSwimlane.title,
     });

+ 2 - 2
client/components/lists/listBody.js

@@ -440,7 +440,7 @@ BlazeComponent.extendComponent({
     if (Utils.boardView() === 'board-view-swimlanes')
       this.swimlaneId = Blaze.getData(swimlane[0])._id;
     else if (Utils.boardView() === 'board-view-lists' || !Utils.boardView)
-      this.swimlaneId = Swimlanes.findOne({ boardId: this.boardId })._id;
+      this.swimlaneId = ReactiveCache.getSwimlane({ boardId: this.boardId })._id;
   },
 
   boards() {
@@ -642,7 +642,7 @@ BlazeComponent.extendComponent({
       );
       if (Utils.boardView() === 'board-view-swimlanes')
         this.swimlaneId = Blaze.getData(swimlane[0])._id;
-      else this.swimlaneId = Swimlanes.findOne({ boardId: this.boardId })._id;
+      else this.swimlaneId = ReactiveCache.getSwimlane({ boardId: this.boardId })._id;
       // List where to insert card
       this.listId = Blaze.getData(this.list[0])._id;
     }

+ 1 - 1
client/lib/dialogWithBoardSwimlaneList.js

@@ -54,7 +54,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
       }
     }
     this.getBoardData(this.selectedBoardId.get());
-    if (!this.selectedSwimlaneId.get() || !Swimlanes.findOne({_id: this.selectedSwimlaneId.get(), boardId: this.selectedBoardId.get()})) {
+    if (!this.selectedSwimlaneId.get() || !ReactiveCache.getSwimlane({_id: this.selectedSwimlaneId.get(), boardId: this.selectedBoardId.get()})) {
       this.setFirstSwimlaneId();
     }
     if (!this.selectedListId.get() || !Lists.findOne({_id: this.selectedListId.get(), boardId: this.selectedBoardId.get()})) {

+ 3 - 3
models/boards.js

@@ -783,7 +783,7 @@ Boards.helpers({
   },
 
   nextSwimlane(swimlane) {
-    return Swimlanes.findOne(
+    return ReactiveCache.getSwimlane(
       {
         boardId: this._id,
         archived: false,
@@ -1193,13 +1193,13 @@ Boards.helpers({
   },
 
   getDefaultSwimline() {
-    let result = Swimlanes.findOne({ boardId: this._id });
+    let result = ReactiveCache.getSwimlane({ boardId: this._id });
     if (result === undefined) {
       Swimlanes.insert({
         title: TAPi18n.__('default'),
         boardId: this._id,
       });
-      result = Swimlanes.findOne({ boardId: this._id });
+      result = ReactiveCache.getSwimlane({ boardId: this._id });
     }
     return result;
   },

+ 2 - 2
models/swimlanes.js

@@ -437,7 +437,7 @@ if (Meteor.isServer) {
 
       JsonRoutes.sendResult(res, {
         code: 200,
-        data: Swimlanes.findOne({
+        data: ReactiveCache.getSwimlane({
           _id: paramSwimlaneId,
           boardId: paramBoardId,
           archived: false,
@@ -501,7 +501,7 @@ if (Meteor.isServer) {
       const paramSwimlaneId = req.params.swimlaneId;
       Authentication.checkBoardAccess(req.userId, paramBoardId);
       const board = ReactiveCache.getBoard(paramBoardId);
-      const swimlane = Swimlanes.findOne({
+      const swimlane = ReactiveCache.getSwimlane({
         _id: paramSwimlaneId,
         boardId: paramBoardId,
       });

+ 7 - 7
server/rulesHelper.js

@@ -88,19 +88,19 @@ RulesHelper = {
       if (action.swimlaneName === '*') {
         swimlane = ReactiveCache.getSwimlane(card.swimlaneId);
         if (boardId !== action.boardId) {
-          swimlane = Swimlanes.findOne({
+          swimlane = ReactiveCache.getSwimlane({
             title: swimlane.title,
             boardId: action.boardId,
           });
         }
       } else {
-        swimlane = Swimlanes.findOne({
+        swimlane = ReactiveCache.getSwimlane({
           title: action.swimlaneName,
           boardId: action.boardId,
         });
       }
       if (swimlane === undefined) {
-        swimlaneId = Swimlanes.findOne({
+        swimlaneId = ReactiveCache.getSwimlane({
           title: 'Default',
           boardId: action.boardId,
         })._id;
@@ -352,7 +352,7 @@ RulesHelper = {
       const list = Lists.findOne({ title: action.listName, boardId });
       let listId = '';
       let swimlaneId = '';
-      const swimlane = Swimlanes.findOne({
+      const swimlane = ReactiveCache.getSwimlane({
         title: action.swimlaneName,
         boardId,
       });
@@ -362,7 +362,7 @@ RulesHelper = {
         listId = list._id;
       }
       if (swimlane === undefined) {
-        swimlaneId = Swimlanes.findOne({ title: 'Default', boardId })._id;
+        swimlaneId = ReactiveCache.getSwimlane({ title: 'Default', boardId })._id;
       } else {
         swimlaneId = swimlane._id;
       }
@@ -379,7 +379,7 @@ RulesHelper = {
       const card = ReactiveCache.getCard(activity.cardId);
       let listId = '';
       let swimlaneId = '';
-      const swimlane = Swimlanes.findOne({
+      const swimlane = ReactiveCache.getSwimlane({
         title: action.swimlaneName,
         boardId: action.boardId,
       });
@@ -389,7 +389,7 @@ RulesHelper = {
         listId = list._id;
       }
       if (swimlane === undefined) {
-        swimlaneId = Swimlanes.findOne({ title: 'Default', boardId: action.boardId })._id;
+        swimlaneId = ReactiveCache.getSwimlane({ title: 'Default', boardId: action.boardId })._id;
       } else {
         swimlaneId = swimlane._id;
       }