|
10 | 10 | thing: { value: "", validate: validator }, |
11 | 11 | property: { value: "", validate: validator }, |
12 | 12 | name: { value: "", validate: validator }, |
13 | | - propname: { value: "" } |
| 13 | + propname: { value: "" }, |
| 14 | + defaultname: { value: true } |
14 | 15 | }; |
15 | 16 |
|
16 | 17 | if (nodeName === "property in hist" || nodeName === "property in poll"){ |
|
64 | 65 | const connection = $("#node-input-connection").val(); |
65 | 66 | $("select#node-input-thing").empty(); |
66 | 67 | $("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); |
70 | 73 | } |
71 | 74 | $("#node-input-thing").trigger("change"); |
72 | 75 | }); |
|
84 | 87 | $("#node-input-property").change(() => { |
85 | 88 | const property_name = $("#node-input-property").find('option:selected').text(); |
86 | 89 | 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) { |
88 | 91 | this.propname = property_name; |
89 | 92 | $("#node-input-name").val(property_name); |
90 | 93 | } |
91 | 94 | $("#node-input-name").trigger("change"); |
92 | 95 | }); |
| 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 | + }); |
93 | 110 | }, |
94 | 111 | oneditsave: function () { |
95 | 112 | console.log("thing_id: " + this.thing); |
|
0 commit comments