This commit is contained in:
2020-08-28 21:17:32 +00:00
parent bc62c8ca0c
commit 41c508cffd

View File

@@ -31,44 +31,14 @@
</v-btn> </v-btn>
</v-btn-toggle> </v-btn-toggle>
</v-col> </v-col>
<v-col cols="12" v-show="activeTab != 'properties'"> <v-col cols="12" v-show="showEditor">
<h6>Editor here</h6> <div id="editContainer"></div>
<div
id="editContainer"
style="width:100%;height:100%;border:1px solid #ccc;"
></div>
<!-- <MonacoEditor
ref="editor"
v-model="obj.template"
language="javascript"
:options="monacoOptions"
/> -->
</v-col> </v-col>
<v-col cols="12" v-show="activeTab == 'properties'"> <v-col cols="12" v-show="activeTab == 'properties'">
<h5>Properties</h5> <h5>Properties</h5>
</v-col> </v-col>
</v-row> </v-row>
</div> </div>
<!-- <gz-report-viewer
:reportId="$route.params.recordid"
:ayaType="$route.params.ayatype"
[Required]
public string Name { get; set; }
public bool Active { get; set; }
public string Notes { get; set; }
public AuthorizationRoles Roles { get; set; }
[Required]
public AyaType ObjectType { get; set; }
public string Template { get; set; }
public string Style { get; set; }
public string JsPrerender { get; set; }
public string JsHelpers { get; set; }
[Required]
public ReportRenderType RenderType { get; set; }
/> -->
</template> </template>
<script> <script>
@@ -76,25 +46,25 @@
/* Xeslint-disable */ /* Xeslint-disable */
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
//https://github.com/egoist/vue-monaco
// import MonacoEditor from "vue-monaco";
import * as monaco from "monaco-editor"; import * as monaco from "monaco-editor";
const FORM_KEY = "ay-report-edit"; const FORM_KEY = "ay-report-edit";
export default { export default {
// components: {
// MonacoEditor
// },
mounted() { mounted() {
let monacoOptions = {
value: 'console.log("Hello, world");',
theme: "vs",
language: "javascript"
};
this.editor = monaco.editor.create( this.editor = monaco.editor.create(
document.getElementById("editContainer"), document.getElementById("editContainer"),
{ null
value: 'console.log("Hello, world");',
theme: "vs",
language: "javascript"
}
); );
console.log(this.editor); this.showEditor = false;
},
beforeDestroy() {
this.editor && this.editor.dispose();
}, },
beforeCreate() { beforeCreate() {
window.$gz.eventBus.$emit("menu-change", { window.$gz.eventBus.$emit("menu-change", {
@@ -116,8 +86,9 @@ export default {
monacoOptions: { automaticLayout: true }, monacoOptions: { automaticLayout: true },
editor: null, editor: null,
editAreaHeight: 300, editAreaHeight: 300,
activeTab: "template", activeTab: "properties",
lastTab: "template", lastTab: "properties",
showEditor: true,
obj: { obj: {
id: 0, id: 0,
concurrency: 0, concurrency: 0,
@@ -176,8 +147,12 @@ import router from "./router";
onViewChange() { onViewChange() {
let vm = this; let vm = this;
let editor = vm.$refs.editor ? vm.$refs.editor.getEditor() : null; let editor = vm.$refs.editor ? vm.$refs.editor.getEditor() : null;
console.log(`Switching from ${vm.lastTab} to ${vm.activeTab}`); // console.log(`Switching from ${vm.lastTab} to ${vm.activeTab}`);
console.log("editor", editor); // console.log("editor", editor);
//todo: use function below for inspiration to save editor state and contents as necessary and switch views
//Note that properties tab doesn't mean need to dump editor as user could be switching back and forth
//so really the lasttab needs to be the last edited tab because we don't need to save when going to properties from script and back again
//save last view stuff //save last view stuff
switch (vm.lastTab) { switch (vm.lastTab) {
@@ -196,43 +171,58 @@ import router from "./router";
//set new view stuff //set new view stuff
switch (vm.activeTab) { switch (vm.activeTab) {
case "properties": case "properties":
vm.showEditor = false;
break; break;
case "template": case "template":
vm.showEditor = true;
break; break;
case "style": case "style":
vm.showEditor = true;
break; break;
case "jsprerender": case "jsprerender":
vm.showEditor = true;
break; break;
case "jshelpers": case "jshelpers":
vm.showEditor = true;
break; break;
} }
vm.lastTab = vm.activeTab; vm.lastTab = vm.activeTab;
/*
function changeTab(selectedTabNode, desiredModelId) {
for (var i = 0; i < tabArea.childNodes.length; i++) {
var child = tabArea.childNodes[i];
if (/tab/.test(child.className)) {
child.className = 'tab';
}
}
selectedTabNode.className = 'tab active';
var currentState = editor.saveViewState();
var currentModel = editor.getModel();
if (currentModel === data.js.model) {
data.js.state = currentState;
} else if (currentModel === data.css.model) {
data.css.state = currentState;
} else if (currentModel === data.html.model) {
data.html.state = currentState;
}
editor.setModel(data[desiredModelId].model);
editor.restoreViewState(data[desiredModelId].state);
editor.focus();
}
*/
}, },
onResize() { onResize() {
// this.editAreaHeight = window.innerHeight / 2; let el = document.getElementById("editContainer");
this.editAreaHeight = window.innerHeight * 0.89; el.style = `width:100%;height:${window.innerHeight * 0.77}px`;
this.resizeEditors(); if (this.editor != null) {
//console.log(this.$refs.scriptEditor.$el.style); this.editor.layout();
},
resizeEditors() {
let h = `${this.editAreaHeight}px`;
// console.log("resizeEditor...");
let ed = this.$refs.editor;
if (ed != null) {
// console.log("editor setting height", h);
ed.$el.style.height = h;
} }
// ed = this.$refs.cssEditor;
// if (ed != null) {
// console.log("cssEditor setting height", h);
// ed.$el.style.height = h;
// }
} }
// ,
// editStyle() {
// return "width: 100%;height: " + this.editAreaHeight + "px;";
// }
} }
}; };
</script> </script>