Quellcode durchsuchen

Add Feature: Card Settings/Show on card/Activities.
Fix: When in Card Settings hiding Comments, only adding new comment is hidden, not old comments.

Thanks to xet7 !

Closes #2925

Lauri Ojansivu vor 5 Jahren
Ursprung
Commit
2fce02afbc

+ 195 - 193
client/components/activities/activities.jade

@@ -8,234 +8,236 @@ template(name="activities")
       +cardActivities
 
 template(name="boardActivities")
-  each currentBoard.activities
-    .activity
-      +userAvatar(userId=user._id)
-      p.activity-desc
-        +memberName(user=user)
+  if currentBoard.allowsActivities
+    each currentBoard.activities
+      .activity
+        +userAvatar(userId=user._id)
+        p.activity-desc
+          +memberName(user=user)
 
-        if($eq activityType 'deleteAttachment')
-          | {{{_ 'activity-delete-attach' cardLink}}}.
+          if($eq activityType 'deleteAttachment')
+            | {{{_ 'activity-delete-attach' cardLink}}}.
 
-        if($eq activityType 'addAttachment')
-          | {{{_ 'activity-attached' attachmentLink cardLink}}}.
+          if($eq activityType 'addAttachment')
+            | {{{_ 'activity-attached' attachmentLink cardLink}}}.
 
-        if($eq activityType 'addBoardMember')
-          | {{{_ 'activity-added' memberLink boardLabel}}}.
+          if($eq activityType 'addBoardMember')
+            | {{{_ 'activity-added' memberLink boardLabel}}}.
 
-        if($eq activityType 'addComment')
-          | {{{_ 'activity-on' cardLink}}}
-          a.activity-comment(href="{{ card.absoluteUrl }}")
-            +viewer
-              = comment.text
+          if($eq activityType 'addComment')
+            | {{{_ 'activity-on' cardLink}}}
+            a.activity-comment(href="{{ card.absoluteUrl }}")
+              +viewer
+                = comment.text
 
-        if($eq activityType 'addChecklist')
-          | {{{_ 'activity-checklist-added' cardLink}}}.
-          .activity-checklist(href="{{ card.absoluteUrl }}")
-            +viewer
-              = checklist.title
-        if($eq activityType 'removeChecklist')
-          | {{{_ 'activity-checklist-removed' cardLink}}}.
+          if($eq activityType 'addChecklist')
+            | {{{_ 'activity-checklist-added' cardLink}}}.
+            .activity-checklist(href="{{ card.absoluteUrl }}")
+              +viewer
+                = checklist.title
+          if($eq activityType 'removeChecklist')
+            | {{{_ 'activity-checklist-removed' cardLink}}}.
 
-        if($eq activityType 'checkedItem')
-          | {{{_ 'activity-checked-item' checkItem checklist.title cardLink}}}.
+          if($eq activityType 'checkedItem')
+            | {{{_ 'activity-checked-item' checkItem checklist.title cardLink}}}.
 
-        if($eq activityType 'uncheckedItem')
-          | {{{_ 'activity-unchecked-item' checkItem checklist.title cardLink}}}.
+          if($eq activityType 'uncheckedItem')
+            | {{{_ 'activity-unchecked-item' checkItem checklist.title cardLink}}}.
 
-        if($eq activityType 'checklistCompleted')
-          | {{{_ 'activity-checklist-completed' checklist.title cardLink}}}.
+          if($eq activityType 'checklistCompleted')
+            | {{{_ 'activity-checklist-completed' checklist.title cardLink}}}.
 
-        if($eq activityType 'checklistUncompleted')
-          | {{{_ 'activity-checklist-uncompleted' checklist.title cardLink}}}.
+          if($eq activityType 'checklistUncompleted')
+            | {{{_ 'activity-checklist-uncompleted' checklist.title cardLink}}}.
 
