summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-11-18 23:37:15 +0200
committerLauri Ojansivu <x@xet7.org>2017-11-18 23:37:15 +0200
commit22e43e659167f0a5a1e9d2c2d4c20996835bd28b (patch)
tree21fc2d536176ad54eba926eb937da091b6b115ae /client
parent13d8e75c05cf8ed90c4b5d8ee5aadad0f9444b8f (diff)
parentb4c3e02b75c2fc9eca3af668fdd8b27b9afaa279 (diff)
downloadwekan-22e43e659167f0a5a1e9d2c2d4c20996835bd28b.tar.gz
wekan-22e43e659167f0a5a1e9d2c2d4c20996835bd28b.tar.bz2
wekan-22e43e659167f0a5a1e9d2c2d4c20996835bd28b.zip
Merge branch 'devel' of https://github.com/thuanpq/wekan into thuanpq-devel
Diffstat (limited to 'client')
-rw-r--r--client/components/settings/peopleBody.jade89
-rw-r--r--client/components/settings/peopleBody.js156
-rw-r--r--client/components/settings/peopleBody.styl15
-rw-r--r--client/components/settings/settingHeader.jade9
-rw-r--r--client/components/users/userHeader.js10
5 files changed, 270 insertions, 9 deletions
diff --git a/client/components/settings/peopleBody.jade b/client/components/settings/peopleBody.jade
new file mode 100644
index 00000000..34004d31
--- /dev/null
+++ b/client/components/settings/peopleBody.jade
@@ -0,0 +1,89 @@
+template(name="people")
+ .setting-content
+ unless currentUser.isAdmin
+ | {{_ 'error-notAuthorized'}}
+ else
+ .content-title
+ span {{_ 'people'}}
+ .content-body
+ .side-menu
+ ul
+ li.active
+ a.js-setting-menu(data-id="people-setting") {{_ 'people'}}
+ .main-body
+ if loading.get
+ +spinner
+ else if people.get
+ +peopleGeneral
+
+template(name="peopleGeneral")
+ table
+ tbody
+ tr
+ th {{_ 'username'}}
+ th {{_ 'fullname'}}
+ th {{_ 'isAdmin'}}
+ th {{_ 'email'}}
+ th {{_ 'verified'}}
+ th {{_ 'createdAt'}}
+ th {{_ 'active'}}
+ th
+ each user in peopleList
+ +peopleRow(userId=user._id)
+
+template(name="peopleRow")
+ tr
+ td.username {{ userData.username }}
+ td {{ userData.profile.fullname }}
+ td
+ if userData.isAdmin
+ | true
+ else
+ | false
+ td {{ userData.emails.[0].address }}
+ td
+ if userData.emails.[0].verified
+ | true
+ else
+ | false
+ td {{ moment userData.createdAt 'LLL' }}
+ td
+ if userData.loginDisabled
+ | false
+ else
+ | true
+ td
+ a.edit-user
+ | edit
+
+template(name="editUserPopup")
+ form
+ label.hide.userId(type="text" value=user._id)
+ label
+ | {{_ 'fullname'}}
+ input.js-profile-fullname(type="text" value=user.profile.fullname autofocus)
+ label
+ | {{_ 'username'}}
+ span.error.hide.username-taken
+ | {{_ 'error-username-taken'}}
+ input.js-profile-username(type="text" value=user.username)
+ label
+ | {{_ 'initials'}}
+ input.js-profile-initials(type="text" value=user.profile.initials)
+ label
+ | {{_ 'email'}}
+ span.error.hide.email-taken
+ | {{_ 'error-email-taken'}}
+ input.js-profile-email(type="email" value="{{user.emails.[0].address}}")
+ label
+ | {{_ 'isAdmin'}}
+ select.select-role.js-profile-isadmin
+ option(value="false") No
+ option(value="true" selected="{{user.isAdmin}}") Yes
+ label
+ | {{_ 'isActive'}}
+ select.select-active.js-profile-isactive
+ option(value="false") Yes
+ option(value="true" selected="{{user.loginDisabled}}") No
+
+ input.primary.wide(type="submit" value="{{_ 'save'}}")
diff --git a/client/components/settings/peopleBody.js b/client/components/settings/peopleBody.js
new file mode 100644
index 00000000..d0da60d0
--- /dev/null
+++ b/client/components/settings/peopleBody.js
@@ -0,0 +1,156 @@
+const usersPerPage = 25;
+
+BlazeComponent.extendComponent({
+ mixins() {
+ return [Mixins.InfiniteScrolling];
+ },
+ onCreated() {
+ this.error = new ReactiveVar('');
+ this.loading = new ReactiveVar(false);
+ this.people = new ReactiveVar(true);
+
+ this.page = new ReactiveVar(1);
+ this.loadNextPageLocked = false;
+ this.callFirstWith(null, 'resetNextPeak');
+ this.autorun(() => {
+ const limit = this.page.get() * usersPerPage;
+
+ this.subscribe('people', limit, () => {
+ this.loadNextPageLocked = false;
+ const nextPeakBefore = this.callFirstWith(null, 'getNextPeak');
+ this.calculateNextPeak();
+ const nextPeakAfter = this.callFirstWith(null, 'getNextPeak');
+ if (nextPeakBefore === nextPeakAfter) {
+ this.callFirstWith(null, 'resetNextPeak');
+ }
+ });
+ });
+ },
+ loadNextPage() {
+ if (this.loadNextPageLocked === false) {
+ this.page.set(this.page.get() + 1);
+ this.loadNextPageLocked = true;
+ }
+ },
+ calculateNextPeak() {
+ const element = this.find('.main-body');
+ if (element) {
+ const altitude = element.scrollHeight;
+ this.callFirstWith(this, 'setNextPeak', altitude);
+ }
+ },
+ reachNextPeak() {
+ this.loadNextPage();
+ },
+ setError(error) {
+ this.error.set(error);
+ },
+ setLoading(w) {
+ this.loading.set(w);
+ },
+ peopleList() {
+ return Users.find({}, {
+ fields: {_id: true},
+ });
+ },
+}).register('people');
+
+Template.peopleRow.helpers({
+ userData() {
+ const userCollection = this.esSearch ? ESSearchResults : Users;
+ return userCollection.findOne(this.userId);
+ },
+});
+
+Template.editUserPopup.helpers({
+ user() {
+ return Users.findOne(this.userId);
+ },
+});
+
+BlazeComponent.extendComponent({
+ onCreated() {
+ },
+ user() {
+ return Users.findOne(this.userId);
+ },
+ events() {
+ return [{
+ 'click a.edit-user': Popup.open('editUser'),
+ }];
+ },
+}).register('peopleRow');
+
+Template.editUserPopup.events({
+ submit(evt, tpl) {
+ evt.preventDefault();
+ const user = Users.findOne(this.userId);
+ const fullname = tpl.find('.js-profile-fullname').value.trim();
+ const username = tpl.find('.js-profile-username').value.trim();
+ const initials = tpl.find('.js-profile-initials').value.trim();
+ const isAdmin = tpl.find('.js-profile-isadmin').value.trim();
+ const isActive = tpl.find('.js-profile-isactive').value.trim();
+ const email = tpl.find('.js-profile-email').value.trim();
+ let isChangeUserName = false;
+ let isChangeEmail = false;
+
+ Users.update(this.userId, {
+ $set: {
+ 'profile.fullname': fullname,
+ 'profile.initials': initials,
+ 'isAdmin': isAdmin === 'true',
+ 'loginDisabled': isActive === 'true',
+ },
+ });
+
+ isChangeUserName = username !== user.username;
+ isChangeEmail = email.toLowerCase() !== user.emails[0].address.toLowerCase();
+
+ if (isChangeUserName && isChangeEmail) {
+ Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), this.userId, function (error) {
+ const usernameMessageElement = tpl.$('.username-taken');
+ const emailMessageElement = tpl.$('.email-taken');
+ if (error) {
+ const errorElement = error.error;
+ if (errorElement === 'username-already-taken') {
+ usernameMessageElement.show();
+ emailMessageElement.hide();
+ } else if (errorElement === 'email-already-taken') {
+ usernameMessageElement.hide();
+ emailMessageElement.show();
+ }
+ } else {
+ usernameMessageElement.hide();
+ emailMessageElement.hide();
+ Popup.close();
+ }
+ });
+ } else if (isChangeUserName) {
+ Meteor.call('setUsername', username, this.userId, function (error) {
+ const usernameMessageElement = tpl.$('.username-taken');
+ if (error) {
+ const errorElement = error.error;
+ if (errorElement === 'username-already-taken') {
+ usernameMessageElement.show();
+ }
+ } else {
+ usernameMessageElement.hide();
+ Popup.close();
+ }
+ });
+ } else if (isChangeEmail) {
+ Meteor.call('setEmail', email.toLowerCase(), this.userId, function (error) {
+ const emailMessageElement = tpl.$('.email-taken');
+ if (error) {
+ const errorElement = error.error;
+ if (errorElement === 'email-already-taken') {
+ emailMessageElement.show();
+ }
+ } else {
+ emailMessageElement.hide();
+ Popup.close();
+ }
+ });
+ } else Popup.close();
+ },
+});
diff --git a/client/components/settings/peopleBody.styl b/client/components/settings/peopleBody.styl
new file mode 100644
index 00000000..2e89ea3b
--- /dev/null
+++ b/client/components/settings/peopleBody.styl
@@ -0,0 +1,15 @@
+.main-body
+ overflow: scroll;
+
+table
+ font-family: arial, sans-serif;
+ border-collapse: collapse;
+ width: 100%;
+
+ td, th
+ border: 1px solid #d2d0d0;
+ text-align: left;
+ padding: 8px;
+
+ tr:nth-child(even)
+ background-color: #dddddd;
diff --git a/client/components/settings/settingHeader.jade b/client/components/settings/settingHeader.jade
index c22cf5c6..e9ea218a 100644
--- a/client/components/settings/settingHeader.jade
+++ b/client/components/settings/settingHeader.jade
@@ -9,13 +9,14 @@ template(name="settingHeaderBar")
a.setting-header-btn.settings(href="{{pathFor 'setting'}}")
i.fa(class="fa-cog")
span {{_ 'settings'}}
+
a.setting-header-btn.informations(href="{{pathFor 'information'}}")
i.fa(class="fa-info-circle")
span {{_ 'info'}}
-//TODO
-// a.setting-header-btn.people
-// i.fa(class="fa-users")
-// span {{_ 'people'}}
+
+ a.setting-header-btn.people(href="{{pathFor 'people'}}")
+ i.fa(class="fa-users")
+ span {{_ 'people'}}
else
a.setting-header-btn.js-log-in(
diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js
index 90205ee1..481b13c3 100644
--- a/client/components/users/userHeader.js
+++ b/client/components/users/userHeader.js
@@ -42,7 +42,7 @@ Template.editProfilePopup.events({
isChangeUserName = username !== Meteor.user().username;
isChangeEmail = email.toLowerCase() !== Meteor.user().emails[0].address.toLowerCase();
if (isChangeUserName && isChangeEmail) {
- Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), function(error) {
+ Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), Meteor.userId(), function (error) {
const usernameMessageElement = tpl.$('.username-taken');
const emailMessageElement = tpl.$('.email-taken');
if (error) {
@@ -61,7 +61,7 @@ Template.editProfilePopup.events({
}
});
} else if (isChangeUserName) {
- Meteor.call('setUsername', username, function(error) {
+ Meteor.call('setUsername', username, Meteor.userId(), function (error) {
const messageElement = tpl.$('.username-taken');
if (error) {
messageElement.show();
@@ -71,7 +71,7 @@ Template.editProfilePopup.events({
}
});
} else if (isChangeEmail) {
- Meteor.call('setEmail', email.toLowerCase(), function(error) {
+ Meteor.call('setEmail', email.toLowerCase(), Meteor.userId(), function (error) {
const messageElement = tpl.$('.email-taken');
if (error) {
messageElement.show();
@@ -105,7 +105,7 @@ Template.editNotificationPopup.events({
// 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(function () {
this.find('#at-field-current_password').focus();
});
@@ -116,7 +116,7 @@ Template.changeLanguagePopup.helpers({
tag: code,
name: lang.name === 'br' ? 'Brezhoneg' : lang.name,
};
- }).sort(function(a, b) {
+ }).sort(function (a, b) {
if (a.name === b.name) {
return 0;
} else {