Skip to content

Commit 1ef8312

Browse files
Detailed view and a comment display
1 parent f2c92ff commit 1ef8312

File tree

6 files changed

+82
-20
lines changed

6 files changed

+82
-20
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cache-visual-editor",
33
"printableName": "Cache Visual Editor",
4-
"version": "0.3.1",
4+
"version": "0.3.2",
55
"description": "Visual class editor for InterSystems Caché",
66
"main": "index.js",
77
"keywords": [

source/client/js/classEditor/card.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { loadLevel } from "./index";
22
import { block } from "../utils";
3+
import { enableItem } from "./card/item";
34

45
function getPropertyBlock (prop) {
5-
let item = block(`div`, `item`),
6+
let item = block(`div`, `header`),
67
icon = block(`div`, `icon ${ prop["Private"] ? "private" : "public" }`),
78
text = block(`span`, `label`),
89
pName = block(`span`, `name`),
@@ -19,6 +20,7 @@ function getPropertyBlock (prop) {
1920
text.appendChild(pType);
2021
}
2122
item.appendChild(text);
23+
enableItem(item, prop);
2224
return item;
2325
}
2426

@@ -34,7 +36,9 @@ function getBlock (key, data) {
3436
break;
3537
}
3638
for (let prop in data[key]) {
37-
body.appendChild(getPropertyBlock(data[key][prop]));
39+
let div = block(`div`, `item`);
40+
div.appendChild(getPropertyBlock(data[key][prop]));
41+
body.appendChild(div);
3842
}
3943
return section;
4044

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { block, insertAfter, clearSelection } from "../../utils";
2+
import { updateGrid } from "../index";
3+
4+
function createView (data) {
5+
let container = block(`div`, `detailed`),
6+
comment = block(`div`, `comment`);
7+
container.appendChild(comment);
8+
comment.setAttribute("contenteditable", "true");
9+
if (data["Description"])
10+
comment.textContent = data["Description"];
11+
return container;
12+
}
13+
14+
export function enableItem (element, data) {
15+
16+
let opened = false,
17+
container;
18+
19+
element.addEventListener("click", () => {
20+
if (!container) container = createView(data);
21+
if (opened = !opened) {
22+
insertAfter(container, element);
23+
} else if (container.parentNode) {
24+
container.parentNode.removeChild(container);
25+
clearSelection();
26+
}
27+
updateGrid();
28+
});
29+
30+
}

source/client/js/classEditor/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ let initCallbacks = [];
1414
*/
1515
let grid = onInit(() => grid = new AutoGrid(document.querySelector("#classBuilderBody")));
1616

17+
export function updateGrid () {
18+
grid.updateGrid();
19+
}
20+
1721
/**
1822
* @type {HTMLElement}
1923
*/

source/client/js/utils.js

+11
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,15 @@ export function block (element = "div", className, textContent) {
1010
if (className) el.className = className;
1111
if (textContent) el.textContent = textContent;
1212
return el;
13+
}
14+
15+
export function insertAfter (elem, refElem) {
16+
return refElem.parentNode.insertBefore(elem, refElem.nextSibling);
17+
}
18+
19+
export function clearSelection () {
20+
if (window.getSelection)
21+
window.getSelection().removeAllRanges();
22+
else if (document.selection)
23+
document.selection.empty();
1324
}

source/client/scss/classBuilder/card.scss

+30-17
Original file line numberDiff line numberDiff line change
@@ -138,32 +138,45 @@ $headerIconWidth: 32px;
138138

139139
> .body {
140140

141-
> .item {
141+
.item {
142142

143-
overflow: hidden;
144-
white-space: pre;
145-
text-overflow: ellipsis;
146-
cursor: pointer;
147-
@include transition($defaultTransition);
143+
.header {
144+
145+
overflow: hidden;
146+
white-space: pre;
147+
text-overflow: ellipsis;
148+
cursor: pointer;
149+
@include transition($defaultTransition);
148150

149-
&:hover {
151+
&:hover {
150152

151-
padding-left: $defaultTransitionPadding;
152-
background: $colorP1;
153-
border-radius: 3px;
153+
padding-left: $defaultTransitionPadding;
154+
background: $colorP1;
155+
border-radius: 3px;
156+
157+
.name {
158+
text-decoration: underline;
159+
}
154160

155-
.name {
156-
text-decoration: underline;
157161
}
158162

159-
}
163+
.type {
160164

161-
.type {
165+
@include transition($defaultTransition);
162166

163-
@include transition($defaultTransition);
167+
&:hover {
168+
color: $colorP2;
169+
}
164170

165-
&:hover {
166-
color: $colorP2;
171+
}
172+
173+
}
174+
175+
.detailed {
176+
177+
.comment {
178+
color: gray;
179+
font-size: x-small;
167180
}
168181

169182
}

0 commit comments

Comments
 (0)