Addressed one of the bugs cited in issue #802 'bug when creating and modifying organization and team'

This commit is contained in:
Emile NDAGIJIMANA 2021-06-07 11:03:49 +02:00
parent 6e46cad56c
commit f5dbe8c6f6
6 changed files with 128 additions and 81 deletions

View file

@ -132,28 +132,28 @@ template(name="newUserRow")
template(name="orgRow")
tr
if orgData.loginDisabled
if orgData.orgIsActive
td <s>{{ orgData.orgDisplayName }}</s>
else
td {{ orgData.orgDisplayName }}
if orgData.loginDisabled
if orgData.orgIsActive
td <s>{{ orgData.orgDesc }}</s>
else
td {{ orgData.orgDesc }}
if orgData.loginDisabled
td <s>{{ orgData.orgName }}</s>
if orgData.orgIsActive
td <s>{{ orgData.orgShortName }}</s>
else
td {{ orgData.orgName }}
if orgData.loginDisabled
td {{ orgData.orgShortName }}
if orgData.orgIsActive
td <s>{{ orgData.orgWebsite }}</s>
else
td {{ orgData.orgWebsite }}
if orgData.loginDisabled
if orgData.orgIsActive
td <s>{{ moment orgData.createdAt 'LLL' }}</s>
else
td {{ moment orgData.createdAt 'LLL' }}
td
if orgData.loginDisabled
if orgData.orgIsActive
| {{_ 'no'}}
else
| {{_ 'yes'}}
@ -166,28 +166,28 @@ template(name="orgRow")
template(name="teamRow")
tr
if teamData.loginDisabled
if teamData.teamIsActive
td <s>{{ teamData.teamDisplayName }}</s>
else
td {{ teamData.teamDisplayName }}
if teamData.loginDisabled
if teamData.teamIsActive
td <s>{{ teamData.teamDesc }}</s>
else
td {{ teamData.teamDesc }}
if teamData.loginDisabled
td <s>{{ teamData.teamName }}</s>
if teamData.teamIsActive
td <s>{{ teamData.teamShortName }}</s>
else
td {{ teamData.teamName }}
if teamData.loginDisabled
td {{ teamData.teamShortName }}
if teamData.teamIsActive
td <s>{{ teamData.teamWebsite }}</s>
else
td {{ teamData.teamWebsite }}
if orgData.loginDisabled
if teamData.teamIsActive
td <s>{{ moment teamData.createdAt 'LLL' }}</s>
else
td {{ moment teamData.createdAt 'LLL' }}
td
if teamData.loginDisabled
if teamData.teamIsActive
| {{_ 'no'}}
else
| {{_ 'yes'}}
@ -268,8 +268,8 @@ template(name="editOrgPopup")
form
label.hide.orgId(type="text" value=org._id)
label
| {{_ 'displayName'}}
input.js-orgDisplayName(type="text" value=org.displayName required)
| {{_ 'orgDisplayName'}}
input.js-orgDisplayName(type="text" value=org.orgDisplayName required)
span.error.hide.orgname-taken
| {{_ 'error-orgname-taken'}}
label
@ -285,7 +285,7 @@ template(name="editOrgPopup")
| {{_ 'active'}}
select.select-active.js-org-isactive
option(value="false") {{_ 'yes'}}
option(value="true" selected="{{org.loginDisabled}}") {{_ 'no'}}
option(value="true" selected="{{org.orgIsActive}}") {{_ 'no'}}
hr
div.buttonsContainer
input.primary.wide(type="submit" value="{{_ 'save'}}")
@ -311,7 +311,7 @@ template(name="editTeamPopup")
| {{_ 'active'}}
select.select-active.js-team-isactive
option(value="false") {{_ 'yes'}}
option(value="true" selected="{{team.loginDisabled}}") {{_ 'no'}}
option(value="true" selected="{{team.teamIsActive}}") {{_ 'no'}}
hr
div.buttonsContainer
input.primary.wide(type="submit" value="{{_ 'save'}}")
@ -385,7 +385,7 @@ template(name="newOrgPopup")
input.js-orgDesc(type="text" value="" required)
label
| {{_ 'shortName'}}
input.js-orgName(type="text" value="" required)
input.js-orgShortName(type="text" value="" required)
label
| {{_ 'website'}}
input.js-orgWebsite(type="text" value="" required)
@ -409,7 +409,7 @@ template(name="newTeamPopup")
input.js-teamDesc(type="text" value="" required)
label
| {{_ 'shortName'}}
input.js-teamName(type="text" value="" required)
input.js-teamShortName(type="text" value="" required)
label
| {{_ 'website'}}
input.js-teamWebsite(type="text" value="" required)

