From d7f59dac841ef7167d6290ba055baa5c9d95d574 Mon Sep 17 00:00:00 2001 From: Hiroki Uchikawa <31908137+HirokiUchikawa@users.noreply.github.com> Date: Fri, 3 Nov 2017 01:50:35 +0900 Subject: [PATCH] Make it possible to save formatting choices separately by the type of object (#1458) --- editor/js/ui/utils.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/editor/js/ui/utils.js b/editor/js/ui/utils.js index 25542bfb1..819ba191f 100644 --- a/editor/js/ui/utils.js +++ b/editor/js/ui/utils.js @@ -171,7 +171,7 @@ RED.utils = (function() { } function formatNumber(element,obj,sourceId,path,cycle,initialFormat) { - var format = (formattedPaths[sourceId] && formattedPaths[sourceId][path]) || initialFormat || "dec"; + var format = (formattedPaths[sourceId] && formattedPaths[sourceId][path] && formattedPaths[sourceId][path]['number']) || initialFormat || "dec"; if (cycle) { if (format === 'dec') { if ((obj.toString().length===13) && (obj<=2147483647000)) { @@ -187,10 +187,12 @@ RED.utils = (function() { format = 'dec'; } formattedPaths[sourceId] = formattedPaths[sourceId]||{}; - formattedPaths[sourceId][path] = format; + formattedPaths[sourceId][path] = formattedPaths[sourceId][path]||{}; + formattedPaths[sourceId][path]['number'] = format; } else if (initialFormat !== undefined){ formattedPaths[sourceId] = formattedPaths[sourceId]||{}; - formattedPaths[sourceId][path] = format; + formattedPaths[sourceId][path] = formattedPaths[sourceId][path]||{}; + formattedPaths[sourceId][path]['number'] = format; } if (format === 'dec') { element.text(""+obj); @@ -204,7 +206,7 @@ RED.utils = (function() { } function formatBuffer(element,button,sourceId,path,cycle) { - var format = (formattedPaths[sourceId] && formattedPaths[sourceId][path]) || "raw"; + var format = (formattedPaths[sourceId] && formattedPaths[sourceId][path] && formattedPaths[sourceId][path]['buffer']) || "raw"; if (cycle) { if (format === 'raw') { format = 'string'; @@ -212,7 +214,8 @@ RED.utils = (function() { format = 'raw'; } formattedPaths[sourceId] = formattedPaths[sourceId]||{}; - formattedPaths[sourceId][path] = format; + formattedPaths[sourceId][path] = formattedPaths[sourceId][path]||{}; + formattedPaths[sourceId][path]['buffer'] = format; } if (format === 'raw') { button.text('raw');