thin_man 0.11.3 → 0.11.4
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/thin_man.js +6 -2
- data/lib/thin_man/ajax_helper.rb +2 -1
- data/lib/thin_man/version.rb +1 -1
- data/test/javascript/spec/thinManSpec.js +19 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 806b08d1f176f46b52043780d6673fd8a6f2a644
|
4
|
+
data.tar.gz: 08858fb27964d6b496e095f5462e22f079377eac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
460
|
-
this.
|
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(){
|
data/lib/thin_man/ajax_helper.rb
CHANGED
@@ -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))
|
data/lib/thin_man/version.rb
CHANGED
@@ -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(){
|