Skip to content

Commit 3bd2eb2

Browse files
Return type under Code Edit, hr styles, other styles
1 parent a1d0112 commit 3bd2eb2

File tree

7 files changed

+61
-13
lines changed

7 files changed

+61
-13
lines changed

source/client/js/classEditor/class/MANIFEST.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,9 @@ export default {
578578
}
579579
},
580580
FormalSpec: {
581-
ignore: true // goes within code editor
581+
ignore: true, // goes within code editor
582+
default: "",
583+
type: "string"
582584
},
583585
GenerateAfter: {
584586
type: "string",
@@ -594,7 +596,9 @@ export default {
594596
},
595597
Implementation: {
596598
ignore: true,
597-
isCode: true
599+
isCode: true,
600+
returnTypeProperty: "ReturnType",
601+
formalSpecProperty: "FormalSpec"
598602
},
599603
Language: {
600604
default: "",
@@ -643,7 +647,8 @@ export default {
643647
},
644648
ReturnType: {
645649
default: "",
646-
type: "string"
650+
type: "string",
651+
ignore: true
647652
},
648653
ReturnTypeParams: {
649654
ignore: true,

source/client/js/classEditor/class/code.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { block, toggle } from "../../domUtils";
22
import { addChange } from "../changes";
33
import { Toast } from "../../toast";
44
import { updateGrid } from "../index";
5+
import { getKeywordView } from "./keyword";
56

67
/**
78
* Returns if the method code has routines.
@@ -20,12 +21,13 @@ function switchToRoutineCode (code) {
2021
return code.replace(/^/, "\t").replace(/\n/g, "\n\t");
2122
}
2223

23-
export function getCodeCaptionView ({ name, data, savePath }) {
24+
export function getCodeCaptionView ({ manifest, name, data, savePath }) {
2425

2526
let div = block(`div`, `property-block`),
2627
header = block(`div`),
2728
editBlock = block(`div`, `editor`),
28-
code = (data[name] || "").replace(/\r?\n$/, ""),
29+
code = (data[name] || "").replace(/\r?\n$/, ``),
30+
returnTypeProp = (manifest[name] || {})["returnTypeProperty"] || ``,
2931
ROUTINE_SUPPORT = hasRoutineCode(code),
3032
useRoutinesToggle = toggle(ROUTINE_SUPPORT),
3133
useRoutinesBlock = block(`div`, `property-block`),
@@ -42,6 +44,13 @@ export function getCodeCaptionView ({ name, data, savePath }) {
4244
vb.appendChild(useRoutinesToggle);
4345
useRoutinesBlock.appendChild(nb);
4446
useRoutinesBlock.appendChild(vb);
47+
if (returnTypeProp)
48+
header.appendChild(getKeywordView({
49+
propManifest: manifest[returnTypeProp],
50+
propName: returnTypeProp,
51+
propData: data["ReturnType"],
52+
savePath: savePath.concat(returnTypeProp)
53+
}));
4554
header.appendChild(useRoutinesBlock);
4655

4756
useRoutinesToggle.checkbox.addEventListener("change", () => {
@@ -78,7 +87,9 @@ export function getCodeCaptionView ({ name, data, savePath }) {
7887
saveChanges();
7988
});
8089

81-
div.appendChild(block(`hr`));
90+
let hr = block(`hr`);
91+
hr.setAttribute(`title`, `Code Editor`);
92+
div.appendChild(hr);
8293
div.appendChild(header);
8394
// setTimeout(() => new AutoGrid(header), 1);
8495
div.appendChild(editBlock);

source/client/js/classEditor/class/keyword.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ function getKeywordEditElement (propName, value, propManifest, savePath) {
77
if (type === "boolean") {
88
input = toggle(!!value);
99
input.checkbox.addEventListener(`change`, () => addChange(
10-
savePath.concat(propName),
10+
savePath,
1111
input.checkbox.checked ? 1 : 0
1212
));
1313
} else if (type === "string") { // string type
1414
input = block(`input`);
1515
input.type = "text";
1616
input.value = value;
1717
input.addEventListener(`input`, () => addChange(
18-
savePath.concat(propName),
18+
savePath,
1919
input.value
2020
));
2121
} else if (type === "select") selBlock: {
@@ -39,7 +39,7 @@ function getKeywordEditElement (propName, value, propManifest, savePath) {
3939
});
4040

4141
input.addEventListener(`change`, () => addChange(
42-
savePath.concat(propName),
42+
savePath,
4343
input.value
4444
));
4545

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ function getMemberDetailedBlock (classData, memberType, classMemberName) {
4646
if (propManifest.ignore || propManifest.default === data[propName]) continue;
4747
if (typeof data[propName] === "object") continue;
4848
container.appendChild(getKeywordView({
49-
propManifest, propName, propData: data[propName], savePath
49+
propManifest,
50+
propName,
51+
propData: data[propName],
52+
savePath: savePath.concat("propName")
5053
}));
5154
}
5255

5356
if (codePropName)
5457
container.appendChild(getCodeCaptionView({
55-
manifest: (MANIFEST[isClass ? "Class" : memberType] || {})[codePropName] || {},
58+
manifest: MANIFEST[isClass ? "Class" : memberType] || {},
5659
name: codePropName,
5760
data: data,
5861
savePath
@@ -150,7 +153,7 @@ function enableMember ({
150153
propManifest: propManifest,
151154
propName: propName,
152155
propData: propManifest.default || "",
153-
savePath: savePath
156+
savePath: savePath.concat(propName)
154157
}));
155158

156159
updateGrid();
@@ -173,6 +176,7 @@ function enableMember ({
173176
}
174177
});
175178
}
179+
176180
if (opened = !opened) {
177181
insertAfter(container, headerElement);
178182
prepend(controls, headerElement);
@@ -181,6 +185,8 @@ function enableMember ({
181185
controls.parentNode.removeChild(controls);
182186
clearSelection();
183187
}
188+
headerElement.classList.toggle("opened");
189+
184190
updateGrid();
185191
});
186192

source/client/js/domUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param {string} [textContent] - Optional content
66
* @returns {Element}
77
*/
8-
export function block (element = "div", className, textContent) {
8+
export function block (element = "div", className, textContent) {
99
let el = document.createElement(element || "div");
1010
if (className) el.className = className;
1111
if (textContent) el.textContent = textContent;

source/client/scss/basic.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,24 @@ button {
7474
}
7575

7676
hr {
77+
78+
position: relative;
7779
border: none;
7880
border-top: 1px solid #ccc;
7981
margin: .5em;
82+
83+
&:after {
84+
content: attr(title);
85+
position: absolute;
86+
top: -7px;
87+
font-size: 10px;
88+
font-family: inherit;
89+
width: 100%;
90+
text-align: center;
91+
color: #ccc;
92+
text-shadow: 0 -1px 2px #fff, 0 1px 2px #fff;
93+
}
94+
8095
}
8196

8297
.toggle {

source/client/scss/classBuilder/card.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ $headerIconSize: $medium;
126126
.header {
127127

128128
> .label {
129+
129130
font-size: $normal;
130131
font-weight: bold;
131132
white-space: nowrap;
132133
overflow: hidden;
133134
text-overflow: ellipsis;
134135
line-height: $headerIconSize;
136+
135137
}
136138

137139
}
@@ -216,6 +218,15 @@ $headerIconSize: $medium;
216218
display: inline-block;
217219
}
218220

221+
&.opened {
222+
223+
> .label > .name {
224+
font-weight: bold;
225+
text-decoration: underline;
226+
}
227+
228+
}
229+
219230
> .controls {
220231

221232
float: right;

0 commit comments

Comments
 (0)