Files
Piwigo/admin/themes/default/js/album_selector.js
T
HWFord 10a8db2102 fixes #2164 batch manager unit mode redesign (#2179)
* Interface Update

Update front end according to web design

Completed the implementation of album manager

* Added image delete mechanism

* Update Validation

* Added filters according to global mode

Page is now fully translated from EN_uk to FR_fr
Harmonized global and unit mode by creating a template for the filters

TODO :

Uncomment updateBlock calls in metaSync and implement tags update

Uncomment pluginSave method and test it with an updated plugin

---------

Co-authored-by: marsooooo <marso.tison@gmail.com>
2024-07-02 11:20:16 +02:00

141 lines
3.4 KiB
JavaScript

function set_up_popin() {
$(".ClosePopIn").on('click', function () {
linked_albums_close();
});
}
function linked_albums_close() {
$("#addLinkedAlbum").fadeOut();
}
function linked_albums_open(pictureId) {
$("#addLinkedAlbum").fadeIn();
if(null != pictureId)
{
console.log(pictureId);
$("#addLinkedAlbum .linkedAlbumPopInContainer").attr("id",pictureId);
}
$(".search-input").val("");
$(".search-input").focus();
$("#searchResult").empty();
$(".limitReached").html(str_no_search_in_progress);
}
function linked_albums_search(searchText, pictureId) {
if (api_method == 'pwg.categories.getList') {
api_params = {
cat_id: 0,
recursive: true,
fullname: true,
search: searchText,
}
} else {
api_params = {
search: searchText,
additional_output: "full_name_with_admin_links",
}
}
$(".linkedAlbumPopInContainer .searching").show();
$.ajax({
url: "ws.php?format=json&method=" + api_method,
type: "POST",
dataType: "json",
data : api_params,
before: function () {
},
success: function (raw_data) {
$(".linkedAlbumPopInContainer .searching").hide();
categories = raw_data.result.categories;
if (typeof pictureId !== 'undefined') {
fill_results(categories, pictureId);
} else {
fill_results(categories);
}
if (raw_data.result.limit_reached) {
$(".limitReached").html(str_result_limit.replace("%d", categories.length));
} else {
if (categories.length == 1) {
$(".limitReached").html(str_album_found);
} else {
$(".limitReached").html(str_albums_found.replace("%d", categories.length));
}
}
},
error: function (e) {
$(".linkedAlbumPopInContainer .searching").hide();
console.log(e.message);
}
})
}
function prefill_search() {
$(".linkedAlbumPopInContainer .searching").show();
if (api_method == "pwg.categories.getList") {
api_params = {
cat_id: 0,
recursive: false,
fullname: true,
limit: limit_params,
};
} else {
api_params = {
additional_output: "full_name_with_admin_links",
};
}
$.ajax({
url: "ws.php?format=json&method=" + api_method,
type: "POST",
dataType: "json",
data: api_params,
success: function (data) {
// for debug
// console.log(data);
$(".linkedAlbumPopInContainer .searching").hide();
const cats = data.result.categories;
const limit = data.result.limit;
prefill_results("root", cats, limit);
},
error: function (e) {
$(".linkedAlbumPopInContainer .searching").hide();
console.log("error : ", e.message);
},
});
}
async function prefill_search_subcats(cat_id) {
let method = {};
if (api_method == "pwg.categories.getList") {
method = {
cat_id: cat_id,
recursive: false,
limit: limit_params,
};
} else {
method = {
additional_output: "full_name_with_admin_links",
};
}
try {
const data = await $.ajax({
url: "ws.php?format=json&method=" + api_method,
type: "POST",
dataType: "json",
data: method,
});
// for debug
// console.log(data);
const cats = data.result.categories.filter((c) => c.id !== +cat_id);
const limit = data.result.limit;
prefill_results(cat_id, cats, limit);
} catch (e) {
console.log("error", e.message);
}
}