pinkman 0.9.1.2 → 0.9.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/pinkman_base/collection.coffee +12 -0
- data/app/assets/javascripts/pinkman_base/common.coffee +14 -1
- data/app/assets/javascripts/pinkman_base/object.js.coffee.erb +14 -13
- data/app/assets/javascripts/pinkman_base/render.coffee.erb +4 -4
- data/app/helpers/pinkman_helper.rb +5 -1
- data/lib/generators/pinkman/app_base_generator.rb +2 -2
- data/lib/pinkman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f071ffd276a4ffce048f6c50bf45867239a60193
|
4
|
+
data.tar.gz: 7a745e4dfa2cf9d6011b3ef43a8fb694fbddb273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ec6ef56b0fb4806b223ec8f157e1effb190db6e6082b0b9955ca6d179cb41b16077d6468a6a49d4a646c384246c49af68fc00677cf0a3587c523b2f9f0a48e
|
7
|
+
data.tar.gz: f8b506709206275f684f6a235339a9f21e7ddf1cf00c7b7c37faa27c02b2e573b6b8282848a7e232f17c01df7e35891b355e07bb3c44eaa3ad3ed29b0f68af91
|
@@ -22,6 +22,14 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
22
22
|
attributes: ->
|
23
23
|
return @collection
|
24
24
|
|
25
|
+
# Desc: json version of this
|
26
|
+
# desc: used in api comunications
|
27
|
+
json: ->
|
28
|
+
json = []
|
29
|
+
@each (object) ->
|
30
|
+
json.push(object.json()) if object.isPink and object.json? and typeof object.json == 'function'
|
31
|
+
json
|
32
|
+
|
25
33
|
# Desc: collection size
|
26
34
|
count: (criteria='') ->
|
27
35
|
if criteria? and typeof criteria == 'function'
|
@@ -255,6 +263,10 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
255
263
|
@push(object)
|
256
264
|
return(this)
|
257
265
|
|
266
|
+
# Desc: fetch from array alias
|
267
|
+
assign: (array...) ->
|
268
|
+
@fetchFromArray(array...)
|
269
|
+
|
258
270
|
# Desc: merges this collection with another
|
259
271
|
merge: (collection) ->
|
260
272
|
if Pinkman.isArray(collection)
|
@@ -1,5 +1,8 @@
|
|
1
1
|
class window.PinkmanCommon
|
2
2
|
|
3
|
+
constructor: (attributesObject) ->
|
4
|
+
@initialize(attributesObject) if attributesObject?
|
5
|
+
|
3
6
|
@privateAttributes = ['isPink','isObject','isCollection','pinkey','config','pinkmanType','collections','renderQueue']
|
4
7
|
|
5
8
|
@mixin: (args...) ->
|
@@ -12,6 +15,12 @@ class window.PinkmanCommon
|
|
12
15
|
object.constructor is this
|
13
16
|
|
14
17
|
|
18
|
+
initialize: (attributesObject) ->
|
19
|
+
if typeof attributesObject == 'object'
|
20
|
+
for key, value of attributesObject
|
21
|
+
@set(key,value) if PinkmanObject.privateAttributes.indexOf(key) is -1
|
22
|
+
|
23
|
+
|
15
24
|
# Desc: return api url path
|
16
25
|
api: () ->
|
17
26
|
if @config? and @config.api?
|
@@ -53,4 +62,8 @@ class window.PinkmanCommon
|
|
53
62
|
Pinkman.reRender this
|
54
63
|
|
55
64
|
watch: () ->
|
56
|
-
@_watching = yes
|
65
|
+
@_watching = yes
|
66
|
+
|
67
|
+
queue: (options) ->
|
68
|
+
@renderQueue = new PinkmanCollection unless @renderQueue?
|
69
|
+
@renderQueue.directPush(options)
|
@@ -2,8 +2,8 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
2
2
|
|
3
3
|
@pinkmanType: 'object'
|
4
4
|
|
5
|
-
constructor: (
|
6
|
-
|
5
|
+
constructor: (args...) ->
|
6
|
+
super(args...)
|
7
7
|
@isPink = true
|
8
8
|
@isObject = true
|
9
9
|
@pinkmanType = 'object'
|
@@ -13,20 +13,13 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
13
13
|
|
14
14
|
Pinkman.objects.push(this)
|
15
15
|
Pinkman.all.push(this)
|
16
|
-
|
17
|
-
@initialize(attributesObject)
|
18
|
-
|
19
|
-
initialize: (attributesObject) ->
|
20
|
-
if typeof attributesObject == 'object'
|
21
|
-
for key, value of attributesObject
|
22
|
-
@set(key,value) if PinkmanObject.privateAttributes.indexOf(key) is -1
|
23
16
|
|
24
17
|
# Desc: assign attributes from a pure javascript object
|
25
18
|
# Usage: a.assign( {attribute: value} )
|
26
19
|
assign: (obj) ->
|
27
20
|
if typeof obj == 'object'
|
28
21
|
for k,v of obj
|
29
|
-
if typeof v == 'object' and this[k]? and this[k].isPink
|
22
|
+
if typeof v == 'object' and this[k]? and this[k].isPink and not v.isPink
|
30
23
|
this[k].assign(v)
|
31
24
|
else
|
32
25
|
this.set(k,v)
|
@@ -45,6 +38,15 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
45
38
|
else
|
46
39
|
a[k] = v
|
47
40
|
return a
|
41
|
+
|
42
|
+
# Desc: json version of this
|
43
|
+
# desc: used in api comunications
|
44
|
+
json: () ->
|
45
|
+
a = new Object
|
46
|
+
for k,v of this
|
47
|
+
if PinkmanObject.privateAttributes.indexOf(k) == -1 and typeof v != 'function'
|
48
|
+
a[k] = if v.isPink then v.json() else v
|
49
|
+
return a
|
48
50
|
|
49
51
|
# Desc: returns a array of attributes keys
|
50
52
|
# Usage:
|
@@ -131,7 +133,7 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
131
133
|
unless @id?
|
132
134
|
Pinkman.ajax.post
|
133
135
|
url: @api()
|
134
|
-
data: { pink_obj: @
|
136
|
+
data: { pink_obj: @json() }
|
135
137
|
complete: (response) =>
|
136
138
|
@assign(response)
|
137
139
|
delete @errors unless response.errors?
|
@@ -139,11 +141,10 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
139
141
|
return(this)
|
140
142
|
|
141
143
|
update: (callback='') ->
|
142
|
-
console.log this
|
143
144
|
if @id?
|
144
145
|
Pinkman.ajax.patch
|
145
146
|
url: @api() + @id
|
146
|
-
data: { pink_obj: @
|
147
|
+
data: { pink_obj: @json() }
|
147
148
|
complete: (response) =>
|
148
149
|
@assign(response)
|
149
150
|
delete @errors unless response.errors?
|
@@ -1,6 +1,3 @@
|
|
1
|
-
PinkmanCollection.prototype.renderQueue = new PinkmanCollection
|
2
|
-
PinkmanObject.prototype.renderQueue = new PinkmanCollection
|
3
|
-
|
4
1
|
Pinkman.templates = new Pinkman.collection
|
5
2
|
|
6
3
|
Pinkman.template_engine = '<%= Pinkman.configuration.js_template_engine %>'
|
@@ -16,6 +13,7 @@ Pinkman.template_engines =
|
|
16
13
|
Pinkman.templates.push(template)
|
17
14
|
|
18
15
|
options.object = options.context if options.context?
|
16
|
+
options.object = new Object unless options.object? and typeof options.object == 'object'
|
19
17
|
content = template.handlebars(options.object)
|
20
18
|
|
21
19
|
|
@@ -36,6 +34,7 @@ Pinkman.template_engines =
|
|
36
34
|
Pinkman.templates.push(template)
|
37
35
|
|
38
36
|
options.object = options.context if options.context?
|
37
|
+
options.object = new Object unless options.object? and typeof options.object == 'object'
|
39
38
|
content = template.hogan.render(options.object)
|
40
39
|
|
41
40
|
if options.target?
|
@@ -55,6 +54,7 @@ Pinkman.template_engines =
|
|
55
54
|
Pinkman.templates.push(template)
|
56
55
|
|
57
56
|
options.object = options.context if options.context?
|
57
|
+
options.object = new Object unless options.object? and typeof options.object == 'object'
|
58
58
|
content = template.markup($('#'+options.template).html(),options.object)
|
59
59
|
|
60
60
|
if options.target?
|
@@ -70,7 +70,7 @@ Pinkman.render = (options) ->
|
|
70
70
|
|
71
71
|
engine = Pinkman.template_engines[Pinkman.template_engine]
|
72
72
|
content = engine(options)
|
73
|
-
options.object.
|
73
|
+
options.object.queue(options) if options.reRender and options.object? and options.object.isPink
|
74
74
|
|
75
75
|
Pinkman.reRender = (object) ->
|
76
76
|
engine = Pinkman.template_engines[Pinkman.template_engine]
|
@@ -13,11 +13,11 @@ module Pinkman
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def object_filename
|
16
|
-
|
16
|
+
'app_object.coffee'
|
17
17
|
end
|
18
18
|
|
19
19
|
def collection_filename
|
20
|
-
|
20
|
+
'app_collection.coffee'
|
21
21
|
end
|
22
22
|
|
23
23
|
def app_name
|
data/lib/pinkman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinkman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.1.
|
4
|
+
version: 0.9.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agilso Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|