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

View File

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

View File

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

View File

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