From 540ce3a6ed804e43673a8fdaa7f7437947cbc0a0 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 12 Apr 2021 23:34:02 +0200 Subject: [PATCH] CardDetails sorting number is displayed at card and can be modified (if configured) --- client/components/cards/cardDetails.jade | 19 +++++++++++++++++++ client/components/cards/cardDetails.js | 10 ++++++++++ client/components/sidebar/sidebar.jade | 6 ++++++ client/components/sidebar/sidebar.js | 20 ++++++++++++++++++++ i18n/en.i18n.json | 1 + models/boards.js | 12 ++++++++++++ 6 files changed, 68 insertions(+) diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index da8bf5120..acde82a54 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -203,6 +203,19 @@ template(name="cardDetails") +viewer = getAssignedBy + if currentBoard.allowsCardSortingByNumber + .card-details-item.card-details-sort-order + h3.card-details-item-title + i.fa.fa-sort + | {{_ 'sort'}} + if canModifyCard + +inlinedForm(classNames="js-card-details-sort") + +editCardSortOrderForm + else + a.js-open-inlined-form + +viewer + = sort + //.card-details-items if customFieldsWD hr @@ -540,6 +553,12 @@ template(name="editCardAssignerForm") button.primary.confirm.js-submit-edit-card-assigner-form(type="submit") {{_ 'save'}} a.fa.fa-times-thin.js-close-inlined-form +template(name="editCardSortOrderForm") + input.js-edit-card-sort(type='text' autofocus value=sort dir="auto") + .edit-controls.clearfix + button.primary.confirm.js-submit-edit-card-sort-form(type="submit") {{_ 'save'}} + a.fa.fa-times-thin.js-close-inlined-form + template(name="cardDetailsActionsPopup") ul.pop-over-list li diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 8345460f0..d7a27ff09 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -361,6 +361,16 @@ BlazeComponent.extendComponent({ this.data().setRequestedBy(''); } }, + 'submit .js-card-details-sort'(event) { + event.preventDefault(); + const sort = parseFloat(this.currentComponent() + .getValue() + .trim()); + if (sort) { + let card = this.data(); + card.move(card.boardId, card.swimlaneId, card.listId, sort); + } + }, 'click .js-go-to-linked-card'() { Utils.goCardId(this.data().linkedId); }, diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade index f0bd05ac7..dcf33dfac 100644 --- a/client/components/sidebar/sidebar.jade +++ b/client/components/sidebar/sidebar.jade @@ -133,6 +133,12 @@ template(name="boardCardSettingsPopup") span i.fa.fa-user-plus | {{_ 'requested-by'}} + div.check-div + a.flex.js-field-has-card-sorting-by-number(class="{{#if allowsCardSortingByNumber}}is-checked{{/if}}") + .materialCheckBox(class="{{#if allowsCardSortingByNumber}}is-checked{{/if}}") + span + i.fa.fa-sort + | {{_ 'card-sorting-by-number'}} div.check-div a.flex.js-field-has-labels(class="{{#if allowsLabels}}is-checked{{/if}}") .materialCheckBox(class="{{#if allowsLabels}}is-checked{{/if}}") diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 5c1026c12..a97016898 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -754,6 +754,10 @@ BlazeComponent.extendComponent({ return this.currentBoard.allowsRequestedBy; }, + allowsCardSortingByNumber() { + return this.currentBoard.allowsCardSortingByNumber; + }, + allowsLabels() { return this.currentBoard.allowsLabels; }, @@ -968,6 +972,22 @@ BlazeComponent.extendComponent({ this.currentBoard.allowsRequestedBy, ); }, + 'click .js-field-has-card-sorting-by-number'(evt) { + evt.preventDefault(); + this.currentBoard.allowsCardSortingByNumber = !this.currentBoard + .allowsCardSortingByNumber; + this.currentBoard.setAllowsCardSortingByNumber( + this.currentBoard.allowsCardSortingByNumber, + ); + $(`.js-field-has-card-sorting-by-number ${MCB}`).toggleClass( + CKCLS, + this.currentBoard.allowsCardSortingByNumber, + ); + $('.js-field-has-card-sorting-by-number').toggleClass( + CKCLS, + this.currentBoard.allowsCardSortingByNumber, + ); + }, 'click .js-field-has-labels'(evt) { evt.preventDefault(); this.currentBoard.allowsLabels = !this.currentBoard.allowsLabels; diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index f28d62ad3..ef5d15c8e 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -664,6 +664,7 @@ "setListColorPopup-title": "Choose a color", "assigned-by": "Assigned By", "requested-by": "Requested By", + "card-sorting-by-number": "Card sorting by number", "board-delete-notice": "Deleting is permanent. You will lose all lists, cards and actions associated with this board.", "delete-board-confirm-popup": "All lists, cards, labels, and activities will be deleted and you won't be able to recover the board contents. There is no undo.", "boardDeletePopup-title": "Delete Board?", diff --git a/models/boards.js b/models/boards.js index 9cda643b1..0364dd9f7 100644 --- a/models/boards.js +++ b/models/boards.js @@ -373,6 +373,14 @@ Boards.attachSchema( defaultValue: true, }, + allowsCardSortingByNumber: { + /** + * Does the board allows card sorting by number? + */ + type: Boolean, + defaultValue: true, + }, + allowsAssignedBy: { /** * Does the board allows requested by? @@ -1190,6 +1198,10 @@ Boards.mutations({ return { $set: { allowsRequestedBy } }; }, + setAllowsCardSortingByNumber(allowsCardSortingByNumber) { + return { $set: { allowsCardSortingByNumber } }; + }, + setAllowsAttachments(allowsAttachments) { return { $set: { allowsAttachments } }; },