mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-07 05:04:58 -05:00
Use consistent value caching format
This commit is contained in:
@@ -216,7 +216,7 @@ var InputBatchSender = function(shinyapp) {
|
||||
|
||||
var InputNoResendDecorator = function(target, initialValues) {
|
||||
this.target = target;
|
||||
this.lastSentValues = initialValues || {};
|
||||
this.lastSentValues = this.reset(initialValues);
|
||||
};
|
||||
(function() {
|
||||
this.setInput = function(name, value) {
|
||||
@@ -235,10 +235,25 @@ var InputNoResendDecorator = function(target, initialValues) {
|
||||
this.lastSentValues[inputName] = { jsonValue, inputType };
|
||||
this.target.setInput(name, value);
|
||||
};
|
||||
this.reset = function(values) {
|
||||
values = values || {};
|
||||
var strValues = values;
|
||||
this.lastSentValues = strValues;
|
||||
this.reset = function(values = {}) {
|
||||
// Given an object with flat name-value format:
|
||||
// { x: "abc", "y.shiny.number": 123 }
|
||||
// Create an object in cache format and save it:
|
||||
// { x: { jsonValue: '"abc"', inputType: "" },
|
||||
// y: { jsonValue: "123", inputType: "shiny.number" } }
|
||||
const cacheValues = {};
|
||||
|
||||
for (let inputName in values) {
|
||||
if (values.hasOwnProperty(inputName)) {
|
||||
let { name, inputType } = splitInputNameType(inputName);
|
||||
cacheValues[name] = {
|
||||
jsonValue: JSON.stringify(values[inputName]),
|
||||
inputType: inputType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
this.lastSentValues = cacheValues;
|
||||
};
|
||||
}).call(InputNoResendDecorator.prototype);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user