-        if($eq activityType 'addChecklistItem')
-          | {{{_ 'activity-checklist-item-added' checklist.title cardLink}}}.
-          .activity-checklist(href="{{ card.absoluteUrl }}")
-            +viewer
-              = checklistItem.title
-        if($eq activityType 'removedChecklistItem')
-          | {{{_ 'activity-checklist-item-removed' checklist.title cardLink}}}.
+          if($eq activityType 'addChecklistItem')
+            | {{{_ 'activity-checklist-item-added' checklist.title cardLink}}}.
+            .activity-checklist(href="{{ card.absoluteUrl }}")
+              +viewer
+                = checklistItem.title
+          if($eq activityType 'removedChecklistItem')
+            | {{{_ 'activity-checklist-item-removed' checklist.title cardLink}}}.
 
-        if($eq activityType 'archivedCard')
-          | {{{_ 'activity-archived' cardLink}}}.
+          if($eq activityType 'archivedCard')
+            | {{{_ 'activity-archived' cardLink}}}.
 
-        if($eq activityType 'archivedList')
-          | {{_ 'activity-archived' list.title}}.
+          if($eq activityType 'archivedList')
+            | {{_ 'activity-archived' list.title}}.
 
-        if($eq activityType 'archivedSwimlane')
-          | {{_ 'activity-archived' swimlane.title}}.
+          if($eq activityType 'archivedSwimlane')
+            | {{_ 'activity-archived' swimlane.title}}.
 
-        if($eq activityType 'createBoard')
-          | {{_ 'activity-created' boardLabel}}.
+          if($eq activityType 'createBoard')
+            | {{_ 'activity-created' boardLabel}}.
 
-        if($eq activityType 'createCard')
-          | {{{_ 'activity-added' cardLink boardLabel}}}.
+          if($eq activityType 'createCard')
+            | {{{_ 'activity-added' cardLink boardLabel}}}.
 
-        if($eq activityType 'createCustomField')
-          | {{_ 'activity-customfield-created' customField}}.
+          if($eq activityType 'createCustomField')
+            | {{_ 'activity-customfield-created' customField}}.
 
-        if($eq activityType 'createList')
-          | {{_ 'activity-added' list.title boardLabel}}.
+          if($eq activityType 'createList')
+            | {{_ 'activity-added' list.title boardLabel}}.
 
-        if($eq activityType 'createSwimlane')
-          | {{_ 'activity-added' swimlane.title boardLabel}}.
+          if($eq activityType 'createSwimlane')
+            | {{_ 'activity-added' swimlane.title boardLabel}}.
 
-        if($eq activityType 'removeList')
-          | {{_ 'activity-removed' title boardLabel}}.
+          if($eq activityType 'removeList')
+            | {{_ 'activity-removed' title boardLabel}}.
 
-        if($eq activityType 'importBoard')
-          | {{{_ 'activity-imported-board' boardLabel sourceLink}}}.
+          if($eq activityType 'importBoard')
+            | {{{_ 'activity-imported-board' boardLabel sourceLink}}}.
 
-        if($eq activityType 'importCard')
-          | {{{_ 'activity-imported' cardLink boardLabel sourceLink}}}.
+          if($eq activityType 'importCard')
+            | {{{_ 'activity-imported' cardLink boardLabel sourceLink}}}.
 
-        if($eq activityType 'importList')
-          | {{{_ 'activity-imported' listLabel boardLabel sourceLink}}}.
+          if($eq activityType 'importList')
+            | {{{_ 'activity-imported' listLabel boardLabel sourceLink}}}.
 
-        if($eq activityType 'joinMember')
-          if($eq user._id member._id)
-            | {{{_ 'activity-joined' cardLink}}}.
-          else
-            | {{{_ 'activity-added' memberLink cardLink}}}.
+          if($eq activityType 'joinMember')
+            if($eq user._id member._id)
+              | {{{_ 'activity-joined' cardLink}}}.
+            else
+              | {{{_ 'activity-added' memberLink cardLink}}}.
 
