Skip to content

Commit

Permalink
Merge pull request #390 from freon4dsl/show-validations
Browse files Browse the repository at this point in the history
Show validations
  • Loading branch information
annekekleppe authored Oct 9, 2024
2 parents 8783327 + c9a1df7 commit db07f5f
Show file tree
Hide file tree
Showing 83 changed files with 6,595 additions and 1,525 deletions.
7 changes: 7 additions & 0 deletions notes/Features-to-be-changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Strange and unexpected behaviour

There are number of behaviour in Freon that we should look into. They are a bit strange.
Either we should warn the user, or we should make some documentation, or ...

## Model unit name change
When the name of a model unit is changed it is saved in a different file. This is unexpected.
63 changes: 63 additions & 0 deletions notes/freon-bugs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Bugs

## Incorrect projection for expression

**Description:** When the AST specifies a specific expression, e.g. for `DocuProject.InsurancePart.risk`, the editor creates a generaic expression projection with a pre- and post- action box.
**Problem:** This is incorrect, as only a NumberLiteralExpression is allowed.

**Solution:** The projection generator should detect that the NumberLiyteralExpression is not a general expression and leave out the pre- and post boxes.

## Node version

(node:55540) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)

# ActionBox background remains blue

The background of a, actionbox become light blue when it is selected/editing. After leaving the actionbox it remains light blue, but it should remove the light blue background.

- TAB in CLICK out: remains blue

- TAB in TAB out: remains blue

- CLICK in TAB out: ok, blue background dissappears

- CLICK in CLICK out: ok, blue background dissappears

## Styling

In `core-svelte/src/notes-on-styling` the olf freon CSS variables are referred to.

This should now use the new css styles for the compponents

## After changing view, cursor is lost

After selecting other projections there is no focus in the editor. You need to first click somewhere.

The cursor should be inside the editor, eg st:

- the same element as it was before

- if that elemenet is not visible, at its paremt

- ...

# Box tree error

The following error occurrs:

` ERROR: Box: nextLeafRight: TextBox for ID-31 of concept Method is mising in its parent (index === -1)`

when selecting method type with click and tryinhg to tab right.

The internal textbox parent should be a referencebox.

**Solved:** AbstractSelectBox `children` returned empty array, but should return an array with the internal textbox.

## External property replacer cannot inpuit anything

In the external tester project the replacers for properties do not react upon any key stroke. So you cannot type anything.    

# LoggerSettings from webapp-lib to webapp-starter

See heading
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build-release": "npm run build-release --workspaces --if-present",
"publish-local": "npm run publish-local --workspaces --if-present",
"unpublish-local": "npm run unpublish-local --workspaces --if-present",
"republish-local": "npm run unpublish-local && npm run publish-local",
"install-local": "npm install --registry http://localhost:4873",
"lint": "npm run lint --workspaces --if-present",
"setup": "npm run setup --workspaces --if-present",
Expand Down Expand Up @@ -64,5 +65,5 @@
"packages/server",
"packages/test"
],
"version": "0.7.0-beta"
"version": "0.7.0-beta3"
}
73 changes: 0 additions & 73 deletions packages/core-svelte/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,6 @@
/* Projectional Editor "globals" */
--freon-colors-inverse_color: #d3e3fd; /* Text color on non_normal background */

--freon-editor-component-background-color: white; /* The background color of the editor */
--freon-editor-component-color: darkblue; /* The color of the text, unless set otherwise by the projection */
--freon-editor-component-font-size: 14px; /* The font size of the text, unless set otherwise by the projection */
--freon-editor-component-font-style: normal; /* The font size of the text, unless set otherwise by the projection */
--freon-editor-component-font-weight: normal; /* The font size of the text, unless set otherwise by the projection */
--freon-editor-component-font-family: "Arial"; /* The font size of the text, unless set otherwise by the projection */
--freon-editor-component-padding: 0px;
--freon-editor-component-margin: 0px;

--freon-dropdown-component-background-color: lightblue;
--freon-dropdown-component-color: blue;
--freon-dropdownitem-component-background-color: inherit;
--freon-dropdownitem-component-selected-color: inherit;
--freon-dropdownitem-component-selected-background-color: inherit;
--freon-dropdownitem-component-hover-color: inherit;
--freon-dropdownitem-component-hover-background-color: inherit;
--freon-dropdown-component-border-color: darkblue;
--freon-dropdownitem-component-color: darkblue;
--freon-dropdownitem-component-border-color: darkblue;

/* Selectable */
--freon-selected-background-color: rgba(211, 227, 253, 255);
--freon-selected-outline-color: inherit;
--freon-selected-outline-style: inherit;
--freon-selected-outline-width: inherit;

/* Others */
--freon-popup-box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.5);

