Browse Source

Move every CustomFields.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory models/)

Martin Filser 2 years ago
parent
commit
981a641bce

+ 3 - 2
models/boards.js

@@ -648,7 +648,7 @@ Boards.helpers({
 
     // copy custom field definitions
     const cfMap = {};
-    CustomFields.find({ boardIds: oldId }).forEach(cf => {
+    ReactiveCache.getCustomFields({ boardIds: oldId }).forEach(cf => {
       const id = cf._id;
       delete cf._id;
       cf.boardIds = [_id];
@@ -966,10 +966,11 @@ Boards.helpers({
   },
 
   customFields() {
-    return CustomFields.find(
+    const ret = ReactiveCache.getCustomFields(
       { boardIds: { $in: [this._id] } },
       { sort: { name: 1 } },
     );
+    return ret;
   },
 
   // XXX currently mutations return no value so we have an issue when using addLabel in import

+ 1 - 1
models/cards.js

@@ -3332,7 +3332,7 @@ if (Meteor.isServer) {
 
     let customFieldsArr = [];
     _.forEach(
-      CustomFields.find({'boardIds': paramBoardId}).fetch(),
+      ReactiveCache.getCustomFields({'boardIds': paramBoardId}),
       function (field) {
         if (field.automaticallyOnCard || field.alwaysOnCard)
           customFieldsArr.push({ _id: field._id, value: null });

+ 1 - 1
models/customFields.js

@@ -307,7 +307,7 @@ if (Meteor.isServer) {
     Authentication.checkBoardAccess(req.userId, paramBoardId);
     JsonRoutes.sendResult(res, {
       code: 200,
-      data: CustomFields.find({ boardIds: { $in: [paramBoardId] } }).map(
+      data: ReactiveCache.getCustomFields({ boardIds: { $in: [paramBoardId] } }).map(
         function(cf) {
           return {
             _id: cf._id,

+ 2 - 2
models/exporter.js

@@ -100,10 +100,10 @@ export class Exporter {
     result.lists = ReactiveCache.getLists(byBoard, noBoardId);
     result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
     result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
-    result.customFields = CustomFields.find(
+    result.customFields = ReactiveCache.getCustomFields(
       { boardIds: this._boardId },
       { fields: { boardIds: 0 } },
-    ).fetch();
+    );
     result.comments = CardComments.find(byBoard, noBoardId).fetch();
     result.activities = Activities.find(byBoard, noBoardId).fetch();
     result.rules = Rules.find(byBoard, noBoardId).fetch();

+ 2 - 2
models/server/ExporterCardPDF.js

@@ -43,7 +43,7 @@ class ExporterCardPDF {
         result.lists = ReactiveCache.getLists(byBoard, noBoardId);
         result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
         result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
-        result.customFields = CustomFields.find(
+        result.customFields = ReactiveCache.getCustomFields(
           {
             boardIds: {
               $in: [this.boardId],
@@ -54,7 +54,7 @@ class ExporterCardPDF {
               boardId: 0,
             },
           },
-        ).fetch();
+        );
         result.comments = CardComments.find(byBoard, noBoardId).fetch();
         result.activities = Activities.find(byBoard, noBoardId).fetch();
         result.rules = Rules.find(byBoard, noBoardId).fetch();

+ 2 - 2
models/server/ExporterExcel.js

@@ -45,7 +45,7 @@ class ExporterExcel {
     result.lists = ReactiveCache.getLists(byBoard, noBoardId);
     result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
     result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
-    result.customFields = CustomFields.find(
+    result.customFields = ReactiveCache.getCustomFields(
       {
         boardIds: {
           $in: [this.boardId],
@@ -56,7 +56,7 @@ class ExporterExcel {
           boardId: 0,
         },
       },
-    ).fetch();
+    );
     result.comments = CardComments.find(byBoard, noBoardId).fetch();
     result.activities = Activities.find(byBoard, noBoardId).fetch();
     result.rules = Rules.find(byBoard, noBoardId).fetch();