-        if($eq activityType 'moveCardBoard')
-          | {{{_ 'activity-moved' cardLink oldBoardName boardName}}}.
+          if($eq activityType 'moveCardBoard')
+            | {{{_ 'activity-moved' cardLink oldBoardName boardName}}}.
 
-        if($eq activityType 'moveCard')
-          | {{{_ 'activity-moved' cardLink oldList.title list.title}}}.
+          if($eq activityType 'moveCard')
+            | {{{_ 'activity-moved' cardLink oldList.title list.title}}}.
 
-        if($eq activityType 'removeBoardMember')
-          | {{{_ 'activity-excluded' memberLink boardLabel}}}.
+          if($eq activityType 'removeBoardMember')
+            | {{{_ 'activity-excluded' memberLink boardLabel}}}.
 
-        if($eq activityType 'restoredCard')
-          | {{{_ 'activity-sent' cardLink boardLabel}}}.
+          if($eq activityType 'restoredCard')
+            | {{{_ 'activity-sent' cardLink boardLabel}}}.
 
-        if($eq activityType 'addedLabel')
-          | {{{_ 'activity-added-label' lastLabel cardLink}}}.
+          if($eq activityType 'addedLabel')
+            | {{{_ 'activity-added-label' lastLabel cardLink}}}.
 
-        if($eq activityType 'removedLabel')
-          | {{{_ 'activity-removed-label' lastLabel cardLink}}}.
+          if($eq activityType 'removedLabel')
+            | {{{_ 'activity-removed-label' lastLabel cardLink}}}.
 
-        if($eq activityType 'setCustomField')
-          | {{{_ 'activity-set-customfield' lastCustomField lastCustomFieldValue cardLink}}}.
+          if($eq activityType 'setCustomField')
+            | {{{_ 'activity-set-customfield' lastCustomField lastCustomFieldValue cardLink}}}.
 
-        if($eq activityType 'unsetCustomField')
-          | {{{_ 'activity-unset-customfield' lastCustomField cardLink}}}.
+          if($eq activityType 'unsetCustomField')
+            | {{{_ 'activity-unset-customfield' lastCustomField cardLink}}}.
 
-        if($eq activityType 'unjoinMember')
-          if($eq user._id member._id)
-            | {{{_ 'activity-unjoined' cardLink}}}.
-          else
-            | {{{_ 'activity-removed' memberLink cardLink}}}.
+          if($eq activityType 'unjoinMember')
+            if($eq user._id member._id)
+              | {{{_ 'activity-unjoined' cardLink}}}.
+            else
+              | {{{_ 'activity-removed' memberLink cardLink}}}.
 
-        span(title=createdAt).activity-meta {{ moment createdAt }}
+          span(title=createdAt).activity-meta {{ moment createdAt }}
 
 template(name="cardActivities")