/*--freon-text-component-font-size: 14px; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-text-component-font-style: normal; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-text-component-font-weight: normal; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-text-component-font-family: "Arial"; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-text-component-padding: 0px;*/
/*--freon-text-component-margin: 0px;*/
/*--freon-text-component-color: darkblue;*/
/*--freon-text-component-background-color: white;*/
/**/
/*--freon-text-component-placeholder-color: blue;*/
/*--freon-text-component-actionplaceholder-color: darkgrey;*/
/**/
/*--freon-label-component-font-style: normal; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-label-component-font-weight: normal; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-label-component-font-family: "Arial"; !* The font size of the text, unless set otherwise by the projection *!*/
/*--freon-label-component-font-size: inherit;*/
/*--freon-label-component-margin: 0px;*/
/*--freon-label-component-padding: 0px;*/
/*--freon-label-component-color: black;*/
/*--freon-label-component-background-color: inherit;*/

--freon-grid-component-border-color: inherit;
--freon-grid-component-border-width: inherit;
--freon-grid-component-border-style: inherit;

--freon-gridcell-component-padding:inherit;
--freon-gridcell-component-margin: inherit;
--freon-gridcell-component-background-color: inherit;
--freon-gridcell-component-color: inherit;
--freon-gridcell-component-justify-left: stretch;

--freon-horizontallist-component-margin: 0px;
--freon-horizontallist-component-padding: 0px;
--freon-horizontallist-component-align-items: baseline;

--freon-verticallist-component-padding: 0px;
--freon-verticallist-component-margin: 0px;
--freon-verticallist-component-border-color: inherited;
--freon-verticallist-component-border-width: inherited;
--freon-verticallist-component-border-style: inherited;
--freon-horizontallist-component-border-color: inherited;
--freon-horizontallist-component-border-width: inherited;
--freon-horizontallist-component-border-style: inherited;

