checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 277037c6ebdf2b0d1aa89843d34f024b17f9c1ceeb4f8e6a0242cd9585a2e336
4
- data.tar.gz: dbb4eab44a12bdd5245ec69ee29e5911ce87b437068cfa70e045969c38dc34d7
3
+ metadata.gz: 291782b4b04a02a359d5cecaccf2c67b3c4d2c3f2b269e6bb607d949e6ecd180
4
+ data.tar.gz: 58a64ecaf2dab1df27e8d1d3d07563efcec47cd7e318fc38b2b9c52302cdecc4
5
5
SHA512:
6
- metadata.gz: 12f60a37950707411fa5b7609b876aa6d20a293afdff00bff96bdc7f6fb64984ac455bd882c886c23feb15eed349afcb563dc567275a5cf2e2acf50541151032
7
- data.tar.gz: e225bf5db201fa1f5bd123145e7d0beb270575e250788e3ff5a62ce563d0b0f2576c167b683927177a36934f56da564ff719a78e9aa766cd13f5b22f8d5db28a
6
+ metadata.gz: 609f4254349dbcc6b21a164d7cfd4c998d92daa64df054ea20318f977feaa759bb0a128627c1f2eb6070a7dea2d4eb837e5d6a368ec43135185e2e416203a3ee
7
+ data.tar.gz: 3715ca1976c898dc5bd8151dc954ab9bb453ff99e224fd7b158ebdbad99ebda66238a3251b8f58145a29ec9e5af88192be2c953e1067b669fbb2878cfa6bd3c6
data/app/assets/javascripts/pinkman_base/collection.coffee CHANGED
@@ -94,6 +94,18 @@ class window.PinkmanCollection extends window.PinkmanCommon
94
94
transformation(o)
95
95
callback(this) if (i == @count()) and typeof callback == 'function'
96
96
return this
97
+
98
+ # rails/ruby equivalent: map
99
+ # Desc: receive a function and apply it to all members and returns an array of values
100
+ map: (transformation='',callback) ->
101
+ array = []
102
+ if transformation? and typeof transformation=='function'
103
+ i = 0
104
+ for o in @collection
105
+ i = i+1
106
+ array.push(transformation(o))
107
+ callback(array) if (i == @count()) and typeof callback == 'function'
108
+ return array
97
109
98
110
# rails/ruby equivalent: where/select
99
111
# Desc: returns a new collection of all members that satisfies a criteria (criteria(obj) returns true)
@@ -519,10 +531,23 @@ class window.PinkmanCollection extends window.PinkmanCommon
519
531
520
532
# --- Cache Related --- #
521
533
534
+ @mangleKey: (key) ->
535
+ @startCaching() unless @_name_md5
536
+ @_name_md5 + key
537
+
538
+ @cache: (key, value) ->
539
+ $c.cache(@mangleKey(key), value)
540
+
541
+ @hasCache: (key) ->
542
+ $c.has(@mangleKey(key))
543
+
544
+ @getCache: (key, callback) ->
545
+ $c.get(@mangleKey(key), callback)
546
+
522
547
@startCaching: () ->
523
548
# cache structure
524
549
@_name_md5 = md5(if @name then @name else @toString()) unless @_name_md5?
525
- $c.cache(@_name_md5, new this) unless $c.has(@_name_md5)
550
+ # $c.cache(@_name_md5, new this) unless $c.has(@_name_md5)
526
551
527
552
# --- Ajax related --- #
528
553
@@ -542,25 +567,23 @@ class window.PinkmanCollection extends window.PinkmanCommon
542
567
543
568
@get: (options) ->
544
569
if $p.isObject(options) and (options.query? or options.params?) and $p.isFunction(options.callback)
545
- @startCaching()
546
- options.cache = yes unless options.cache?
547
- query = Pinkman.mergeObjects(options.scope, Pinkman.mergeObjects(options.query, options.params))
548
- query_md5 = md5(JSON.stringify(query) + @_name_md5)
570
+ options.cache = false unless options.cache?
571
+ query_md5 = $p.objHash(options)
572
+ if options.cache and @hasCache(query_md5)
573
+ @getCache(query_md5, options.callback)
549
- if options.cache and $c.has(query_md5)
550
- $c.get(query_md5, options.callback)
551
574
else
552
575
col = new this
553
576
obj = new col.config.memberClass
554
577
params = new Object
555
578
params.scope = options.scope || Pinkman.scope(obj)
556
579
params.query = options.query
557
- params = Pinkman.mergeObjects(params, options.params)
558
- Pinkman.ajax.get
580
+ params = $p.mergeObjects(params, options.params)
581
+ $p.ajax.get
559
582
url: options.url || obj.api('get')
560
583
data: params
561
584
complete: (response) =>
562
585
col.fetchFromArray(response)
563
- $c.cache(query_md5, col)
586
+ @cache(query_md5, col)
564
587
options.callback(col)
565
588
else
566
589
throw "Pinkman Error: collection.get invalid options #{options.toString()}"
@@ -622,7 +645,6 @@ class window.PinkmanCollection extends window.PinkmanCommon
622
645
if options? and typeof options == 'object' and options.url?
623
646
options_md5 = md5(JSON.stringify(options) + @className())
624
647
options.params = new Object unless options.params?
625
- options.cache = yes unless options.cache?
626
648
if options.scope?
627
649
options.params.scope = options.scope
628
650
else
@@ -633,12 +655,11 @@ class window.PinkmanCollection extends window.PinkmanCommon
633
655
Pinkman.ajax.get
634
656
url: Pinkman.json2url(options.url, options.params)
635
657
complete: (response) =>
636
- $c.cache(options_md5, response) if options.cache
637
658
@handleFetchResponse(response, options)
638
659
return(this)
639
660
640
- handleFetchResponse: (response,options) ->
641
- @constructor.startCaching()
661
+ handleFetchResponse: (response, options) ->
662
+ # @constructor.startCaching()
642
663
if response?
643
664
[@errors, @error] = [response.errors, response.error] if response.errors? or response.error?
644
665
@@ -652,7 +673,7 @@ class window.PinkmanCollection extends window.PinkmanCommon
652
673
653
674
if response.length > 0
654
675
# CACHING INSTANCES
655
- $c.get(@constructor._name_md5).fetchFromArray(response)
676
+ # $c.get(@constructor._name_md5).fetchFromArray(response)
656
677
657
678
@_recent.fetchFromArray(response)
658
679
@fetchFromArray(response)
data/app/assets/javascripts/pinkman_base/controller.coffee CHANGED
@@ -72,13 +72,14 @@ class window.PinkmanController extends window.PinkmanObject
72
72
if args.length == 1
73
73
@actions.getBy('name',args[0])
74
74
else
75
- [name, eventName,callback,unknown...] = args
75
+ [name, eventName, callback, preventDefault, unknown...] = args
76
76
PinkmanAction.define
77
77
id: "#{@pinkey}-#{name}-#{eventName}"
78
78
name: name
79
79
eventName: eventName
80
80
callback: callback
81
81
controller: this
82
+ preventDefault: if preventDefault? then preventDefault else true
82
83
selector: "##{this.id} [data-action='#{name}']"
83
84
84
85
@@ -406,6 +407,11 @@ class window.PinkmanAction extends window.PinkmanObject
406
407
a.set 'controller', options.controller
407
408
a.set 'selector', options.selector
408
409
a.set 'eventName', options.eventName
410
+
411
+ # default value for preventDefault: yes
412
+ # console.log options.preventDefault
413
+ a.set 'preventDefault', options.preventDefault
414
+
409
415
# a.log 'eventName'
410
416
a.set 'call', options.callback if options.callback
411
417
Pinkman.actions.push(a)
@@ -455,7 +461,15 @@ class window.PinkmanAction extends window.PinkmanObject
455
461
$('body').on eventName, action.selector, (ev) ->
456
462
# debugger
457
463
# console.log "#{action.id}: called - #{action.name}"
458
- ev.preventDefault() if eventName != 'keypress' and eventName != 'mousedown'
464
+
465
+ ev.preventDefault() if (eventName != 'keypress' and eventName != 'mousedown') and action.preventDefault
466
+ # debug mode
467
+ # if (eventName != 'keypress' and eventName != 'mousedown') and action.preventDefault
468
+ # console.log 'chamou prevent default'
469
+ # ev.preventDefault()
470
+ # else
471
+ # console.log 'não chamou prevent default'
472
+
459
473
obj = window.Pinkman.closest($(this))
460
474
action.call(obj,$(this),ev)
461
475
data/app/assets/javascripts/pinkman_base/pinkman.coffee CHANGED
@@ -62,6 +62,12 @@ class window.Pinkman
62
62
63
63
# --- tools and facilities
64
64
65
+ @md5: (args...) ->
66
+ md5(args...)
67
+
68
+ @objHash: (obj) ->
69
+ @md5(JSON.stringify(obj))
70
+
65
71
@top: ->
66
72
window.scrollTo(0,0)
67
73
data/app/assets/javascripts/pinkman_base/router.coffee CHANGED
@@ -44,7 +44,7 @@ class window.PinkmanPath extends Pinkman.object
44
44
@set('depth',i)
45
45
@set('staticDepth',s)
46
46
@set('dynamicDepth',d)
47
- PinkmanCache.cache("p-path-#{url}",this)
47
+ PinkmanCache.cache("p-path-#{url}", this)
48
48
49
49
@depth: (url) ->
50
50
a = url.split('/')
data/lib/pinkman/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module Pinkman
2
- VERSION = "1.3.7"
2
+ VERSION = "1.4.3"
3
3
end
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: 1.3.7
4
+ version: 1.4.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: 2019-08-01 00:00:00.000000000 Z
11
+ date: 2019-10-01 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: bundler
@@ -322,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
322
- !ruby/object:Gem::Version
323
323
version: '0'
324
324
requirements: []
325
- rubygems_version: 3.0.3
325
+ rubygems_version: 3.0.6
326
326
signing_key:
327
327
specification_version: 4
328
328
summary: Small Rails-js framework.