-  each currentCard.activities
-    .activity
-      +userAvatar(userId=user._id)
-      p.activity-desc
-        +memberName(user=user)
-        if($eq activityType 'createCard')
-          | {{_ 'activity-added' cardLabel listName}}.
-        if($eq activityType 'importCard')
-          | {{{_ 'activity-imported' cardLabel list.title sourceLink}}}.
-        if($eq activityType 'joinMember')
-          if($eq user._id member._id)
-            | {{_ 'activity-joined' cardLabel}}.
-          else
-            | {{{_ 'activity-added' memberLink cardLabel}}}.
-        if($eq activityType 'unjoinMember')
-          if($eq user._id member._id)
-            | {{_ 'activity-unjoined' cardLabel}}.
-          else
-            | {{{_ 'activity-removed' cardLabel memberLink}}}.
-        if($eq activityType 'archivedCard')
-          | {{_ 'activity-archived' cardLabel}}.
-
-        if($eq activityType 'addedLabel')
-          | {{{_ 'activity-added-label-card' lastLabel }}}.
-
-        if($eq activityType 'removedLabel')
-          | {{{_ 'activity-removed-label-card' lastLabel }}}.
-
-        if($eq activityType 'removeChecklist')
-          | {{{_ 'activity-checklist-removed' cardLabel}}}.
-
-        if($eq activityType 'checkedItem')
-          | {{{_ 'activity-checked-item-card' checkItem checklist.title }}}.
-
-        if($eq activityType 'uncheckedItem')
-          | {{{_ 'activity-unchecked-item-card' checkItem checklist.title }}}.
-
-        if($eq activityType 'checklistCompleted')
-          | {{{_ 'activity-checklist-completed-card' checklist.title }}}.
-
-        if($eq activityType 'checklistUncompleted')
-          | {{{_ 'activity-checklist-uncompleted-card' checklist.title }}}.
-
-        if($eq activityType 'restoredCard')
-          | {{_ 'activity-sent' cardLabel boardLabel}}.
-        if($eq activityType 'moveCard')
-          | {{_ 'activity-moved' cardLabel oldList.title list.title}}.
-
-        if($eq activityType 'moveCardBoard')
-          | {{{_ 'activity-moved' cardLink oldBoardName boardName}}}.
-
-        if($eq activityType 'addAttachment')
-          | {{{_ 'activity-attached' attachmentLink cardLabel}}}.
-          if attachment.isImage
-            img.attachment-image-preview(src=attachment.url)
-        if($eq activityType 'deleteAttachment')
-          | {{{_ 'activity-delete-attach'  cardLabel}}}.
-        if($eq activityType 'removedChecklist')
-          | {{{_ 'activity-checklist-removed' cardLabel}}}.
-        if($eq activityType 'addChecklist')
-          | {{{_ 'activity-checklist-added' cardLabel}}}.
-          .activity-checklist
-            +viewer
-              = checklist.title
-        if($eq activityType 'addChecklistItem')
-          | {{{_ 'activity-checklist-item-added' checklist.title cardLink}}}.
-          .activity-checklist(href="{{ card.absoluteUrl }}")
-            +viewer
-              = checklistItem.title
-        
-        if(currentData.timeKey)
-          | {{{_ activityType }}}
-          = ' '
-          i(title=currentData.timeValue).activity-meta {{ moment currentData.timeValue 'LLL' }}
-          if (currentData.timeOldValue)
-              = ' '                                                                                    
-              | {{{_ "previous_as" }}}
-              = ' '
-              i(title=currentData.timeOldValue).activity-meta {{ moment currentData.timeOldValue 'LLL' }}
-          = ' @'
-        else if(currentData.timeValue)
-          | {{{_ activityType currentData.timeValue}}}
-        
-
-        if($eq activityType 'deleteComment')
-          | {{{_ 'activity-deleteComment' currentData.commentId}}}.
-        if($eq activityType 'editComment')
-          | {{{_ 'activity-editComment' currentData.commentId}}}.
-        if($eq activityType 'addComment')
-          +inlinedForm(classNames='js-edit-comment')
-            +editor(autofocus=true)
-              = comment.text
-            .edit-controls
-              button.primary(type="submit") {{_ 'edit'}}
-          else
-            .activity-comment
+  if currentBoard.allowsComments
+    each currentCard.activities
+      .activity
+        +userAvatar(userId=user._id)
+        p.activity-desc
+          +memberName(user=user)
+          if($eq activityType 'createCard')
+            | {{_ 'activity-added' cardLabel listName}}.
+          if($eq activityType 'importCard')
+            | {{{_ 'activity-imported' cardLabel list.title sourceLink}}}.
+          if($eq activityType 'joinMember')
+            if($eq user._id member._id)
+              | {{_ 'activity-joined' cardLabel}}.
+            else
+              | {{{_ 'activity-added' memberLink cardLabel}}}.
+          if($eq activityType 'unjoinMember')
+            if($eq user._id member._id)
+              | {{_ 'activity-unjoined' cardLabel}}.
+            else
+              | {{{_ 'activity-removed' cardLabel memberLink}}}.
+          if($eq activityType 'archivedCard')
+            | {{_ 'activity-archived' cardLabel}}.
+
+          if($eq activityType 'addedLabel')
+            | {{{_ 'activity-added-label-card' lastLabel }}}.
+
+          if($eq activityType 'removedLabel')
+            | {{{_ 'activity-removed-label-card' lastLabel }}}.
+
+          if($eq activityType 'removeChecklist')
+            | {{{_ 'activity-checklist-removed' cardLabel}}}.
+
+          if($eq activityType 'checkedItem')
+            | {{{_ 'activity-checked-item-card' checkItem checklist.title }}}.
+
+          if($eq activityType 'uncheckedItem')
+            | {{{_ 'activity-unchecked-item-card' checkItem checklist.title }}}.
+
+          if($eq activityType 'checklistCompleted')
+            | {{{_ 'activity-checklist-completed-card' checklist.title }}}.
+
+          if($eq activityType 'checklistUncompleted')
+            | {{{_ 'activity-checklist-uncompleted-card' checklist.title }}}.
+
+          if($eq activityType 'restoredCard')
+            | {{_ 'activity-sent' cardLabel boardLabel}}.
+          if($eq activityType 'moveCard')
+            | {{_ 'activity-moved' cardLabel oldList.title list.title}}.
+
+          if($eq activityType 'moveCardBoard')
+            | {{{_ 'activity-moved' cardLink oldBoardName boardName}}}.
+
+          if($eq activityType 'addAttachment')
+            | {{{_ 'activity-attached' attachmentLink cardLabel}}}.
+            if attachment.isImage
+              img.attachment-image-preview(src=attachment.url)
+          if($eq activityType 'deleteAttachment')
+            | {{{_ 'activity-delete-attach'  cardLabel}}}.
+          if($eq activityType 'removedChecklist')
+            | {{{_ 'activity-checklist-removed' cardLabel}}}.
+          if($eq activityType 'addChecklist')
+            | {{{_ 'activity-checklist-added' cardLabel}}}.
+            .activity-checklist
               +viewer
