Skip to content

Commit

Permalink
Fix schemas and rename model #88 (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcardle authored Jun 4, 2020
1 parent 53c4958 commit 54a432f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
22 changes: 14 additions & 8 deletions src/components/AppView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default {
.doc(appid)
.update(formdata);
},
schemas.app,
schemas.app(),
{ name: this.$store.getters.apps()[appid].data().name }
);
},
Expand Down Expand Up @@ -323,7 +323,7 @@ export default {
.doc(fieldid)
.update(formdata);
},
schemas.field,
schemas.field(),
{
name: fieldData.name,
type: fieldData.type,
Expand Down Expand Up @@ -367,24 +367,30 @@ export default {
);
},
_modelSchemaForApp: function() {
var schema_with_users_models = schemas.model.slice(0);
var schema_with_users_models = schemas.model();
const data = this.$store.getters.projectData(this.id);
Object.keys(data.apps).map(app => {
const newOpts = {}
Object.keys(data.apps).forEach(app => {
const appData = this.appData(app);
Object.keys(appData.models).map(modelid => {
Object.keys(appData.models).forEach(modelid => {
const modelData = this.modelData(modelid);
const rel = appData.name + ".models." + modelData.name;
schema_with_users_models[1].options[rel] = {
newOpts[rel] = {
type: "user",
model: modelid,
app: app
};
});
});
const baseOpts = Object.assign({}, schema_with_users_models[1].options)
const opts = Object.assign({}, baseOpts, newOpts)
schema_with_users_models[1].options = opts
return schema_with_users_models;
},
_relationshipSchemaForApp: function() {
var schema_with_users_models = schemas.relationship.slice(0);
var schema_with_users_models = schemas.relationship();
const data = this.$store.getters.projectData(this.id);
Object.keys(data.apps).map(app => {
const appData = this.appData(app);
Expand Down Expand Up @@ -431,7 +437,7 @@ export default {
formdata => {
this.addField(model, formdata.name, formdata.type, formdata.args);
},
schemas.field
schemas.field()
);
},
addModel: function(
Expand Down
4 changes: 2 additions & 2 deletions src/components/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default {
(formdata) => {
this.$firestore.collection('projects').doc(this.id).update(formdata)
},
schemas.project,
schemas.project(),
this.$store.getters.projectData(this.id)
)
},
Expand All @@ -298,7 +298,7 @@ export default {
showFormDialog(
'Add new application',
(formdata) => {this.addApp(formdata.name)},
schemas.app
schemas.app()
)
},
addApp: function (name) {
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/AddProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var addProjectMixin = {
console.log('caught', e)
})
},
schemas.project
schemas.project()
)
}
})
Expand Down
10 changes: 5 additions & 5 deletions src/schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Django from '@/django/'

const django = new Django()

const project = [
const project = () => [
{
fieldType: "TextInput",
placeholder: "This will be the importable python name for your project.",
Expand All @@ -24,7 +24,7 @@ const project = [
}
]

const app = [
const app = () => [
{
fieldType: "TextInput",
placeholder: "This will be the importable python name for your app.",
Expand All @@ -35,7 +35,7 @@ const app = [
}
]

const model = [
const model = () => [
{
fieldType: "TextInput",
placeholder: "amodel",
Expand All @@ -58,7 +58,7 @@ const model = [
}
]

const field = [
const field = () => [
{
fieldType: "TextInput",
placeholder: "afield",
Expand Down Expand Up @@ -91,7 +91,7 @@ const field = [
}
]

const relationship = [
const relationship = () => [
{
fieldType: "TextInput",
placeholder: "arelationship",
Expand Down

0 comments on commit 54a432f

Please sign in to comment.