djgentelella 0.3.18__py3-none-any.whl → 0.3.20__py3-none-any.whl
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.
- djgentelella/__init__.py +1 -1
- djgentelella/blog/forms.py +3 -3
- djgentelella/fields/files.py +125 -0
- djgentelella/forms/decorators.py +3 -3
- djgentelella/forms/forms.py +153 -33
- djgentelella/forms/models.py +2 -2
- djgentelella/serializers/selects.py +32 -0
- djgentelella/settings.py +1 -1
- djgentelella/static/djgentelella.flags.vendors.min.css +1 -1
- djgentelella/static/djgentelella.readonly.vendors.min.js +1 -1
- djgentelella/static/djgentelella.vendors.header.min.js +1 -1
- djgentelella/static/djgentelella.vendors.min.js +3 -2
- djgentelella/static/gentelella/css/custom.css +42 -2
- djgentelella/static/gentelella/js/base/dateranges_gridslider.js +1 -2
- djgentelella/static/gentelella/js/base/fileupload.widget.js +175 -72
- djgentelella/static/gentelella/js/base.js +178 -75
- djgentelella/static/gentelella/js/datatables.js +20 -3
- djgentelella/static/gentelella/js/obj_api_management.js +150 -51
- djgentelella/static/gentelella/js/widgets.js +2 -1
- djgentelella/static/vendors/flags/1x1/cp.svg +2 -2
- djgentelella/static/vendors/flags/1x1/dg.svg +2 -2
- djgentelella/static/vendors/flags/1x1/es-ga.svg +2 -2
- djgentelella/static/vendors/flags/4x3/ac.svg +2 -2
- djgentelella/static/vendors/flags/4x3/ea.svg +2 -2
- djgentelella/static/vendors/flags/4x3/es-ct.svg +2 -2
- djgentelella/static/vendors/friconix/friconix.js +1 -1
- djgentelella/static/vendors/interact/interact.min.js +3 -2
- djgentelella/static/vendors/storymapjs/storymap.js +1 -1
- djgentelella/templates/forms/as_grid.html +39 -0
- djgentelella/templates/forms/as_horizontal.html +36 -0
- djgentelella/templates/forms/as_inline.html +38 -0
- djgentelella/templates/forms/as_plain.html +33 -0
- djgentelella/templates/gentelella/index.html +14 -14
- djgentelella/templates/gentelella/widgets/chunkedupload.html +9 -14
- djgentelella/templates/gentelella/widgets/file.html +4 -9
- djgentelella/tests/__init__.py +2 -1
- djgentelella/tests/fields/__init__.py +0 -0
- djgentelella/tests/fields/files.py +39 -0
- djgentelella/views/select2autocomplete.py +8 -2
- djgentelella/widgets/core.py +33 -0
- djgentelella/widgets/files.py +37 -8
- {djgentelella-0.3.18.dist-info → djgentelella-0.3.20.dist-info}/METADATA +30 -15
- {djgentelella-0.3.18.dist-info → djgentelella-0.3.20.dist-info}/RECORD +47 -39
- {djgentelella-0.3.18.dist-info → djgentelella-0.3.20.dist-info}/WHEEL +1 -1
- {djgentelella-0.3.18.dist-info → djgentelella-0.3.20.dist-info}/AUTHORS +0 -0
- {djgentelella-0.3.18.dist-info → djgentelella-0.3.20.dist-info}/LICENSE.txt +0 -0
- {djgentelella-0.3.18.dist-info → djgentelella-0.3.20.dist-info}/top_level.txt +0 -0
|
@@ -866,7 +866,7 @@ a:focus {
|
|
|
866
866
|
}
|
|
867
867
|
|
|
868
868
|
.wysiwyg{
|
|
869
|
-
overflow:scroll;
|
|
869
|
+
overflow:scroll;
|
|
870
870
|
max-height:500px;
|
|
871
871
|
}
|
|
872
872
|
.nav>li>a:hover,
|
|
@@ -4611,4 +4611,44 @@ border-bottom:2px solid #E6E9ED;
|
|
|
4611
4611
|
}
|
|
4612
4612
|
.menu-top-navbar:hover{
|
|
4613
4613
|
color:inherit;
|
|
4614
|
-
}
|
|
4614
|
+
}
|
|
4615
|
+
|
|
4616
|
+
.file-link {
|
|
4617
|
+
white-space: nowrap;
|
|
4618
|
+
overflow: hidden;
|
|
4619
|
+
text-overflow: ellipsis;
|
|
4620
|
+
}
|
|
4621
|
+
.input-group > .custom-file {
|
|
4622
|
+
display: -webkit-box;
|
|
4623
|
+
display: -ms-flexbox;
|
|
4624
|
+
display: flex;
|
|
4625
|
+
-webkit-box-align: center;
|
|
4626
|
+
-ms-flex-align: center;
|
|
4627
|
+
align-items: center;
|
|
4628
|
+
}
|
|
4629
|
+
|
|
4630
|
+
.custom-file {
|
|
4631
|
+
position: relative;
|
|
4632
|
+
display: inline-block;
|
|
4633
|
+
width: 100%;
|
|
4634
|
+
height: calc(1.47em + 1rem + 2px);
|
|
4635
|
+
margin-bottom: 0;
|
|
4636
|
+
border: 1px solid #ccc;
|
|
4637
|
+
}
|
|
4638
|
+
|
|
4639
|
+
input-group > .custom-file {
|
|
4640
|
+
position: relative;
|
|
4641
|
+
-webkit-box-flex: 1;
|
|
4642
|
+
-ms-flex: 1 1 0%;
|
|
4643
|
+
flex: 1 1 0%;
|
|
4644
|
+
min-width: 0;
|
|
4645
|
+
margin-bottom: 0;
|
|
4646
|
+
}
|
|
4647
|
+
.custom-file-input {
|
|
4648
|
+
position: relative;
|
|
4649
|
+
z-index: 2;
|
|
4650
|
+
width: 100%;
|
|
4651
|
+
height: calc(1.47em + 1rem + 2px);
|
|
4652
|
+
margin: 0;
|
|
4653
|
+
opacity: 0;
|
|
4654
|
+
}
|
|
@@ -104,7 +104,6 @@ function grid_slider(instance) {
|
|
|
104
104
|
'onChange': function (data) {
|
|
105
105
|
$("input[name=" + obj.attr('data-target-from') + "]").val(data.from);
|
|
106
106
|
$("input[name=" + obj.attr('data-target-to') + "]").val(data.to);
|
|
107
|
-
console.log(obj.attr('data-target-to'));
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
return option;
|
|
@@ -157,7 +156,7 @@ function date_grid_slider(instance) {
|
|
|
157
156
|
});
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
instance.ionRangeSlider({
|
|
159
|
+
return instance.ionRangeSlider({
|
|
161
160
|
type: "single",
|
|
162
161
|
hide_min_max: false,
|
|
163
162
|
min: dateToTS(new Date(obj.attr('data_min'))),
|
|
@@ -27,77 +27,180 @@ $.fn.fileuploadwidget = function(){
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
var $this=$(e)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
$.each($(this), function(i, e){
|
|
31
|
+
var $this=$(e);
|
|
32
|
+
var $parentdiv=$this.closest('.fileupload');
|
|
33
|
+
var input_token=$this.data('inputtoken');
|
|
34
|
+
var obj={
|
|
35
|
+
parentdiv: $this.closest('.input-group'),
|
|
36
|
+
upload_url: $this.data('href'),
|
|
37
|
+
field_name: $this.attr('name'),
|
|
38
|
+
div_message: $parentdiv.find($this.data('message')),
|
|
39
|
+
div_process: $parentdiv.find($this.data('process')),
|
|
40
|
+
div_download: $parentdiv.find("#download_"+$this.data('inputtoken') ),
|
|
41
|
+
div_remove: $parentdiv.find("#remove_"+$this.data('inputtoken') ),
|
|
42
|
+
url_done: $this.data('done'),
|
|
43
|
+
current_icon: 'eyes',
|
|
44
|
+
input_token: input_token,
|
|
45
|
+
input_field: $parentdiv.find('input[name="'+input_token+'"]'),
|
|
46
|
+
default_value: "",
|
|
47
|
+
fileshow: $parentdiv.find('.fileshow'),
|
|
48
|
+
uploadfilecontent: $parentdiv.find('.uploadfilecontent'),
|
|
49
|
+
removecheck: $this.closest('.fileupload').find('input[data-widget="CheckboxInput"]'),
|
|
50
|
+
change_fn: function(e){
|
|
51
|
+
var parent=e;
|
|
52
|
+
return function(event){
|
|
53
|
+
let current_value=parent.input_field.val();
|
|
54
|
+
if(current_value.length==0){
|
|
55
|
+
current_value=parent.default_value;
|
|
56
|
+
}
|
|
57
|
+
try{
|
|
58
|
+
let data = JSON.parse(current_value);
|
|
59
|
+
parent.render_widget_data(data);
|
|
60
|
+
}catch(e) {
|
|
61
|
+
// do nothing
|
|
62
|
+
}
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
icon_action_toggle: function(){
|
|
67
|
+
if(this.current_icon==='eyes'){
|
|
68
|
+
this.show_upload();
|
|
69
|
+
}else{
|
|
70
|
+
this.show_eyes();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
show_eyes:function(){
|
|
74
|
+
this.current_icon='eyes';
|
|
75
|
+
this.change_icon_file_show('fa fa-eye');
|
|
76
|
+
},
|
|
77
|
+
show_upload: function(){
|
|
78
|
+
this.current_icon='upload';
|
|
79
|
+
this.change_icon_file_show('fa fa-cloud-upload');
|
|
80
|
+
},
|
|
81
|
+
render_widget_data: function(data){
|
|
82
|
+
var parent=this;
|
|
83
|
+
if("token" in data ){
|
|
84
|
+
//data.display_name
|
|
85
|
+
parent.uploadfilecontent.hide();
|
|
86
|
+
parent.div_download.hide();
|
|
87
|
+
parent.div_remove.hide();
|
|
88
|
+
parent.div_message.show();
|
|
89
|
+
parent.div_message.html(data.display_name);
|
|
90
|
+
parent.show_upload();
|
|
91
|
+
}else if ("url" in data){
|
|
92
|
+
parent.div_download.show();
|
|
93
|
+
parent.div_remove.show();
|
|
94
|
+
parent.div_message.show();
|
|
95
|
+
parent.uploadfilecontent.hide();
|
|
96
|
+
parent.div_download.find('a')[0].href=data.url;
|
|
97
|
+
parent.div_message.html(data.display_name);
|
|
98
|
+
parent.show_upload();
|
|
99
|
+
}else{
|
|
100
|
+
parent.div_download.hide();
|
|
101
|
+
parent.div_remove.hide();
|
|
102
|
+
parent.uploadfilecontent.show();
|
|
103
|
+
parent.div_message.hide();
|
|
104
|
+
parent.show_eyes();
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
change_icon_file_show: function(touseclass){
|
|
108
|
+
this.fileshow.find('i').removeClass();
|
|
109
|
+
this.fileshow.find('i').addClass(touseclass);
|
|
110
|
+
},
|
|
111
|
+
init: function(){
|
|
112
|
+
$this.attr("required", false);
|
|
113
|
+
this.div_message.hide();
|
|
114
|
+
this.div_remove.hide();
|
|
115
|
+
var parent=this;
|
|
116
|
+
this.fileshow.on('click', function(){
|
|
117
|
+
parent.uploadfilecontent.toggle();
|
|
118
|
+
parent.div_message.toggle();
|
|
119
|
+
parent.icon_action_toggle();
|
|
120
|
+
});
|
|
121
|
+
this.input_field[0].onchange=this.change_fn(this);
|
|
122
|
+
this.default_value=this.input_field.val();
|
|
123
|
+
if(this.default_value !== ""){
|
|
124
|
+
this.input_field.trigger('change');
|
|
125
|
+
}
|
|
126
|
+
this.removecheck.on('ifToggled', function(event){
|
|
127
|
+
let current_data=JSON.parse(parent.input_field.val());
|
|
128
|
+
if(this.checked){
|
|
129
|
+
current_data['actions']="delete";
|
|
130
|
+
}else{
|
|
131
|
+
if('actions' in current_data) delete current_data.actions;
|
|
132
|
+
}
|
|
133
|
+
parent.input_field.val(JSON.stringify(current_data));
|
|
134
|
+
});
|
|
135
|
+
$this.fileupload({
|
|
136
|
+
url: parent.upload_url,
|
|
137
|
+
dataType: "json",
|
|
138
|
+
maxChunkSize: 100000, // Chunks of 100 kB
|
|
139
|
+
formData: form_data,
|
|
140
|
+
dropZone: $this,
|
|
141
|
+
add: function(e, data) { // Called before starting upload
|
|
65
142
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
143
|
+
parent.div_message.empty();
|
|
144
|
+
// If this is the second file you're uploading we need to remove the
|
|
145
|
+
// old upload_id and just keep the csrftoken (which is always first).
|
|
146
|
+
form_data.splice(1);
|
|
147
|
+
calculate_md5(data.files[0], 100000); // Again, chunks of 100 kB
|
|
148
|
+
data.paramName='file';
|
|
149
|
+
data.submit();
|
|
150
|
+
parent.uploadfilecontent.hide();
|
|
151
|
+
parent.div_message.show();
|
|
152
|
+
parent.div_message.html(data.files[0].name);
|
|
153
|
+
},
|
|
154
|
+
chunkdone: function (e, data) { // Called after uploading each chunk
|
|
155
|
+
if (form_data.length < 2) {
|
|
156
|
+
form_data.push(
|
|
157
|
+
{"name": "upload_id", "value": data.result.upload_id}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
var progress = parseInt(data.loaded / data.total * 100.0, 10);
|
|
161
|
+
parent.div_process.text( progress + "%");
|
|
162
|
+
}
|
|
163
|
+
}).bind('fileuploaddone', function (e, data) {
|
|
164
|
+
parent.input_field.val(JSON.stringify(
|
|
165
|
+
{'token': data.result.upload_id,
|
|
166
|
+
'display_name': data.files[0].name }));
|
|
167
|
+
parent.input_field.trigger('change');
|
|
168
|
+
$.ajax({
|
|
169
|
+
type: "POST",
|
|
170
|
+
url: parent.url_done,
|
|
171
|
+
data: {
|
|
172
|
+
csrfmiddlewaretoken: csrf,
|
|
173
|
+
upload_id: data.result.upload_id,
|
|
174
|
+
md5: md5
|
|
175
|
+
},
|
|
176
|
+
dataType: "json",
|
|
177
|
+
success: function(data) {
|
|
178
|
+
parent.div_process.html(' <i class="fa fa-check"></i>');
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}).bind('fileuploadchunkfail', function (e, data) {
|
|
182
|
+
parent.resetEmpty();
|
|
183
|
+
Swal.fire(
|
|
184
|
+
gettext('Problem in the Internet?'),
|
|
185
|
+
data.errorThrown,
|
|
186
|
+
'error'
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
resetEmpty: function(){
|
|
191
|
+
this.div_message.html("");
|
|
192
|
+
this.div_message.hide();
|
|
193
|
+
this.div_download.hide();
|
|
194
|
+
this.div_remove.hide();
|
|
195
|
+
this.uploadfilecontent.show();
|
|
196
|
+
},
|
|
197
|
+
addRemote: function(item){
|
|
198
|
+
this.input_field.val(JSON.stringify(item));
|
|
199
|
+
this.input_field.trigger('change');
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
obj.init();
|
|
203
|
+
$this.data('fileUploadWidget', obj);
|
|
204
|
+
|
|
205
|
+
});
|
|
206
|
+
}
|
|
@@ -358,81 +358,185 @@ $.fn.fileuploadwidget = function(){
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
|
|
361
|
-
|
|
362
|
-
var $this=$(e)
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
361
|
+
$.each($(this), function(i, e){
|
|
362
|
+
var $this=$(e);
|
|
363
|
+
var $parentdiv=$this.closest('.fileupload');
|
|
364
|
+
var input_token=$this.data('inputtoken');
|
|
365
|
+
var obj={
|
|
366
|
+
parentdiv: $this.closest('.input-group'),
|
|
367
|
+
upload_url: $this.data('href'),
|
|
368
|
+
field_name: $this.attr('name'),
|
|
369
|
+
div_message: $parentdiv.find($this.data('message')),
|
|
370
|
+
div_process: $parentdiv.find($this.data('process')),
|
|
371
|
+
div_download: $parentdiv.find("#download_"+$this.data('inputtoken') ),
|
|
372
|
+
div_remove: $parentdiv.find("#remove_"+$this.data('inputtoken') ),
|
|
373
|
+
url_done: $this.data('done'),
|
|
374
|
+
current_icon: 'eyes',
|
|
375
|
+
input_token: input_token,
|
|
376
|
+
input_field: $parentdiv.find('input[name="'+input_token+'"]'),
|
|
377
|
+
default_value: "",
|
|
378
|
+
fileshow: $parentdiv.find('.fileshow'),
|
|
379
|
+
uploadfilecontent: $parentdiv.find('.uploadfilecontent'),
|
|
380
|
+
removecheck: $this.closest('.fileupload').find('input[data-widget="CheckboxInput"]'),
|
|
381
|
+
change_fn: function(e){
|
|
382
|
+
var parent=e;
|
|
383
|
+
return function(event){
|
|
384
|
+
let current_value=parent.input_field.val();
|
|
385
|
+
if(current_value.length==0){
|
|
386
|
+
current_value=parent.default_value;
|
|
387
|
+
}
|
|
388
|
+
try{
|
|
389
|
+
let data = JSON.parse(current_value);
|
|
390
|
+
parent.render_widget_data(data);
|
|
391
|
+
}catch(e) {
|
|
392
|
+
// do nothing
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
icon_action_toggle: function(){
|
|
398
|
+
if(this.current_icon==='eyes'){
|
|
399
|
+
this.show_upload();
|
|
400
|
+
}else{
|
|
401
|
+
this.show_eyes();
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
show_eyes:function(){
|
|
405
|
+
this.current_icon='eyes';
|
|
406
|
+
this.change_icon_file_show('fa fa-eye');
|
|
407
|
+
},
|
|
408
|
+
show_upload: function(){
|
|
409
|
+
this.current_icon='upload';
|
|
410
|
+
this.change_icon_file_show('fa fa-cloud-upload');
|
|
411
|
+
},
|
|
412
|
+
render_widget_data: function(data){
|
|
413
|
+
var parent=this;
|
|
414
|
+
if("token" in data ){
|
|
415
|
+
//data.display_name
|
|
416
|
+
parent.uploadfilecontent.hide();
|
|
417
|
+
parent.div_download.hide();
|
|
418
|
+
parent.div_remove.hide();
|
|
419
|
+
parent.div_message.show();
|
|
420
|
+
parent.div_message.html(data.display_name);
|
|
421
|
+
parent.show_upload();
|
|
422
|
+
}else if ("url" in data){
|
|
423
|
+
parent.div_download.show();
|
|
424
|
+
parent.div_remove.show();
|
|
425
|
+
parent.div_message.show();
|
|
426
|
+
parent.uploadfilecontent.hide();
|
|
427
|
+
parent.div_download.find('a')[0].href=data.url;
|
|
428
|
+
parent.div_message.html(data.display_name);
|
|
429
|
+
parent.show_upload();
|
|
430
|
+
}else{
|
|
431
|
+
parent.div_download.hide();
|
|
432
|
+
parent.div_remove.hide();
|
|
433
|
+
parent.uploadfilecontent.show();
|
|
434
|
+
parent.div_message.hide();
|
|
435
|
+
parent.show_eyes();
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
change_icon_file_show: function(touseclass){
|
|
439
|
+
this.fileshow.find('i').removeClass();
|
|
440
|
+
this.fileshow.find('i').addClass(touseclass);
|
|
441
|
+
},
|
|
442
|
+
init: function(){
|
|
443
|
+
$this.attr("required", false);
|
|
444
|
+
this.div_message.hide();
|
|
445
|
+
this.div_remove.hide();
|
|
446
|
+
var parent=this;
|
|
447
|
+
this.fileshow.on('click', function(){
|
|
448
|
+
parent.uploadfilecontent.toggle();
|
|
449
|
+
parent.div_message.toggle();
|
|
450
|
+
parent.icon_action_toggle();
|
|
451
|
+
});
|
|
452
|
+
this.input_field[0].onchange=this.change_fn(this);
|
|
453
|
+
this.default_value=this.input_field.val();
|
|
454
|
+
if(this.default_value !== ""){
|
|
455
|
+
this.input_field.trigger('change');
|
|
456
|
+
}
|
|
457
|
+
this.removecheck.on('ifToggled', function(event){
|
|
458
|
+
let current_data=JSON.parse(parent.input_field.val());
|
|
459
|
+
if(this.checked){
|
|
460
|
+
current_data['actions']="delete";
|
|
461
|
+
}else{
|
|
462
|
+
if('actions' in current_data) delete current_data.actions;
|
|
463
|
+
}
|
|
464
|
+
parent.input_field.val(JSON.stringify(current_data));
|
|
465
|
+
});
|
|
466
|
+
$this.fileupload({
|
|
467
|
+
url: parent.upload_url,
|
|
468
|
+
dataType: "json",
|
|
469
|
+
maxChunkSize: 100000, // Chunks of 100 kB
|
|
470
|
+
formData: form_data,
|
|
471
|
+
dropZone: $this,
|
|
472
|
+
add: function(e, data) { // Called before starting upload
|
|
473
|
+
|
|
474
|
+
parent.div_message.empty();
|
|
475
|
+
// If this is the second file you're uploading we need to remove the
|
|
476
|
+
// old upload_id and just keep the csrftoken (which is always first).
|
|
477
|
+
form_data.splice(1);
|
|
478
|
+
calculate_md5(data.files[0], 100000); // Again, chunks of 100 kB
|
|
479
|
+
data.paramName='file';
|
|
480
|
+
data.submit();
|
|
481
|
+
parent.uploadfilecontent.hide();
|
|
482
|
+
parent.div_message.show();
|
|
483
|
+
parent.div_message.html(data.files[0].name);
|
|
484
|
+
},
|
|
485
|
+
chunkdone: function (e, data) { // Called after uploading each chunk
|
|
486
|
+
if (form_data.length < 2) {
|
|
487
|
+
form_data.push(
|
|
488
|
+
{"name": "upload_id", "value": data.result.upload_id}
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
var progress = parseInt(data.loaded / data.total * 100.0, 10);
|
|
492
|
+
parent.div_process.text( progress + "%");
|
|
493
|
+
}
|
|
494
|
+
}).bind('fileuploaddone', function (e, data) {
|
|
495
|
+
parent.input_field.val(JSON.stringify(
|
|
496
|
+
{'token': data.result.upload_id,
|
|
497
|
+
'display_name': data.files[0].name }));
|
|
498
|
+
parent.input_field.trigger('change');
|
|
499
|
+
$.ajax({
|
|
500
|
+
type: "POST",
|
|
501
|
+
url: parent.url_done,
|
|
502
|
+
data: {
|
|
503
|
+
csrfmiddlewaretoken: csrf,
|
|
504
|
+
upload_id: data.result.upload_id,
|
|
505
|
+
md5: md5
|
|
506
|
+
},
|
|
507
|
+
dataType: "json",
|
|
508
|
+
success: function(data) {
|
|
509
|
+
parent.div_process.html(' <i class="fa fa-check"></i>');
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}).bind('fileuploadchunkfail', function (e, data) {
|
|
513
|
+
parent.resetEmpty();
|
|
514
|
+
Swal.fire(
|
|
515
|
+
gettext('Problem in the Internet?'),
|
|
516
|
+
data.errorThrown,
|
|
517
|
+
'error'
|
|
518
|
+
);
|
|
519
|
+
});
|
|
520
|
+
},
|
|
521
|
+
resetEmpty: function(){
|
|
522
|
+
this.div_message.html("");
|
|
523
|
+
this.div_message.hide();
|
|
524
|
+
this.div_download.hide();
|
|
525
|
+
this.div_remove.hide();
|
|
526
|
+
this.uploadfilecontent.show();
|
|
527
|
+
},
|
|
528
|
+
addRemote: function(item){
|
|
529
|
+
this.input_field.val(JSON.stringify(item));
|
|
530
|
+
this.input_field.trigger('change');
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
obj.init();
|
|
534
|
+
$this.data('fileUploadWidget', obj);
|
|
535
|
+
|
|
536
|
+
});
|
|
434
537
|
}
|
|
435
538
|
|
|
539
|
+
|
|
436
540
|
function extract_select2_context(context, instance){
|
|
437
541
|
let data=instance.data();
|
|
438
542
|
let dropdownparent=data.dropdownparent;
|
|
@@ -1254,7 +1358,6 @@ function grid_slider(instance) {
|
|
|
1254
1358
|
'onChange': function (data) {
|
|
1255
1359
|
$("input[name=" + obj.attr('data-target-from') + "]").val(data.from);
|
|
1256
1360
|
$("input[name=" + obj.attr('data-target-to') + "]").val(data.to);
|
|
1257
|
-
console.log(obj.attr('data-target-to'));
|
|
1258
1361
|
}
|
|
1259
1362
|
}
|
|
1260
1363
|
return option;
|
|
@@ -1307,7 +1410,7 @@ function date_grid_slider(instance) {
|
|
|
1307
1410
|
});
|
|
1308
1411
|
}
|
|
1309
1412
|
|
|
1310
|
-
instance.ionRangeSlider({
|
|
1413
|
+
return instance.ionRangeSlider({
|
|
1311
1414
|
type: "single",
|
|
1312
1415
|
hide_min_max: false,
|
|
1313
1416
|
min: dateToTS(new Date(obj.attr('data_min'))),
|