+                = checklist.title
+          if($eq activityType 'addChecklistItem')
+            | {{{_ 'activity-checklist-item-added' checklist.title cardLink}}}.
+            .activity-checklist(href="{{ card.absoluteUrl }}")
+              +viewer
+                = checklistItem.title
+
+          if(currentData.timeKey)
+            | {{{_ activityType }}}
+            = ' '
+            i(title=currentData.timeValue).activity-meta {{ moment currentData.timeValue 'LLL' }}
+            if (currentData.timeOldValue)
+                = ' '
+                | {{{_ "previous_as" }}}
+                = ' '
+                i(title=currentData.timeOldValue).activity-meta {{ moment currentData.timeOldValue 'LLL' }}
+            = ' @'
+          else if(currentData.timeValue)
+            | {{{_ activityType currentData.timeValue}}}
+
+
+          if($eq activityType 'deleteComment')
+            | {{{_ 'activity-deleteComment' currentData.commentId}}}.
+          if($eq activityType 'editComment')
+            | {{{_ 'activity-editComment' currentData.commentId}}}.
+          if($eq activityType 'addComment')
+            +inlinedForm(classNames='js-edit-comment')
+              +editor(autofocus=true)
                 = comment.text
-            span(title=createdAt).activity-meta {{ moment createdAt }}
-              if ($eq currentUser._id comment.userId)
-                = ' - '
-                a.js-open-inlined-form {{_ "edit"}}
-                = ' - '
-                a.js-delete-comment {{_ "delete"}}
+              .edit-controls
+                button.primary(type="submit") {{_ 'edit'}}
+            else
+              .activity-comment
+                +viewer
+                  = comment.text
+              span(title=createdAt).activity-meta {{ moment createdAt }}
+                if ($eq currentUser._id comment.userId)
+                  = ' - '
+                  a.js-open-inlined-form {{_ "edit"}}
+                  = ' - '
+                  a.js-delete-comment {{_ "delete"}}
 
