fix: Templates should not be visible in collection structure

This commit is contained in:
Tom Moor
2021-03-10 09:39:42 -08:00
parent f50b88716b
commit 0aa72036d7
2 changed files with 61 additions and 4 deletions

View File

@ -578,8 +578,10 @@ Document.prototype.archiveWithChildren = async function (userId, options) {
Document.prototype.publish = async function (userId: string, options) {
if (this.publishedAt) return this.save(options);
const collection = await Collection.findByPk(this.collectionId);
await collection.addDocumentToStructure(this, 0);
if (!this.template) {
const collection = await Collection.findByPk(this.collectionId);
await collection.addDocumentToStructure(this, 0);
}
this.lastModifiedById = userId;
this.publishedAt = new Date();
@ -636,8 +638,10 @@ Document.prototype.unarchive = async function (userId: string) {
if (!parent) this.parentDocumentId = undefined;
}
await collection.addDocumentToStructure(this);
this.collection = collection;
if (!this.template) {
await collection.addDocumentToStructure(this);
this.collection = collection;
}
if (this.deletedAt) {
await this.restore();