summaryrefslogtreecommitdiffstats
path: root/client/components/users
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/users')
-rw-r--r--client/components/users/userAvatar.js124
-rw-r--r--client/components/users/userHeader.js43
2 files changed, 83 insertions, 84 deletions
diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js
index a35415e2..b0702468 100644
--- a/client/components/users/userAvatar.js
+++ b/client/components/users/userAvatar.js
@@ -1,98 +1,98 @@
Meteor.subscribe('my-avatars');
Template.userAvatar.helpers({
- userData: function() {
+ userData() {
return Users.findOne(this.userId, {
fields: {
profile: 1,
- username: 1
- }
+ username: 1,
+ },
});
},
- memberType: function() {
- var user = Users.findOne(this.userId);
+ memberType() {
+ const user = Users.findOne(this.userId);
return user && user.isBoardAdmin() ? 'admin' : 'normal';
},
- presenceStatusClassName: function() {
- var userPresence = Presences.findOne({ userId: this.userId });
- if (! userPresence)
+ presenceStatusClassName() {
+ const userPresence = Presences.findOne({ userId: this.userId });
+ if (!userPresence)
return 'disconnected';
else if (Session.equals('currentBoard', userPresence.state.currentBoardId))
return 'active';
else
return 'idle';
- }
+ },
});
Template.userAvatar.events({
- 'click .js-change-avatar': Popup.open('changeAvatar')
+ 'click .js-change-avatar': Popup.open('changeAvatar'),
});
Template.userAvatarInitials.helpers({
- initials: function() {
- var user = Users.findOne(this.userId);
+ initials() {
+ const user = Users.findOne(this.userId);
return user && user.getInitials();
},
- viewPortWidth: function() {
- var user = Users.findOne(this.userId);
+ viewPortWidth() {
+ const user = Users.findOne(this.userId);
return (user && user.getInitials().length || 1) * 12;
- }
+ },
});
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'changeAvatarPopup';
},
- onCreated: function() {
+ onCreated() {
this.error = new ReactiveVar('');
},
- avatarUrlOptions: function() {
+ avatarUrlOptions() {
return {
auth: false,
- brokenIsFine: true
+ brokenIsFine: true,
};
},
- uploadedAvatars: function() {
+ uploadedAvatars() {
return Avatars.find({userId: Meteor.userId()});
},
- isSelected: function() {
- var userProfile = Meteor.user().profile;
- var avatarUrl = userProfile && userProfile.avatarUrl;
- var currentAvatarUrl = this.currentData().url(this.avatarUrlOptions());
+ isSelected() {
+ const userProfile = Meteor.user().profile;
+ const avatarUrl = userProfile && userProfile.avatarUrl;
+ const currentAvatarUrl = this.currentData().url(this.avatarUrlOptions());
return avatarUrl === currentAvatarUrl;
},
- noAvatarUrl: function() {
- var userProfile = Meteor.user().profile;
- var avatarUrl = userProfile && userProfile.avatarUrl;
- return ! avatarUrl;
+ noAvatarUrl() {
+ const userProfile = Meteor.user().profile;
+ const avatarUrl = userProfile && userProfile.avatarUrl;
+ return !avatarUrl;
},
- setAvatar: function(avatarUrl) {
+ setAvatar(avatarUrl) {
Meteor.users.update(Meteor.userId(), {
$set: {
- 'profile.avatarUrl': avatarUrl
- }
+ 'profile.avatarUrl': avatarUrl,
+ },
});
},
- setError: function(error) {
+ setError(error) {
this.error.set(error);
},
- events: function() {
+ events() {
return [{
- 'click .js-upload-avatar': function() {
+ 'click .js-upload-avatar'() {
this.$('.js-upload-avatar-input').click();
},
- 'change .js-upload-avatar-input': function(evt) {
+ 'change .js-upload-avatar-input'(evt) {
let file, fileUrl;
FS.Utility.eachFile(evt, (f) => {
@@ -106,71 +106,71 @@ BlazeComponent.extendComponent({
if (fileUrl) {
this.setError('');
- let fetchAvatarInterval = window.setInterval(() => {
+ const fetchAvatarInterval = window.setInterval(() => {
$.ajax({
url: fileUrl,
success: () => {
this.setAvatar(file.url(this.avatarUrlOptions()));
window.clearInterval(fetchAvatarInterval);
- }
+ },
});
}, 100);
}
},
- 'click .js-select-avatar': function() {
- var avatarUrl = this.currentData().url(this.avatarUrlOptions());
+ 'click .js-select-avatar'() {
+ const avatarUrl = this.currentData().url(this.avatarUrlOptions());
this.setAvatar(avatarUrl);
},
- 'click .js-select-initials': function() {
+ 'click .js-select-initials'() {
this.setAvatar('');
},
- 'click .js-delete-avatar': function() {
+ 'click .js-delete-avatar'() {
Avatars.remove(this.currentData()._id);
- }
+ },
}];
- }
+ },
}).register('changeAvatarPopup');
Template.cardMembersPopup.helpers({
- isCardMember: function() {
- var cardId = Template.parentData()._id;
- var cardMembers = Cards.findOne(cardId).members || [];
+ isCardMember() {
+ const cardId = Template.parentData()._id;
+ const cardMembers = Cards.findOne(cardId).members || [];
return _.contains(cardMembers, this.userId);
},
- user: function() {
+ user() {
return Users.findOne(this.userId);
- }
+ },
});
Template.cardMembersPopup.events({
- 'click .js-select-member': function(evt) {
- var cardId = Template.parentData(2).data._id;
- var memberId = this.userId;
- var operation;
+ 'click .js-select-member'(evt) {
+ const cardId = Template.parentData(2).data._id;
+ const memberId = this.userId;
+ let operation;
if (Cards.find({ _id: cardId, members: memberId}).count() === 0)
operation = '$addToSet';
else
operation = '$pull';
- var query = {};
- query[operation] = {
- members: memberId
- };
- Cards.update(cardId, query);
+ Cards.update(cardId, {
+ [operation]: {
+ members: memberId,
+ },
+ });
evt.preventDefault();
- }
+ },
});
Template.cardMemberPopup.helpers({
- user: function() {
+ user() {
return Users.findOne(this.userId);
- }
+ },
});
Template.cardMemberPopup.events({
- 'click .js-remove-member': function() {
+ 'click .js-remove-member'() {
Cards.update(this.cardId, {$pull: {members: this.userId}});
Popup.close();
},
- 'click .js-edit-profile': Popup.open('editProfile')
+ 'click .js-edit-profile': Popup.open('editProfile'),
});
diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js
index 2110faa6..d8b1ee48 100644
--- a/client/components/users/userHeader.js
+++ b/client/components/users/userHeader.js
@@ -1,6 +1,6 @@
Template.headerUserBar.events({
'click .js-open-header-member-menu': Popup.open('memberMenu'),
- 'click .js-change-avatar': Popup.open('changeAvatar')
+ 'click .js-change-avatar': Popup.open('changeAvatar'),
});
Template.memberMenuPopup.events({
@@ -8,58 +8,57 @@ Template.memberMenuPopup.events({
'click .js-change-avatar': Popup.open('changeAvatar'),
'click .js-change-password': Popup.open('changePassword'),
'click .js-change-language': Popup.open('changeLanguage'),
- 'click .js-logout': function(evt) {
+ 'click .js-logout'(evt) {
evt.preventDefault();
AccountsTemplates.logout();
- }
+ },
});
Template.editProfilePopup.events({
- submit: function(evt, tpl) {
+ submit(evt, tpl) {
evt.preventDefault();
- var fullname = $.trim(tpl.find('.js-profile-fullname').value);
- var username = $.trim(tpl.find('.js-profile-username').value);
- var initials = $.trim(tpl.find('.js-profile-initials').value);
+ const fullname = $.trim(tpl.find('.js-profile-fullname').value);
+ const username = $.trim(tpl.find('.js-profile-username').value);
+ const initials = $.trim(tpl.find('.js-profile-initials').value);
Users.update(Meteor.userId(), {$set: {
'profile.fullname': fullname,
- 'profile.initials': initials
+ 'profile.initials': initials,
}});
// XXX We should report the error to the user.
if (username !== Meteor.user().username) {
Meteor.call('setUsername', username);
}
Popup.back();
- }
+ },
});
// XXX For some reason the useraccounts autofocus isnt working in this case.
// See https://github.com/meteor-useraccounts/core/issues/384
-Template.changePasswordPopup.onRendered(function() {
+Template.changePasswordPopup.onRendered(() => {
this.find('#at-field-current_password').focus();
});
Template.changeLanguagePopup.helpers({
- languages: function() {
- return _.map(TAPi18n.getLanguages(), function(lang, tag) {
- return {
- tag: tag,
- name: lang.name
- };
+ languages() {
+ return _.map(TAPi18n.getLanguages(), (lang, tag) => {
+ const name = lang.name;
+ return { tag, name };
});
},
- isCurrentLanguage: function() {
+
+ isCurrentLanguage() {
return this.tag === TAPi18n.getLanguage();
- }
+ },
});
Template.changeLanguagePopup.events({
- 'click .js-set-language': function(evt) {
+ 'click .js-set-language'(evt) {
Users.update(Meteor.userId(), {
$set: {
- 'profile.language': this.tag
- }
+ 'profile.language': this.tag,
+ },
});
evt.preventDefault();
- }
+ },
});