-        else
-          span(title=createdAt).activity-meta {{ moment createdAt }}
+          else
+            span(title=createdAt).activity-meta {{ moment createdAt }}

+ 9 - 8
client/components/cards/cardDetails.jade

@@ -261,14 +261,15 @@ template(name="cardDetails")
       if currentUser.isBoardMember
         unless currentUser.isNoComments
           +commentForm
-    unless currentUser.isNoComments
-      if isLoaded.get
-        if isLinkedCard
-          +activities(card=this mode="linkedcard")
-        else if isLinkedBoard
-          +activities(card=this mode="linkedboard")
-        else
-          +activities(card=this mode="card")
+    if currentBoard.allowsActivities
+      unless currentUser.isNoComments
+        if isLoaded.get
+          if isLinkedCard
+            +activities(card=this mode="linkedcard")
+          else if isLinkedBoard
+            +activities(card=this mode="linkedboard")
+          else
+            +activities(card=this mode="card")
 
 template(name="editCardTitleForm")
   textarea.js-edit-card-title(rows='1' autofocus dir="auto")

+ 6 - 0
client/components/sidebar/sidebar.jade

@@ -153,6 +153,12 @@ template(name="boardCardSettingsPopup")
         span
           i.fa.fa-comment-o
           | {{_ 'comment'}}
+    div.check-div
+      a.flex.js-field-has-comments(class="{{#if allowsActivities}}is-checked{{/if}}")
+        .materialCheckBox(class="{{#if allowsActivities}}is-checked{{/if}}")
+        span
+          i.fa.fa-history
+          | {{_ 'activities'}}
 
 template(name="boardSubtaskSettingsPopup")
   form.board-subtask-settings

+ 16 - 0
client/components/sidebar/sidebar.js

@@ -882,6 +882,22 @@ BlazeComponent.extendComponent({
             this.currentBoard.allowsComments,
           );
         },
+        'click .js-field-has-activities'(evt) {
+          evt.preventDefault();
+          this.currentBoard.allowsActivities = !this.currentBoard
+            .allowsActivities;
+          this.currentBoard.setAllowsActivities(
+            this.currentBoard.allowsActivities,
+          );
+          $(`.js-field-has-activities ${MCB}`).toggleClass(
+            CKCLS,
+            this.currentBoard.allowsActivities,
+          );
+          $('.js-field-has-activities').toggleClass(
+            CKCLS,
+            this.currentBoard.allowsActivities,
+          );
+        },
       },
     ];
   },

+ 12 - 0
models/boards.js

@@ -332,6 +332,14 @@ Boards.attachSchema(
       defaultValue: true,
     },
 
+    allowsActivities: {
+      /**
+       * Does the board allows comments?
+       */
+      type: Boolean,
+      defaultValue: true,
+    },
+
     allowsLabels: {
       /**
        * Does the board allows labels?
@@ -1119,6 +1127,10 @@ Boards.mutations({
     return { $set: { allowsComments } };
   },
 
+  setAllowsActivities(allowsActivities) {
+    return { $set: { allowsActivities } };
+  },
+
   setAllowsReceivedDate(allowsReceivedDate) {
     return { $set: { allowsReceivedDate } };
   },

+ 16 - 0
server/migrations.js

@@ -985,3 +985,19 @@ Migrations.add('add-requested-by-allowed', () => {
     noValidateMulti,
   );
 });
+
+Migrations.add('add-activities-allowed', () => {
+  Boards.update(
+    {
+      allowsActivities: {
+        $exists: false,
+      },
+    },
+    {
+      $set: {
+        allowsActivities: true,
+      },
+    },
+    noValidateMulti,
+  );
+});