Noded/frontend#77 - track node ID with file box record
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2021-02-04 15:54:48 -06:00
parent 1758340a7b
commit d8e445ba7a
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
4 changed files with 18 additions and 14 deletions

View File

@ -20,7 +20,7 @@ class FileBoxController extends Controller {
UUID: req.body.rootUUID, UUID: req.body.rootUUID,
}) })
if ( !root || root.pageId !== req.form.page.UUID ) { if ( !root || root.nodeId !== req.form.node.UUID ) {
return res.status(400) return res.status(400)
.message('Invalid rootUUID.') .message('Invalid rootUUID.')
.api() .api()
@ -39,7 +39,7 @@ class FileBoxController extends Controller {
UUID: req.body.parentUUID, UUID: req.body.parentUUID,
}) })
if ( !parent || parent.pageId !== req.form.page.UUID ) { if ( !parent || parent.nodeId !== req.form.node.UUID ) {
return res.status(400) return res.status(400)
.message('Invalid parentUUID') .message('Invalid parentUUID')
.api() .api()
@ -49,6 +49,7 @@ class FileBoxController extends Controller {
const box = new FileBox({ const box = new FileBox({
name: req.body.name, name: req.body.name,
pageId: req.form.page.UUID, pageId: req.form.page.UUID,
nodeId: req.form.node.UUID,
}) })
if ( req.body.rootUUID ) { if ( req.body.rootUUID ) {
@ -71,7 +72,7 @@ class FileBoxController extends Controller {
async update(req, res, next) { async update(req, res, next) {
const FileBox = this.models.get('api:files:FileBox') const FileBox = this.models.get('api:files:FileBox')
const { file_box, page } = req.form const { file_box, page, node } = req.form
if ( req.body.name ) { if ( req.body.name ) {
file_box.name = req.body.name file_box.name = req.body.name
@ -83,6 +84,7 @@ class FileBoxController extends Controller {
active: true, active: true,
rootUUID: file_box.rootUUID, rootUUID: file_box.rootUUID,
pageId: page.UUID, pageId: page.UUID,
nodeId: node.UUID,
}) })
if ( !new_parent || new_parent.UUID === file_box.UUID ) { if ( !new_parent || new_parent.UUID === file_box.UUID ) {

View File

@ -291,7 +291,7 @@ class Page extends VersionedModel {
children.push({ children.push({
id: box.pageId, id: box.pageId,
// node_id // FIXME need to track this w/ the file boxes node_id: box.nodeId,
children: [], children: [],
type: 'file_box', type: 'file_box',
name: box.name, name: box.name,

View File

@ -12,6 +12,7 @@ class FileBoxModel extends Model {
UUID: { type: String, default: uuid }, UUID: { type: String, default: uuid },
name: String, name: String,
pageId: String, pageId: String,
nodeId: String,
parentUUID: String, parentUUID: String,
rootUUID: String, rootUUID: String,
fileIds: [String], fileIds: [String],
@ -56,6 +57,7 @@ class FileBoxModel extends Model {
name: this.name, name: this.name,
title: this.name, title: this.name,
pageId: this.pageId, pageId: this.pageId,
nodeId: this.nodeId,
parentUUID: this.parentUUID, parentUUID: this.parentUUID,
rootUUID: this.rootUUID, rootUUID: this.rootUUID,
fileIds: this.fileIds || [], fileIds: this.fileIds || [],

View File

@ -5,22 +5,22 @@ module.exports = exports = {
middleware: [], middleware: [],
get: { get: {
'/:PageId/:FileBoxId': [ '/:PageId/:NodeId/:FileBoxId': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'view' }], ['middleware::api:DataInjection', { access_level: 'view' }],
'controller::api:v1:FileBox.get_box', 'controller::api:v1:FileBox.get_box',
], ],
'/:PageId/:FileBoxId/files': [ '/:PageId/:NodeId/:FileBoxId/files': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'view' }], ['middleware::api:DataInjection', { access_level: 'view' }],
'controller::api:v1:FileBox.get_files', 'controller::api:v1:FileBox.get_files',
], ],
'/:PageId/:FileBoxId/files/:FileBoxFileId': [ '/:PageId/:NodeId/:FileBoxId/files/:FileBoxFileId': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'view' }], ['middleware::api:DataInjection', { access_level: 'view' }],
'controller::api:v1:FileBox.download_file', 'controller::api:v1:FileBox.download_file',
], ],
'/:PageId/:FileBoxId/children': [ '/:PageId/:NodeId/:FileBoxId/children': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'view' }], ['middleware::api:DataInjection', { access_level: 'view' }],
'controller::api:v1:FileBox.get_children', 'controller::api:v1:FileBox.get_children',
@ -28,23 +28,23 @@ module.exports = exports = {
}, },
post: { post: {
'/:PageId/create': [ '/:PageId/:NodeId/create': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'update' }], ['middleware::api:DataInjection', { access_level: 'update' }],
'controller::api:v1:FileBox.create', 'controller::api:v1:FileBox.create',
], ],
'/:PageId/:FileBoxId': [ '/:PageId/:NodeId/:FileBoxId': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'update' }], ['middleware::api:DataInjection', { access_level: 'update' }],
'controller::api:v1:FileBox.update', 'controller::api:v1:FileBox.update',
], ],
'/:PageId/:FileBoxId/files': [ '/:PageId/:NodeId/:FileBoxId/files': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'update' }], ['middleware::api:DataInjection', { access_level: 'update' }],
['middleware::upload:UploadFile', { tag: 'file_box_file' }], ['middleware::upload:UploadFile', { tag: 'file_box_file' }],
'controller::api:v1:FileBox.upload_files', 'controller::api:v1:FileBox.upload_files',
], ],
'/:PageId/:FileBoxId/files/:FileBoxFileId': [ '/:PageId/:NodeId/:FileBoxId/files/:FileBoxFileId': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'update' }], ['middleware::api:DataInjection', { access_level: 'update' }],
'controller::api:v1:FileBox.update_file', 'controller::api:v1:FileBox.update_file',
@ -52,12 +52,12 @@ module.exports = exports = {
}, },
delete: { delete: {
'/:PageId/:FileBoxId': [ '/:PageId/:NodeId/:FileBoxId': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'update' }], ['middleware::api:DataInjection', { access_level: 'update' }],
'controller::api:v1:FileBox.delete_box', 'controller::api:v1:FileBox.delete_box',
], ],
'/:PageId/:FileBoxId/files/:FileBoxFileId': [ '/:PageId/:NodeId/:FileBoxId/files/:FileBoxFileId': [
'middleware::auth:ApiRoute', 'middleware::auth:ApiRoute',
['middleware::api:DataInjection', { access_level: 'update' }], ['middleware::api:DataInjection', { access_level: 'update' }],
'controller::api:v1:FileBox.delete_file', 'controller::api:v1:FileBox.delete_file',