Skip to content

Commit 954e4d2

Browse files
committed
refactor EditAttributesView
1 parent 528782f commit 954e4d2

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

media/CircleEditor/view-sidebar.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,8 @@ sidebar.EditAttributesView = class {
274274
return (au < bu) ? -1 : (au > bu) ? 1 : 0;
275275
});
276276
this._addHeader('Attributes');
277-
let index = 0;
278-
for (const attribute of sortedAttributes) {
279-
this._addAttribute(attribute.name, attribute, index);
280-
index++;
277+
for (let idx = 0; idx < sortedAttributes.length; idx++) {
278+
this._addAttribute(sortedAttributes[idx].name, sortedAttributes[idx], idx);
281279
}
282280
if (isCustom === true) {
283281
const addAttribute = this._host.document.createElement('div');
@@ -321,10 +319,18 @@ sidebar.EditAttributesView = class {
321319
this._editObject._attribute[key.name] = key.value;
322320
this._editObject._attribute[key.name + '_type'] = key.type;
323321
}
324-
keys.push('attribute');
325-
this._editObject._attribute['attribute'] = 'value';
326-
this._editObject._attribute['attribute_type'] = 'string';
327-
this._editObject._attribute.keys = keys;
322+
323+
for (let i = 1; true; i++) {
324+
if (!keys.includes('NewAttribute' + i.toString())) {
325+
const key = 'NewAttribute' + i.toString();
326+
keys.push(key);
327+
328+
this._editObject._attribute[key] = 'Write a new value for this attribute';
329+
this._editObject._attribute[key + '_type'] = 'string';
330+
this._editObject._attribute.keys = keys;
331+
break;
332+
}
333+
}
328334

329335
vscode.postMessage({
330336
command: 'edit',

0 commit comments

Comments
 (0)