add back to project button; pre-filled inline snippets from projects

This commit is contained in:
2019-08-07 13:01:05 -05:00
parent 84e3e94920
commit 1c0bdffc68
8 changed files with 85 additions and 8 deletions

View File

@@ -138,7 +138,38 @@ class v1 {
return _flitter.error(res, 401, {reason: 'You do not have permission to view this project.'})
}
return _flitter.view(res, 'dash_v1:view', {user: req.session.auth.user, snippets, project, outs, show_back: true, title: 'View: '+project.name })
return _flitter.view(res, 'dash_v1:view', {user: req.session.auth.user, snippets, project, outs, show_back: true, window_back: true, title: 'View: '+project.name })
}
async project_view_inline_helper(req, res, next){
const project = await Project.findById(req.params.id)
if ( !project ){
return _flitter.error(res, 404, {reason: 'Project not found with the specified ID.'})
}
if ( !await devbug.permission.project.view(project, req.session.auth.user) ){
return _flitter.error(res, 401, {reason: 'You do not have permission to view this project.'})
}
const code = devbug.get_inline(req.params.type, project)
if ( !code ) return _flitter.error(res, 404, {reason: 'Inline helper snippet not found with the specified type.'})
let type;
if ( req.params.type === 'node' ) type = 'javascript'
else if ( req.params.type === 'php' ) type = 'php'
else type = 'text'
return _flitter.view(res, 'dash_v1:in_editor', {
user: req.session.auth.user,
project,
show_back: true,
readonly: true,
editor_code: code,
editor_lang: 'ace/mode/'+type,
title: 'Inline Helper for '+project.name+' ('+req.params.type+')'
})
}
async out_view(req, res, next){