formily 0.0.5.5.7 → 0.0.5.5.9
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/formily/base/buttons.js +19 -0
- data/app/assets/javascripts/formily/base/form_response.js +22 -1
- data/app/assets/javascripts/formily/formily_url.js.erb +5 -2
- data/app/assets/stylesheets/formily/foundation_fix.scss +6 -0
- data/app/controllers/formily/forms_controller.rb +3 -12
- data/app/controllers/formily/iframe/forms_controller.rb +7 -17
- data/app/controllers/formily/submit_data_controller.rb +7 -0
- data/app/models/formily/form.rb +6 -0
- data/app/models/formily/submit.rb +8 -1
- data/app/views/formily/helpers/_related_forms_tr.html.haml +7 -2
- data/app/views/formily/partial/_form.haml +3 -0
- data/config/routes.rb +1 -0
- data/lib/formily/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: 966730c1ed08384468fff0f6840c15a866e41f23
|
4
|
+
data.tar.gz: a76f7649a99b0fb2dfc7fcf964ccfe53759c2371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc07e3d91213b72d5061b709d509606b85a623734f545e9346b36dddf86bead27745727e06527c09eb41d22280f57879aa5249c5184d462060580f61e3bc6a52
|
7
|
+
data.tar.gz: f30d8de78c624cc3777e22833de2b9b005869bf5e54733f89964303b9670d055780d7fbdc8a899b139afa25cbecaef2852208db0ca613a40ac3148327a01cbc4
|
@@ -63,6 +63,25 @@ $(document).ready(function() {
|
|
63
63
|
$('.formily-edit').remove();
|
64
64
|
});
|
65
65
|
|
66
|
+
$(document).on('click', '#formily_delete', function(e){
|
67
|
+
if(isFormilyFileUploaded()){
|
68
|
+
var self = $(this);
|
69
|
+
var id = self.data('formilyDeleteResponseId');
|
70
|
+
var data = self.data('formilyResponse');
|
71
|
+
|
72
|
+
if(confirm('Are you sure you want to delete the form submission?')){
|
73
|
+
$.ajax({
|
74
|
+
url: FormilyRoutes.response_delete_path(id),
|
75
|
+
data: data,
|
76
|
+
type: 'DELETE',
|
77
|
+
success: function(){
|
78
|
+
closeWindowFunc('formily_update_table');
|
79
|
+
}
|
80
|
+
});
|
81
|
+
}
|
82
|
+
}
|
83
|
+
});
|
84
|
+
|
66
85
|
$('#formily_form_tag').on('submit', function(e){
|
67
86
|
var form = $(this);
|
68
87
|
|
@@ -25,4 +25,25 @@ $(document).ready(function() {
|
|
25
25
|
e.preventDefault();
|
26
26
|
});
|
27
27
|
|
28
|
-
|
28
|
+
$(document).on('click', 'span[data-formily-delete-response-id]', function(e){
|
29
|
+
var self = $(this);
|
30
|
+
var id = self.data('formilyDeleteResponseId');
|
31
|
+
var data = self.data('formilyResponse');
|
32
|
+
|
33
|
+
if(confirm('Are you sure you want to delete the form submission?')){
|
34
|
+
$.ajax({
|
35
|
+
url: FormilyRoutes.response_delete_path(id),
|
36
|
+
data: data,
|
37
|
+
type: 'DELETE',
|
38
|
+
success: function(){
|
39
|
+
$(document).trigger('formily_update_table', data);
|
40
|
+
},
|
41
|
+
error: function(resp){
|
42
|
+
console.error(resp.responseJSON.msg);
|
43
|
+
alert(resp.responseJSON.msg);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}
|
47
|
+
e.preventDefault();
|
48
|
+
});
|
49
|
+
});
|
@@ -22,5 +22,8 @@ window.FormilyRoutes = {
|
|
22
22
|
},
|
23
23
|
form_upload_file_path: function () {
|
24
24
|
return "<%= url.upload_file_formily_submit_data_path %>";
|
25
|
-
}
|
26
|
-
|
25
|
+
},
|
26
|
+
response_delete_path: function (id) {
|
27
|
+
return "<%= url.destroy_response_formily_submit_data_path(0).to_s[0...-1] %>" + id.toString();
|
28
|
+
},
|
29
|
+
};
|
@@ -17,16 +17,9 @@ class Formily::FormsController < FormilyController
|
|
17
17
|
|
18
18
|
def show
|
19
19
|
@form = Formily::Form.find(params[:id])
|
20
|
-
|
21
|
-
@obj_rel =
|
22
|
-
|
23
|
-
@submit = @form.submits.find_by(id: params[:submit_id])
|
24
|
-
|
25
|
-
if @submit.blank?
|
26
|
-
@submit = Formily::Submit.create({form_id: @form.id, resource_id: params[:model_id],
|
27
|
-
user_id: params[:user_id], resource_type: params[:model_name]})
|
28
|
-
end
|
29
|
-
|
20
|
+
form_model = params[:model_name].safe_constantize
|
21
|
+
@obj_rel = form_model.find(params[:model_id])
|
22
|
+
@submit = @form.find_or_create_submission_by(params)
|
30
23
|
end
|
31
24
|
|
32
25
|
def edit
|
@@ -90,7 +83,6 @@ class Formily::FormsController < FormilyController
|
|
90
83
|
render partial: 'preview', layout: false, locals: {:@form => form, :@obj_rel => form, :@submit => submit}
|
91
84
|
end
|
92
85
|
|
93
|
-
|
94
86
|
def reload_formily_table
|
95
87
|
user_id = params[:user_id]
|
96
88
|
obj_rel = params[:resource_type].safe_constantize.find(params[:resource_id])
|
@@ -98,7 +90,6 @@ class Formily::FormsController < FormilyController
|
|
98
90
|
render locals: {obj_rel: obj_rel, user_id: user_id, flag: params[:flag].present?}, layout: false
|
99
91
|
end
|
100
92
|
|
101
|
-
|
102
93
|
def add_new_response
|
103
94
|
submit = Formily::Submit.where(params.permit(:form_id, :resource_id, :user_id, :resource_type))
|
104
95
|
.order(created_at: :desc).first
|
@@ -1,28 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
class Formily::Iframe::FormsController < FormilyController
|
3
|
-
|
4
3
|
def show
|
5
4
|
@form = Formily::Form.find(params[:id])
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@obj_rel = model.blank? ? nil : model.find(params[:model_id])
|
10
|
-
|
11
|
-
@submit = @form.submits.find_by(id: params[:submit_id])
|
12
|
-
|
13
|
-
if @submit.blank?
|
14
|
-
@submit = Formily::Submit.create({form_id: @form.id, resource_id: params[:model_id],
|
15
|
-
user_id: params[:user_id], resource_type: params[:model_name]})
|
16
|
-
end
|
5
|
+
form_model = params[:model_name].safe_constantize
|
6
|
+
@obj_rel = form_model.blank? ? nil : form_model.find(params[:model_id])
|
7
|
+
@submit = @form.find_or_create_submission_by(params)
|
17
8
|
end
|
18
9
|
|
19
10
|
def add
|
20
11
|
end
|
21
12
|
|
22
|
-
|
23
13
|
private
|
24
|
-
def formily_layout
|
25
|
-
'formily_iframe'
|
26
|
-
end
|
27
14
|
|
28
|
-
|
15
|
+
def formily_layout
|
16
|
+
'formily_iframe'
|
17
|
+
end
|
18
|
+
end
|
@@ -137,6 +137,13 @@ class Formily::SubmitDataController < FormilyController
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
def destroy_response
|
141
|
+
submit = Formily::Submit.find(params[:id])
|
142
|
+
submit.destroy
|
143
|
+
|
144
|
+
render json: {}, status: :ok
|
145
|
+
end
|
146
|
+
|
140
147
|
private
|
141
148
|
def set_layout
|
142
149
|
if params[:iframe]
|
data/app/models/formily/form.rb
CHANGED
@@ -25,6 +25,12 @@ class Formily::Form < ActiveRecord::Base
|
|
25
25
|
'#response'
|
26
26
|
end
|
27
27
|
|
28
|
+
def find_or_create_submission_by(attributes)
|
29
|
+
submission = submits.find_by(id: attributes[:submit_id])
|
30
|
+
submission ||= submits.find_by(resource_id: attributes[:model_id], user_id: attributes[:user_id], resource_type: attributes[:model_name])
|
31
|
+
submission ||= submits.create(resource_id: attributes[:model_id], user_id: attributes[:user_id], resource_type: attributes[:model_name])
|
32
|
+
end
|
33
|
+
|
28
34
|
private
|
29
35
|
|
30
36
|
def delete_data
|
@@ -5,6 +5,8 @@ class Formily::Submit < ActiveRecord::Base
|
|
5
5
|
|
6
6
|
has_paper_trail
|
7
7
|
|
8
|
+
after_destroy :delete_data
|
9
|
+
|
8
10
|
belongs_to :form
|
9
11
|
has_many :input_values, foreign_key: :submit_id, class_name: 'Formily::InputValue', dependent: :destroy
|
10
12
|
|
@@ -44,4 +46,9 @@ class Formily::Submit < ActiveRecord::Base
|
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
|
49
|
+
private
|
50
|
+
|
51
|
+
def delete_data
|
52
|
+
input_values.destroy_all
|
53
|
+
end
|
54
|
+
end
|
@@ -4,12 +4,13 @@
|
|
4
4
|
|
5
5
|
- submits = [nil] if submits.blank?
|
6
6
|
|
7
|
+
- p = {user_id: user_id, authenticity_token: form_authenticity_token, form_id: form.id, resource_id: obj_rel.id, resource_type: obj_rel.class.to_s}
|
8
|
+
|
7
9
|
- submits.each_with_index do |submit, i|
|
8
10
|
|
9
11
|
%tr{'data-formily-form-id' => form.id}
|
10
12
|
%td.icon
|
11
13
|
- if i == 0
|
12
|
-
- p = {user_id: user_id, authenticity_token: form_authenticity_token, form_id: form.id, resource_id: obj_rel.id, resource_type: obj_rel.class.to_s}
|
13
14
|
%span.ff-icon-plus{title: 'Add New Response', 'data-tooltip'=> (browser.device.ipad? ? nil : ''), 'data-formily-new-response' => p.to_json, 'data-href' => add_new_response_formily_forms_path}
|
14
15
|
%td.icon
|
15
16
|
- if submit && submit.input_values.count > 0
|
@@ -25,4 +26,8 @@
|
|
25
26
|
= show_formily_form_link_tag form.id, obj_rel, submit.try(:id) , user_id, title, class: 'response'
|
26
27
|
|
27
28
|
- if form.description.present?
|
28
|
-
%span.has-tip.tip-top{'data-tooltip'=> '', 'aria-haspopup'=>true, title: form.description} ?
|
29
|
+
%span.has-tip.tip-top{'data-tooltip'=> '', 'aria-haspopup'=>true, title: form.description} ?
|
30
|
+
|
31
|
+
%td.icon
|
32
|
+
- if submit.present?
|
33
|
+
%span.ff-icon-trash-empty{title: 'Delete Response', 'data-tooltip'=> (browser.device.ipad? ? nil : ''), 'data-formily-delete-response-id' => submit.id, 'data-formily-response' => p.to_json}
|
@@ -34,4 +34,7 @@
|
|
34
34
|
|
35
35
|
%input.button.tiny#formily_cancel{type: 'button', value: 'Cancel', title: 'Cancel'}
|
36
36
|
|
37
|
+
- p = {user_id: @user_id, authenticity_token: form_authenticity_token, form_id: @form.id, resource_id: @obj_rel.id, resource_type: @obj_rel.class.to_s}
|
38
|
+
%input.button.tiny.alert#formily_delete{type: 'button', value: 'Delete', title: 'Delete', 'data-formily-delete-response-id' => @submit.id, 'data-formily-response' => p.to_json}
|
39
|
+
|
37
40
|
.formily-spinner
|
data/config/routes.rb
CHANGED
data/lib/formily/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formily
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.5.5.
|
4
|
+
version: 0.0.5.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|