diff options
author | Kristian Lyngstol <kly@kly.no> | 2019-02-13 20:41:13 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2019-02-13 20:47:24 +0100 |
commit | 813ed7a7bc6f906f261deedd23d487938323fe30 (patch) | |
tree | 24afa548294391e59ecaa22ac0837f3ab544399e /web/api/write/switches | |
parent | 146a858dce8133acc8284294e4262417b40611ff (diff) |
Front + api: Fix parsing of JSON-fields for switches
Sort of.
It's two issues at once, related:
1. API: The problem here was that the old way of updating tags simply didn't
use actual JSON, but just sent "'foo','bar','baz'" as a text string. This
seems dumb so I've made it send actual JSON now - just like the "placement"
field. This meant updating the API. And it's not pretty, but it works.
2. Front: I've simplified nms-types a bit (hopefully to provide to simple
methods: either get/set the raw value, or get/set strings. There was a bug
where we sent text-encoded json instead of real json, and the reason
was a confusion between when we're dealing with JSON and when we're
dealing with strings. Now we are explicit.
This makes the nmsEditRow-thing slightly uglier, but it needs to be fixed
properly either way. In the future, we should provide renderers and editors
based on types, e.g.: Placement-editor could start as a general-purpose
JSON-editor, and the "switch reference" should be a drop-down.... etc.
Fixes #202
Diffstat (limited to 'web/api/write/switches')
-rwxr-xr-x | web/api/write/switches | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/web/api/write/switches b/web/api/write/switches index e42c4b3..1f91d48 100755 --- a/web/api/write/switches +++ b/web/api/write/switches @@ -97,7 +97,9 @@ foreach my $tmp2 (@tmp) { push @dups, "not really, but: " . $switch{'placement'}; } if (defined($switch{'tags'})) { - $switch{'tags'} =~ s/'/"/g; + # MY GOD I HATE THIS + # But I'm too lazy to improve it more for now. + $switch{'tags'} = "[". join(",", map { "\"".$_."\"" } @{$switch{'tags'}})."]"; } my @set; map { |