[frio] Add support for asynchronous call to /filerm module for post categories and folders

- This prevents the page to change to an empty page when clicking on the remove link of categories and folders
This commit is contained in:
Hypolite Petovan 2022-09-05 01:04:32 -04:00
parent cacfc6ec92
commit 60d1779717
2 changed files with 21 additions and 5 deletions

View File

@ -56,7 +56,6 @@
jotTextOpenUI(document.getElementById("profile-jot-text"));
});
/* show images / file browser window
*
**/
@ -125,6 +124,24 @@
Dialog.doFileBrowser("main");
jotActive();
});
$('body').on('click', '.p-category .filerm', function(e){
e.preventDefault();
let $href = $(e.target).attr('href');
// Prevents arbitrary Ajax requests
if ($href.substr(0, 7) === 'filerm/') {
$(e.target).parent().removeClass('btn-success btn-danger');
$.post($href)
.done(function() {
liking = 1;
force_update = true;
})
.always(function () {
NavUpdate();
});
}
});
});
function deleteCheckedItems() {
@ -281,7 +298,6 @@
return false;
});
});
}
function jotClearLocation() {

View File

@ -278,12 +278,12 @@ as the value of $top_child_total (this is done at the end of this file)
<span class="mention label label-default sm">{{$tag nofilter}} <i class="fa fa-eye-slash" aria-hidden="true"></i></span>
{{/foreach*}}
{{/if}}
{{foreach $item.folders as $cat}}
<span class="folder label btn-danger sm p-category">{{$cat.name}}{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{foreach $item.folders as $folder}}
<span class="folder label btn-danger sm p-category">{{$folder.name}}{{if $folder.removeurl}} (<a href="{{$folder.removeurl}}" class="filerm" title="{{$remove}}">x</a>){{/if}}</span>
{{/foreach}}
{{foreach $item.categories as $cat}}
<span class="category label btn-success sm p-category"><a href="{{$cat.url}}">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
<span class="category label btn-success sm p-category"><a href="{{$cat.url}}">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" class="filerm" title="{{$remove}}">x</a>){{/if}}</span>
{{/foreach}}
</div>
{{if $item.edited}}<div class="itemedited text-muted">{{$item.edited['label']}} (<span title="{{$item.edited['date']}}">{{$item.edited['relative']}}</span>)</div>{{/if}}