--freon-boolean-checkbox-color: orange;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"access": "public"
},
"name": "@freon4dsl/core-svelte",
"version": "0.7.0-beta",
"version": "0.7.0-beta3",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/freon4dsl/Freon4dsl"
"url": "git+https://github.com/freon4dsl/Freon4dsl.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,7 @@
"!dist/**/*.spec.*"
],
"devDependencies": {
"@freon4dsl/core": "^0.7.0-beta",
"@freon4dsl/core": "^0.7.0-beta3",
"mobx": "^6.12.3",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/svelte": "^5.1.0",
Expand All @@ -70,7 +70,7 @@
"@material/switch": "^14.0.0",
"@smui/ripple": "^7.0.0",
"svelte": "^4.2.17",
"@freon4dsl/core": "^0.7.0-beta",
"@freon4dsl/core": "^0.7.0-beta3",
"mobx": "^6.12.3"
}
}
2 changes: 1 addition & 1 deletion packages/core-svelte/src/Notes-on-styling.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RadioComponent uses "--mdc-theme-secondary" for its color, if you want to override this value set "--freon-boolean-radiobox-color".
CheckComponent uses "--mdc-theme-secondary", if you want to override set "--freon-boolean-checkbox-color".
CheckComponent uses "--mdc-theme-secondary", if you want to override use "--freon-boolean-checkbox-color".
SwitchComponent uses "--mdc-theme-primary", if you want to override set "--freon-boolean-switch-color".
NumericSliderComponent uses "--mdc-theme-primary", if you want to override set "--freon-numeric-slider-color".
InnerSwitchComponent uses "--mdc-theme-primary", if you want to override set "--freon-boolean-switch-color".
28 changes: 5 additions & 23 deletions packages/core-svelte/src/lib/components/ContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* such that the complete menu stays within the bounderies of the editor viewport. The state of the editor
* viewport is stored in the EditorViewportStore (by FreonComponent).
*/
import { clickOutsideConditional } from "./svelte-utils/index.js";
import { calculatePos, clickOutsideConditional } from "./svelte-utils/index.js";
import { tick } from "svelte";
import { FreLogger, MenuItem, FreEditor } from "@freon4dsl/core";
import { contextMenuVisible } from "./svelte-utils/ContextMenuStore.js";
Expand Down Expand Up @@ -70,7 +70,7 @@
*/
async function openSub(itemIndex: number) {
submenuOpen = true;
await tick(); // wait in order to detemrine the size of the submenu
await tick(); // wait in order to determine the size of the submenu
// determine the 'normal' position of the sub menu, which is
// (itemHeight px) lower than the main menu, 20 px left to the end of the item
topSub = top + itemHeight + itemIndex * (itemHeight + 2 + 3 + 4); // add 2 for gap, 3 for margin, 4 for padding
Expand All @@ -80,31 +80,13 @@
leftSub = calculatePos($viewport.height, submenuHeight, leftSub);
}
/**
* This calculates the position of the context- or sub-menu, either on x-axis or y-axis
*/
function calculatePos(editor: number, menu: number, mouse: number): number {
let result: number;
// see if the menu will fit in the editor view, if not: position it left/up, not right/down of the mouse click
if (editor - mouse < menu) {
result = mouse - menu;
} else {
result = mouse;
}
// if the result should be outside the editor view, then position it on the leftmost/uppermost point
if (result < 0) {
result = 0;
}
return result;
}
/**
* This function finds the context menu dimensions the moment that
* $contextMenuVisible becomes true and the menu is shown.
*/
function getContextMenuDimension(node: HTMLElement) {
menuHeight = node.offsetHeight;
menuWidth = node.offsetWidth;
function getContextMenuDimension(htmlElement: HTMLElement) {
menuHeight = htmlElement.offsetHeight;
menuWidth = htmlElement.offsetWidth;
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
};
</script>

<span class="dropdown-component-container">
<nav class="dropdown-component"
id="{id}"
>
Expand All @@ -50,3 +51,10 @@
</div>
{/if}
</nav>
</span>

<style>
.dropdown-component-container {
position: relative;
}
</style>
45 changes: 45 additions & 0 deletions packages/core-svelte/src/lib/components/ErrorMarker.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script lang="ts">
import {afterUpdate, onMount, tick} from "svelte";
import ErrorTooltip from "$lib/components/ErrorTooltip.svelte";
import {viewport} from "$lib/components/svelte-utils/index.js";
import {Box} from "@freon4dsl/core";
export let box: Box;
export let element;
let content;
let top = 10;
let height = 8;
async function calcPos() {
await tick();
if (!!element) {
let elementRect = element.getBoundingClientRect();
if (!!elementRect) {
// console.log(`ErrorMarker top ${elementRect.top} bottom ${elementRect.bottom} height ${elementRect.height} viewport.top ${$viewport.top}`)
// get the position of the element relative to the editor view
top = elementRect.top - $viewport.top;
} else {
console.log("No bounding rect")
}
} else {
console.log("NO element")
}
}
onMount(() => {
calcPos();
content = box.errorMessages;
})
afterUpdate( () => {
calcPos();
content = box.errorMessages;
})
// todo Calculate parentLeft, or change it to parentRight. At the moment we assume that the ErrorMarker is at the left border of the FreonComponent.
</script>

<span class="error-positioning" style="top: {top}px; height: {height}px;">
<ErrorTooltip {box} hasErr={true} parentTop={top} parentLeft={2}>
<span class="error-marker" style="height: {height}px;">&nbsp</span>
</ErrorTooltip>
</span>
71 changes: 71 additions & 0 deletions packages/core-svelte/src/lib/components/ErrorTooltip.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!-- Copied and adapted from https://svelte.dev/repl/dd6754a2ad0547c5b1c1ea37c0293fef?version=4.2.19 -->

<script lang="ts">
import { viewport } from "$lib/components/svelte-utils/EditorViewportStore.js";
import {Box} from "@freon4dsl/core";
export let box: Box;
export let hasErr: boolean = false;
export let parentTop: number = 0;
export let parentLeft: number = 0;
let content: string[] = [];
let isHovered: boolean = false;
// position of error message(s)
let top = 0;
let left = 0;
async function mouseOver(event: MouseEvent) {
if (hasErr) {
isHovered = true;
// Get the position of the mouse relative to the editor view and - if applicable - to its ErrorMarker parent.
// Because an ErrorMarker also has its 'position' set to something other than 'static', we need to take its position into account.
left = event.pageX - $viewport.left - parentLeft + 5;
top = event.pageY - $viewport.top - parentTop + 5;
// console.log(`ErrorTooltip: left-top [${left}, ${top}] event [${event.pageX}, ${event.pageY}] parent [${parentLeft}, ${parentTop}] viewport [${$viewport.left}, ${$viewport.top}]`)
content = box.errorMessages;
}
}
function mouseMove(event: MouseEvent) {
if (hasErr && isHovered) {
// Get the position of the mouse relative to the editor view and - if applicable - to its ErrorMarker parent.
// Because an ErrorMarker also has its 'position' set to something other than 'static'.
left = event.pageX - $viewport.left - parentLeft + 5;
top = event.pageY - $viewport.top - parentTop + 5;
}
}
function mouseLeave() {
isHovered = false;
}
// Empty function to avoid error: "Svelte: A11y: on:mouseover must be accompanied by on:focus"
function onFocus() {
}
</script>

<span role= "group"
on:mouseover={mouseOver}
on:mouseleave={mouseLeave}
on:mousemove={mouseMove}
on:focus={onFocus}
>
<slot />
</span>

{#if isHovered}
<div
style="top: {top}px; left: {left}px;"
class="error-tooltip"
>
{#if content.length > 1}
<ol class="error-tooltip-list-content">
{#each content as item}
{#if item.length > 0}
<li>{item}</li>
{/if}
{/each}
</ol>
{:else}
<span class="error-tooltip-single-content">{content[0]} </span>
{/if}
</div>
{/if}
Loading

0 comments on commit db07f5f

Please sign in to comment.