feat: Implement update flow folder API endpoint
This commit is contained in:
@@ -2,6 +2,7 @@ import { ValidationError } from 'objection';
|
||||
import Base from './base.js';
|
||||
import Step from './step.js';
|
||||
import User from './user.js';
|
||||
import Folder from './folder.js';
|
||||
import Execution from './execution.js';
|
||||
import ExecutionStep from './execution-step.js';
|
||||
import globalVariable from '../helpers/global-variable.js';
|
||||
@@ -88,6 +89,14 @@ class Flow extends Base {
|
||||
to: 'users.id',
|
||||
},
|
||||
},
|
||||
folder: {
|
||||
relation: Base.HasOneRelation,
|
||||
modelClass: Folder,
|
||||
join: {
|
||||
from: 'flows.folder_id',
|
||||
to: 'folders.id',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
static async populateStatusProperty(flows) {
|
||||
@@ -338,6 +347,23 @@ class Flow extends Base {
|
||||
return allowedToRunFlows ? false : true;
|
||||
}
|
||||
|
||||
async updateFolder(folderId) {
|
||||
const user = await this.$relatedQuery('user');
|
||||
|
||||
const folder = await user
|
||||
.$relatedQuery('folders')
|
||||
.findOne({
|
||||
id: folderId,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
await this.$query().patch({
|
||||
folderId: folder.id,
|
||||
});
|
||||
|
||||
return this.$query().withGraphFetched('folder');
|
||||
}
|
||||
|
||||
async updateStatus(newActiveValue) {
|
||||
if (this.active === newActiveValue) {
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user