better explr

This commit is contained in:
jr-k 2024-07-17 18:07:00 +02:00
parent cc16d59e15
commit 34cc7c3b8d
6 changed files with 82 additions and 41 deletions

View File

@ -76,7 +76,7 @@ jQuery(function ($) {
if (selectionRectangle) { if (selectionRectangle) {
selectionRectangle.remove(); selectionRectangle.remove();
setTimeout(function() { setTimeout(function () {
selectionRectangle = null; selectionRectangle = null;
selectionStart = null; selectionStart = null;
}, 100); }, 100);
@ -112,13 +112,14 @@ jQuery(function ($) {
}); });
$('.draggable').each(function () { $('.draggable').each(function () {
$(this).draggable({ $(this).multiDraggable({
revert: "invalid", revert: "invalid",
revertDuration: 10, revertDuration: 10,
start: function(event, ui) { group: 'li.highlight-clicked',
startNative: function (event, ui) {
$('body').addClass('dragging'); $('body').addClass('dragging');
}, },
stop: function() { stopNative: function () {
$('body').removeClass('dragging'); $('body').removeClass('dragging');
} }
}); });
@ -136,19 +137,34 @@ jQuery(function ($) {
drop: function (event, ui) { drop: function (event, ui) {
$(this).removeClass("highlight-drop"); $(this).removeClass("highlight-drop");
const $form = $('#folder-move-form'); const $form = $('#folder-move-form');
const $moved = ui.draggable; const $moved = $('.ui-draggable-dragging');
const $target = $(this); const $target = $(this);
$form.find('[name=is_folder]').val($moved.attr('data-folder')) const folder_ids = [], entity_ids = [];
$form.find('[name=entity_id]').val($moved.attr('data-id'))
$form.find('[name=new_folder_id]').val($target.attr('data-id')) $moved.each(function () {
ui.draggable.position({ const $item = $(this);
my: "center", const is_folder = $item.attr('data-folder') === '1';
at: "center", const id = $item.attr('data-id');
of: $(this),
using: function (pos) { if (is_folder) {
$(this).animate(pos, 50); folder_ids.push(id);
} else {
entity_ids.push(id);
} }
$item.position({
my: "center",
at: "center",
of: $target,
using: function (pos) {
$item.animate(pos, 50);
}
});
}); });
$form.find('[name=entity_ids]').val(entity_ids.join(','))
$form.find('[name=folder_ids]').val(folder_ids.join(','))
$form.find('[name=new_folder_id]').val($target.attr('data-id'))
$form.submit(); $form.submit();
} }
}); });
@ -300,7 +316,7 @@ jQuery(function ($) {
const $prevLi = $selectedLi.prev('li:visible'); const $prevLi = $selectedLi.prev('li:visible');
const $nextLi = $selectedLiLast.next('li:visible'); const $nextLi = $selectedLiLast.next('li:visible');
const verticalNeighbors = getAboveBelowElement($selectedLi); const verticalNeighbors = getAboveBelowElement($selectedLi);
const clearIfNoMeta = function() { const clearIfNoMeta = function () {
if (!e.metaKey && !e.ctrlKey && !e.shiftKey) { if (!e.metaKey && !e.ctrlKey && !e.shiftKey) {
clearSelection() clearSelection()
} }

View File

@ -189,11 +189,24 @@ class ContentController(ObController):
def slideshow_content_folder_move(self): def slideshow_content_folder_move(self):
working_folder_path, working_folder = self.get_working_folder() working_folder_path, working_folder = self.get_working_folder()
self._model_store.folder().move_to_folder( entity_ids = request.form['entity_ids'].split(',')
entity_id=request.form['entity_id'], folder_ids = request.form['folder_ids'].split(',')
folder_id=request.form['new_folder_id'],
entity_is_folder=True if 'is_folder' in request.form and request.form['is_folder'] == '1' else False, for id in entity_ids:
) self._model_store.folder().move_to_folder(
entity_id=id,
folder_id=request.form['new_folder_id'],
entity_is_folder=False,
entity=FolderEntity.CONTENT
)
for id in folder_ids:
self._model_store.folder().move_to_folder(
entity_id=id,
folder_id=request.form['new_folder_id'],
entity_is_folder=True,
entity=FolderEntity.CONTENT
)
return redirect(url_for('slideshow_content_list', path=working_folder_path)) return redirect(url_for('slideshow_content_list', path=working_folder_path))

View File

@ -177,12 +177,24 @@ class FleetNodePlayerController(ObController):
def fleet_node_player_folder_move(self): def fleet_node_player_folder_move(self):
working_folder_path, working_folder = self.get_working_folder() working_folder_path, working_folder = self.get_working_folder()
entity_ids = request.form['entity_ids'].split(',')
folder_ids = request.form['folder_ids'].split(',')
self._model_store.folder().move_to_folder( for id in entity_ids:
entity_id=request.form['entity_id'], self._model_store.folder().move_to_folder(
folder_id=request.form['new_folder_id'], entity_id=id,
entity_is_folder=True if 'is_folder' in request.form and request.form['is_folder'] == '1' else False, folder_id=request.form['new_folder_id'],
) entity_is_folder=False,
entity=FolderEntity.NODE_PLAYER
)
for id in folder_ids:
self._model_store.folder().move_to_folder(
entity_id=id,
folder_id=request.form['new_folder_id'],
entity_is_folder=True,
entity=FolderEntity.NODE_PLAYER
)
return redirect(url_for('fleet_node_player_list', path=working_folder_path)) return redirect(url_for('fleet_node_player_list', path=working_folder_path))

View File

@ -143,10 +143,10 @@ class FolderManager(ModelManager):
self._db.update_by_id(self.TABLE_NAME, id, self.pre_update({"name": name})) self._db.update_by_id(self.TABLE_NAME, id, self.pre_update({"name": name}))
self.post_update(id) self.post_update(id)
def move_to_folder(self, entity_id: int, folder_id: int, entity_is_folder=False) -> None: def move_to_folder(self, entity_id: int, entity: FolderEntity, folder_id: Optional[int] = None, entity_is_folder=False) -> None:
folder = self.get(folder_id) folder = self.get(folder_id) if folder_id else None
if not folder and not entity_is_folder: if folder and folder.entity != entity:
return return
if entity_is_folder: if entity_is_folder:
@ -157,15 +157,15 @@ class FolderManager(ModelManager):
table = None table = None
if folder.entity == FolderEntity.CONTENT: if entity == FolderEntity.CONTENT:
table = ContentManager.TABLE_NAME table = ContentManager.TABLE_NAME
elif folder.entity == FolderEntity.NODE_PLAYER: elif entity == FolderEntity.NODE_PLAYER:
table = NodePlayerManager.TABLE_NAME table = NodePlayerManager.TABLE_NAME
if table: if table:
return self._db.execute_write_query( return self._db.execute_write_query(
query="UPDATE {} set folder_id = ? WHERE id = ?".format(table), query="UPDATE {} set folder_id = ? WHERE id = ?".format(table),
params=(folder_id, entity_id) params=(folder_id if folder else None, entity_id)
) )
def get_working_folder(self, entity: FolderEntity) -> str: def get_working_folder(self, entity: FolderEntity) -> str:

View File

@ -14,6 +14,7 @@
<script src="{{ STATIC_PREFIX }}js/explorer.js"></script> <script src="{{ STATIC_PREFIX }}js/explorer.js"></script>
<script src="{{ STATIC_PREFIX }}js/fleet/node-players.js"></script> <script src="{{ STATIC_PREFIX }}js/fleet/node-players.js"></script>
<script src="{{ STATIC_PREFIX }}js/lib/jquery-ui.min.js"></script> <script src="{{ STATIC_PREFIX }}js/lib/jquery-ui.min.js"></script>
<script src="{{ STATIC_PREFIX }}js/lib/jquery-multidraggable.js"></script>
{{ HOOK(H_FLEET_NODE_PLAYER_JAVASCRIPT) }} {{ HOOK(H_FLEET_NODE_PLAYER_JAVASCRIPT) }}
{% endblock %} {% endblock %}
@ -83,11 +84,10 @@
{% endwith %} {% endwith %}
</div> </div>
<form id="folder-move-form" action="{{ url_for('fleet_node_player_folder_move') }}" class="hidden" <form id="folder-move-form" action="{{ url_for('fleet_node_player_folder_move') }}?path={{ working_folder_path }}" class="hidden" method="POST">
method="POST"> <input type="hidden" name="entity_ids"/>
<input type="hidden" name="entity_id"/> <input type="hidden" name="folder_ids"/>
<input type="hidden" name="new_folder_id"/> <input type="hidden" name="new_folder_id"/>
<input type="hidden" name="is_folder"/>
</form> </form>
<div class="page-content"> <div class="page-content">
@ -132,7 +132,7 @@
{% set parent_path = '/'.join(working_folder_path.rstrip('/').split('/')[:-1]) %} {% set parent_path = '/'.join(working_folder_path.rstrip('/').split('/')[:-1]) %}
{% if parent_path %} {% if parent_path %}
<li class="previous-folder droppable" data-path="{{ parent_path }}" <li class="previous-folder droppable" data-path="{{ parent_path }}"
data-id="{{ working_folder.parent_id }}" data-folder="1"> data-id="{{ working_folder.parent_id if working_folder.parent_id else '' }}" data-folder="1">
<a href="{{ url_for('fleet_node_player_cd', path=parent_path) }}" <a href="{{ url_for('fleet_node_player_cd', path=parent_path) }}"
class="explr-link explr-item-selectable explr-item-folder"> class="explr-link explr-item-selectable explr-item-folder">
<i class="fa fa-folder"></i> <i class="fa fa-folder"></i>

View File

@ -21,6 +21,7 @@
<script src="{{ STATIC_PREFIX }}js/slideshow/contents.js"></script> <script src="{{ STATIC_PREFIX }}js/slideshow/contents.js"></script>
<script src="{{ STATIC_PREFIX }}js/lib/jquery-ui.min.js"></script> <script src="{{ STATIC_PREFIX }}js/lib/jquery-ui.min.js"></script>
<script src="{{ STATIC_PREFIX }}js/lib/jquery-fileupload.js"></script> <script src="{{ STATIC_PREFIX }}js/lib/jquery-fileupload.js"></script>
<script src="{{ STATIC_PREFIX }}js/lib/jquery-multidraggable.js"></script>
<script src="{{ STATIC_PREFIX }}js/dragdrop.js"></script> <script src="{{ STATIC_PREFIX }}js/dragdrop.js"></script>
{{ HOOK(H_SLIDESHOW_CONTENT_JAVASCRIPT) }} {{ HOOK(H_SLIDESHOW_CONTENT_JAVASCRIPT) }}
@ -105,11 +106,10 @@
{% endwith %} {% endwith %}
</div> </div>
<form id="folder-move-form" action="{{ url_for('slideshow_content_folder_move') }}" class="hidden" <form id="folder-move-form" action="{{ url_for('slideshow_content_folder_move') }}?path={{ working_folder_path }}" class="hidden" method="POST">
method="POST"> <input type="hidden" name="entity_ids"/>
<input type="hidden" name="entity_id"/> <input type="hidden" name="folder_ids"/>
<input type="hidden" name="new_folder_id"/> <input type="hidden" name="new_folder_id"/>
<input type="hidden" name="is_folder"/>
</form> </form>
<div class="page-content"> <div class="page-content">
@ -154,7 +154,7 @@
{% set parent_path = '/'.join(working_folder_path.rstrip('/').split('/')[:-1]) %} {% set parent_path = '/'.join(working_folder_path.rstrip('/').split('/')[:-1]) %}
{% if parent_path %} {% if parent_path %}
<li class="previous-folder droppable" data-path="{{ parent_path }}" <li class="previous-folder droppable" data-path="{{ parent_path }}"
data-id="{{ working_folder.parent_id }}" data-folder="1"> data-id="{{ working_folder.parent_id if working_folder.parent_id else '' }}" data-folder="1">
<a href="{{ url_for('slideshow_content_cd', path=parent_path) }}" <a href="{{ url_for('slideshow_content_cd', path=parent_path) }}"
class="explr-link explr-item-selectable explr-item-folder"> class="explr-link explr-item-selectable explr-item-folder">
<i class="fa fa-folder"></i> <i class="fa fa-folder"></i>