Skip to content

Commit 9eeb952

Browse files
committed
Improved the management of property name labels
1 parent 82e32c2 commit 9eeb952

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

arduino-cloud.html

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
thing: { value: "", validate: validator },
1111
property: { value: "", validate: validator },
1212
name: { value: "", validate: validator },
13-
propname: { value: "" }
13+
propname: { value: "" },
14+
defaultname: { value: true }
1415
};
1516

1617
if (nodeName === "property in hist" || nodeName === "property in poll"){
@@ -64,9 +65,11 @@
6465
const connection = $("#node-input-connection").val();
6566
$("select#node-input-thing").empty();
6667
$("select#node-input-property").empty();
67-
// $("#node-input-name").val("");
68-
if (connection !== "_ADD_") {
69-
initThings(connection, this.thing);
68+
if(this.defaultname) {
69+
$("#node-input-name").val("");
70+
}
71+
if (this.connection !== connection && connection !== "_ADD_") {
72+
initThings(connection);
7073
}
7174
$("#node-input-thing").trigger("change");
7275
});
@@ -84,12 +87,26 @@
8487
$("#node-input-property").change(() => {
8588
const property_name = $("#node-input-property").find('option:selected').text();
8689
const property_value = $("#node-input-property").find('option:selected').val();
87-
if (property_name !== "" && property_value !== "" && property_value !== undefined && this.propname === "") {
90+
if (property_name !== "" && property_value !== "" && property_value !== undefined && this.defaultname) {
8891
this.propname = property_name;
8992
$("#node-input-name").val(property_name);
9093
}
9194
$("#node-input-name").trigger("change");
9295
});
96+
$("#node-input-name").change(() => {
97+
const name = $("#node-input-name").val();
98+
if (name === "") {
99+
this.defaultname = true;
100+
} else {
101+
if (this.propname !== "") {
102+
if (name !== this.propname) {
103+
this.defaultname = false;
104+
} else {
105+
this.defaultname = true;
106+
}
107+
}
108+
}
109+
});
93110
},
94111
oneditsave: function () {
95112
console.log("thing_id: " + this.thing);

0 commit comments

Comments
 (0)