mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Since 07cc454 (ie the switch to Meteor 1.2) we includes the `es5-shim`
polyfill to support methods like `Array.prototype.forEach` in a
consistent way across all supported browsers (IE8+).
MDG recently released a blog post recommending the use of these native
methods instead of underscore [0]. We know follow this recommendation.
This commit also favor some ES6 features (argument defaults,
destructing assignment) in places where we didn’t use them.
[0]: http://info.meteor.com/blog/es2015-get-started
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
Template.headerUserBar.events({
|
|
'click .js-open-header-member-menu': Popup.open('memberMenu'),
|
|
'click .js-change-avatar': Popup.open('changeAvatar'),
|
|
});
|
|
|
|
Template.memberMenuPopup.events({
|
|
'click .js-edit-profile': Popup.open('editProfile'),
|
|
'click .js-change-avatar': Popup.open('changeAvatar'),
|
|
'click .js-change-password': Popup.open('changePassword'),
|
|
'click .js-change-language': Popup.open('changeLanguage'),
|
|
'click .js-logout'(evt) {
|
|
evt.preventDefault();
|
|
|
|
AccountsTemplates.logout();
|
|
},
|
|
});
|
|
|
|
Template.editProfilePopup.events({
|
|
submit(evt, tpl) {
|
|
evt.preventDefault();
|
|
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,
|
|
}});
|
|
// 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() {
|
|
this.find('#at-field-current_password').focus();
|
|
});
|
|
|
|
Template.changeLanguagePopup.helpers({
|
|
languages() {
|
|
return TAPi18n.getLanguages().map((lang, tag) => {
|
|
const name = lang.name;
|
|
return { tag, name };
|
|
});
|
|
},
|
|
|
|
isCurrentLanguage() {
|
|
return this.tag === TAPi18n.getLanguage();
|
|
},
|
|
});
|
|
|
|
Template.changeLanguagePopup.events({
|
|
'click .js-set-language'(evt) {
|
|
Users.update(Meteor.userId(), {
|
|
$set: {
|
|
'profile.language': this.tag,
|
|
},
|
|
});
|
|
evt.preventDefault();
|
|
},
|
|
});
|