browse-everything 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +105 -30
- data/.gitignore +4 -2
- data/.rubocop.yml +54 -34
- data/.rubocop_todo.yml +0 -5
- data/.tool-versions +2 -0
- data/CONTRIBUTING.md +22 -0
- data/Gemfile +41 -33
- data/README.md +66 -31
- data/Rakefile +9 -1
- data/app/assets/javascripts/browse_everything/behavior.js +45 -31
- data/app/assets/javascripts/browse_everything.js +1 -1
- data/app/assets/javascripts/treetable.webpack.js +687 -0
- data/app/controllers/browse_everything_controller.rb +60 -60
- data/app/helpers/browse_everything_helper.rb +4 -0
- data/app/views/browse_everything/_files.html.erb +3 -2
- data/bin/rails +14 -0
- data/browse-everything.gemspec +13 -12
- data/lib/browse_everything/auth/google/credentials.rb +5 -5
- data/lib/browse_everything/auth/google/request_parameters.rb +38 -38
- data/lib/browse_everything/driver/base.rb +15 -14
- data/lib/browse_everything/driver/box.rb +56 -56
- data/lib/browse_everything/driver/dropbox.rb +44 -41
- data/lib/browse_everything/driver/file_system.rb +31 -18
- data/lib/browse_everything/driver/google_drive.rb +38 -38
- data/lib/browse_everything/driver/s3.rb +61 -61
- data/lib/browse_everything/engine.rb +10 -3
- data/lib/browse_everything/file_entry.rb +1 -1
- data/lib/browse_everything/retriever.rb +69 -69
- data/lib/browse_everything/version.rb +1 -1
- data/lib/browse_everything.rb +1 -1
- data/spec/dummy_test_app/Rakefile +6 -0
- data/spec/dummy_test_app/app/assets/config/manifest.js +3 -0
- data/spec/dummy_test_app/app/assets/images/.keep +0 -0
- data/spec/dummy_test_app/app/assets/javascripts/application.js +25 -0
- data/spec/dummy_test_app/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy_test_app/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy_test_app/app/assets/stylesheets/application.scss +18 -0
- data/spec/dummy_test_app/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy_test_app/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy_test_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_test_app/app/controllers/concerns/.keep +0 -0
- data/spec/{support → dummy_test_app}/app/controllers/file_handler_controller.rb +0 -0
- data/spec/dummy_test_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_test_app/app/jobs/application_job.rb +2 -0
- data/spec/dummy_test_app/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy_test_app/app/models/application_record.rb +3 -0
- data/spec/dummy_test_app/app/models/concerns/.keep +0 -0
- data/spec/dummy_test_app/app/views/file_handler/index.html.erb +10 -0
- data/spec/{support → dummy_test_app}/app/views/file_handler/main.html.erb +6 -3
- data/spec/dummy_test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_test_app/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy_test_app/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy_test_app/bin/bundle +3 -0
- data/spec/dummy_test_app/bin/rails +4 -0
- data/spec/dummy_test_app/bin/rake +4 -0
- data/spec/dummy_test_app/bin/setup +38 -0
- data/spec/dummy_test_app/bin/update +29 -0
- data/spec/dummy_test_app/bin/yarn +11 -0
- data/spec/dummy_test_app/config/application.rb +27 -0
- data/spec/dummy_test_app/config/boot.rb +5 -0
- data/spec/dummy_test_app/config/browse_everything_providers.yml +25 -0
- data/spec/dummy_test_app/config/cable.yml +10 -0
- data/spec/dummy_test_app/config/database.yml +25 -0
- data/spec/dummy_test_app/config/environment.rb +5 -0
- data/spec/dummy_test_app/config/environments/development.rb +54 -0
- data/spec/dummy_test_app/config/environments/production.rb +91 -0
- data/spec/dummy_test_app/config/environments/test.rb +42 -0
- data/spec/dummy_test_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy_test_app/config/initializers/assets.rb +14 -0
- data/spec/dummy_test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_test_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy_test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_test_app/config/initializers/inflections.rb +16 -0
- data/spec/dummy_test_app/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_test_app/config/locales/en.yml +33 -0
- data/spec/dummy_test_app/config/puma.rb +56 -0
- data/spec/dummy_test_app/config/routes.rb +9 -0
- data/spec/dummy_test_app/config/secrets.yml +32 -0
- data/spec/dummy_test_app/config/spring.rb +6 -0
- data/spec/dummy_test_app/config.ru +5 -0
- data/spec/dummy_test_app/lib/assets/.keep +0 -0
- data/spec/dummy_test_app/log/.keep +0 -0
- data/spec/dummy_test_app/package.json +5 -0
- data/spec/dummy_test_app/public/404.html +67 -0
- data/spec/dummy_test_app/public/422.html +67 -0
- data/spec/dummy_test_app/public/500.html +66 -0
- data/spec/dummy_test_app/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy_test_app/public/apple-touch-icon.png +0 -0
- data/spec/dummy_test_app/public/favicon.ico +0 -0
- data/spec/dummy_test_app/tmp/.gitkeep +0 -0
- data/spec/features/select_files_spec.rb +1 -0
- data/spec/features/test_compiling_stylesheets_spec.rb +1 -1
- data/spec/lib/browse_everything/driver_spec.rb +43 -3
- data/spec/spec_helper.rb +3 -28
- data/tasks/ci.rake +1 -1
- metadata +180 -94
- data/karma.conf.js +0 -71
- data/spec/javascripts/behavior_spec.js +0 -7
- data/spec/javascripts/helpers/jasmine-jquery.js +0 -838
- data/spec/javascripts/helpers/jquery.js +0 -11008
- data/spec/javascripts/karma_spec.rb +0 -16
- data/spec/support/app/views/file_handler/index.html.erb +0 -6
- data/spec/test_app_templates/Gemfile.extra +0 -9
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -61
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
$(function () {
|
4
4
|
var dialog = $('div#browse-everything');
|
5
|
+
var selected_files = new Map(); // { url: input element object }
|
5
6
|
|
6
7
|
var initialize = function initialize(obj, options) {
|
7
8
|
if ($('div#browse-everything').length === 0) {
|
@@ -46,25 +47,21 @@ $(function () {
|
|
46
47
|
return t.replace(/\+/g, ' ').split('=', 2);
|
47
48
|
});
|
48
49
|
var elements = $(fields).map(function () {
|
49
|
-
return $("<input type='hidden'/>").attr('name', decodeURIComponent(this[0])).val(decodeURIComponent(this[1]))[0]
|
50
|
+
return $("<input type='hidden'/>").attr('name', decodeURIComponent(this[0])).val(decodeURIComponent(this[1]))[0];
|
50
51
|
});
|
51
|
-
return $(elements.toArray()
|
52
|
+
return $(elements.toArray());
|
52
53
|
};
|
53
54
|
|
54
55
|
var indicateSelected = function indicateSelected() {
|
55
|
-
return
|
56
|
-
|
56
|
+
return selected_files.forEach(function (value, key) {
|
57
|
+
var row = $('*[data-ev-location=\'' + key + '\']');
|
58
|
+
row.find('.ev-select-file').prop('checked', true);
|
59
|
+
return row.addClass('ev-selected');
|
57
60
|
});
|
58
61
|
};
|
59
62
|
|
60
63
|
var fileIsSelected = function fileIsSelected(row) {
|
61
|
-
|
62
|
-
$('input.ev-url').each(function () {
|
63
|
-
if (this.value === $(row).data('ev-location')) {
|
64
|
-
return result = true;
|
65
|
-
}
|
66
|
-
});
|
67
|
-
return result;
|
64
|
+
return selected_files.has(row.data('ev-location'));
|
68
65
|
};
|
69
66
|
|
70
67
|
var toggleFileSelect = function toggleFileSelect(row) {
|
@@ -77,27 +74,26 @@ $(function () {
|
|
77
74
|
return updateFileCount();
|
78
75
|
};
|
79
76
|
|
77
|
+
var hidden_input_prototype = $("<input type='hidden' class='ev-url' name='selected_files[]'/>");
|
80
78
|
var selectFile = function selectFile(row) {
|
81
|
-
var target_form = $('form.ev-submit-form');
|
82
79
|
var file_location = row.data('ev-location');
|
83
|
-
var hidden_input =
|
84
|
-
|
80
|
+
var hidden_input = hidden_input_prototype.clone().val(file_location);
|
81
|
+
selected_files.set(file_location, hidden_input);
|
85
82
|
if (!$(row).find('.ev-select-file').prop('checked')) {
|
86
83
|
return $(row).find('.ev-select-file').prop('checked', true);
|
87
84
|
}
|
88
85
|
};
|
89
86
|
|
90
87
|
var unselectFile = function unselectFile(row) {
|
91
|
-
var target_form = $('form.ev-submit-form');
|
92
88
|
var file_location = row.data('ev-location');
|
93
|
-
|
89
|
+
selected_files.delete(file_location);
|
94
90
|
if ($(row).find('.ev-select-file').prop('checked')) {
|
95
91
|
return $(row).find('.ev-select-file').prop('checked', false);
|
96
92
|
}
|
97
93
|
};
|
98
94
|
|
99
95
|
var updateFileCount = function updateFileCount() {
|
100
|
-
var count =
|
96
|
+
var count = selected_files.size;
|
101
97
|
var files = count === 1 ? "file" : "files";
|
102
98
|
return $('.ev-status').html(count + ' ' + files + ' selected');
|
103
99
|
};
|
@@ -125,7 +121,7 @@ $(function () {
|
|
125
121
|
};
|
126
122
|
|
127
123
|
var selectChildRows = function selectChildRows(row, action) {
|
128
|
-
|
124
|
+
var returned_rows = $('table#file-list tr').each(function () {
|
129
125
|
if ($(this).data('tt-parent-id')) {
|
130
126
|
var re = RegExp($(row).data('tt-id'), 'i');
|
131
127
|
if ($(this).data('tt-parent-id').match(re)) {
|
@@ -149,11 +145,12 @@ $(function () {
|
|
149
145
|
$(this).removeClass('ev-selected');
|
150
146
|
unselectFile($(this));
|
151
147
|
}
|
152
|
-
return updateFileCount();
|
153
148
|
}
|
154
149
|
}
|
155
150
|
}
|
156
151
|
});
|
152
|
+
updateFileCount();
|
153
|
+
return returned_rows;
|
157
154
|
};
|
158
155
|
|
159
156
|
var tableSetup = function tableSetup(table) {
|
@@ -262,21 +259,29 @@ $(function () {
|
|
262
259
|
|
263
260
|
$.fn.browseEverything = function (options) {
|
264
261
|
var ctx = $(this).data('ev-state');
|
262
|
+
|
263
|
+
// Try and load the options from the HTML data attributes
|
265
264
|
if (ctx == null && options == null) {
|
266
265
|
options = $(this).data();
|
267
266
|
}
|
267
|
+
|
268
268
|
if (options != null) {
|
269
269
|
ctx = initialize(this[0], options);
|
270
|
-
$(this).click(function () {
|
271
|
-
dialog.data('ev-state', ctx);
|
272
|
-
return dialog.load(ctx.opts.route, function () {
|
273
|
-
setTimeout(refreshFiles, 500);
|
274
|
-
ctx.callbacks.show.fire();
|
275
|
-
return dialog.modal('show');
|
276
|
-
});
|
277
|
-
});
|
278
270
|
}
|
279
271
|
|
272
|
+
$(this).click(function () {
|
273
|
+
dialog.data('ev-state', ctx);
|
274
|
+
return dialog.load(ctx.opts.route, function () {
|
275
|
+
setTimeout(refreshFiles, 50);
|
276
|
+
ctx.callbacks.show.fire();
|
277
|
+
dialog.removeClass('fade')
|
278
|
+
.removeClass('in')
|
279
|
+
.addClass('show');
|
280
|
+
|
281
|
+
return dialog.modal('show');
|
282
|
+
});
|
283
|
+
});
|
284
|
+
|
280
285
|
if (ctx) {
|
281
286
|
return ctx.callback_proxy;
|
282
287
|
} else {
|
@@ -312,6 +317,7 @@ $(function () {
|
|
312
317
|
$(document).on('click', 'button.ev-cancel', function (event) {
|
313
318
|
event.preventDefault();
|
314
319
|
dialog.data('ev-state').callbacks.cancel.fire();
|
320
|
+
selected_files.clear();
|
315
321
|
return $('.ev-browser').modal('hide');
|
316
322
|
});
|
317
323
|
|
@@ -319,6 +325,7 @@ $(function () {
|
|
319
325
|
event.preventDefault();
|
320
326
|
$(this).button('loading');
|
321
327
|
startWait();
|
328
|
+
$('form.ev-submit-form').append(Array.from(selected_files.values()));
|
322
329
|
var main_form = $(this).closest('form');
|
323
330
|
var resolver_url = main_form.data('resolver');
|
324
331
|
var ctx = dialog.data('ev-state');
|
@@ -330,12 +337,13 @@ $(function () {
|
|
330
337
|
}).done(function (data) {
|
331
338
|
if (ctx.opts.target != null) {
|
332
339
|
var fields = toHiddenFields({ selected_files: data });
|
333
|
-
$(ctx.opts.target).append(
|
340
|
+
$(ctx.opts.target).append(fields);
|
334
341
|
}
|
335
342
|
return ctx.callbacks.done.fire(data);
|
336
343
|
}).fail(function (xhr, status, error) {
|
337
344
|
return ctx.callbacks.fail.fire(status, error, xhr.responseText);
|
338
345
|
}).always(function () {
|
346
|
+
selected_files.clear();
|
339
347
|
$('body').css('cursor', 'default');
|
340
348
|
$('.ev-browser').modal('hide');
|
341
349
|
return $('#browse-btn').focus();
|
@@ -439,10 +447,16 @@ var auto_toggle = function auto_toggle() {
|
|
439
447
|
if (typeof Turbolinks !== 'undefined' && Turbolinks !== null && Turbolinks.supported) {
|
440
448
|
// Use turbolinks:load for Turbolinks 5, otherwise use the old way
|
441
449
|
if (Turbolinks.BrowserAdapter) {
|
442
|
-
$(document).on('turbolinks:load',
|
450
|
+
$(document).on('turbolinks:load', function() {
|
451
|
+
// make sure turbolinks:load AND jquery onReady have BOTH happened,
|
452
|
+
// they could come in any order.
|
453
|
+
$(auto_toggle);
|
454
|
+
});
|
443
455
|
} else {
|
444
|
-
$(document).on('page:change',
|
456
|
+
$(document).on('page:change', function() {
|
457
|
+
$(auto_toggle);
|
458
|
+
});
|
445
459
|
}
|
446
460
|
} else {
|
447
|
-
$(
|
461
|
+
$(auto_toggle);
|
448
462
|
}
|