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

@ -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 });
});
}