kindred 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3465d1e245a7f0cf1067d66a04ad4c98493f951f
4
- data.tar.gz: b8b0966261f9143aa752203daaa974e52bdee79e
3
+ metadata.gz: b421090a728ee4d577793daa54f0fd9c466694ee
4
+ data.tar.gz: 7cfa98cbc0d52d353e1b2ef1087820efd16681fc
5
5
  SHA512:
6
- metadata.gz: 317bddd16739fe19eefc638f5257d2020aaf612b46e552e84fd381f674c3be66aa79a0a18b0e01bea81fb395b57f12d71a5967ba8e4c3aa007a41502d6be0c98
7
- data.tar.gz: 9e7412044e010dca7d252ca790bcde4b551d23adbc8314bfc0bf200dc321fc726f92ad8c8127ad44e98de0fd6008f52b6f80564b89e491796f6e4fab91a4be1a
6
+ metadata.gz: 8628507353c77140621c8f0e8dac1629fe1f3a1314497b1068e3183d9b67a08d40113d2d0af2ff75f3a296931436705372b41e217858bf86e96684bac3812534
7
+ data.tar.gz: 792b4363274f77c0ecbb6eefff3a00d562e6ee378f9f9029b1c0ca8f57d8678bed6d2cc9f71c677a25b5924f308706ae96e99294c078425e4b96aa943fd868d4
@@ -46,6 +46,9 @@ class App.ActivePage
46
46
  # TODO make this work with span and p
47
47
  $("div[data-k-uuid='" + @uuid + "'][data-attr='" + attr + "'], span[data-k-uuid='" + @uuid + "'][data-attr='" + attr + "'], p[data-k-uuid='" + @uuid + "'][data-attr='" + attr + "']").html(val)
48
48
 
49
+ update_meta_on_page: ->
50
+ $("[data-kindred-model]").find("div[data-k-uuid='" + @uuid + "']").data("meta", @meta)
51
+
49
52
  dirty_from_page: ->
50
53
  dirty = []
51
54
  $.each $("input[data-k-uuid='" + @uuid + "'], select[data-k-uuid='" + @uuid + "']"), (i, input) =>
@@ -75,6 +78,8 @@ class App.ActivePage
75
78
  if !isNaN(parseFloat(model_data.data("id"))) && isFinite(model_data.data("id"))
76
79
  @id = model_data.data("id")
77
80
 
81
+ @meta = model_data.data("meta")
82
+
78
83
  $("select[data-k-uuid='" + @uuid + "']").each (i, select) =>
79
84
  @set $(select).data("attr"), $(select).val()
80
85
 
@@ -91,7 +96,7 @@ class App.ActivePage
91
96
  $("[data-k-uuid='" + @uuid + "'][data-attr='" + attr + "']").data("val", val)
92
97
 
93
98
  _append_data_model_to_page: ->
94
- model_div = "<div data-k-uuid=" + @uuid + " data-id=" + @id + " data-class=" + @snake_name + "></div>"
99
+ model_div = "<div data-k-uuid=" + @uuid + " data-id=" + @id + " data-class=" + @snake_name + " data-meta=" + @_stringified_meta() + " ></div>"
95
100
  $("[data-kindred-model]").append(model_div)
96
101
 
97
102
  _input_dirty: (input) ->
@@ -101,3 +106,9 @@ class App.ActivePage
101
106
  !(input.data("val").toString() == input.prop("checked").toString())
102
107
  else
103
108
  !(input.data("val").toString() == input.val().toString())
109
+
110
+ _stringified_meta: ->
111
+ if @meta?
112
+ JSON.stringify(@meta)
113
+ else
114
+ ""
@@ -48,6 +48,12 @@ class App.Base extends App.VirtualClass App.ActivePage, App.Setup
48
48
  remove: (attr_name) ->
49
49
  delete @attributes[attr_name]
50
50
 
51
+ set_meta: (attr_name, val) ->
52
+ @meta[attr_name] = val
53
+
54
+ remove_meta: (attr_name) ->
55
+ delete @meta[attr_name]
56
+
51
57
  save: ->
52
58
  if !isNaN(parseFloat(@id)) && isFinite(@id)
53
59
  path = @route + "/" + @id + ".json"
@@ -1,10 +1,13 @@
1
1
  class App.Setup
2
- constructor: (@opts) ->
2
+ constructor: (@opts, meta_data) ->
3
3
  @_set_name_properties()
4
4
  @_set_self()
5
5
 
6
6
  @opts ||= {}
7
7
 
8
+ if meta_data?
9
+ @meta = meta_data["meta"]
10
+
8
11
  @attributes = {}
9
12
  template = @opts.template || App[@constructor.name].template
10
13
 
@@ -1,5 +1,5 @@
1
1
  module TemplateHelper
2
- def template(model: nil, collection: nil, target_uuid: nil, &block)
2
+ def template(model: nil, collection: nil, target_uuid: nil, meta: nil, &block)
3
3
  model_name = model
4
4
 
5
5
  @kindred_hash ||= {}
@@ -8,6 +8,7 @@ module TemplateHelper
8
8
  template: capture(&block),
9
9
  collection: collection,
10
10
  target_uuid: target_uuid,
11
+ meta: meta
11
12
  }
12
13
  })
13
14
  self.controller.instance_variable_set(:@kindred_hash, @kindred_hash)
@@ -1,3 +1,3 @@
1
1
  module Kindred
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindred
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Piccolo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails