Browse Source

Merge branch 'bronger-sorted-archives'

Lauri Ojansivu 4 years ago
parent
commit
c42d0d7423

+ 1 - 1
client/components/boards/boardArchive.js

@@ -11,7 +11,7 @@ BlazeComponent.extendComponent({
     return Boards.find(
     return Boards.find(
       { archived: true },
       { archived: true },
       {
       {
-        sort: { sort: 1 /* boards default sorting */ },
+        sort: { archivedAt: -1, modifiedAt: -1 },
       },
       },
     );
     );
   },
   },

+ 15 - 0
client/components/sidebar/sidebarArchives.jade

@@ -14,6 +14,11 @@ template(name="archivesSidebar")
           if currentUser.isBoardMember
           if currentUser.isBoardMember
             unless isWorker
             unless isWorker
               p.quiet
               p.quiet
+                if this.archivedAt
+                  | {{_ 'archived-at' }}
+                  | 
+                  | {{ moment this.archivedAt 'LLL' }}
+                  br
                 a.js-restore-card {{_ 'restore'}}
                 a.js-restore-card {{_ 'restore'}}
                 if currentUser.isBoardAdmin
                 if currentUser.isBoardAdmin
                   | -
                   | -
@@ -37,6 +42,11 @@ template(name="archivesSidebar")
               if currentUser.isBoardMember
               if currentUser.isBoardMember
                 unless isWorker
                 unless isWorker
                   p.quiet
                   p.quiet
+                    if this.archivedAt
+                      | {{_ 'archived-at' }}
+                      | 
+                      | {{ moment this.archivedAt 'LLL' }}
+                      br
                     a.js-restore-list {{_ 'restore'}}
                     a.js-restore-list {{_ 'restore'}}
                     if currentUser.isBoardAdmin
                     if currentUser.isBoardAdmin
                       | -
                       | -
@@ -58,6 +68,11 @@ template(name="archivesSidebar")
               if currentUser.isBoardMember
               if currentUser.isBoardMember
                 unless isWorker
                 unless isWorker
                   p.quiet
                   p.quiet
+                    if this.archivedAt
+                      | {{_ 'archived-at' }}
+                      | 
+                      | {{ moment this.archivedAt 'LLL' }}
+                      br
                     a.js-restore-swimlane {{_ 'restore'}}
                     a.js-restore-swimlane {{_ 'restore'}}
                     if currentUser.isBoardAdmin
                     if currentUser.isBoardAdmin
                       | -
                       | -

+ 6 - 0
client/components/sidebar/sidebarArchives.js

@@ -34,6 +34,8 @@ BlazeComponent.extendComponent({
     return Cards.find({
     return Cards.find({
       archived: true,
       archived: true,
       boardId: Session.get('currentBoard'),
       boardId: Session.get('currentBoard'),
+    }, {
+      sort: { archivedAt: -1, modifiedAt: -1 },
     });
     });
   },
   },
 
 
@@ -41,6 +43,8 @@ BlazeComponent.extendComponent({
     return Lists.find({
     return Lists.find({
       archived: true,
       archived: true,
       boardId: Session.get('currentBoard'),
       boardId: Session.get('currentBoard'),
+    }, {
+      sort: { archivedAt: -1, modifiedAt: -1 },
     });
     });
   },
   },
 
 
@@ -48,6 +52,8 @@ BlazeComponent.extendComponent({
     return Swimlanes.find({
     return Swimlanes.find({
       archived: true,
       archived: true,
       boardId: Session.get('currentBoard'),
       boardId: Session.get('currentBoard'),
+    }, {
+      sort: { archivedAt: -1, modifiedAt: -1 },
     });
     });
   },
   },
 
 

+ 2 - 1
i18n/en.i18n.json

@@ -951,5 +951,6 @@
   "excel-font": "Arial",
   "excel-font": "Arial",
   "number": "Number",
   "number": "Number",
   "label-colors": "Label Colors",
   "label-colors": "Label Colors",
