Commit 08130f59 authored by Mario's avatar Mario
Browse files

files_ng: fix regressions and add helper functions for UI changes

parent af1d3662
Pipeline #371345 passed with stage
in 3 minutes and 38 seconds
......@@ -97,7 +97,7 @@ class Browser extends DAV\Browser\Plugin {
$arr = explode('/', $parent->os_path);
end($arr);
$folder_parent = isset($arr[1]) ? prev($arr) : '';
$folder_parent = ((isset($arr[1])) ? prev($arr) : '');
$folder_list = attach_folder_select_list($channel_id);
......@@ -255,8 +255,8 @@ class Browser extends DAV\Browser\Plugin {
$ft['photo_icon'] = $photo_icon;
$ft['is_owner'] = $is_owner;
$ft['is_creator'] = $is_creator;
$ft['rel_path'] = (($nick) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href);
$ft['full_path'] = z_root() . (($nick) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href);
$ft['rel_path'] = (($data) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href);
$ft['full_path'] = z_root() . (($data) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href);
$ft['name'] = $name;
$ft['type'] = $type;
$ft['size'] = $size;
......
......@@ -2508,7 +2508,7 @@ function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpat
* @param int $resource_id
* @param string $new_folder_hash
* @param (optional) string $newname
* @param (optional) boolean $check_dupes
* @param (optional) boolean $recurse
* @return array Associative array with:
* * \e boolean \b success
* * \e string \b resource_id
......@@ -2564,7 +2564,7 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '',
$filename = (($newname) ? basename($newname) : $oldfilename);
// duplicate detection.
if($check_dupes) {
if($recurse) {
$s = q("select filename, id, hash, filesize from attach where filename = '%s' and folder = '%s' ",
dbesc($filename),
dbesc($new_folder_hash)
......@@ -2708,7 +2708,7 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '',
* @param int $resource_id
* @param string $new_folder_hash
* @param (optional) string $newname
* @param (optional) boolean $check_dupes
* @param (optional) boolean $recurse
* @return array Associative array with:
* * \e boolean \b success
* * \e string \b resource_id of the new resource
......
......@@ -7,11 +7,7 @@
display: none;
}
[id^="perms-panel-"] {
padding: 3px 10px 0px 10px !important;
}
[id^="attach-edit-panel-"],
.attach-edit-panel,
#attach-multi-edit-panel {
padding: 3px 10px 0px 10px !important;
}
......@@ -73,7 +69,7 @@
}
.attach-drop-ok {
background-color: aliceblue;
background-color: aliceblue !important;
}
.attach-drop-zone {
......
......@@ -17,60 +17,42 @@ $(document).ready(function () {
$('.cloud-tool-perms-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
$('.cloud-tool').hide();
$('.cloud-index').removeClass('cloud-index-active');
$('#cloud-tool-submit-' + id).show();
$('#cloud-index-' + id).addClass('cloud-index-active');
activate_id(id);
});
$('.cloud-tool-rename-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
$('.cloud-tool').hide();
$('.cloud-index').removeClass('cloud-index-active');
$('#cloud-tool-rename-' + id + ', #cloud-tool-submit-' + id).show();
$('#cloud-index-' + id).addClass('cloud-index-active');
activate_id(id);
$('#cloud-tool-rename-' + id).show();
});
$('.cloud-tool-move-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
$('.cloud-tool').hide();
$('.cloud-index').removeClass('cloud-index-active');
$('#cloud-tool-move-' + id + ', #cloud-tool-submit-' + id).show();
$('#cloud-index-' + id).addClass('cloud-index-active');
activate_id(id);
$('#cloud-tool-move-' + id).show();
});
$('.cloud-tool-categories-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
$('.cloud-tool').hide();
$('.cloud-index').removeClass('cloud-index-active');
activate_id(id);
$('#id_categories_' + id).tagsinput({
tagClass: 'badge badge-pill badge-warning text-dark'
});
$('#cloud-tool-categories-' + id + ', #cloud-tool-submit-' + id).show();
$('#cloud-index-' + id).addClass('cloud-index-active');
$('#cloud-tool-categories-' + id).show();
});
$('.cloud-tool-download-btn').on('click', function (e) {
let id = $(this).data('id');
$('.cloud-tool').hide();
close_and_deactivate_all_panels();
});
$('.cloud-tool-delete-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
$('.cloud-tool').hide();
$('.cloud-index').removeClass('cloud-index-active');
$('#cloud-index-' + id).addClass('cloud-index-active');
close_and_deactivate_all_panels();
let confirm = confirmDelete();
if (confirm) {
......@@ -95,11 +77,9 @@ $(document).ready(function () {
$('.cloud-tool-cancel-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
$('.cloud-tool').hide();
$('#cloud-index-' + id).removeClass('cloud-index-active');
close_and_deactivate_all_panels();
$('#attach_edit_form_' + id).trigger('reset');
$('#id_categories_' + id).tagsinput('destroy');
});
// Per File Tools Eend
......@@ -223,43 +203,48 @@ $(document).ready(function () {
}
if($('.cloud-multi-tool-checkbox:checked').length) {
$('#cloud-multi-actions').addClass('cloud-index-active');
close_all_panels();
$('#cloud-multi-actions').addClass('bg-warning');
$('#multi-dropdown-button').fadeIn();
}
else {
$('#cloud-multi-actions').removeClass('cloud-index-active');
$('#cloud-multi-actions').removeClass('bg-warning');
$('#multi-dropdown-button').fadeOut();
close_and_deactivate_all_panels();
disable_multi_acl();
}
});
$('#cloud-multi-tool-perms-btn').on('click', function (e) {
e.preventDefault();
$('.cloud-tool, .cloud-multi-tool').hide();
$('#multi-perms').val(1);
$('#cloud-multi-tool-submit, #recurse_container, #multi-dbtn-acl').show();
close_all_panels();
enable_multi_acl();
$('#cloud-multi-tool-submit').show();
});
$('#cloud-multi-tool-move-btn').on('click', function (e) {
e.preventDefault();
$('.cloud-tool, .cloud-multi-tool, #recurse_container, #multi-dbtn-acl').hide();
$('#multi-perms').val(0);
close_all_panels();
disable_multi_acl();
$('#cloud-multi-tool-submit, #cloud-multi-tool-move').show();
});
$('#cloud-multi-tool-categories-btn').on('click', function (e) {
e.preventDefault();
$('.cloud-tool, .cloud-multi-tool, #recurse_container, #multi-dbtn-acl').hide();
close_all_panels();
disable_multi_acl();
$('#id_categories').tagsinput({
tagClass: 'badge badge-pill badge-warning text-dark'
});
$('#multi-perms').val(0);
$('#cloud-multi-tool-categories, #cloud-multi-tool-submit').show();
$('#cloud-multi-tool-submit, #cloud-multi-tool-categories').show();
});
$('#cloud-multi-tool-delete-btn').on('click', function (e) {
......@@ -295,18 +280,57 @@ $(document).ready(function () {
$('.cloud-multi-tool-cancel-btn').on('click', function (e) {
e.preventDefault();
$('.cloud-multi-tool, #recurse_container, #multi-dbtn-acl').hide();
close_and_deactivate_all_panels();
disable_multi_acl();
$('#attach_multi_edit_form').trigger('reset');
$('#multi-perms').val(0);
$('#id_categories').tagsinput('destroy');
});
// Multi Tools End
// Helper Functions
function disable_multi_acl() {
$('#multi-perms').val(0);
$('#multi-dbtn-acl, #recurse_container').hide();
$('#attach-multi-edit-perms').removeClass('btn-group');
}
function enable_multi_acl() {
$('#multi-perms').val(1);
$('#multi-dbtn-acl, #recurse_container').show();
$('#attach-multi-edit-perms').addClass('btn-group');
}
function close_all_panels() {
$('.cloud-tool, .cloud-multi-tool').hide();
}
function deactivate_all_panels() {
$('.cloud-index').removeClass('cloud-index-active');
}
function close_and_deactivate_all_panels() {
close_all_panels();
deactivate_all_panels();
}
function activate_id(id) {
close_and_deactivate_all_panels();
$('#cloud-multi-tool-select-all, .cloud-multi-tool-checkbox').prop('checked', false).trigger('change');
$('#cloud-tool-submit-' + id).show();
$('#cloud-index-' + id).addClass('cloud-index-active');
$('#cloud-tool-submit-' + id).show();
}
});
// initialize
function UploadInit() {
......
......@@ -60,6 +60,7 @@
<td><i class="fa fa-level-up"></i></td>
<td colspan="6"><a href="{{$parentpath}}" title="{{$parent}}" class="p-2" draggable="false">..</a></td>
</tr>
<tr class="cloud-tools"><td colspan="8" class="attach-edit-panel"> {{* this is for display consistency *}}</td></tr>
{{/if}}
{{if $entries.0}}
<tr id="cloud-multi-actions">
......@@ -76,25 +77,25 @@
<td colspan="3">
{{if $is_owner}}
<div class="dropdown">
<button class="btn btn-outline-secondary btn-sm" id="multi-dropdown-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-ellipsis-v"></i> Bulk Actions
<button class="btn btn-warning btn-sm" id="multi-dropdown-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-ellipsis-v d-table-cell"></i><span class="d-none d-md-table-cell">Bulk Actions</span>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button">
{{if $is_owner}}
<a id="cloud-multi-tool-perms-btn" class="dropdown-item cloud-tool-perms-btn" href="#"><i class="fa fa-fw fa-lock"></i> Adjust permissions</a>
<a id="cloud-multi-tool-perms-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-lock"></i> Adjust permissions</a>
{{/if}}
<a id="cloud-multi-tool-move-btn" class="dropdown-item cloud-tool-move-btn" href="#"><i class="fa fa-fw fa-copy"></i> Move or copy</a>
<a id="cloud-multi-tool-categories-btn" class="dropdown-item cloud-tool-categories-btn" href="#"><i class="fa fa-fw fa-asterisk"></i> Categories</a>
<a id="cloud-multi-tool-move-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-copy"></i> Move or copy</a>
<a id="cloud-multi-tool-categories-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-asterisk"></i> Categories</a>
<a id="cloud-multi-tool-delete-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-trash-o"></i> {{$delete}}</a>
</div>
</div>
{{else if $is_admin}}
<div class="dropdown">
<button class="btn btn-link btn-sm" id="dropdown-button-{{$item.attach_id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-ellipsis-v"></i>
<button class="btn btn-warning btn-sm" id="multi-dropdown-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-ellipsis-v d-table-cell"></i><span class="d-none d-md-table-cell">Bulk Actions</span>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button">
<a id="cloud-multi-tool-delete-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-trash-o"></i> {{$delete}}</a>
<a id="cloud-multi-tool-delete-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-trash-o"></i> {{$admin_delete}}</a>
</div>
</div>
{{/if}}
......@@ -193,7 +194,7 @@
<td class="d-none d-md-table-cell p-2">{{$item.last_modified}}</td>
</tr>
<tr id="cloud-tools-{{$item.attach_id}}" class="cloud-tools">
<td id="attach-edit-panel-{{$item.attach_id}}" colspan="8">
<td id="attach-edit-panel-{{$item.attach_id}}" class="attach-edit-panel" colspan="8">
<form id="attach_edit_form_{{$item.attach_id}}" action="attach_edit" method="post" class="acl-form" data-form_id="attach_edit_form_{{$item.attach_id}}" data-allow_cid='{{$item.allow_cid}}' data-allow_gid='{{$item.allow_gid}}' data-deny_cid='{{$item.deny_cid}}' data-deny_gid='{{$item.deny_gid}}'>
<input type="hidden" name="attach_id" value="{{$item.attach_id}}" />
<input type="hidden" name="channel_id" value="{{$channel_id}}" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment