mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 03:09:58 +03:00
issue #2164 update extensibility for unit mode
Added new options of validation and updated existing code injection methods see Skeleton extension for more details about extensibility
This commit is contained in:
parent
5c080bf379
commit
811bee3eb5
2 changed files with 77 additions and 80 deletions
|
@ -1,4 +1,4 @@
|
|||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
// Detect unsaved changes on any inputs
|
||||
let user_interacted = false;
|
||||
|
||||
|
@ -340,51 +340,58 @@ function saveChanges(pictureId) {
|
|||
if ($("#picture-" + pictureId + " .local-unsaved-badge").css('display') === 'block') {
|
||||
disableLocalButton(pictureId);
|
||||
// Retrieve Infos
|
||||
const name = $("#picture-" + pictureId +" #name").val();
|
||||
const author = $("#picture-" + pictureId +" #author").val();
|
||||
const name = $("#picture-" + pictureId + " #name").val();
|
||||
const author = $("#picture-" + pictureId + " #author").val();
|
||||
const date_creation = $("#picture-" + pictureId + " #date_creation").val();
|
||||
const comment = $("#picture-" + pictureId +" #description").val();
|
||||
const level = $("#picture-" + pictureId +" #level" + " option:selected").val();
|
||||
const comment = $("#picture-" + pictureId + " #description").val();
|
||||
const level = $("#picture-" + pictureId + " #level option:selected").val();
|
||||
// Get Categories
|
||||
const categories = get_related_category(pictureId);
|
||||
let categoriesStr = categories.join(';');
|
||||
// Get Tags
|
||||
let tags = [];
|
||||
$("#picture-" + pictureId +" #tags" + " option").each(function() {
|
||||
$("#picture-" + pictureId + " #tags option").each(function () {
|
||||
let tagId = $(this).val().replace(/~~/g, '');
|
||||
tags.push(tagId);
|
||||
});
|
||||
let tagsStr = tags.join(',');
|
||||
let ajax_data = {
|
||||
method: 'pwg.images.setInfo',
|
||||
image_id: pictureId,
|
||||
name: name,
|
||||
author: author,
|
||||
date_creation: date_creation,
|
||||
comment: comment,
|
||||
categories: categoriesStr,
|
||||
tag_ids: tagsStr,
|
||||
level: level,
|
||||
single_value_mode: "replace",
|
||||
multiple_value_mode: "replace",
|
||||
pwg_token: jQuery("input[name=pwg_token]").val()
|
||||
};
|
||||
|
||||
for (let key_index in pluginValues) {
|
||||
let pluginValues_selector = pluginValues[key_index].selector;
|
||||
let full_selector = $("#picture-" + pictureId + " " + pluginValues_selector);
|
||||
let pluginValues_value = full_selector.val();
|
||||
ajax_data[pluginValues[key_index].api_key] = pluginValues_value;
|
||||
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: 'ws.php?format=json',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
method: 'pwg.images.setInfo',
|
||||
image_id: pictureId,
|
||||
name: name,
|
||||
author: author,
|
||||
date_creation: date_creation,
|
||||
comment: comment,
|
||||
categories: categoriesStr,
|
||||
tag_ids: tagsStr,
|
||||
level: level,
|
||||
single_value_mode: "replace",
|
||||
multiple_value_mode: "replace",
|
||||
pwg_token: jQuery("input[name=pwg_token]").val()
|
||||
},
|
||||
data: ajax_data,
|
||||
success: function(data) {
|
||||
const isOk = data.stat && data.stat === 'ok';
|
||||
if (isOk) {
|
||||
console.log("Data saved successfully for picture " + pictureId);
|
||||
enableLocalButton(pictureId);
|
||||
enableGlobalButton();
|
||||
hideUnsavedLocalBadge(pictureId);
|
||||
showSuccessLocalBadge(pictureId);
|
||||
updateSuccessGlobalBadge();
|
||||
// Call for extension's save
|
||||
// This is the first method we're implementing to validate extension's data
|
||||
// More informations will be provided on next skeleton update
|
||||
// Method 1 for extension's save (see Skeleton extension for more details)
|
||||
pluginSaveLoop(activePlugins, pictureId);
|
||||
}
|
||||
else {
|
||||
|
@ -422,7 +429,7 @@ function pluginFunctionMapInit(activePlugins) {
|
|||
const functionName = pluginId + '_batchManagerSave';
|
||||
if (typeof window[functionName] === 'function') {
|
||||
pluginFunctionMap[pluginId] = window[functionName];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -438,46 +445,46 @@ function pluginSaveLoop(activePlugins, pictureId) {
|
|||
|
||||
});
|
||||
}
|
||||
//UPDATE BLOCKS (Yet to be implemented)
|
||||
function updateBlock(pictureId) {
|
||||
$.ajax({
|
||||
url: 'ws.php?format=json',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
method: 'pwg.images.getInfo',
|
||||
image_id: pictureId,
|
||||
format: 'json'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.stat === 'ok') {
|
||||
$("#picture-" + pictureId + " #name-" + pictureId).val(response.result.name);
|
||||
$("#picture-" + pictureId + " #author-" + pictureId).val(response.result.author);
|
||||
$("#picture-" + pictureId + " #date_creation-" + pictureId).val(response.result.date_creation);
|
||||
$("#picture-" + pictureId + " #description-" + pictureId).val(response.result.comment);
|
||||
$("#picture-" + pictureId + " #level-" + pictureId).val(response.result.level);
|
||||
$("#picture-" + pictureId + " #filename-" + pictureId).text(response.result.file);
|
||||
$("#picture-" + pictureId + " #filesize-" + pictureId).text(response.result.filesize);
|
||||
$("#picture-" + pictureId + " #dimensions-" + pictureId).text(response.result.width + "x" + response.result.height);
|
||||
// updateTags(response.result.tags, pictureId); //Yet to be implemented
|
||||
showMetasyncSuccesBadge(pictureId);
|
||||
enableLocalButton(pictureId);
|
||||
enableGlobalButton();
|
||||
} else {
|
||||
console.error("Error:", response.message);
|
||||
showErrorLocalBadge(pictureId);
|
||||
enableLocalButton(pictureId);
|
||||
enableGlobalButton();
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error:", status, error);
|
||||
showErrorLocalBadge(pictureId);
|
||||
enableLocalButton(pictureId);
|
||||
}
|
||||
});
|
||||
}
|
||||
//TAGS UPDATE Yet to be implemented
|
||||
// UPDATE BLOCKS (Yet to be implemented)
|
||||
// function updateBlock(pictureId) {
|
||||
// $.ajax({
|
||||
// url: 'ws.php?format=json',
|
||||
// type: 'GET',
|
||||
// dataType: 'json',
|
||||
// data: {
|
||||
// method: 'pwg.images.getInfo',
|
||||
// image_id: pictureId,
|
||||
// format: 'json'
|
||||
// },
|
||||
// success: function(response) {
|
||||
// if (response.stat === 'ok') {
|
||||
// $("#picture-" + pictureId + " #name-" + pictureId).val(response.result.name);
|
||||
// $("#picture-" + pictureId + " #author-" + pictureId).val(response.result.author);
|
||||
// $("#picture-" + pictureId + " #date_creation-" + pictureId).val(response.result.date_creation);
|
||||
// $("#picture-" + pictureId + " #description-" + pictureId).val(response.result.comment);
|
||||
// $("#picture-" + pictureId + " #level-" + pictureId).val(response.result.level);
|
||||
// $("#picture-" + pictureId + " #filename-" + pictureId).text(response.result.file);
|
||||
// $("#picture-" + pictureId + " #filesize-" + pictureId).text(response.result.filesize);
|
||||
// $("#picture-" + pictureId + " #dimensions-" + pictureId).text(response.result.width + "x" + response.result.height);
|
||||
// updateTags(response.result.tags, pictureId); //Yet to be implemented
|
||||
// showMetasyncSuccesBadge(pictureId);
|
||||
// enableLocalButton(pictureId);
|
||||
// enableGlobalButton();
|
||||
// } else {
|
||||
// console.error("Error:", response.message);
|
||||
// showErrorLocalBadge(pictureId);
|
||||
// enableLocalButton(pictureId);
|
||||
// enableGlobalButton();
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// console.error("Error:", status, error);
|
||||
// showErrorLocalBadge(pictureId);
|
||||
// enableLocalButton(pictureId);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// TAGS UPDATE Yet to be implemented
|
||||
// function updateTags(tagsData, pictureId) {
|
||||
// const $tagsUpdate = $('#tags-'+pictureId).selectize({
|
||||
// create: true,
|
||||
|
|
|
@ -83,6 +83,8 @@ const strs_privacy = {
|
|||
const all_related_categories_ids = [];
|
||||
let related_categories_ids = [];
|
||||
let b_current_picture_id;
|
||||
{* Check Skeleton extension for more details about extensibility *}
|
||||
pluginValues = [];
|
||||
{/footer_script}
|
||||
|
||||
|
||||
|
@ -221,20 +223,6 @@ let b_current_picture_id;
|
|||
<select name="level" id="level" size="1">
|
||||
{html_options options=$level_options selected=$element.level_options_selected}
|
||||
</select>
|
||||
{*
|
||||
<div class="advanced-filter-item advanced-filter-privacy" >
|
||||
<div class="privacy-label-container">
|
||||
<strong>{'Who can see this photo?'|@translate}</strong>
|
||||
<label class="advanced-filter-item-label" for="privacy-filter" ><span class="privacy">{$level_options[$element.LEVEL]}</span></label>
|
||||
</div>
|
||||
<div class="advanced-filter-item-container">
|
||||
<div id="privacy-filter" class="select-bar"></div>
|
||||
<div class="slider-bar-wrapper">
|
||||
<div class="slider-bar-container privacy-filter-slider" value="{$element.LEVEL_CONVERT}" id="{$element.ID}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
*}
|
||||
</div>
|
||||
<div class="full-line-tag-box" id="action_add_tags">
|
||||
<strong>{'Tags'|@translate}</strong>
|
||||
|
@ -269,7 +257,9 @@ let b_current_picture_id;
|
|||
<strong>{'Description'|@translate}</strong>
|
||||
<textarea cols="50" rows="4" name="description" class="description-box" id="description">{$element.DESCRIPTION}</textarea>
|
||||
</div>
|
||||
{if !empty($PLUGIN_BATCH_MANAGER_UNIT_PHOTO_END)}{$PLUGIN_BATCH_MANAGER_UNIT_PHOTO_END}{/if}
|
||||
{foreach from=$PLUGINS_BATCH_MANAGER_UNIT_ELEMENT_SUBTEMPLATE item=PATH}
|
||||
{include file=$PATH}
|
||||
{/foreach}
|
||||
{* Plugins anchor 1 *}
|
||||
<div class="validation-container">
|
||||
<div class="save-button-container">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue