diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-09-05 01:31:25 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-09-05 01:37:55 +0200 |
commit | 82b322777852b0f7b3f93295a0dbcc0c238bd20d (patch) | |
tree | cb75983a021909ac96f99bdb1448cd2ebee72b48 | |
parent | 6a92963e2a79e2819b7492a0389c1c48a9467ba3 (diff) | |
download | wekan-82b322777852b0f7b3f93295a0dbcc0c238bd20d.tar.gz wekan-82b322777852b0f7b3f93295a0dbcc0c238bd20d.tar.bz2 wekan-82b322777852b0f7b3f93295a0dbcc0c238bd20d.zip |
Fix member permission modification
Fixes #280
-rw-r--r-- | client/components/boards/boardColors.styl | 2 | ||||
-rw-r--r-- | client/components/boards/boardsList.styl | 5 | ||||
-rw-r--r-- | client/components/cards/cardDetails.jade | 2 | ||||
-rw-r--r-- | client/components/main/layouts.styl | 7 | ||||
-rw-r--r-- | client/components/main/popup.styl | 8 | ||||
-rw-r--r-- | client/components/main/spinner.styl | 16 | ||||
-rw-r--r-- | client/components/sidebar/sidebar.jade | 22 | ||||
-rw-r--r-- | client/components/sidebar/sidebar.js | 13 | ||||
-rw-r--r-- | client/components/users/userAvatar.js | 1 | ||||
-rw-r--r-- | collections/boards.js | 8 | ||||
-rw-r--r-- | collections/users.js | 8 |
11 files changed, 57 insertions, 35 deletions
diff --git a/client/components/boards/boardColors.styl b/client/components/boards/boardColors.styl index d131701c..b1ddfe6d 100644 --- a/client/components/boards/boardColors.styl +++ b/client/components/boards/boardColors.styl @@ -18,7 +18,7 @@ setBoardColor(color) button[type=submit].primary, input[type=submit].primary background-color: darken(color, 20%) - &.pop-over .pop-over-list li a:hover, + &.pop-over .pop-over-list li a:not(.disabled):hover, .sidebar .sidebar-content .sidebar-btn:hover, .sidebar-list li a:hover background-color: lighten(color, 10%) diff --git a/client/components/boards/boardsList.styl b/client/components/boards/boardsList.styl index 8e296028..9978fab8 100644 --- a/client/components/boards/boardsList.styl +++ b/client/components/boards/boardsList.styl @@ -68,7 +68,10 @@ $spaceBetweenTiles = 16px color: white li:hover a - color: #f6f6f6 + &:hover + .fa-star, + .fa-star-o + color: white .fa-star, .fa-star-o diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index 37156191..497cdf64 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -91,7 +91,7 @@ template(name="moveCardPopup") +boardLists template(name="cardMembersPopup") - ul.pop-over-list.pop-over-member-list + ul.pop-over-list.js-card-member-list each board.members li.item(class="{{#if isCardMember}}active{{/if}}") a.name.js-select-member(href="#") diff --git a/client/components/main/layouts.styl b/client/components/main/layouts.styl index 65239cd6..87133391 100644 --- a/client/components/main/layouts.styl +++ b/client/components/main/layouts.styl @@ -28,6 +28,9 @@ body flex: 1 overflow: hidden + .sk-spinner + margin-top: 30vh + #modal position: absolute top: 0 @@ -267,7 +270,7 @@ dd .fa.fa-lock.colorful color: #f44336 -.pop-over .pop-over-list li a:hover +.pop-over .pop-over-list li a:not(.disabled):hover .fa, .fa.colorful color: white @@ -278,7 +281,7 @@ a &.fa, i.fa color: darken(white, 35%) - &:hover, &.is-active + &:not(.disabled):hover, &:not(.disabled).is-active &.fa, i.fa color: darken(white, 60%) diff --git a/client/components/main/popup.styl b/client/components/main/popup.styl index e44bb5c6..3bef4f7d 100644 --- a/client/components/main/popup.styl +++ b/client/components/main/popup.styl @@ -120,6 +120,9 @@ $popupWidth = 300px .at-result background: #b2dfdb + .sk-spinner + margin: 40px auto + for depth in (1..6) .popup-container-depth-{depth} transform: translateX(- depth * $popupWidth) @@ -133,7 +136,7 @@ $popupWidth = 300px cursor: pointer display: block font-weight: 700 - padding: 0px 10px + padding: 1.5px 10px position: relative margin: 0 -10px text-decoration: none @@ -145,7 +148,7 @@ $popupWidth = 300px width: auto padding-right: 22px - &:hover + &:not(.disabled):hover background-color: #005377 color: #fff @@ -162,7 +165,6 @@ $popupWidth = 300px font-size: 12px font-weight: 400 line-height: 15px - margin-top: 4px &.current background-color: #e2e6e9 diff --git a/client/components/main/spinner.styl b/client/components/main/spinner.styl index f4b8cc86..b211cf35 100644 --- a/client/components/main/spinner.styl +++ b/client/components/main/spinner.styl @@ -13,16 +13,12 @@ * */ -.sk-spinner-wave { - - &.sk-spinner { - width: 50px; - height: 50px; - margin: auto; - margin-top: 30vh; - text-align: center; - font-size: 10px; - } +.sk-spinner { + width: 50px; + height: 50px; + margin: auto; + text-align: center; + font-size: 10px; div { background-color: #333; diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade index f162fd6c..7e9cde80 100644 --- a/client/components/sidebar/sidebar.jade +++ b/client/components/sidebar/sidebar.jade @@ -26,7 +26,7 @@ template(name="membersWidget") i.fa.fa-user | {{_ 'members'}} .board-widget-content - each currentBoard.members + each currentBoard.activeMembers +userAvatar(userId=this.userId showStatus=true) unless isSandstorm if currentUser.isBoardAdmin @@ -50,7 +50,7 @@ template(name="labelsWidget") template(name="memberPopup") .board-member-menu .miniprofile-header - +userAvatar(userId=user._id) + +userAvatar(userId=user._id showEdit=true) .info h3 .js-profile= user.profile.fullname @@ -67,10 +67,12 @@ template(name="memberPopup") | {{_ 'change-permissions'}} span.quiet (#{memberType}) li - if currentUser.isBoardAdmin - a.js-remove-member {{_ 'remove-from-board'}} + if $eq currentUser._id userId + //- + XXX Not implemented! + // a.js-leave-member {{_ 'leave-board'}} else - a.js-leave-member {{_ 'leave-board'}} + a.js-remove-member {{_ 'remove-from-board'}} template(name="removeMemberPopup") @@ -81,16 +83,16 @@ template(name="addMemberPopup") .js-search-member +esInput(index="users") - ul.pop-over-member-list + ul.pop-over-list +esEach(index="users") - li.item.js-member-item(class="{{#if isBoardMember }}disabled{{/if}}") - a.name.js-select-member(title="{{ profile.name }} ({{ username }})") + li.item.js-member-item(class="{{#if isBoardMember}}disabled{{/if}}") + a.name.js-select-member(title="{{profile.name}} ({{username}})") +userAvatar(userId=_id) span.full-name = profile.name - | (<span class="username">{{ username }}</span>) + | (<span class="username">{{username}}</span>) if isBoardMember - .extra-text.quiet ({{_ 'joined'}}) + .quiet ({{_ 'joined'}}) +ifEsIsSearching(index='users') +spinner diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 51f3e0e4..ccc7e5aa 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -206,7 +206,7 @@ Template.addMemberPopup.helpers({ }); Template.addMemberPopup.events({ - 'click .pop-over-member-list li:not(.disabled)'() { + 'click .js-select-member'() { const userId = this._id; const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentMembersIds = _.pluck(currentBoard.members, 'userId'); @@ -233,14 +233,14 @@ Template.addMemberPopup.events({ }, }); -Template.addMemberPopup.onRendered(() => { +Template.addMemberPopup.onRendered(function() { this.find('.js-search-member input').focus(); }); Template.changePermissionsPopup.events({ 'click .js-set-admin, click .js-set-normal'(event) { const currentBoard = Boards.findOne(Session.get('currentBoard')); - const memberIndex = getMemberIndex(currentBoard, this.user._id); + const memberIndex = getMemberIndex(currentBoard, this.userId); const isAdmin = $(event.currentTarget).hasClass('js-set-admin'); Boards.update(currentBoard._id, { @@ -254,10 +254,13 @@ Template.changePermissionsPopup.events({ Template.changePermissionsPopup.helpers({ isAdmin() { - return this.user.isBoardAdmin(); + const user = Users.findOne(this.userId); + return user.isBoardAdmin(); }, + isLastAdmin() { - if (!this.user.isBoardAdmin()) + const user = Users.findOne(this.userId); + if (!user.isBoardAdmin()) return false; const currentBoard = Boards.findOne(Session.get('currentBoard')); const nbAdmins = _.where(currentBoard.members, { isAdmin: true }).length; diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js index 5337f6e2..2b9ac84b 100644 --- a/client/components/users/userAvatar.js +++ b/client/components/users/userAvatar.js @@ -137,6 +137,7 @@ Template.cardMembersPopup.helpers({ const cardMembers = Cards.findOne(cardId).members || []; return _.contains(cardMembers, this.userId); }, + user() { return Users.findOne(this.userId); }, diff --git a/collections/boards.js b/collections/boards.js index 8260fc3d..ddfa5016 100644 --- a/collections/boards.js +++ b/collections/boards.js @@ -123,16 +123,24 @@ Boards.helpers({ isPublic() { return this.permission === 'public'; }, + lists() { return Lists.find({ boardId: this._id, archived: false }, { sort: { sort: 1 }}); }, + activities() { return Activities.find({ boardId: this._id }, { sort: { createdAt: -1 }}); }, + + activeMembers() { + return _.where(this.members, {isActive: true}); + }, + absoluteUrl() { return FlowRouter.path('board', { id: this._id, slug: this.slug }); }, + colorClass() { return `board-color-${this.color}`; }, diff --git a/collections/users.js b/collections/users.js index 276c9f9e..34a94605 100644 --- a/collections/users.js +++ b/collections/users.js @@ -12,23 +12,27 @@ Users.helpers({ boards() { return Boards.find({ userId: this._id }); }, + starredBoards() { const starredBoardIds = this.profile.starredBoards || []; return Boards.find({archived: false, _id: {$in: starredBoardIds}}); }, + hasStarred(boardId) { const starredBoardIds = this.profile.starredBoards || []; return _.contains(starredBoardIds, boardId); }, + isBoardMember() { const board = Boards.findOne(Session.get('currentBoard')); return board && _.contains(_.pluck(board.members, 'userId'), this._id) && _.where(board.members, {userId: this._id})[0].isActive; }, + isBoardAdmin() { const board = Boards.findOne(Session.get('currentBoard')); - if (this.isBoardMember(board)) - return _.where(board.members, {userId: this._id})[0].isAdmin; + return board && this.isBoardMember(board) && + _.where(board.members, {userId: this._id})[0].isAdmin; }, getInitials() { |