pinkman 0.9.1.24 → 0.9.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/pinkman_base/object.js.coffee.erb +17 -7
- data/app/assets/javascripts/pinkman_base/render.coffee.erb +3 -6
- data/lib/generators/pinkman/templates/api.rb.erb +4 -11
- data/lib/pinkman/serializer/base.rb +10 -1
- data/lib/pinkman/serializer/scope.rb +1 -1
- 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: 0e67efb282a22795bcde07d95c93c2875b520be7
|
|
4
|
+
data.tar.gz: bd67054d547e3ab8a3c302149371dd0969ed7c39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 076ceb22a7d302bf17bc98f243299da856f3bdc4d26267a9dbf58ebcda873df033deea4501413bda02000bcd76f7d5bde059dd407def5c1d8fe11dd66a2264de
|
|
7
|
+
data.tar.gz: d61a793ed823ee530998b4445b5c94347af179561d850798dc90d199ebd40b155a7b204415ff82594e0fade7ee4e98324631c4ad0d584f10f529f228b8bd42ea
|
|
@@ -157,7 +157,6 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
|
157
157
|
reload: (callback) ->
|
|
158
158
|
params = new Object
|
|
159
159
|
params.scope = Pinkman.scope(this)
|
|
160
|
-
|
|
161
160
|
Pinkman.ajax.get
|
|
162
161
|
url: Pinkman.json2url(@api() + @id,params)
|
|
163
162
|
complete: (response) =>
|
|
@@ -186,15 +185,26 @@ class window.PinkmanObject extends window.PinkmanCommon
|
|
|
186
185
|
@removeFromAllCollections()
|
|
187
186
|
Pinkman.ajax.delete
|
|
188
187
|
url: @api() + @id
|
|
188
|
+
data: { scope: Pinkman.scope(this) }
|
|
189
189
|
complete: (response) =>
|
|
190
190
|
@assign(response)
|
|
191
191
|
delete @errors unless response.errors?
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
192
|
+
@id = null unless @errors?
|
|
193
|
+
callback(this) if callback? and typeof callback=='function'
|
|
194
|
+
return(this)
|
|
195
|
+
else
|
|
196
|
+
return(false)
|
|
197
|
+
|
|
198
|
+
delete: (callback='') ->
|
|
199
|
+
if @id?
|
|
200
|
+
Pinkman.ajax.delete
|
|
201
|
+
url: @api() + @id
|
|
202
|
+
data: { scope: Pinkman.scope(this) }
|
|
203
|
+
complete: (response) =>
|
|
204
|
+
@assign(response)
|
|
205
|
+
delete @errors unless response.errors?
|
|
206
|
+
@id = null unless @errors?
|
|
207
|
+
callback(this) if callback? and typeof callback=='function'
|
|
198
208
|
return(this)
|
|
199
209
|
else
|
|
200
210
|
return(false)
|
|
@@ -93,16 +93,13 @@ Pinkman.saveElementScrollPosition = (id) ->
|
|
|
93
93
|
a = Pinkman.scrolling.find(id)
|
|
94
94
|
a = new Pinkman.object unless a?
|
|
95
95
|
a.set('id',id)
|
|
96
|
-
|
|
97
|
-
elementPos = if element? then element.offset().top else 0
|
|
98
|
-
referencePos = if element.children()? then element.children().first().offset().top else 0
|
|
99
|
-
position = elementPos - referencePos
|
|
100
|
-
|
|
96
|
+
position = if document.getElementById(id) then document.getElementById(id).scrollTop else 0
|
|
101
97
|
a.set('position', position)
|
|
102
98
|
Pinkman.scrolling.push(a)
|
|
103
99
|
|
|
104
100
|
Pinkman.restoreElementScrollPosition = (id) ->
|
|
105
|
-
|
|
101
|
+
if Pinkman.scrolling.include(id: id)
|
|
102
|
+
document.getElementById(id).scrollTop = Pinkman.scrolling.find(id).position
|
|
106
103
|
|
|
107
104
|
Pinkman.reRender = (object) ->
|
|
108
105
|
if object.renderQueue?
|
|
@@ -25,21 +25,14 @@ class Api::<%= controller_name %> < ApiController
|
|
|
25
25
|
# post api/<%= api_name %>
|
|
26
26
|
def create
|
|
27
27
|
@<%= instance_name %>.assign_attributes <%= params_method_name %>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
else
|
|
31
|
-
render json: {errors: @<%= instance_name %>.errors}
|
|
32
|
-
end
|
|
28
|
+
@<%= instance_name %>.save
|
|
29
|
+
render json: @<%= instance_name %>.json_for(current_scope)
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
# put/patch api/<%= api_name %>/:id
|
|
36
33
|
def update
|
|
37
|
-
@<%= instance_name %>.
|
|
38
|
-
|
|
39
|
-
render json: @<%= instance_name %>.json_for(current_scope)
|
|
40
|
-
else
|
|
41
|
-
render json: {errors: @<%= instance_name %>.errors}
|
|
42
|
-
end
|
|
34
|
+
@<%= instance_name %>.update <%= params_method_name %>
|
|
35
|
+
render json: @<%= instance_name %>.json_for(current_scope)
|
|
43
36
|
end
|
|
44
37
|
|
|
45
38
|
# delete api/<%= api_name %>/:id
|
|
@@ -6,14 +6,16 @@ module Pinkman
|
|
|
6
6
|
module Serializer
|
|
7
7
|
|
|
8
8
|
class Base < ActiveModel::Serializer
|
|
9
|
+
attr_accessor :errors
|
|
10
|
+
attr_accessor :params
|
|
9
11
|
|
|
10
12
|
def initialize *args
|
|
11
13
|
super(*args)
|
|
14
|
+
@errors = Base.format_errors(args.first.errors.to_h) if args.first.errors.present? and args.first.errors.any?
|
|
12
15
|
@params = OpenStruct.new(args[1][:params]) if args.length > 1 and args[1].is_a?(Hash) and args[1][:params]
|
|
13
16
|
self
|
|
14
17
|
end
|
|
15
18
|
|
|
16
|
-
attr_accessor :params
|
|
17
19
|
|
|
18
20
|
self.root = false
|
|
19
21
|
|
|
@@ -65,6 +67,12 @@ module Pinkman
|
|
|
65
67
|
end
|
|
66
68
|
end
|
|
67
69
|
|
|
70
|
+
def self.format_errors errors
|
|
71
|
+
e = Hash.new
|
|
72
|
+
errors.each {|k,v| e[k] = [v].flatten}
|
|
73
|
+
e
|
|
74
|
+
end
|
|
75
|
+
|
|
68
76
|
def attributes *args
|
|
69
77
|
hash = super(*args)
|
|
70
78
|
if scope
|
|
@@ -74,6 +82,7 @@ module Pinkman
|
|
|
74
82
|
model.column_names.each {|attribute| hash[attribute] = object.send(attribute) } if include_all && model && model.methods.include?(:column_names)
|
|
75
83
|
pinkmanscope.read.each {|attribute| hash[attribute] = object.send(attribute) if object.methods.include?(attribute)}
|
|
76
84
|
pinkmanscope.read.each {|attribute| hash[attribute] = send(attribute) if self.methods.include?(attribute)}
|
|
85
|
+
hash[:errors] = self.class.format_errors(errors) if errors.present? and errors.any?
|
|
77
86
|
hash
|
|
78
87
|
end
|
|
79
88
|
end
|
|
@@ -27,7 +27,7 @@ module Pinkman
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def can_read? attribute
|
|
30
|
-
read.include?(:all) or read.include?(attribute.to_sym) or attribute == :error or attribute == :errors
|
|
30
|
+
read.include?(:all) or read.include?(attribute.to_sym) or attribute.to_sym == :error or attribute.to_sym == :errors
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def can_write? attribute
|
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.26
|
|
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-05-
|
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|