Skip to content

Commit e967e5a

Browse files
Making class wider when editing code, AutoGrid cards width fixes
1 parent ff09a0f commit e967e5a

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cache-visual-editor",
33
"printableName": "Cache Visual Editor",
44
"packageName": "VisualEditor",
5-
"version": "0.8.6",
5+
"version": "0.8.7",
66
"description": "Visual class editor for InterSystems Caché",
77
"main": "index.js",
88
"keywords": [

source/client/js/classEditor/class/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export function getClassElement (data) {
1919
}`),
2020
header = block(`div`, `header`);
2121

22+
data[`__visualClassElement`] = card;
23+
2224
if (type === "class") // float priority
2325
head.appendChild(controls);
2426
head.appendChild(headIcon);

source/client/js/classEditor/class/member.js

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getKeywordView } from "./keyword";
66
import MANIFEST from "./MANIFEST";
77
import { MEMBER_SECTIONS, getMemberSection } from "./memberSection";
88
import { getCodeCaptionView } from "./code";
9+
import { updateGridElement } from "./../index";
910

1011
/**
1112
* Creates and returns interactive class block property editor.
@@ -85,6 +86,9 @@ function enableMember ({
8586
? [classData["Name"]]
8687
: [classData["Name"], classBlockName, classBlockPropName];
8788

89+
if (typeof classData[`__visualCodeBlocksOpened`] === "undefined")
90+
classData[`__visualCodeBlocksOpened`] = 0;
91+
8892
headerElement.addEventListener(`click`, () => {
8993
if (!container) {
9094

@@ -187,6 +191,13 @@ function enableMember ({
187191
}
188192
headerElement.classList.toggle("opened");
189193

194+
if (classBlockName === "Methods") {
195+
classData[`__visualCodeBlocksOpened`] += opened ? 1 : -1;
196+
updateGridElement(classData[`__visualClassElement`], {
197+
width: classData[`__visualCodeBlocksOpened`] > 0 ? 2 : 1
198+
});
199+
}
200+
190201
updateGrid();
191202
});
192203

source/client/js/classEditor/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ let grid = onInit(() => grid = new AutoGrid(document.querySelector("#classBuilde
2222
* Function which updates current grid.
2323
*/
2424
export function updateGrid () {
25-
window.autoGrid = grid;
2625
grid.updateGrid();
2726
}
2827

28+
export function updateGridElement (element, data = {}) {
29+
if (element instanceof HTMLElement)
30+
grid.updateChild(element, data);
31+
}
32+
2933
/**
3034
* Behaviors for elements on page.
3135
* @type {HTMLElement}

0 commit comments

Comments
 (0)