summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-06-06 14:48:36 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-06-06 14:50:45 +0200
commit12919cbfc6c3fd0793624776b3afb70e3a0cdd1a (patch)
tree102b78eff3f2dcfa863d3361757144a4c7a8ab22
parent49167ccaa91376bf70c400013641f76d1164950e (diff)
downloadwekan-12919cbfc6c3fd0793624776b3afb70e3a0cdd1a.tar.gz
wekan-12919cbfc6c3fd0793624776b3afb70e3a0cdd1a.tar.bz2
wekan-12919cbfc6c3fd0793624776b3afb70e3a0cdd1a.zip
Restore the popup to add a member to the board
-rw-r--r--client/components/boards/boardHeader.jade4
-rw-r--r--client/components/boards/boardHeader.js2
-rw-r--r--client/components/sidebar/events.js76
-rw-r--r--client/components/sidebar/helpers.js37
-rw-r--r--client/components/sidebar/sidebar.jade50
-rw-r--r--client/components/sidebar/sidebar.js111
-rw-r--r--client/components/sidebar/templates.html77
7 files changed, 164 insertions, 193 deletions
diff --git a/client/components/boards/boardHeader.jade b/client/components/boards/boardHeader.jade
index 6f12b8cc..86fbe255 100644
--- a/client/components/boards/boardHeader.jade
+++ b/client/components/boards/boardHeader.jade
@@ -120,3 +120,7 @@ template(name="boardChangeTitlePopup")
| {{_ 'title'}}
input.js-board-name(type="text" value="{{title}}" autofocus)
input.primary.wide(type="submit" value="{{_ 'rename'}}")
+
+template(name="closeBoardPopup")
+ p {{_ 'close-board-pop'}}
+ button.js-confirm.negate.full(type="submit") {{_ 'close'}}
diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js
index 28238d4c..d0a1340c 100644
--- a/client/components/boards/boardHeader.js
+++ b/client/components/boards/boardHeader.js
@@ -33,7 +33,7 @@ BlazeComponent.extendComponent({
// Only show the star counter if the number of star is greater than 2
showStarCounter: function() {
var currentBoard = this.currentData();
- return currentBoard && currentBoard.stars > 2;
+ return currentBoard && currentBoard.stars >= 2;
},
events: function() {
diff --git a/client/components/sidebar/events.js b/client/components/sidebar/events.js
deleted file mode 100644
index a1aeb13a..00000000
--- a/client/components/sidebar/events.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var getMemberIndex = function(board, searchId) {
- for (var i = 0; i < board.members.length; i++) {
- if (board.members[i].userId === searchId)
- return i;
- }
- throw new Meteor.Error('Member not found');
-};
-
-Template.memberPopup.events({
- 'click .js-filter-member': function() {
- Filter.members.toogle(this.userId);
- Popup.close();
- },
- 'click .js-change-role': Popup.open('changePermissions'),
- 'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
- var currentBoard = Boards.findOne(Session.get('currentBoard'));
- var memberIndex = getMemberIndex(currentBoard, this.userId);
- var setQuery = {};
- setQuery[['members', memberIndex, 'isActive'].join('.')] = false;
- Boards.update(currentBoard._id, { $set: setQuery });
- Popup.close();
- }),
- 'click .js-leave-member': function() {
- // @TODO
- Popup.close();
- }
-});
-
-Template.membersWidget.events({
- 'click .js-open-manage-board-members': Popup.open('addMember'),
- 'click .member': Popup.open('member')
-});
-
-Template.labelsWidget.events({
- 'click .js-label': Popup.open('editLabel'),
- 'click .js-add-label': Popup.open('createLabel')
-});
-
-// Template.addMemberPopup.events({
-// 'click .pop-over-member-list li:not(.disabled)': function(event, t) {
-// var userId = this._id;
-// var boardId = t.data.board._id;
-// var currentMembersIds = _.pluck(t.data.board.members, 'userId');
-// if (currentMembersIds.indexOf(userId) === -1) {
-// Boards.update(boardId, {
-// $push: {
-// members: {
-// userId: userId,
-// isAdmin: false,
-// isActive: true
-// }
-// }
-// });
-// } else {
-// var memberIndex = getMemberIndex(t.data.board, userId);
-// var setQuery = {};
-// setQuery[['members', memberIndex, 'isActive'].join('.')] = true;
-// Boards.update(boardId, { $set: setQuery });
-// }
-// Popup.close();
-// }
-// });
-
-// Template.changePermissionsPopup.events({
-// 'click .js-set-admin, click .js-set-normal': function(event) {
-// var currentBoard = Boards.findOne(Session.get('currentBoard'));
-// var memberIndex = getMemberIndex(currentBoard, this.user._id);
-// var isAdmin = $(event.currentTarget).hasClass('js-set-admin');
-// var setQuery = {};
-// setQuery[['members', memberIndex, 'isAdmin'].join('.')] = isAdmin;
-// Boards.update(currentBoard._id, {
-// $set: setQuery
-// });
-// Popup.back(1);
-// }
-// });
diff --git a/client/components/sidebar/helpers.js b/client/components/sidebar/helpers.js
deleted file mode 100644
index 9d3340ad..00000000
--- a/client/components/sidebar/helpers.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Template.addMemberPopup.helpers({
-// isBoardMember: function() {
-// var user = Users.findOne(this._id);
-// return user && user.isBoardMember();
-// }
-// });
-
-Template.memberPopup.helpers({
- user: function() {
- return Users.findOne(this.userId);
- },
- memberType: function() {
- var type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
- return TAPi18n.__(type).toLowerCase();
- }
-});
-
-// Template.removeMemberPopup.helpers({
-// user: function() {
-// return Users.findOne(this.userId)
-// },
-// board: function() {
-// return currentBoard();
-// }
-// });
-
-// Template.changePermissionsPopup.helpers({
-// isAdmin: function() {
-// return this.user.isBoardAdmin();
-// },
-// isLastAdmin: function() {
-// if (! this.user.isBoardAdmin())
-// return false;
-// var nbAdmins = _.where(currentBoard().members, { isAdmin: true }).length;
-// return nbAdmins === 1;
-// }
-// });
diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade
index 7e237233..e6265a61 100644
--- a/client/components/sidebar/sidebar.jade
+++ b/client/components/sidebar/sidebar.jade
@@ -34,7 +34,8 @@ template(name="membersWidget")
showStatus=true)
unless isSandstorm
if currentUser.isBoardAdmin
- a.js-open-manage-board-members
+ a.member.add-member.js-manage-board-members
+ i.fa.fa-plus
.clearfix
template(name="labelsWidget")
@@ -54,7 +55,7 @@ template(name="memberPopup")
+userAvatar(user=user)
.info
h3.bottom
- a.js-profile(href="{{pathFor route='Profile' username=user.username}}")
+ .js-profile
= user.profile.name
p.quiet.bottom @#{user.username}
if currentUser.isBoardMember
@@ -71,3 +72,48 @@ template(name="memberPopup")
a.js-remove-member {{_ 'remove-from-board'}}
else
a.js-leave-member {{_ 'leave-board'}}
+
+
+template(name="removeMemberPopup")
+ p {{_ 'remove-member-pop' name=user.profile.name username=user.username boardTitle=board.title}}
+ button.js-confirm.negate.full(type="submit") {{_ 'remove-member'}}
+
+template(name="addMemberPopup")
+ .js-search-member
+ +esInput(index="users")
+
+ ul.pop-over-member-list
+ +esEach(index="users")
+ li.item.js-member-item(class="{{#if isBoardMember }}disabled{{/if}}")
+ a.name.js-select-member(title="{{ profile.name }} ({{ username }})")
+ +userAvatar(user=this size="small")
+ span.full-name
+ = profile.name
+ | (<span class="username">{{ username }}</span>)
+ if isBoardMember
+ .extra-text.quiet ({{_ 'joined'}})
+
+ +ifEsIsSearching(index='users')
+ +spinner
+
+ +ifEsHasNoResults(index="users")
+ .manage-member-section
+ p.quiet {{_ 'no-results'}}
+
+template(name="changePermissionsPopup")
+ ul.pop-over-list
+ li
+ a(class="{{#if isLastAdmin}}disabled{{else}}js-set-admin{{/if}}")
+ | {{_ 'admin'}}
+ if isAdmin
+ i.fa.fa-check
+ span.sub-name {{_ 'admin-desc'}}
+ li
+ a(class="{{#if isLastAdmin}}disabled{{else}}js-set-normal{{/if}}")
+ | {{_ 'normal'}}
+ unless isAdmin
+ i.fa.fa-check
+ span.sub-name {{_ 'normal-desc'}}
+ if isLastAdmin
+ hr
+ p.quiet.bottom {{_ 'last-admin-desc'}}
diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js
index 777d72e1..f3844fcd 100644
--- a/client/components/sidebar/sidebar.js
+++ b/client/components/sidebar/sidebar.js
@@ -132,3 +132,114 @@ EscapeActions.register('sidebarView',
function() { Sidebar.setView(defaultView); },
function() { return Sidebar && Sidebar.getView() !== defaultView; }
);
+
+var getMemberIndex = function(board, searchId) {
+ for (var i = 0; i < board.members.length; i++) {
+ if (board.members[i].userId === searchId)
+ return i;
+ }
+ throw new Meteor.Error('Member not found');
+};
+
+Template.memberPopup.helpers({
+ user: function() {
+ return Users.findOne(this.userId);
+ },
+ memberType: function() {
+ var type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
+ return TAPi18n.__(type).toLowerCase();
+ }
+});
+
+Template.memberPopup.events({
+ 'click .js-filter-member': function() {
+ Filter.members.toogle(this.userId);
+ Popup.close();
+ },
+ 'click .js-change-role': Popup.open('changePermissions'),
+ 'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
+ var currentBoard = Boards.findOne(Session.get('currentBoard'));
+ var memberIndex = getMemberIndex(currentBoard, this.userId);
+ var setQuery = {};
+ setQuery[['members', memberIndex, 'isActive'].join('.')] = false;
+ Boards.update(currentBoard._id, { $set: setQuery });
+ Popup.close();
+ }),
+ 'click .js-leave-member': function() {
+ // XXX Not implemented
+ Popup.close();
+ }
+});
+
+Template.membersWidget.events({
+ 'click .js-member': Popup.open('member'),
+ 'click .js-manage-board-members': Popup.open('addMember')
+});
+
+Template.labelsWidget.events({
+ 'click .js-label': Popup.open('editLabel'),
+ 'click .js-add-label': Popup.open('createLabel')
+});
+
+Template.addMemberPopup.helpers({
+ isBoardMember: function() {
+ var user = Users.findOne(this._id);
+ return user && user.isBoardMember();
+ }
+});
+
+Template.addMemberPopup.events({
+ 'click .pop-over-member-list li:not(.disabled)': function() {
+ var userId = this._id;
+ var currentBoard = Boards.findOne(Session.get('currentBoard'));
+ var currentMembersIds = _.pluck(currentBoard.members, 'userId');
+ if (currentMembersIds.indexOf(userId) === -1) {
+ Boards.update(currentBoard._id, {
+ $push: {
+ members: {
+ userId: userId,
+ isAdmin: false,
+ isActive: true
+ }
+ }
+ });
+ } else {
+ var memberIndex = getMemberIndex(currentBoard, userId);
+ var setQuery = {};
+ setQuery[['members', memberIndex, 'isActive'].join('.')] = true;
+ Boards.update(currentBoard._id, { $set: setQuery });
+ }
+ Popup.close();
+ }
+});
+
+Template.addMemberPopup.onRendered(function() {
+ this.find('.js-search-member input').focus();
+});
+
+Template.changePermissionsPopup.events({
+ 'click .js-set-admin, click .js-set-normal': function(event) {
+ var currentBoard = Boards.findOne(Session.get('currentBoard'));
+ var memberIndex = getMemberIndex(currentBoard, this.user._id);
+ var isAdmin = $(event.currentTarget).hasClass('js-set-admin');
+ var setQuery = {};
+ setQuery[['members', memberIndex, 'isAdmin'].join('.')] = isAdmin;
+ Boards.update(currentBoard._id, {
+ $set: setQuery
+ });
+ Popup.back(1);
+ }
+});
+
+Template.changePermissionsPopup.helpers({
+ isAdmin: function() {
+ return this.user.isBoardAdmin();
+ },
+ isLastAdmin: function() {
+ if (! this.user.isBoardAdmin())
+ return false;
+ var currentBoard = Boards.findOne(Session.get('currentBoard'));
+ var nbAdmins = _.where(currentBoard.members, { isAdmin: true }).length;
+ return nbAdmins === 1;
+ }
+});
diff --git a/client/components/sidebar/templates.html b/client/components/sidebar/templates.html
deleted file mode 100644
index 12e7be0a..00000000
--- a/client/components/sidebar/templates.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!-- XXX Translate these template into jade -->
-<template name="closeBoardPopup">
- <p>{{_ 'close-board-pop'}}</p>
- <input type="submit" class="js-confirm negate full" value="{{_ 'close'}}">
-</template>
-
-<template name="removeMemberPopup">
- <p>{{_ 'remove-member-pop'
- name=user.profile.name
- username=user.username
- boardTitle=board.title}}</p>
- <input type="submit" class="js-confirm negate full" value="{{_ 'remove-member'}}">
-</template>
-
-<template name="addMemberPopup">
- <div class="search-with-spinner">
- {{> esInput index="users" }}
- </div>
-
- <div class="manage-member-section hide js-search-results" style="display: block;">
- <ul class="pop-over-member-list options js-list">
- {{# esEach index="users"}}
- <li class="item js-member-item {{# if isBoardMember }}disabled{{/if}}">
- <a href="#" class="name js-select-member {{# if isBoardMember }}multi-line{{/if}}" title="{{ profile.name }} ({{ username }})">
- {{> userAvatar user=this size="small" }}
- <span class="full-name">
- {{ profile.name }} (<span class="username">{{ username }}</span>)
- </span>
- {{# if isBoardMember }}
- <div class="extra-text quiet">({{_ 'joined'}})</div>
- {{/if}}
- <span class="icon-sm fa fa-chevron-right light option js-open-option"></span>
- </a>
- </li>
- {{/esEach }}
- </ul>
- </div>
-
- {{# ifEsIsSearching index='users' }}
- <div class="tac">
- <span class="tabbed-pane-main-col-loading-spinner spinner"></span>
- </div>
- {{ /ifEsIsSearching }}
-
- {{# ifEsHasNoResults index="users" }}
- <div class="manage-member-section js-no-results">
- <p class="quiet center" style="padding: 16px 4px;">{{_ 'no-results'}}</p>
- </div>
- {{ /ifEsHasNoResults }}
-
- <div class="manage-member-section js-helper">
- <p class="bottom quiet" style="padding: 6px;">{{_ 'search-member-desc'}}</p>
- </div>
-</template>
-
-<template name="changePermissionsPopup">
- <ul class="pop-over-list">
- <li>
- <a class="{{#if isLastAdmin}}disabled{{else}}js-set-admin{{/if}}">
- {{_ 'admin'}}
- {{#if isAdmin}}<span class="icon-sm fa fa-check"></span>{{/if}}
- <span class="sub-name">{{_ 'admin-desc'}}</span>
- </a>
- </li>
- <li>
- <a class="{{#if isLastAdmin}}disabled{{else}}js-set-normal{{/if}}">
- {{_ 'normal'}}
- {{#unless isAdmin}}<span class="icon-sm fa fa-check"></span>{{/unless}}
- <span class="sub-name">{{_ 'normal-desc'}}</span>
- </a>
- </li>
- </ul>
- {{#if isLastAdmin}}
- <hr>
- <p class="quiet bottom">{{_ 'last-admin-desc'}}</p>
- {{/if}}
-</template>