View file

@ -150,7 +150,7 @@ BlazeComponent.extendComponent({
const teams = Team.find(this.findTeamsOptions.get(), {
fields: { _id: true },
});
this.numberTeams.set(team.count(false));
this.numberTeams.set(teams.count(false));
return teams;
},
peopleList() {
@ -407,7 +407,7 @@ BlazeComponent.extendComponent({
Template.editOrgPopup.events({
submit(event, templateInstance) {
event.preventDefault();
const org = Orgs.findOne(this.orgId);
const org = Org.findOne(this.orgId);
const orgDisplayName = templateInstance
.find('.js-orgDisplayName')
@ -415,7 +415,7 @@ Template.editOrgPopup.events({
const orgDesc = templateInstance.find('.js-orgDesc').value.trim();
const orgShortName = templateInstance.find('.js-orgShortName').value.trim();
const orgWebsite = templateInstance.find('.js-orgWebsite').value.trim();
const orgIsActive = templateInstance.find('.js-org-isactive').value.trim();
const orgIsActive = templateInstance.find('.js-org-isactive').value.trim() == 'true';
const isChangeOrgDisplayName = orgDisplayName !== org.orgDisplayName;
const isChangeOrgDesc = orgDesc !== org.orgDesc;
@ -423,21 +423,25 @@ Template.editOrgPopup.events({
const isChangeOrgWebsite = orgWebsite !== org.orgWebsite;
const isChangeOrgIsActive = orgIsActive !== org.orgIsActive;
if (isChangeOrgDisplayName) {
Meteor.call('setOrgDisplayName', org, orgDisplayName);
if(isChangeOrgDisplayName || isChangeOrgDesc || isChangeOrgShortName || isChangeOrgWebsite || isChangeOrgIsActive){
Meteor.call('setOrgAllFields', org, orgDisplayName, orgDesc, orgShortName, orgWebsite, orgIsActive);
}
if (isChangeOrgDesc) {
Meteor.call('setOrgDesc', org, orgDesc);
}
// if (isChangeOrgDisplayName) {
// Meteor.call('setOrgDisplayName', org, orgDisplayName);
// }
if (isChangeOrgShortName) {
Meteor.call('setOrgShortName', org, orgShortName);
}
// if (isChangeOrgDesc) {
// Meteor.call('setOrgDesc', org, orgDesc);
// }
if (isChangeOrgIsActive) {
Meteor.call('setOrgIsActive', org, orgIsActive);
}
// if (isChangeOrgShortName) {
// Meteor.call('setOrgShortName', org, orgShortName);
// }
// if (isChangeOrgIsActive) {
// Meteor.call('setOrgIsActive', org, orgIsActive);
// }
Popup.close();
},
@ -446,7 +450,7 @@ Template.editOrgPopup.events({
Template.editTeamPopup.events({
submit(event, templateInstance) {
event.preventDefault();
const team = Teams.findOne(this.teamId);
const team = Team.findOne(this.teamId);
const teamDisplayName = templateInstance
.find('.js-teamDisplayName')
@ -456,9 +460,7 @@ Template.editTeamPopup.events({
.find('.js-teamShortName')
.value.trim();
const teamWebsite = templateInstance.find('.js-teamWebsite').value.trim();
const teamIsActive = templateInstance
.find('.js-team-isactive')
.value.trim();
const teamIsActive = templateInstance.find('.js-team-isactive').value.trim() == 'true';
const isChangeTeamDisplayName = teamDisplayName !== team.teamDisplayName;
const isChangeTeamDesc = teamDesc !== team.teamDesc;
@ -466,21 +468,24 @@ Template.editTeamPopup.events({
const isChangeTeamWebsite = teamWebsite !== team.teamWebsite;
const isChangeTeamIsActive = teamIsActive !== team.teamIsActive;
if (isChangeTeamDisplayName) {
Meteor.call('setTeamDisplayName', team, teamDisplayName);
if(isChangeTeamDisplayName || isChangeTeamDesc || isChangeTeamShortName || isChangeTeamWebsite || isChangeTeamIsActive){
Meteor.call('setTeamAllFields', team, teamDisplayName, teamDesc, teamShortName, teamWebsite, teamIsActive);
}
// if (isChangeTeamDisplayName) {
// Meteor.call('setTeamDisplayName', team, teamDisplayName);
// }
if (isChangeTeamDesc) {
Meteor.call('setTeamDesc', team, teamDesc);
}
// if (isChangeTeamDesc) {
// Meteor.call('setTeamDesc', team, teamDesc);
// }
if (isChangeTeamShortName) {
Meteor.call('setTeamShortName', team, teamShortName);
}
// if (isChangeTeamShortName) {
// Meteor.call('setTeamShortName', team, teamShortName);
// }
if (isChangeTeamIsActive) {
Meteor.call('setTeamIsActive', team, teamIsActive);
}
// if (isChangeTeamIsActive) {
// Meteor.call('setTeamIsActive', team, teamIsActive);
// }
Popup.close();
},
@ -608,7 +613,7 @@ Template.newOrgPopup.events({
const orgDesc = templateInstance.find('.js-orgDesc').value.trim();
const orgShortName = templateInstance.find('.js-orgShortName').value.trim();
const orgWebsite = templateInstance.find('.js-orgWebsite').value.trim();
const orgIsActive = templateInstance.find('.js-org-isactive').value.trim();
const orgIsActive = templateInstance.find('.js-org-isactive').value.trim() == 'true';
Meteor.call(
'setCreateOrg',
@ -633,9 +638,7 @@ Template.newTeamPopup.events({
.find('.js-teamShortName')
.value.trim();
const teamWebsite = templateInstance.find('.js-teamWebsite').value.trim();
const teamIsActive = templateInstance
.find('.js-team-isactive')
.value.trim();
const teamIsActive = templateInstance.find('.js-team-isactive').value.trim() == 'true';
Meteor.call(
'setCreateTeam',

View file

@ -36,11 +36,19 @@ Org.attachSchema(
optional: true,
max: 255,
},
orgIsActive: {
/**
* status of the organization
*/
type: Boolean,
optional: true,
},
createdAt: {
/**
* creation date of the organization
*/
type: Date,
denyUpdate: false,
// eslint-disable-next-line consistent-return
autoValue() {
if (this.isInsert) {
@ -81,7 +89,7 @@ if (Meteor.isServer) {
check(orgDesc, String);
check(orgShortName, String);
check(orgWebsite, String);
check(orgIsActive, String);
check(orgIsActive, Boolean);
const nOrgNames = Org.find({ orgShortName }).count();
if (nOrgNames > 0) {
@ -100,17 +108,17 @@ if (Meteor.isServer) {
setOrgDisplayName(org, orgDisplayName) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(org, String);
check(org, Object);
check(orgDisplayName, String);
Org.update(org, {
$set: { orgDisplayName: orgDisplayName },
$set: { orgDisplayName: orgDisplayNameorgShortName},
});
}
},
setOrgDesc(org, orgDesc) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(org, String);
check(org, Object);
check(orgDesc, String);
Org.update(org, {
$set: { orgDesc: orgDesc },
@ -120,7 +128,7 @@ if (Meteor.isServer) {
setOrgShortName(org, orgShortName) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(org, String);
check(org, Object);
check(orgShortName, String);
Org.update(org, {
$set: { orgShortName: orgShortName },
@ -130,20 +138,35 @@ if (Meteor.isServer) {
setOrgIsActive(org, orgIsActive) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(org, String);
check(orgIsActive, String);
check(org, Object);
check(orgIsActive, Boolean);
Org.update(org, {
$set: { orgIsActive: orgIsActive },
});
}
},
setOrgAllFields(org, orgDisplayName, orgDesc, orgShortName, orgWebsite, orgIsActive) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(org, Object);
check(orgDisplayName, String);
check(orgDesc, String);
check(orgShortName, String);
check(orgWebsite, String);
check(orgIsActive, Boolean);
Org.update(org, {
$set: { orgDisplayName : orgDisplayName, orgDesc : orgDesc, orgShortName : orgShortName, orgWebsite : orgWebsite, orgIsActive: orgIsActive },
});
}
},
});
}
if (Meteor.isServer) {
// Index for Organization name.
Meteor.startup(() => {
Org._collection._ensureIndex({ name: -1 });
// Org._collection._ensureIndex({ name: -1 });
Org._collection._ensureIndex({ orgDisplayName: -1 });
});
}

View file

@ -36,6 +36,13 @@ Team.attachSchema(
optional: true,
max: 255,
},
teamIsActive: {
/**
* status of the team
*/
type: Boolean,
optional: true,
},
createdAt: {
/**
* creation date of the team
@ -81,7 +88,7 @@ if (Meteor.isServer) {
check(teamDesc, String);
check(teamShortName, String);
check(teamWebsite, String);
check(teamIsActive, String);
check(teamIsActive, Boolean);
const nTeamNames = Team.find({ teamShortName }).count();
if (nTeamNames > 0) {
@ -100,7 +107,7 @@ if (Meteor.isServer) {
setTeamDisplayName(team, teamDisplayName) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(team, String);
check(team, Object);
check(teamDisplayName, String);
Team.update(team, {
$set: { teamDisplayName: teamDisplayName },
@ -110,7 +117,7 @@ if (Meteor.isServer) {
setTeamDesc(team, teamDesc) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(team, String);
check(team, Object);
check(teamDesc, String);
Team.update(team, {
$set: { teamDesc: teamDesc },
@ -120,7 +127,7 @@ if (Meteor.isServer) {
setTeamShortName(team, teamShortName) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(team, String);
check(team, Object);
check(teamShortName, String);
Team.update(team, {
$set: { teamShortName: teamShortName },
@ -130,20 +137,34 @@ if (Meteor.isServer) {
setTeamIsActive(team, teamIsActive) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(team, String);
check(teamIsActive, String);
check(team, Object);
check(teamIsActive, Boolean);
Team.update(team, {
$set: { teamIsActive: teamIsActive },
});
}
},
setTeamAllFields(team, teamDisplayName, teamDesc, teamShortName, teamWebsite, teamIsActive) {
if (Meteor.user() && Meteor.user().isAdmin) {
check(team, Object);
check(teamDisplayName, String);
check(teamDesc, String);
check(teamShortName, String);
check(teamWebsite, String);
check(teamIsActive, Boolean);
Team.update(team, {
$set: { teamDisplayName: teamDisplayName, teamDesc: teamDesc, teamShortName: teamShortName, teamWebsite: teamWebsite, teamIsActive: teamIsActive },
});
}
},
});
}
if (Meteor.isServer) {
// Index for Team name.
Meteor.startup(() => {
Team._collection._ensureIndex({ name: -1 });
Team._collection._ensureIndex({ teamDisplayName: -1 });
});
}

View file

@ -12,13 +12,13 @@ Meteor.publish('org', function(query, limit) {
limit,
sort: { createdAt: -1 },
fields: {
displayName: 1,
desc: 1,
name: 1,
website: 1,
teams: 1,
orgDisplayName: 1,
orgDesc: 1,
orgShortName: 1,
orgWebsite: 1,
orgTeams: 1,
createdAt: 1,
loginDisabled: 1,
orgIsActive: 1,
},
});
}

View file

@ -12,13 +12,13 @@ Meteor.publish('team', function(query, limit) {
limit,
sort: { createdAt: -1 },
fields: {
displayName: 1,
desc: 1,
name: 1,
website: 1,
teamDisplayName: 1,
teamDesc: 1,
teamShortName: 1,
teamWebsite: 1,
teams: 1,
createdAt: 1,
loginDisabled: 1,
teamIsActive: 1,
},
});
}