Improve version modal rendering calls
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2021-03-16 10:35:57 -05:00
parent a7d3ec6a1f
commit ffb5e35205
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
4 changed files with 31 additions and 2 deletions

View File

@ -37,7 +37,13 @@ class FormCode extends Controller {
} }
async get_config(req, res) { async get_config(req, res) {
return res.api(req.form.codium) const { codium } = req.form
if ( req.query.version ) {
return res.api(await codium.as_version(req.query.version))
}
return res.api(codium)
} }
async set_values(req, res) { async set_values(req, res) {

View File

@ -37,11 +37,23 @@ class FormDatabase extends Controller {
async get_config(req, res) { async get_config(req, res) {
const { page, node, database } = req.form const { page, node, database } = req.form
if ( req.query.version ) {
console.log('db version', req.query.version)
return res.api(await database.as_version(req.query.version))
}
return res.api(database) return res.api(database)
} }
async get_columns(req, res) { async get_columns(req, res) {
const { page, node, database } = req.form let { page, node, database } = req.form
if ( req.query.database_version ) {
database = await database.as_version(req.query.database_version)
if ( !database )
return res.status(400)
.message('Version not found.')
.api()
}
const columns = [] const columns = []
for ( const col_id of database.ColumnIds ) { for ( const col_id of database.ColumnIds ) {

View File

@ -30,6 +30,11 @@ class Node extends VersionedModel {
}; };
} }
__initialize_version(base, data = {}) {
super.__initialize_version(base, data)
this.associated_type_version_num = data.associated_type_version_num
}
// Static and instance methods can go here // Static and instance methods can go here
get page() { get page() {
const Page = this.models.get('api:Page') const Page = this.models.get('api:Page')

View File

@ -369,6 +369,12 @@ class Page extends VersionedModel {
return data return data
} }
async as_version(version_num = undefined) {
const inst = await super.as_version(version_num)
inst.node_version_nums = inst.__version_data?.node_version_nums
return inst
}
async revert_to_version(version_num, user_id = undefined) { async revert_to_version(version_num, user_id = undefined) {
const Node = this.models.get('api:Node') const Node = this.models.get('api:Node')
const reverted = await super.revert_to_version(version_num, user_id) const reverted = await super.revert_to_version(version_num, user_id)