Track file group versioning & include version num in node versions
This commit is contained in:
parent
a584631b75
commit
3bef5f3423
@ -39,7 +39,7 @@ class File extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
await group.save()
|
||||
await group.version_save(`Added to page "${page.Name}"`, req.user.id)
|
||||
req.user.allow(`files:${group.UUID}`)
|
||||
await req.user.save()
|
||||
|
||||
@ -85,11 +85,12 @@ class File extends Controller {
|
||||
if ( !group ) return res.status(404).message('Invalid file group.').api({})
|
||||
// if ( !group.accessible_by(req.user) ) return req.security.deny()
|
||||
|
||||
let file_name = ''
|
||||
if ( req.uploads.uploaded_file ) {
|
||||
group.FileIds.push(req.uploads.uploaded_file.id)
|
||||
}
|
||||
|
||||
await group.save()
|
||||
await group.version_save(`Added file${file_name ? ' "'+file_name+'"' : ''}`, req.user.id)
|
||||
return res.redirect(req.body.redirectTo ? req.body.redirectTo : '/')
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
const Model = require('flitter-orm/src/model/Model')
|
||||
const VersionedModel = require('../VersionedModel')
|
||||
const uuid = require('uuid/v4')
|
||||
|
||||
/*
|
||||
@ -6,10 +6,11 @@ const uuid = require('uuid/v4')
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class FileGroup extends Model {
|
||||
class FileGroup extends VersionedModel {
|
||||
static get schema() {
|
||||
// Return a flitter-orm schema here.
|
||||
return {
|
||||
...super.schema,
|
||||
NodeId: String,
|
||||
PageId: String,
|
||||
FileIds: [String],
|
||||
|
@ -69,6 +69,12 @@ class Node extends VersionedModel {
|
||||
if ( code ) {
|
||||
data.associated_type_version_num = code.version_num
|
||||
}
|
||||
} else if ( this.Type === 'file_ref' && this.Value?.Value ) {
|
||||
const FileGroup = this.models.get('api:FileGroup')
|
||||
const group = await FileGroup.findOne({ UUID: this.Value?.Value })
|
||||
if ( group ) {
|
||||
data.associated_type_version_num = group.version_num
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
|
Loading…
Reference in New Issue
Block a user