-  "label-names": "Label Names"
+  "label-names": "Label Names",
+  "archived-at": "archived at"
 }
 }

+ 8 - 1
models/boards.js

@@ -43,6 +43,13 @@ Boards.attachSchema(
         }
         }
       },
       },
     },
     },
+    archivedAt: {
+      /**
+       * Latest archiving time of the board
+       */
+      type: Date,
+      optional: true,
+    },
     createdAt: {
     createdAt: {
       /**
       /**
        * Creation time of the board
        * Creation time of the board
@@ -1042,7 +1049,7 @@ Boards.helpers({
 
 
 Boards.mutations({
 Boards.mutations({
   archive() {
   archive() {
-    return { $set: { archived: true } };
+    return { $set: { archived: true, archivedAt: new Date() } };
   },
   },
 
 
   restore() {
   restore() {

+ 8 - 0
models/cards.js

@@ -26,6 +26,13 @@ Cards.attachSchema(
         }
         }
       },
       },
     },
     },
+    archivedAt: {
+      /**
+       * latest archiving date
+       */
+      type: Date,
+      optional: true,
+    },
     parentId: {
     parentId: {
       /**
       /**
        * ID of the parent card
        * ID of the parent card
@@ -1449,6 +1456,7 @@ Cards.mutations({
     return {
     return {
       $set: {
       $set: {
         archived: true,
         archived: true,
+        archivedAt: new Date(),
       },
       },
     };
     };
   },
   },

+ 9 - 1
models/lists.js

@@ -32,6 +32,13 @@ Lists.attachSchema(
         }
         }
       },
       },
     },
     },
+    archivedAt: {
+      /**
+       * latest archiving date
+       */
+      type: Date,
+      optional: true,
+    },
     boardId: {
     boardId: {
       /**
       /**
        * the board associated to this list
        * the board associated to this list
@@ -292,7 +299,7 @@ Lists.mutations({
         return card.archive();
         return card.archive();
       });
       });
     }
     }
-    return { $set: { archived: true } };
+    return { $set: { archived: true, archivedAt: new Date() } };
   },
   },
 
 
   restore() {
   restore() {
@@ -384,6 +391,7 @@ if (Meteor.isServer) {
   Meteor.startup(() => {
   Meteor.startup(() => {
     Lists._collection._ensureIndex({ modifiedAt: -1 });
     Lists._collection._ensureIndex({ modifiedAt: -1 });
     Lists._collection._ensureIndex({ boardId: 1 });
     Lists._collection._ensureIndex({ boardId: 1 });
+    Lists._collection._ensureIndex({ archivedAt: -1 });
   });
   });
 
 
   Lists.after.insert((userId, doc) => {
   Lists.after.insert((userId, doc) => {

+ 8 - 1
models/swimlanes.js

@@ -23,6 +23,13 @@ Swimlanes.attachSchema(
         }
         }
       },
       },
     },
     },
+    archivedAt: {
+      /**
+       * latest archiving date of the swimlane
+       */
+      type: Date,
+      optional: true,
+    },
     boardId: {
     boardId: {
       /**
       /**
        * the ID of the board the swimlane is attached to
        * the ID of the board the swimlane is attached to
@@ -259,7 +266,7 @@ Swimlanes.mutations({
         return list.archive();
         return list.archive();
       });
       });
     }
     }
-    return { $set: { archived: true } };
+    return { $set: { archived: true, archivedAt: new Date() } };
   },
   },
 
 
   restore() {
   restore() {

+ 4 - 1
server/publications/boards.js

@@ -63,8 +63,11 @@ Meteor.publish('archivedBoards', function() {
         archived: 1,
         archived: 1,
         slug: 1,
         slug: 1,
         title: 1,
         title: 1,
+        createdAt: 1,
+        modifiedAt: 1,
+        archivedAt: 1,
       },
       },
-      sort: { sort: 1 /* boards default sorting */ },
+      sort: { archivedAt: -1, modifiedAt: -1 },
     },
     },
   );
   );
 });
 });