Commit 9da14a5d authored by Vivek's avatar Vivek

updated spreadsheet data model. made state-transfer methods same for all type of gadgets.

parent 65d0dbd8
...@@ -288,7 +288,7 @@ ...@@ -288,7 +288,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.32516.10981.40311</string> </value> <value> <string>945.32551.59996.17425</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1441288577.91</float> <float>1441714251.16</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
var current_state = {},\n var current_state = {},\n
gadget = this;\n gadget = this;\n
return RSVP.Queue()\n return RSVP.Queue()\n
.push(function(){\n .push(function() {\n
return gadget.getContent();\n return gadget.getContent();\n
})\n })\n
.push(function(content) {\n .push(function(content) {\n
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.33714.48637.10274</string> </value> <value> <string>945.39610.42841.21043</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1441361996.21</float> <float>1441714262.07</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
var current_state = {},\n var current_state = {},\n
gadget = this;\n gadget = this;\n
return RSVP.Queue()\n return RSVP.Queue()\n
.push(function(){\n .push(function() {\n
return gadget.getContent();\n return gadget.getContent();\n
})\n })\n
.push(function(content) {\n .push(function(content) {\n
...@@ -319,7 +319,7 @@ ...@@ -319,7 +319,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.33781.46058.13073</string> </value> <value> <string>945.33788.56308.37819</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -337,7 +337,7 @@ ...@@ -337,7 +337,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1441364931.54</float> <float>1441714291.87</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -109,27 +109,12 @@ ...@@ -109,27 +109,12 @@
\n \n
rJS(window)\n rJS(window)\n
.declareMethod(\'getContent\', function () {\n .declareMethod(\'getContent\', function () {\n
var gadget = this;\n var gadget = this,\n
return gadget.props.hot.getData();\n temp_data = gadget.props.hot.getData(),\n
})\n temp_columns = gadget.props.hot.getColHeader(),\n
.declareMethod(\'setContent\', function (content) {\n
return;\n
})\n
.declareMethod(\'clearContent\', function () {\n
return;\n
})\n
.declareMethod(\'initStateTransfer\', function () {\n
var current_state = {},\n
gadget = this;\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getContent();\n
})\n
.push(function(content) {\n
var columns = [],\n
data = [],\n data = [],\n
temp_columns = content[0],\n columns = [],\n
temp_row, \n content = {},\n
i, j;\n i, j;\n
for(i = 0; i < temp_columns.length; i += 1) {\n for(i = 0; i < temp_columns.length; i += 1) {\n
var title = (temp_columns[i] === null ? \'\' : temp_columns[i]);\n var title = (temp_columns[i] === null ? \'\' : temp_columns[i]);\n
...@@ -137,33 +122,28 @@ ...@@ -137,33 +122,28 @@
title: title\n title: title\n
});\n });\n
}\n }\n
for(i = 1; i < content.length; i += 1) {\n for(i = 0; i < temp_data.length; i += 1) {\n
var d = (data[i - 1] = {});\n var d = (data[i] = {}),\n
temp_row = content[i];\n temp_row = temp_data[i];\n
for(j = 0; j < temp_row.length; j += 1) { \n for(j = 0; j < temp_row.length; j += 1) { \n
d[j] = temp_row[j];\n d[j] = temp_row[j];\n
}\n }\n
}\n }\n
current_state.columns = columns;\n content.columns = columns;\n
current_state.content = data;\n content.data = data;\n
return current_state;\n return content;\n
});\n
})\n })\n
.declareMethod(\'finishStateTransfer\', function (current_state) {\n .declareMethod(\'setContent\', function (content) {\n
var gadget = this,\n var gadget = this,\n
content = current_state.content,\n temp_columns = content.columns,\n
temp_columns = current_state.columns,\n temp_data = content.data,\n
hot = gadget.props.hot,\n hot = gadget.props.hot,\n
data = [],\n data = [],\n
temp_row = [],\n temp_row = [],\n
i, j;\n i, j;\n
for(i = 0; i < temp_columns.length; i += 1) {\n for(i = 0; i < temp_data.length; i += 1) {\n
temp_row.push(temp_columns[i].title);\n var d = (data[i] = []);\n
}\n temp_row = temp_data[i];\n
data.push(temp_row);\n
for(i = 0; i < content.length; i += 1) {\n
var d = (data[i + 1] = []);\n
temp_row = content[i];\n
for(j = 0; j < Object.keys(temp_row).length; j += 1) {\n for(j = 0; j < Object.keys(temp_row).length; j += 1) {\n
d.push(temp_row[j]);\n d.push(temp_row[j]);\n
}\n }\n
...@@ -171,7 +151,26 @@ ...@@ -171,7 +151,26 @@
hot.loadData(data);\n hot.loadData(data);\n
return;\n return;\n
})\n })\n
.declareMethod(\'clearContent\', function () {\n
return;\n
})\n
.declareMethod(\'initStateTransfer\', function () {\n
var current_state = {},\n
gadget = this;\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getContent();\n
})\n
.push(function(content) {\n
current_state.content = content;\n
return current_state;\n
});\n
})\n
.declareMethod(\'finishStateTransfer\', function (current_state) {\n
return this.setContent(current_state.content);\n
})\n
.declareMethod(\'initSubGadget\', function () {\n .declareMethod(\'initSubGadget\', function () {\n
// hard coded data for demo purpose.\n
var data = [["", "Ford", "Volvo", "Toyota", "Honda"],\n var data = [["", "Ford", "Volvo", "Toyota", "Honda"],\n
["2014", 10, 11, 12, 13],\n ["2014", 10, 11, 12, 13],\n
["2015", 20, 11, 14, 13],\n ["2015", 20, 11, 14, 13],\n
...@@ -329,7 +328,7 @@ ...@@ -329,7 +328,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.32551.63779.17083</string> </value> <value> <string>945.39661.40347.63863</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -347,7 +346,7 @@ ...@@ -347,7 +346,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1441293672.51</float> <float>1441717677.15</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -102,10 +102,10 @@ ...@@ -102,10 +102,10 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
/*jslint indent: 2 */\n /*jslint indent: 2 */\n
/*global window, jQuery, rJS, Slick*/\n /*global window, jQuery, rJS, RSVP, Slick*/\n
"use strict";\n "use strict";\n
\n \n
(function (window, $, rJS, Slick) {\n (function (window, $, rJS, RSVP, Slick) {\n
\n \n
function requiredFieldValidator(value) {\n function requiredFieldValidator(value) {\n
if (value === null || value === undefined || !value.length) {\n if (value === null || value === undefined || !value.length) {\n
...@@ -123,27 +123,15 @@ ...@@ -123,27 +123,15 @@
} else {\n } else {\n
return letter;\n return letter;\n
}\n }\n
}\n }\n
\n \n
rJS(window).\n rJS(window).\n
declareMethod(\'getContent\', function () {\n declareMethod(\'getContent\', function () {\n
return this.props.grid.getData();\n
})\n
\n
.declareMethod(\'setContent\', function (content) {\n
return;\n
})\n
\n
.declareMethod(\'clearContent\', function () {\n
return;\n
})\n
\n
.declareMethod(\'initStateTransfer\', function () {\n
var gadget = this,\n var gadget = this,\n
current_state = {},\n
grid = gadget.props.grid,\n grid = gadget.props.grid,\n
temp_data = grid.getData(),\n temp_data = grid.getData(),\n
temp_columns = grid.getColumns(),\n temp_columns = grid.getColumns(),\n
content = {},\n
columns = [],\n columns = [],\n
data = [],\n data = [],\n
column_index_dict = {},\n column_index_dict = {},\n
...@@ -165,15 +153,15 @@ ...@@ -165,15 +153,15 @@
d[column_index_dict[item]] = temp_row[item];\n d[column_index_dict[item]] = temp_row[item];\n
}\n }\n
}\n }\n
current_state.columns = columns;\n content.columns = columns;\n
current_state.content = data;\n content.data = data;\n
return current_state;\n return content;\n
})\n })\n
\n \n
.declareMethod(\'finishStateTransfer\', function (current_state) {\n .declareMethod(\'setContent\', function (content) {\n
var gadget = this,\n var gadget = this,\n
content = current_state.content,\n temp_columns = content.columns,\n
temp_columns = current_state.columns,\n temp_data = content.data,\n
grid = gadget.props.grid,\n grid = gadget.props.grid,\n
columns = [],\n columns = [],\n
data = [],\n data = [],\n
...@@ -188,9 +176,9 @@ ...@@ -188,9 +176,9 @@
"editor": Slick.Editors.Text \n "editor": Slick.Editors.Text \n
});\n });\n
}\n }\n
for(i = 0; i < content.length; i += 1) {\n for(i = 0; i < temp_data.length; i += 1) {\n
var d = (data[i] = {});\n var d = (data[i] = {});\n
temp_row = content[i];\n temp_row = temp_data[i];\n
for(j = 0; j < Object.keys(temp_row).length; j += 1) {\n for(j = 0; j < Object.keys(temp_row).length; j += 1) {\n
d[columns[j].field] = temp_row[j];\n d[columns[j].field] = temp_row[j];\n
}\n }\n
...@@ -200,6 +188,28 @@ ...@@ -200,6 +188,28 @@
grid.render();\n grid.render();\n
return;\n return;\n
})\n })\n
\n
.declareMethod(\'clearContent\', function () {\n
return;\n
})\n
\n
.declareMethod(\'initStateTransfer\', function () {\n
var current_state = {},\n
gadget = this;\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getContent();\n
})\n
.push(function(content) {\n
current_state.content = content;\n
return current_state;\n
});\n
})\n
\n
.declareMethod(\'finishStateTransfer\', function (current_state) {\n
return this.setContent(current_state.content);\n
})\n
\n
.declareMethod(\'initSubGadget\', function () {\n .declareMethod(\'initSubGadget\', function () {\n
var gadget = this;\n var gadget = this;\n
var grid,\n var grid,\n
...@@ -242,7 +252,7 @@ ...@@ -242,7 +252,7 @@
g.props = {};\n g.props = {};\n
});\n });\n
\n \n
}(window, jQuery, rJS, Slick));\n }(window, jQuery, rJS, RSVP, Slick));\n
]]></string> </value> ]]></string> </value>
...@@ -380,7 +390,7 @@ ...@@ -380,7 +390,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.33860.24768.49083</string> </value> <value> <string>945.39646.6878.42018</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -398,7 +408,7 @@ ...@@ -398,7 +408,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1441369486.01</float> <float>1441716413.3</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment