This commit is contained in:
Jori Lallo 2016-06-25 22:36:16 -07:00
parent a0649e6fd3
commit 4beb84f4bc
6 changed files with 10 additions and 11 deletions

View File

@ -6,7 +6,7 @@ import Sequelize from 'sequelize';
import auth from './auth';
import user from './user';
import atlases from './atlases';
import collections from './collections';
import documents from './documents';
import validation from './validation';
@ -44,7 +44,7 @@ api.use(validation());
router.use('/', auth.routes());
router.use('/', user.routes());
router.use('/', atlases.routes());
router.use('/', collections.routes());
router.use('/', documents.routes());
// Router is embedded in a Koa application wrapper, because koa-router does not

View File

@ -14,7 +14,7 @@ const Atlas = sequelize.define('atlas', {
type: { type: DataTypes.STRING, validate: { isIn: allowedAtlasTypes }},
/* type: atlas */
atlasStructure: DataTypes.JSONB,
navigationTree: DataTypes.JSONB,
}, {
tableName: 'atlases',
hooks: {
@ -32,8 +32,8 @@ const Atlas = sequelize.define('atlas', {
},
instanceMethods: {
async getStructure() {
if (this.atlasStructure) {
return this.atlasStructure;
if (this.navigationTree) {
return this.navigationTree;
}
const getNodeForDocument = async (document) => {
@ -122,7 +122,7 @@ const Atlas = sequelize.define('atlas', {
throw new Error('Invalid navigation tree');
}
this.atlasStructure = newTree;
this.navigationTree = newTree;
await this.save();
return newTree;
@ -147,7 +147,7 @@ const Atlas = sequelize.define('atlas', {
return node;
};
this.atlasStructure = insertNode(this.atlasStructure);
this.navigationTree = insertNode(this.navigationTree);
}
}
});

View File

@ -32,8 +32,7 @@ export function presentAtlas(atlas, includeRecentDocuments=false) {
}
if (atlas.type === 'atlas') {
// Todo replace with `.atlasStructure`
data.structure = await atlas.getStructure();
data.navigationTree = await atlas.getStructure();
}
if (includeRecentDocuments) {

View File

@ -21,7 +21,7 @@ class Atlas extends React.Component {
// Forward directly to root document
if (data.type === 'atlas') {
History.replace(data.structure.url);
History.replace(data.navigationTree.url);
}
})
}

View File

@ -115,7 +115,7 @@ class DocumentScene extends React.Component {
<div className={ styles.sidebar }>
<Tree
paddingLeft={10}
tree={ doc.atlas.structure }
tree={ doc.atlas.navigationTree }
onChange={this.handleChange}
isNodeCollapsed={this.isNodeCollapsed}
renderNode={this.renderNode}