diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-10 18:07:34 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-10 18:07:34 (GMT) |
commit | b0e471c85b5564bf39c2d2d3ecf2c9b5d84d464b (patch) | |
tree | 2298e3b784e2276cd202fb1b55125ddb2b5b24e1 | |
parent | ac208823f95632b8137d01c19103f142f24a6468 (diff) |
DependencyInput class
-rw-r--r-- | webapp/coffee/dependency_input.coffee | 15 | ||||
-rw-r--r-- | webapp/js_tests/files.json | 1 | ||||
-rw-r--r-- | webapp/js_tests/spec/DependencyInputSpec.js | 14 | ||||
-rw-r--r-- | webapp/js_tests/spec/coffee/DependencyInputSpec.coffee | 16 | ||||
-rw-r--r-- | webapp/webapp/static/js/dependency_input.js | 21 |
5 files changed, 67 insertions, 0 deletions
diff --git a/webapp/coffee/dependency_input.coffee b/webapp/coffee/dependency_input.coffee new file mode 100644 index 0000000..52e836d --- /dev/null +++ b/webapp/coffee/dependency_input.coffee @@ -0,0 +1,15 @@ +class DependencyInput + constructor: (@group_order, @field_order) -> + + render: -> """ + <span class="_parentesis _parentesis_open">(</span><span class="_parentesis _parentesis_close">)</span> + <input + class="span2 droppable dependence_value" + type="text" + name="groups.#{@group_order}.fields.#{@field_order}.dependence.values" + value="" + placeholder="nro. ID" /> + <span class="_parentesis _parentesis_open">(</span><span class="_parentesis _parentesis_close">)</span> + """ + +window.DependencyInput = DependencyInput
\ No newline at end of file diff --git a/webapp/js_tests/files.json b/webapp/js_tests/files.json index b0e9f4f..b5762f4 100644 --- a/webapp/js_tests/files.json +++ b/webapp/js_tests/files.json @@ -5,6 +5,7 @@ "/static/js/jquery-ui.js", "/static/js/mustache-0.7.0.js", "/static/js/factoryField.js", + "/static/js/dependency_input.js", "/static/js/dynamic_structure.js" ], "media_files": [ diff --git a/webapp/js_tests/spec/DependencyInputSpec.js b/webapp/js_tests/spec/DependencyInputSpec.js new file mode 100644 index 0000000..8b2bd37 --- /dev/null +++ b/webapp/js_tests/spec/DependencyInputSpec.js @@ -0,0 +1,14 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + describe("DependencyInput", function() { + return it("should render html element", function() { + var dependency_input, expected, field_order, group_order; + expected = "<span class=\"_parentesis _parentesis_open\">(</span><span class=\"_parentesis _parentesis_close\">)</span>\n<input\n class=\"span2 droppable dependence_value\"\n type=\"text\"\n name=\"groups.1.fields.1.dependence.values\"\n value=\"\"\n placeholder=\"nro. ID\" />\n<span class=\"_parentesis _parentesis_open\">(</span><span class=\"_parentesis _parentesis_close\">)</span>"; + group_order = "1"; + field_order = "1"; + dependency_input = new DependencyInput(group_order, field_order); + return expect(dependency_input.render()).toBe(expected); + }); + }); + +}).call(this); diff --git a/webapp/js_tests/spec/coffee/DependencyInputSpec.coffee b/webapp/js_tests/spec/coffee/DependencyInputSpec.coffee new file mode 100644 index 0000000..5a1759c --- /dev/null +++ b/webapp/js_tests/spec/coffee/DependencyInputSpec.coffee @@ -0,0 +1,16 @@ +describe "DependencyInput", -> + it "should render html element", -> + expected = """ + <span class="_parentesis _parentesis_open">(</span><span class="_parentesis _parentesis_close">)</span> + <input + class="span2 droppable dependence_value" + type="text" + name="groups.1.fields.1.dependence.values" + value="" + placeholder="nro. ID" /> + <span class="_parentesis _parentesis_open">(</span><span class="_parentesis _parentesis_close">)</span> + """ + group_order = "1" + field_order = "1" + dependency_input = new DependencyInput(group_order, field_order) + expect(dependency_input.render()).toBe(expected) diff --git a/webapp/webapp/static/js/dependency_input.js b/webapp/webapp/static/js/dependency_input.js new file mode 100644 index 0000000..574b2fd --- /dev/null +++ b/webapp/webapp/static/js/dependency_input.js @@ -0,0 +1,21 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + var DependencyInput; + + DependencyInput = (function() { + function DependencyInput(group_order, field_order) { + this.group_order = group_order; + this.field_order = field_order; + } + + DependencyInput.prototype.render = function() { + return "<span class=\"_parentesis _parentesis_open\">(</span><span class=\"_parentesis _parentesis_close\">)</span>\n<input\n class=\"span2 droppable dependence_value\"\n type=\"text\"\n name=\"groups." + this.group_order + ".fields." + this.field_order + ".dependence.values\"\n value=\"\"\n placeholder=\"nro. ID\" />\n<span class=\"_parentesis _parentesis_open\">(</span><span class=\"_parentesis _parentesis_close\">)</span>"; + }; + + return DependencyInput; + + })(); + + window.DependencyInput = DependencyInput; + +}).call(this); |