diff --git a/frontend/src/components/sidebar/ModelManager.vue b/frontend/src/components/sidebar/ModelManager.vue
index 5bb0f84..85780a5 100644
--- a/frontend/src/components/sidebar/ModelManager.vue
+++ b/frontend/src/components/sidebar/ModelManager.vue
@@ -6,16 +6,16 @@
-
+
- Editor Sources
+ Editor Sources ({{ editors.length }})
@@ -26,14 +26,8 @@
No active model
-
diff --git a/frontend/src/components/sidebar/model/AddEditorToModelPopup.vue b/frontend/src/components/sidebar/model/AddEditorToModelPopup.vue
index 27632b8..9f10b28 100644
--- a/frontend/src/components/sidebar/model/AddEditorToModelPopup.vue
+++ b/frontend/src/components/sidebar/model/AddEditorToModelPopup.vue
@@ -1,9 +1,7 @@
-
-
-
+
@@ -15,7 +13,7 @@
+ :items="editors" item-title="name">
@@ -65,13 +63,10 @@ export default {
model: [Model, LocalModel],
},
computed: {
- ...mapGetters(['editors']),
- },
- mounted: () => {
- // console.log(this.connections)
+ ...mapGetters(['editors', 'activeEditor', 'getConnectionByName',]),
},
methods: {
- ...mapActions(['addEditorToModel']),
+ ...mapActions(['addEditorToModel', 'newEditor']),
showPopup() {
this.dialog = true;
},
@@ -79,6 +74,22 @@ export default {
this.localAddEditorToModel();
},
localAddEditorToModel() {
+ // create it with alias name if not exist
+ let local = this;
+ if (!this.editor) {
+ const fullConnection = local.getConnectionByName(local.activeEditor.connection)
+
+ local.newEditor({
+ name: local.name,
+ connection: fullConnection,
+ syntax: 'preql',
+ }).then(() => {
+ local.editor = local.name
+ return localAddEditortoModel()
+ })
+
+ }
+ //otherwise add
this.addEditorToModel({
alias: this.name,
editor: this.editor,
diff --git a/frontend/src/store/modules/editors.ts b/frontend/src/store/modules/editors.ts
index 926d21b..6ed8684 100644
--- a/frontend/src/store/modules/editors.ts
+++ b/frontend/src/store/modules/editors.ts
@@ -191,6 +191,9 @@ const mutations = {
},
newEditor(state, data) {
let newEd: Editor | RawEditor | null = null
+ if (!data.name) {
+ throw Error('Editor name is required')
+ }
if (data.syntax === 'preql') {
newEd = new Editor(data.name, data.connection.type, data.connection.name,);
}