mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Merge pull request #3996 from Emile840/master
[Admin panel / People] possibility of adding a team to all selected Users
This commit is contained in:
commit
08ac1f6b69
6 changed files with 20490 additions and 18 deletions
|
@ -40,6 +40,11 @@ template(name="people")
|
|||
| {{_ 'search'}}
|
||||
.ext-box-right
|
||||
span {{#unless isMiniScreen}}{{_ 'people-number'}}{{/unless}} #{peopleNumber}
|
||||
.divAddOrRemoveTeam#divAddOrRemoveTeam
|
||||
button#addOrRemoveTeam
|
||||
i.fa.fa-edit
|
||||
| {{_ 'add'}} / {{_ 'delete'}} {{_ 'teams'}}
|
||||
|
||||
.content-body
|
||||
.side-menu
|
||||
ul
|
||||
|
@ -97,9 +102,12 @@ template(name="teamGeneral")
|
|||
+teamRow(teamId=team._id)
|
||||
|
||||
template(name="peopleGeneral")
|
||||
#divAddOrRemoveTeamContainer
|
||||
+modifyTeamsUsers
|
||||
table
|
||||
tbody
|
||||
tr
|
||||
th
|
||||
th {{_ 'username'}}
|
||||
th {{_ 'fullname'}}
|
||||
th {{_ 'initials'}}
|
||||
|
@ -202,6 +210,12 @@ template(name="teamRow")
|
|||
|
||||
template(name="peopleRow")
|
||||
tr
|
||||
if userData.loginDisabled
|
||||
td
|
||||
input.selectUserChkBox(type="checkbox", disabled="disabled", id="{{userData._id}}")
|
||||
else
|
||||
td
|
||||
input.selectUserChkBox(type="checkbox", id="{{userData._id}}")
|
||||
if userData.loginDisabled
|
||||
td.username <s>{{ userData.username }}</s>
|
||||
else
|
||||
|
@ -453,6 +467,24 @@ template(name="newTeamPopup")
|
|||
div.buttonsContainer
|
||||
input.primary.wide(type="submit" value="{{_ 'save'}}")
|
||||
|
||||
template(name="modifyTeamsUsers")
|
||||
label
|
||||
| {{_ 'teams'}}
|
||||
select.js-teamsUser#jsteamsUser
|
||||
each value in teamsDatas
|
||||
option(value="{{value._id}}") {{_ value.teamDisplayName}}
|
||||
hr
|
||||
label
|
||||
| {{_ 'Action'}}
|
||||
.form-group.flex
|
||||
input.wekan-form-control#addAction(type="radio" name="action" value="true" checked="checked")
|
||||
span {{_ 'Add'}}
|
||||
input.wekan-form-control#deleteAction(type="radio" name="action" value="false")
|
||||
span {{_ 'Delete'}}
|
||||
div.buttonsContainer
|
||||
input.primary.wide#addTeamBtn(type="submit" value="{{_ 'save'}}")
|
||||
input.primary.wide#cancelBtn(type="submit" value="{{_ 'Cancel'}}")
|
||||
|
||||
template(name="newUserPopup")
|
||||
form
|
||||
//label.hide.userId(type="text" value=user._id)
|
||||
|
|
|
@ -2,6 +2,7 @@ const orgsPerPage = 25;
|
|||
const teamsPerPage = 25;
|
||||
const usersPerPage = 25;
|
||||
let userOrgsTeamsAction = ""; //poosible actions 'addOrg', 'addTeam', 'removeOrg' or 'removeTeam' when adding or modifying a user
|
||||
let selectedUserChkBoxUserIds = [];
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
mixins() {
|
||||
|
@ -81,6 +82,9 @@ BlazeComponent.extendComponent({
|
|||
'click #searchButton'() {
|
||||
this.filterPeople();
|
||||
},
|
||||
'click #addOrRemoveTeam'(){
|
||||
document.getElementById("divAddOrRemoveTeamContainer").style.display = 'block';
|
||||
},
|
||||
'keydown #searchInput'(event) {
|
||||
if (event.keyCode === 13 && !event.shiftKey) {
|
||||
this.filterPeople();
|
||||
|
@ -385,11 +389,111 @@ BlazeComponent.extendComponent({
|
|||
{
|
||||
'click a.edit-user': Popup.open('editUser'),
|
||||
'click a.more-settings-user': Popup.open('settingsUser'),
|
||||
'click .selectUserChkBox': function(ev){
|
||||
if(ev.currentTarget){
|
||||
if(ev.currentTarget.checked){
|
||||
if(!selectedUserChkBoxUserIds.includes(ev.currentTarget.id)){
|
||||
selectedUserChkBoxUserIds.push(ev.currentTarget.id);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(selectedUserChkBoxUserIds.includes(ev.currentTarget.id)){
|
||||
let index = selectedUserChkBoxUserIds.indexOf(ev.currentTarget.id);
|
||||
if(index > -1)
|
||||
selectedUserChkBoxUserIds.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(selectedUserChkBoxUserIds.length > 0)
|
||||
document.getElementById("divAddOrRemoveTeam").style.display = 'block';
|
||||
else
|
||||
document.getElementById("divAddOrRemoveTeam").style.display = 'none';
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
}).register('peopleRow');
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
onCreated() {},
|
||||
teamsDatas() {
|
||||
return Team.find({}, {sort: { createdAt: -1 }});
|
||||
},
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
'click #cancelBtn': function(){
|
||||
let selectedElt = document.getElementById("jsteamsUser");
|
||||
document.getElementById("divAddOrRemoveTeamContainer").style.display = 'none';
|
||||
},
|
||||
'click #addTeamBtn': function(){
|
||||
let selectedElt;
|
||||
let selectedEltValue;
|
||||
let selectedEltValueId;
|
||||
let userTms = [];
|
||||
let currentUser;
|
||||
let currUserTeamIndex;
|
||||
|
||||
selectedElt = document.getElementById("jsteamsUser");
|
||||
selectedEltValue = selectedElt.options[selectedElt.selectedIndex].text;
|
||||
selectedEltValueId = selectedElt.options[selectedElt.selectedIndex].value;
|
||||
|
||||
if(document.getElementById('addAction').checked){
|
||||
for(let i = 0; i < selectedUserChkBoxUserIds.length; i++){
|
||||
currentUser = Users.findOne(selectedUserChkBoxUserIds[i]);
|
||||
userTms = currentUser.teams;
|
||||
if(userTms == undefined || userTms.length == 0){
|
||||
userTms = [];
|
||||
userTms.push({
|
||||
"teamId": selectedEltValueId,
|
||||
"teamDisplayName": selectedEltValue,
|
||||
})
|
||||
}
|
||||
else if(userTms.length > 0)
|
||||
{
|
||||
currUserTeamIndex = userTms.findIndex(function(t){ return t.teamId == selectedEltValueId});
|
||||
if(currUserTeamIndex == -1){
|
||||
userTms.push({
|
||||
"teamId": selectedEltValueId,
|
||||
"teamDisplayName": selectedEltValue,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Users.update(selectedUserChkBoxUserIds[i], {
|
||||
$set:{
|
||||
teams: userTms
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(let i = 0; i < selectedUserChkBoxUserIds.length; i++){
|
||||
currentUser = Users.findOne(selectedUserChkBoxUserIds[i]);
|
||||
userTms = currentUser.teams;
|
||||
if(userTms !== undefined || userTms.length > 0)
|
||||
{
|
||||
currUserTeamIndex = userTms.findIndex(function(t){ return t.teamId == selectedEltValueId});
|
||||
if(currUserTeamIndex != -1){
|
||||
userTms.splice(currUserTeamIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Users.update(selectedUserChkBoxUserIds[i], {
|
||||
$set:{
|
||||
teams: userTms
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("divAddOrRemoveTeamContainer").style.display = 'none';
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
}).register('modifyTeamsUsers');
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
events() {
|
||||
return [
|
||||
|
|
|
@ -55,3 +55,31 @@ table
|
|||
|
||||
.js-teams,.js-teamsNewUser
|
||||
display: none;
|
||||
|
||||
.selectUserChkBox
|
||||
position: static !important;
|
||||
visibility: visible !important;
|
||||
left: 0 !important;
|
||||
|
||||
#divAddOrRemoveTeam
|
||||
background: green;
|
||||
display: none;
|
||||
|
||||
#addOrRemoveTeam
|
||||
background: green;
|
||||
color: white;
|
||||
|
||||
#divAddOrRemoveTeamContainer
|
||||
display: none;
|
||||
margin: auto;
|
||||
width: 50%;
|
||||
border: 3px solid green;
|
||||
padding: 10px;
|
||||
|
||||
#cancelBtn
|
||||
margin-left: 5% !important;
|
||||
background: orange;
|
||||
color: white;
|
||||
|
||||
#deleteAction
|
||||
margin-left: 5% !important;
|
||||
|
|
7465
package-lock.json
generated
7465
package-lock.json
generated
File diff suppressed because it is too large
Load diff
12876
package-lock.json.orig
Normal file
12876
package-lock.json.orig
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +0,0 @@
|
|||
cd ~/repos/wekan/.build
|
||||
find . -name "*phantomjs*" | xargs rm -rf
|
||||
cd ~/repos/wekan
|
Loading…
Add table
Add a link
Reference in a new issue