thin_man 0.11.3 → 0.11.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1220da7c4d7f921e1b49a0523bedb0ac29327831
4
- data.tar.gz: a2504fab73b453d1ff2ffe001a2dc2f891369029
3
+ metadata.gz: 806b08d1f176f46b52043780d6673fd8a6f2a644
4
+ data.tar.gz: 08858fb27964d6b496e095f5462e22f079377eac
5
5
  SHA512:
6
- metadata.gz: 5f634db41a4ece9187c2addb1d214a6ef3783b8e1e8cc749dacbe31fe957e9f669b42a857a8b709ac9755663819f036a5b69226b3af6595804e07809954d502a
7
- data.tar.gz: 3b0e0fa9f33757649136aa95c768b89767658f0625bf0f32049665f4dce13e1378e3118eb58425cef4af898a1d98bb8b66b678198e6838ae9ca3d1094769a4b9
6
+ metadata.gz: c1f733149473923a46bf63415874961e46f7648adb150a2567aba5978c87ceedf3ad8e0f15117d918abfe5e5d9f3a30750e9ffc6d44fb72b6ba83b692b8ab5b3
7
+ data.tar.gz: 6ddbf1ba65765379811b916cb64e3d429adb57e312b797d5edba13e932fbee06fb1415e6b95e158ea1cf193eb279127befcf739bb7ea87c15841bb270b998b5a
@@ -456,8 +456,12 @@ var initThinMan = function(){
456
456
  thin_man.DeleteLink = thin_man.AjaxSubmission.extend({
457
457
  ajaxSuccess: function(data,textStatus,jqXHR){
458
458
  this._super(data,textStatus,jqXHR);
459
- if(this.target){
460
- this.target.remove();
459
+ if(this.data('replace-response')){
460
+ this.insertHtml(data);
461
+ } else {
462
+ if(this.target){
463
+ this.target.remove();
464
+ }
461
465
  }
462
466
  },
463
467
  getAjaxType: function(){
@@ -28,12 +28,13 @@ module ThinMan
28
28
  html_options.merge(ajax_options))
29
29
  end
30
30
 
31
- def ajax_delete(name, options, html_options, target, sub_class: nil)
31
+ def ajax_delete(name, options, html_options, target, sub_class: nil, replace_response: false)
32
32
  ajax_options = {
33
33
  'data-ajax-delete' => true,
34
34
  'data-ajax-target' => target
35
35
  }
36
36
  ajax_options.merge!('data-sub-type' => sub_class) if sub_class.present?
37
+ ajax_options.merge!('data-replace-response' => true) if replace_response
37
38
  link_to(name,
38
39
  options,
39
40
  html_options.merge(ajax_options))
@@ -1,3 +1,3 @@
1
1
  module ThinMan
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
@@ -45,13 +45,11 @@ describe("thin_man", function(){
45
45
 
46
46
  describe("Display flash message", function(){
47
47
  it("successfully response", function(){
48
- var thin = new thin_man.AjaxLinkSubmission($link);
49
48
  thin.ajaxComplete(TestResponses.success);
50
49
  expect(thin.flash.flash_content.text()).toMatch('successfully response');
51
50
  });
52
51
 
53
52
  it("error response", function(){
54
- var thin = new thin_man.AjaxLinkSubmission($link);
55
53
  thin.ajaxComplete(TestResponses.error);
56
54
  expect(thin.flash.flash_content.text()).toMatch('error response');
57
55
  });
@@ -64,6 +62,25 @@ describe("thin_man", function(){
64
62
  expect($.fn.fadeOut).toHaveBeenCalled();
65
63
  });
66
64
  });
65
+
66
+ describe(".ajaxError", function(){
67
+ var $link, thin;
68
+
69
+ beforeEach(function(){
70
+ $link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"] #test_dom_id');
71
+ thin = new thin_man.AjaxLinkSubmission($link);
72
+ });
73
+
74
+ it('as a string', function(){
75
+ thin.ajaxError(TestResponses.conflictString);
76
+ expect($('#test_dom_id').html()).toMatch('conflict string response');
77
+ });
78
+
79
+ it('as an object', function(){
80
+ thin.ajaxError(TestResponses.conflict);
81
+ expect($('#test_dom_id').html()).toMatch('Required field');
82
+ });
83
+ });
67
84
  });
68
85
 
69
86
  describe("AjaxLinkSubmission", function(){
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut, Adam Bialek