thecore_ui_commons 2.1.13 → 2.2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f510ad3fa384e9d3a3598f949d7a71bd233c690c72022244df397108ac0224cc
|
4
|
+
data.tar.gz: 1bb0f13df31b05f4c9953b050cbcef0b16a827dc6dd950d694dd919fd57fb16d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d0ddc4c4992240d4e0e5b1a9cbc6b9baf98a7708fa76cadbb7e30c364d2338a3965890a4c59fc259b29fc6dfcf5d68f1d8ace41eea8443142a53496498501e
|
7
|
+
data.tar.gz: baf89f83fca413e37606f7ca6dd40e414d5a5a7cae102f18cdcd4e3f83f2d78aea903a22c894df9799cbe39a84390e6cd575f3f15a578eab2d7a237ae0a6c714
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<%
|
2
|
+
=begin%>
|
3
|
+
Call using, for example:
|
4
|
+
<%=render "thecore_utils/drag_drop_uploader", target: "drop-zone", file_upload_desc: I18n.t(:file_upload), file_upload_sub: I18n.t(:file_upload_subtitle, extensions: exts), url: rails_admin.send("#{action_name}_path")%>
|
5
|
+
|
6
|
+
All the parameters are mandatory:
|
7
|
+
- target (The HTML element which will inherid the D&D functionality)
|
8
|
+
- file_upload_desc (Description of the upload functionality)
|
9
|
+
- file_upload_sub (Subtitle to the description -> A space where to put extra info)
|
10
|
+
- url (the action to perform async when files are dropped on the element.)
|
11
|
+
<%
|
12
|
+
=end%>
|
13
|
+
|
14
|
+
<style>
|
15
|
+
/* layout.css Style */
|
16
|
+
.upload-drop-zone {
|
17
|
+
height: 200px;
|
18
|
+
border-width: 2px;
|
19
|
+
margin-bottom: 20px;
|
20
|
+
}
|
21
|
+
|
22
|
+
/* skin.css Style*/
|
23
|
+
.upload-drop-zone {
|
24
|
+
color: #ccc;
|
25
|
+
border-style: dashed;
|
26
|
+
border-color: #ccc;
|
27
|
+
line-height: 200px;
|
28
|
+
text-align: center
|
29
|
+
}
|
30
|
+
|
31
|
+
.upload-drop-zone.drop {
|
32
|
+
color: #222;
|
33
|
+
border-color: #222;
|
34
|
+
}
|
35
|
+
</style>
|
36
|
+
|
37
|
+
<div class="panel panel-default">
|
38
|
+
<div class="panel-heading">
|
39
|
+
<strong><%=file_upload_desc%></strong>
|
40
|
+
<small><%=file_upload_sub%></small>
|
41
|
+
<div class="pull-right" id="<%=target%>-upload-drop-zone-feedback">
|
42
|
+
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<div class="panel-body">
|
46
|
+
|
47
|
+
<!-- Drop Zone -->
|
48
|
+
<div class="upload-drop-zone" id="<%=target%>">
|
49
|
+
<%=I18n.t :please_drag_and_drop_here%>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div id="upload-status">
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<script>
|
58
|
+
var fileupload = {
|
59
|
+
init: function () {
|
60
|
+
$('#<%=target%>').on("drop", this.ondrop);
|
61
|
+
$('#<%=target%>').on("dragover", this.ondragover);
|
62
|
+
$('#<%=target%>').on("dragleave", this.ondragleave);
|
63
|
+
},
|
64
|
+
|
65
|
+
beforeSuccess: function(){
|
66
|
+
console.log("beforeSuccess");
|
67
|
+
},
|
68
|
+
|
69
|
+
ondrop: function (e) {
|
70
|
+
// console.log(e)
|
71
|
+
e.preventDefault();
|
72
|
+
$('#<%=target%>').removeClass('drop');
|
73
|
+
$("#<%=target%>-upload-drop-zone-feedback").html("<i class='fa fa-spinner fa-spin '></i>");
|
74
|
+
|
75
|
+
// console.log(e.dataTransfer.files);
|
76
|
+
var fd = new FormData();
|
77
|
+
$.each(e.originalEvent.dataTransfer.files, function (i, file) {
|
78
|
+
fd.append('files[]', file);
|
79
|
+
});
|
80
|
+
|
81
|
+
$.ajax({
|
82
|
+
url: '<%=url%>',
|
83
|
+
data: fd,
|
84
|
+
processData: false,
|
85
|
+
contentType: false,
|
86
|
+
type: 'POST',
|
87
|
+
success: function () {
|
88
|
+
fileupload.beforeSuccess();
|
89
|
+
$("#<%=target%>-upload-drop-zone-feedback").html($('<i class="fa fa-check-square-o" aria-hidden="true"></i>').delay(3000).fadeOut(400));
|
90
|
+
},
|
91
|
+
error: function () {
|
92
|
+
$("#<%=target%>-upload-drop-zone-feedback").html($('<i class="fa fa-exclamation-circle" aria-hidden="true"></i>').delay(3000).fadeOut(400));
|
93
|
+
}
|
94
|
+
});
|
95
|
+
// startUpload(e.dataTransfer.files)
|
96
|
+
},
|
97
|
+
|
98
|
+
ondragover: function () {
|
99
|
+
$('#<%=target%>').addClass('drop');
|
100
|
+
return false;
|
101
|
+
},
|
102
|
+
|
103
|
+
ondragleave: function () {
|
104
|
+
$('#<%=target%>').removeClass('drop');
|
105
|
+
return false;
|
106
|
+
}
|
107
|
+
|
108
|
+
};
|
109
|
+
fileupload.init();
|
110
|
+
</script>
|
@@ -2,15 +2,22 @@ module Helpers
|
|
2
2
|
module ThecoreUiCommonsHelper
|
3
3
|
def get_asset_tags_for(basename)
|
4
4
|
out = []
|
5
|
+
|
5
6
|
# Needs to reverse since Paths are traversed in the order they occur in the search path. By default, this means the files in app/assets take precedence, and will mask corresponding paths in lib and vendor.
|
6
7
|
Rails.application.config.assets.paths.reverse.each do |basedir|
|
7
8
|
base = "#{basedir}/**/#{basename}"
|
8
|
-
base_s = Dir["#{base}.scss"]
|
9
|
+
base_s = Dir["#{base}.{css,scss}"]
|
9
10
|
base_j = Dir["#{base}.js"]
|
10
|
-
|
11
|
-
out <<
|
11
|
+
|
12
|
+
(out << stylesheet_link_tag("#{get_folder base_s}/#{basename}", media: 'all', 'data-turbolinks-track' => true) if base_s.any?) rescue nil
|
13
|
+
(out << javascript_include_tag("#{get_folder base_j}/#{basename}", 'data-turbolinks-track' => true) if base_j.any?) rescue nil
|
12
14
|
end
|
13
|
-
|
15
|
+
|
16
|
+
# Application level assets
|
17
|
+
(out << stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track' => true)) rescue nil
|
18
|
+
(out << javascript_include_tag('application', 'data-turbolinks-track' => true)) rescue nil
|
19
|
+
|
20
|
+
out.join("\n").html_safe
|
14
21
|
end
|
15
22
|
|
16
23
|
def get_folder(base)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_ui_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_background_jobs
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- app/views/layouts/mailer.html.erb
|
126
126
|
- app/views/layouts/mailer.text.erb
|
127
127
|
- app/views/layouts/thecore.html.erb
|
128
|
+
- app/views/thecore_utils/_drag_drop_uploader.html.erb
|
128
129
|
- config/initializers/charts_helper.rb
|
129
130
|
- config/initializers/thecore_ui_commons_application_config.rb
|
130
131
|
- config/initializers/thecore_ui_commons_helper.rb
|