Skip to content

Commit

Permalink
Merge pull request #5 from anomalylabs/feature-notify-when-overwritin…
Browse files Browse the repository at this point in the history
…g-files

File field type notifies when overwriting a file
  • Loading branch information
RyanThompson committed May 17, 2016
2 parents 5951863 + 04d96a9 commit 9992b63
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions resources/js/upload.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Disabling autoDiscover, otherwise Dropzone will try to attach twice.
Dropzone.autoDiscover = false;

$(function () {

var uploaded = [];
Expand All @@ -19,7 +22,18 @@ $(function () {
sending: function (file, xhr, formData) {
formData.append('folder', element.data('folder'));
},
accept: function(file, done) {
$.getJSON('/admin/files/exists/' + element.data('folder') + '/' + file.name, function(data) {
if(data.exists) {
if(!confirm(file.name + " " + element.data('overwrite'))) {
dropzone.removeFile(file);
return;
}
}

done();
});
},
autoQueue: true,
thumbnailWidth: 24,
thumbnailHeight: 24,
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'choose_files' => 'Which files would you like to use?',
'no_files_selected' => 'No files selected.',
'no_uploads' => 'No files uploaded.',
'overwrite' => 'has already been uploaded. Would you like to overwrite it?',
'uploading' => 'Uploading',
'loading' => 'Loading'
];
1 change: 1 addition & 0 deletions resources/views/upload/partials/body.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
data-message="{{ trans('anomaly.field_type.files::message.upload') }}"
data-loading="{{ trans('anomaly.field_type.files::message.loading') }}"
data-uploading="{{ trans('anomaly.field_type.files::message.uploading') }}"
data-overwrite="{{ trans('anomaly.field_type.file::message.overwrite') }}"
data-max-parallel="{{ setting_value('anomaly.module.files::max_parallel_uploads', 3) }}"
data-allowed="{{ folder.allowed_types.value ? '.' ~ folder.allowed_types.value|join(',.') }}"></div>

Expand Down

0 comments on commit 9992b63

Please sign in to comment.