Skip to content

Commit

Permalink
fix(modeler/jsonforms): fix bugs (#589)
Browse files Browse the repository at this point in the history
* fix(modeler): flatten element templates if given in an array and change default location to .camunda/element-templates

* feat(modeler): ask for execution platform if a new diagram is created

* fix(modeler/jsonforms): commands
  • Loading branch information
peterhnm authored May 9, 2024
1 parent 979d962 commit 4eec588
Show file tree
Hide file tree
Showing 46 changed files with 1,725 additions and 2,585 deletions.
15 changes: 14 additions & 1 deletion apps/miranum-extension-pack/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.11] - 2024-05-09

### Added

* **\[Miranum Modeler\]** Ask for the execution platform when a new diagram is created (#589)

### Fixed

* **\[Miranum Modeler\]** Flatten the element templates if given in an array (#589)
* **\[Miranum Modeler\]** Minor bug fixes (#589)
* **\[Miranum Jsonforms\]** Minor bug fixes (#589)

## [0.5.10] - 2024-04-30

### Fixed
Expand Down Expand Up @@ -101,7 +113,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* **\[Miranum Console\]** Use a single webview when the user triggers the available commands (#125)


[unreleased]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.10-vscode...HEAD
[unreleased]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.11-vscode...HEAD
[0.5.11]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.10...release/v0.5.11-vscode
[0.5.10]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.9...release/v0.5.10-vscode
[0.5.9]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.8...release/v0.5.9-vscode
[0.5.8]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.7...release/v0.5.8-vscode
Expand Down
66 changes: 38 additions & 28 deletions apps/miranum-jsonforms-preview-webview/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Command,
createResolver,
GetJsonFormCommand,
GetSettingCommand,
JsonFormQuery,
LogErrorCommand,
Query,
Expand All @@ -29,7 +30,7 @@ import { minimalSchema, minimalUiSchema, personSchema, personUiSchema } from "./
let defaultSchema: JsonSchema = minimalSchema;
let defaultUiSchema: UISchemaElement = minimalUiSchema;
let defaultRenderer: JsonFormsRendererRegistryEntry[] = [];
let defaultRenderer: JsonFormsRendererRegistryEntry[] = [...vuetifyRenderers];
if (import.meta.env.MODE === "development") {
defaultSchema = personSchema;
Expand All @@ -40,11 +41,13 @@ if (import.meta.env.MODE === "development") {
const vscode = getVsCodeApi();
const jsonFormResolver = createResolver<JsonFormQuery>();
const settingResolver = createResolver<SettingQuery>();
const previewSetting = ref<string>();
const key = ref(0);
const previewSchema = ref<JsonSchema>(defaultSchema);
const previewUiSchema = ref<UISchemaElement>(defaultUiSchema);
const renderers = ref<JsonFormsRendererRegistryEntry[]>(defaultRenderer);
const rendererStyle = ref<string>("");
const previewData = ref<any>({});
Expand All @@ -62,9 +65,14 @@ onBeforeMount(async () => {
}
vscode.postMessage(new GetJsonFormCommand());
vscode.postMessage(new GetSettingCommand());
const jsonFormQuery = await jsonFormResolver.wait();
const settingQuery = await settingResolver.wait();
loading = false;
updateRenderer(jsonFormQuery?.schema, jsonFormQuery?.uischema);
updateSchema(jsonFormQuery?.schema, jsonFormQuery?.uischema);
updateRenderer(settingQuery?.renderer);
});
onUnmounted(() => {
Expand All @@ -89,8 +97,12 @@ async function onReceiveMessage(message: MessageEvent<Query | Command>) {
case queryOrCommand.type === "SettingQuery": {
const settingQuery = queryOrCommand as SettingQuery;
try {
previewSetting.value = settingQuery.renderer;
renderers.value = getRenderers(settingQuery.renderer);
if (loading) {
settingResolver.done(settingQuery);
return;
}
updateRenderer(settingQuery.renderer);
} catch (error) {
vscode.postMessage(new LogErrorCommand((error as Error).message));
}
Expand All @@ -99,26 +111,32 @@ async function onReceiveMessage(message: MessageEvent<Query | Command>) {
}
}
function getRenderers(id?: RendererOption): JsonFormsRendererRegistryEntry[] {
switch (id) {
case "vuetify":
return [...vuetifyRenderers];
case "vanilla":
return [...vanillaRenderers, ...boplusVueVanillaRenderers];
default:
throw new Error("Unknown renderer id: " + id);
}
}
const debouncedUpdate = debounce(updateSchema, 100);
const debouncedUpdate = debounce(updateRenderer, 100);
function updateRenderer(schema?: JsonSchema, uischema?: UISchemaElement): void {
function updateSchema(schema?: JsonSchema, uischema?: UISchemaElement): void {
if (schema) {
previewSchema.value = schema;
}
if (uischema) {
previewUiSchema.value = uischema;
}
key.value++;
}
function updateRenderer(id?: RendererOption) {
switch (id) {
case "vuetify":
renderers.value = [...vuetifyRenderers];
rendererStyle.value = "";
break;
case "vanilla":
renderers.value = [...vanillaRenderers, ...boplusVueVanillaRenderers];
rendererStyle.value = "styleA";
break;
default:
throw new Error("Unknown renderer id: " + id);
}
key.value++;
}
function onUpdate(jsonForm: any) {
Expand All @@ -130,17 +148,9 @@ function onUpdate(jsonForm: any) {
<template>
<div class="flex flex-col">
<div class="card p-4" style="min-height: 106px">
<div v-if="previewSetting === 'vanilla'" class="styleA">
<JsonForms
:data="previewData"
:renderers="renderers"
:schema="previewSchema"
:uischema="previewUiSchema"
@change="onUpdate"
/>
</div>
<div v-else>
<div :class="rendererStyle">
<JsonForms
:key="key"
:data="previewData"
:renderers="renderers"
:schema="previewSchema"
Expand Down
9 changes: 8 additions & 1 deletion apps/miranum-jsonforms/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.11] - 2024-05-09

### Fixed

* Minor bug fixes (#589)

## [0.5.10] - 2024-04-30

### Fixed
Expand Down Expand Up @@ -55,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Correction of tabs placement in preview (#59)

[unreleased]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.10-vscode...HEAD
[unreleased]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.11-vscode...HEAD
[0.5.11]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.10...release/v0.5.11-vscode
[0.5.10]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.9...release/v0.5.10-vscode
[0.5.9]: https://github.com/Miragon/miranum-ide/compare/release/v0.5.8...release/v0.5.9-vscode
24 changes: 14 additions & 10 deletions apps/miranum-jsonforms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"contributes": {
"customEditors": [
{
"viewType": "miranum-jsonforms.formBuilder",
"id": "miranum-jsonforms.formBuilder",
"viewType": "miranum-jsonforms.formEditor",
"id": "miranum-jsonforms.formEditor",
"displayName": "Miranum: JsonForms Editor",
"selector": [
{
Expand Down Expand Up @@ -99,44 +99,48 @@
{
"command": "miranum-jsonforms.togglePreview",
"key": "ctrl+shift+p",
"when": "miranum-jsonforms.formBuilderCounter > 0"
"when": "miranum-jsonforms.formEditorCounter > 0"
},
{
"command": "miranum-jsonforms.toggleTextEditor",
"key": "ctrl+shift+t",
"when": "miranum-jsonforms.formBuilderCounter > 0"
"when": "miranum-jsonforms.formEditorCounter > 0"
},
{
"command": "miranum-jsonforms.openLoggingConsole",
"key": "ctrl+shift+l",
"when": "miranum-jsonforms.formBuilderCounter > 0"
"when": "miranum-jsonforms.formEditorCounter > 0"
}
],
"menus": {
"commandPalette": [
{
"command": "miranum-jsonforms.togglePreview",
"when": "miranum-jsonforms.formBuilderCounter > 0"
"when": "miranum-jsonforms.formEditorCounter > 0"
},
{
"command": "miranum-jsonforms.toggleTextEditor",
"when": "miranum-jsonforms.formBuilderCounter > 0"
"when": "miranum-jsonforms.formEditorCounter > 0"
},
{
"command": "miranum-jsonforms.openLoggingConsole",
"when": "miranum-jsonforms.formBuilderCounter > 0"
"when": "miranum-jsonforms.formEditorCounter > 0"
},
{
"command": "miranum-jsonforms.splitFormFile",
"when": "miranum-jsonforms.formEditorCounter > 0"
}
],
"editor/title": [
{
"command": "miranum-jsonforms.togglePreview",
"group": "navigation",
"when": "activeWebviewPanelId == 'miranum-jsonforms.formBuilder'"
"when": "activeWebviewPanelId == 'miranum-jsonforms.formEditor'"
},
{
"command": "miranum-jsonforms.toggleTextEditor",
"group": "navigation",
"when": "activeWebviewPanelId == 'miranum-jsonforms.formBuilder'"
"when": "activeWebviewPanelId == 'miranum-jsonforms.formEditor'"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/miranum-jsonforms/src/adapter/helper/vscode/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getNonce } from "@miranum-ide/vscode/miranum-vscode";
const formBuilderProjectPath = "miranum-jsonforms-builder-webview";
const formPreviewProjectPath = "miranum-jsonforms-preview-webview";

export function formBuilderUi(webview: Webview, extensionUri: Uri): string {
export function formEditorUi(webview: Webview, extensionUri: Uri): string {
const baseUri = Uri.joinPath(extensionUri, formBuilderProjectPath);

const scriptUri = webview.asWebviewUri(Uri.joinPath(baseUri, "index.js"));
Expand Down
8 changes: 4 additions & 4 deletions apps/miranum-jsonforms/src/adapter/in/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class VsCodeToggleFormPreviewCommand {
);
}

toggle() {
this.formPreviewAdapter.toggle();
async toggle() {
await this.formPreviewAdapter.toggle();
}
}

Expand All @@ -73,8 +73,8 @@ export class VsCodeToggleTextEditorCommand {
);
}

toggle() {
this.toggleTextEditorInPort.toggle();
async toggle() {
await this.toggleTextEditorInPort.toggle();
}
}

Expand Down
Loading

0 comments on commit 4eec588

Please sign in to comment.