diff --git a/src/components/AppView.vue b/src/components/AppView.vue index 422627e..f285d7d 100644 --- a/src/components/AppView.vue +++ b/src/components/AppView.vue @@ -272,7 +272,7 @@ export default { .doc(appid) .update(formdata); }, - schemas.app, + schemas.app(), { name: this.$store.getters.apps()[appid].data().name } ); }, @@ -323,7 +323,7 @@ export default { .doc(fieldid) .update(formdata); }, - schemas.field, + schemas.field(), { name: fieldData.name, type: fieldData.type, @@ -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); @@ -431,7 +437,7 @@ export default { formdata => { this.addField(model, formdata.name, formdata.type, formdata.args); }, - schemas.field + schemas.field() ); }, addModel: function( diff --git a/src/components/Project.vue b/src/components/Project.vue index 16f26b2..3778536 100644 --- a/src/components/Project.vue +++ b/src/components/Project.vue @@ -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) ) }, @@ -298,7 +298,7 @@ export default { showFormDialog( 'Add new application', (formdata) => {this.addApp(formdata.name)}, - schemas.app + schemas.app() ) }, addApp: function (name) { diff --git a/src/mixins/AddProject.js b/src/mixins/AddProject.js index f30f9f7..92ffa4c 100644 --- a/src/mixins/AddProject.js +++ b/src/mixins/AddProject.js @@ -38,7 +38,7 @@ var addProjectMixin = { console.log('caught', e) }) }, - schemas.project + schemas.project() ) } }) diff --git a/src/schemas/index.js b/src/schemas/index.js index ef7c7ec..1162c72 100644 --- a/src/schemas/index.js +++ b/src/schemas/index.js @@ -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.", @@ -24,7 +24,7 @@ const project = [ } ] -const app = [ +const app = () => [ { fieldType: "TextInput", placeholder: "This will be the importable python name for your app.", @@ -35,7 +35,7 @@ const app = [ } ] -const model = [ +const model = () => [ { fieldType: "TextInput", placeholder: "amodel", @@ -58,7 +58,7 @@ const model = [ } ] -const field = [ +const field = () => [ { fieldType: "TextInput", placeholder: "afield", @@ -91,7 +91,7 @@ const field = [ } ] -const relationship = [ +const relationship = () => [ { fieldType: "TextInput", placeholder: "arelationship",