summaryrefslogtreecommitdiffstats
path: root/client/components/sidebar
diff options
context:
space:
mode:
authorfloatinghotpot <rjfun.mobile@gmail.com>2015-12-07 11:15:57 +0800
committerfloatinghotpot <rjfun.mobile@gmail.com>2015-12-07 11:15:57 +0800
commit011f53ad0828c0979d15e232abf501180c741288 (patch)
tree41330fe4e47c443dd9fefd0493f30a186e4c4999 /client/components/sidebar
parentd4c5310d65cbdfbd002288d33eba429ace33bc3c (diff)
downloadwekan-011f53ad0828c0979d15e232abf501180c741288.tar.gz
wekan-011f53ad0828c0979d15e232abf501180c741288.tar.bz2
wekan-011f53ad0828c0979d15e232abf501180c741288.zip
add: invite user via email, invited user can accept or decline, allow member to quit
Diffstat (limited to 'client/components/sidebar')
-rw-r--r--client/components/sidebar/sidebar.jade51
-rw-r--r--client/components/sidebar/sidebar.js109
2 files changed, 127 insertions, 33 deletions
diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade
index f98ea4ee..3a5c7fdb 100644
--- a/client/components/sidebar/sidebar.jade
+++ b/client/components/sidebar/sidebar.jade
@@ -33,6 +33,13 @@ template(name="membersWidget")
a.member.add-member.js-manage-board-members
i.fa.fa-plus
.clearfix
+ if isInvited
+ hr
+ p
+ i.fa.fa-exclamation-circle
+ | {{_ 'just-invited'}}
+ button.js-member-invite-accept.primary {{_ 'accept'}}
+ button.js-member-invite-decline {{_ 'decline'}}
template(name="labelsWidget")
.board-widget.board-widget-labels
@@ -56,6 +63,10 @@ template(name="memberPopup")
h3
.js-profile= user.profile.fullname
p.quiet @#{user.username}
+ if isInvited
+ p
+ i.fa.fa-exclamation-circle
+ | {{_ 'not-accepted-yet'}}
ul.pop-over-list
li
@@ -68,9 +79,7 @@ template(name="memberPopup")
span.quiet (#{memberType})
li
if $eq currentUser._id userId
- //-
- XXX Not implemented!
- // a.js-leave-member {{_ 'leave-board'}}
+ a.js-leave-member {{_ 'leave-board'}}
else
a.js-remove-member {{_ 'remove-from-board'}}
@@ -83,23 +92,29 @@ template(name="addMemberPopup")
.js-search-member
+esInput(index="users")
- 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}})")
- +userAvatar(userId=_id esSearch=true)
- span.full-name
- = profile.fullname
- | (<span class="username">{{username}}</span>)
- if isBoardMember
- .quiet ({{_ 'joined'}})
+ if loading.get
+ +spinner
+ else if error.get
+ .warning {{_ error.get}}
+ else
+ 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}})")
+ +userAvatar(userId=_id esSearch=true)
+ span.full-name
+ = profile.fullname
+ | (<span class="username">{{username}}</span>)
+ if isBoardMember
+ .quiet ({{_ 'joined'}})
- +ifEsIsSearching(index='users')
- +spinner
+ +ifEsIsSearching(index='users')
+ +spinner
- +ifEsHasNoResults(index="users")
- .manage-member-section
- p.quiet {{_ 'no-results'}}
+ +ifEsHasNoResults(index="users")
+ .manage-member-section
+ p.quiet {{_ 'no-results'}}
+ button.js-email-invite.primary.full {{_ 'email-invite'}}
template(name="changePermissionsPopup")
ul.pop-over-list
diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js
index ef071fe0..5b58dbd9 100644
--- a/client/components/sidebar/sidebar.js
+++ b/client/components/sidebar/sidebar.js
@@ -117,6 +117,9 @@ Template.memberPopup.helpers({
const type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
return TAPi18n.__(type).toLowerCase();
},
+ isInvited() {
+ return Users.findOne(this.userId).isInvitedTo(Session.get('currentBoard'));
+ },
});
Template.memberPopup.events({
@@ -132,8 +135,13 @@ Template.memberPopup.events({
Popup.close();
}),
'click .js-leave-member'() {
- // XXX Not implemented
- Popup.close();
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ Meteor.call('quitBoard', currentBoard, (err, ret) => {
+ if (!ret && ret) {
+ Popup.close();
+ FlowRouter.go('home');
+ }
+ });
},
});
@@ -146,9 +154,29 @@ Template.removeMemberPopup.helpers({
},
});
+Template.membersWidget.helpers({
+ isInvited() {
+ const user = Meteor.user();
+ return user && user.isInvitedTo(Session.get('currentBoard'));
+ },
+});
+
Template.membersWidget.events({
'click .js-member': Popup.open('member'),
'click .js-manage-board-members': Popup.open('addMember'),
+ 'click .js-member-invite-accept'() {
+ const boardId = Session.get('currentBoard');
+ Meteor.user().removeInvite(boardId);
+ },
+ 'click .js-member-invite-decline'() {
+ const boardId = Session.get('currentBoard');
+ Meteor.call('quitBoard', boardId, (err, ret) => {
+ if (!err && ret) {
+ Meteor.user().removeInvite(boardId);
+ FlowRouter.go('home');
+ }
+ });
+ },
});
Template.labelsWidget.events({
@@ -194,25 +222,76 @@ function draggableMembersLabelsWidgets() {
Template.membersWidget.onRendered(draggableMembersLabelsWidgets);
Template.labelsWidget.onRendered(draggableMembersLabelsWidgets);
-Template.addMemberPopup.helpers({
+BlazeComponent.extendComponent({
+ template() {
+ return 'addMemberPopup';
+ },
+
+ onCreated() {
+ this.error = new ReactiveVar('');
+ this.loading = new ReactiveVar(false);
+ },
+
+ onRendered() {
+ this.find('.js-search-member input').focus();
+ this.setLoading(false);
+ },
+
isBoardMember() {
- const user = Users.findOne(this._id);
+ const userId = this.currentData()._id;
+ const user = Users.findOne(userId);
return user && user.isBoardMember();
},
-});
-Template.addMemberPopup.events({
- 'click .js-select-member'() {
- const userId = this._id;
- const currentBoard = Boards.findOne(Session.get('currentBoard'));
- currentBoard.addMember(userId);
- Popup.close();
+ isValidEmail(email) {
+ return SimpleSchema.RegEx.Email.test(email);
},
-});
-Template.addMemberPopup.onRendered(function() {
- this.find('.js-search-member input').focus();
-});
+ setError(error) {
+ this.error.set(error);
+ },
+
+ setLoading(w) {
+ this.loading.set(w);
+ },
+
+ isLoading() {
+ return this.loading.get();
+ },
+
+ inviteUser(idNameEmail) {
+ const boardId = Session.get('currentBoard');
+ this.setLoading(true);
+ const self = this;
+ Meteor.call('inviteUserToBoard', idNameEmail, boardId, (err, ret) => {
+ self.setLoading(false);
+ if (err) self.setError(err.error);
+ else if (ret.email) self.setError('email-sent');
+ else Popup.close();
+ });
+ },
+
+ events() {
+ return [{
+ 'keyup input'() {
+ this.setError('');
+ },
+ 'click .js-select-member'() {
+ const userId = this.currentData()._id;
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ if (currentBoard.memberIndex(userId)<0) {
+ this.inviteUser(userId);
+ }
+ },
+ 'click .js-email-invite'() {
+ const idNameEmail = $('.js-search-member input').val();
+ if (idNameEmail.indexOf('@')<0 || this.isValidEmail(idNameEmail)) {
+ this.inviteUser(idNameEmail);
+ } else this.setError('email-invalid');
+ },
+ }];
+ },
+}).register('addMemberPopup');
Template.changePermissionsPopup.events({
'click .js-set-admin, click .js-set-normal'(event) {