2019-07-15 19:39:30 +03:00
|
|
|
Org = new Mongo.Collection('org');
|
|
|
|
|
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* A Organization in Wekan. A Enterprise in Trello.
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
|
|
|
Org.attachSchema(
|
|
|
|
new SimpleSchema({
|
2019-07-15 23:50:30 +03:00
|
|
|
_id: {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
|
|
|
* the organization id
|
|
|
|
*/
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
autoValue() {
|
|
|
|
if (this.isInsert && !this.isSet) {
|
2019-07-15 23:36:29 +03:00
|
|
|
return incrementCounter('counters', 'orgId', 1);
|
2019-07-15 19:39:30 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
displayName: {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* the name to display for the organization
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
2020-12-28 21:08:27 +02:00
|
|
|
type: String,
|
2019-07-15 19:39:30 +03:00
|
|
|
optional: true,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
desc: {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* the description the organization
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
max: 190,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
name: {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* short name of the organization
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
max: 255,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
website: {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* website of the organization
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
max: 255,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
teams: {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* List of teams of a organization
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
2020-12-28 21:08:27 +02:00
|
|
|
type: [Object],
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
autoValue() {
|
|
|
|
if (this.isInsert && !this.isSet) {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
teamId: this.teamId,
|
|
|
|
isAdmin: true,
|
|
|
|
isActive: true,
|
|
|
|
isNoComments: false,
|
|
|
|
isCommentOnly: false,
|
|
|
|
isWorker: false,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
},
|
2019-07-15 19:39:30 +03:00
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
'teams.$.teamId': {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* The uniq ID of the team
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
|
|
|
type: String,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
'teams.$.isAdmin': {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* Is the team an admin of the board?
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
2020-12-28 21:08:27 +02:00
|
|
|
type: Boolean,
|
|
|
|
},
|
|
|
|
'teams.$.isActive': {
|
|
|
|
/**
|
|
|
|
* Is the team active?
|
|
|
|
*/
|
|
|
|
type: Boolean,
|
|
|
|
},
|
|
|
|
'teams.$.isNoComments': {
|
|
|
|
/**
|
|
|
|
* Is the team not allowed to make comments
|
|
|
|
*/
|
|
|
|
type: Boolean,
|
2019-07-15 19:39:30 +03:00
|
|
|
optional: true,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
'teams.$.isCommentOnly': {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* Is the team only allowed to comment on the board
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
2020-12-28 21:08:27 +02:00
|
|
|
type: Boolean,
|
2019-07-15 19:39:30 +03:00
|
|
|
optional: true,
|
|
|
|
},
|
2020-12-28 21:08:27 +02:00
|
|
|
'teams.$.isWorker': {
|
2019-07-15 19:39:30 +03:00
|
|
|
/**
|
2020-12-28 21:08:27 +02:00
|
|
|
* Is the team only allowed to move card, assign himself to card and comment
|
2019-07-15 19:39:30 +03:00
|
|
|
*/
|
2020-12-28 21:08:27 +02:00
|
|
|
type: Boolean,
|
2019-07-15 19:39:30 +03:00
|
|
|
optional: true,
|
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
/**
|
|
|
|
* creation date of the organization
|
|
|
|
*/
|
|
|
|
type: Date,
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
autoValue() {
|
|
|
|
if (this.isInsert) {
|
|
|
|
return new Date();
|
2019-09-05 12:29:45 -05:00
|
|
|
} else if (this.isUpsert) {
|
|
|
|
return { $setOnInsert: new Date() };
|
2019-07-15 19:39:30 +03:00
|
|
|
} else {
|
|
|
|
this.unset();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
modifiedAt: {
|
|
|
|
type: Date,
|
|
|
|
denyUpdate: false,
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
autoValue() {
|
|
|
|
if (this.isInsert || this.isUpsert || this.isUpdate) {
|
|
|
|
return new Date();
|
|
|
|
} else {
|
|
|
|
this.unset();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
2019-07-15 22:47:30 +03:00
|
|
|
if (Meteor.isServer) {
|
|
|
|
// Index for Organization name.
|
|
|
|
Meteor.startup(() => {
|
|
|
|
Org._collection._ensureIndex({ name: -1 });
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-15 19:39:30 +03:00
|
|
|
export default Org;
|