mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 11:19:55 +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
|
// Detect unsaved changes on any inputs
|
||||||
let user_interacted = false;
|
let user_interacted = false;
|
||||||
|
|
||||||
|
@ -340,51 +340,58 @@ function saveChanges(pictureId) {
|
||||||
if ($("#picture-" + pictureId + " .local-unsaved-badge").css('display') === 'block') {
|
if ($("#picture-" + pictureId + " .local-unsaved-badge").css('display') === 'block') {
|
||||||
disableLocalButton(pictureId);
|
disableLocalButton(pictureId);
|
||||||
// Retrieve Infos
|
// Retrieve Infos
|
||||||
const name = $("#picture-" + pictureId +" #name").val();
|
const name = $("#picture-" + pictureId + " #name").val();
|
||||||
const author = $("#picture-" + pictureId +" #author").val();
|
const author = $("#picture-" + pictureId + " #author").val();
|
||||||
const date_creation = $("#picture-" + pictureId + " #date_creation").val();
|
const date_creation = $("#picture-" + pictureId + " #date_creation").val();
|
||||||
const comment = $("#picture-" + pictureId +" #description").val();
|
const comment = $("#picture-" + pictureId + " #description").val();
|
||||||
const level = $("#picture-" + pictureId +" #level" + " option:selected").val();
|
const level = $("#picture-" + pictureId + " #level option:selected").val();
|
||||||
// Get Categories
|
// Get Categories
|
||||||
const categories = get_related_category(pictureId);
|
const categories = get_related_category(pictureId);
|
||||||
let categoriesStr = categories.join(';');
|
let categoriesStr = categories.join(';');
|
||||||
// Get Tags
|
// Get Tags
|
||||||
let tags = [];
|
let tags = [];
|
||||||
$("#picture-" + pictureId +" #tags" + " option").each(function() {
|
$("#picture-" + pictureId + " #tags option").each(function () {
|
||||||
let tagId = $(this).val().replace(/~~/g, '');
|
let tagId = $(this).val().replace(/~~/g, '');
|
||||||
tags.push(tagId);
|
tags.push(tagId);
|
||||||
});
|
});
|
||||||
let tagsStr = tags.join(',');
|
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({
|
$.ajax({
|
||||||
url: 'ws.php?format=json',
|
url: 'ws.php?format=json',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: 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()
|
|
||||||
},
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
const isOk = data.stat && data.stat === 'ok';
|
const isOk = data.stat && data.stat === 'ok';
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
console.log("Data saved successfully for picture " + pictureId);
|
|
||||||
enableLocalButton(pictureId);
|
enableLocalButton(pictureId);
|
||||||
enableGlobalButton();
|
enableGlobalButton();
|
||||||
hideUnsavedLocalBadge(pictureId);
|
hideUnsavedLocalBadge(pictureId);
|
||||||
showSuccessLocalBadge(pictureId);
|
showSuccessLocalBadge(pictureId);
|
||||||
updateSuccessGlobalBadge();
|
updateSuccessGlobalBadge();
|
||||||
// Call for extension's save
|
// Method 1 for extension's save (see Skeleton extension for more details)
|
||||||
// This is the first method we're implementing to validate extension's data
|
|
||||||
// More informations will be provided on next skeleton update
|
|
||||||
pluginSaveLoop(activePlugins, pictureId);
|
pluginSaveLoop(activePlugins, pictureId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -422,7 +429,7 @@ function pluginFunctionMapInit(activePlugins) {
|
||||||
const functionName = pluginId + '_batchManagerSave';
|
const functionName = pluginId + '_batchManagerSave';
|
||||||
if (typeof window[functionName] === 'function') {
|
if (typeof window[functionName] === 'function') {
|
||||||
pluginFunctionMap[pluginId] = window[functionName];
|
pluginFunctionMap[pluginId] = window[functionName];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,46 +445,46 @@ function pluginSaveLoop(activePlugins, pictureId) {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//UPDATE BLOCKS (Yet to be implemented)
|
// UPDATE BLOCKS (Yet to be implemented)
|
||||||
function updateBlock(pictureId) {
|
// function updateBlock(pictureId) {
|
||||||
$.ajax({
|
// $.ajax({
|
||||||
url: 'ws.php?format=json',
|
// url: 'ws.php?format=json',
|
||||||
type: 'GET',
|
// type: 'GET',
|
||||||
dataType: 'json',
|
// dataType: 'json',
|
||||||
data: {
|
// data: {
|
||||||
method: 'pwg.images.getInfo',
|
// method: 'pwg.images.getInfo',
|
||||||
image_id: pictureId,
|
// image_id: pictureId,
|
||||||
format: 'json'
|
// format: 'json'
|
||||||
},
|
// },
|
||||||
success: function(response) {
|
// success: function(response) {
|
||||||
if (response.stat === 'ok') {
|
// if (response.stat === 'ok') {
|
||||||
$("#picture-" + pictureId + " #name-" + pictureId).val(response.result.name);
|
// $("#picture-" + pictureId + " #name-" + pictureId).val(response.result.name);
|
||||||
$("#picture-" + pictureId + " #author-" + pictureId).val(response.result.author);
|
// $("#picture-" + pictureId + " #author-" + pictureId).val(response.result.author);
|
||||||
$("#picture-" + pictureId + " #date_creation-" + pictureId).val(response.result.date_creation);
|
// $("#picture-" + pictureId + " #date_creation-" + pictureId).val(response.result.date_creation);
|
||||||
$("#picture-" + pictureId + " #description-" + pictureId).val(response.result.comment);
|
// $("#picture-" + pictureId + " #description-" + pictureId).val(response.result.comment);
|
||||||
$("#picture-" + pictureId + " #level-" + pictureId).val(response.result.level);
|
// $("#picture-" + pictureId + " #level-" + pictureId).val(response.result.level);
|
||||||
$("#picture-" + pictureId + " #filename-" + pictureId).text(response.result.file);
|
// $("#picture-" + pictureId + " #filename-" + pictureId).text(response.result.file);
|
||||||
$("#picture-" + pictureId + " #filesize-" + pictureId).text(response.result.filesize);
|
// $("#picture-" + pictureId + " #filesize-" + pictureId).text(response.result.filesize);
|
||||||
$("#picture-" + pictureId + " #dimensions-" + pictureId).text(response.result.width + "x" + response.result.height);
|
// $("#picture-" + pictureId + " #dimensions-" + pictureId).text(response.result.width + "x" + response.result.height);
|
||||||
// updateTags(response.result.tags, pictureId); //Yet to be implemented
|
// updateTags(response.result.tags, pictureId); //Yet to be implemented
|
||||||
showMetasyncSuccesBadge(pictureId);
|
// showMetasyncSuccesBadge(pictureId);
|
||||||
enableLocalButton(pictureId);
|
// enableLocalButton(pictureId);
|
||||||
enableGlobalButton();
|
// enableGlobalButton();
|
||||||
} else {
|
// } else {
|
||||||
console.error("Error:", response.message);
|
// console.error("Error:", response.message);
|
||||||
showErrorLocalBadge(pictureId);
|
// showErrorLocalBadge(pictureId);
|
||||||
enableLocalButton(pictureId);
|
// enableLocalButton(pictureId);
|
||||||
enableGlobalButton();
|
// enableGlobalButton();
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
error: function(xhr, status, error) {
|
// error: function(xhr, status, error) {
|
||||||
console.error("Error:", status, error);
|
// console.error("Error:", status, error);
|
||||||
showErrorLocalBadge(pictureId);
|
// showErrorLocalBadge(pictureId);
|
||||||
enableLocalButton(pictureId);
|
// enableLocalButton(pictureId);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
//TAGS UPDATE Yet to be implemented
|
// TAGS UPDATE Yet to be implemented
|
||||||
// function updateTags(tagsData, pictureId) {
|
// function updateTags(tagsData, pictureId) {
|
||||||
// const $tagsUpdate = $('#tags-'+pictureId).selectize({
|
// const $tagsUpdate = $('#tags-'+pictureId).selectize({
|
||||||
// create: true,
|
// create: true,
|
||||||
|
|
|
@ -83,6 +83,8 @@ const strs_privacy = {
|
||||||
const all_related_categories_ids = [];
|
const all_related_categories_ids = [];
|
||||||
let related_categories_ids = [];
|
let related_categories_ids = [];
|
||||||
let b_current_picture_id;
|
let b_current_picture_id;
|
||||||
|
{* Check Skeleton extension for more details about extensibility *}
|
||||||
|
pluginValues = [];
|
||||||
{/footer_script}
|
{/footer_script}
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,20 +223,6 @@ let b_current_picture_id;
|
||||||
<select name="level" id="level" size="1">
|
<select name="level" id="level" size="1">
|
||||||
{html_options options=$level_options selected=$element.level_options_selected}
|
{html_options options=$level_options selected=$element.level_options_selected}
|
||||||
</select>
|
</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>
|
||||||
<div class="full-line-tag-box" id="action_add_tags">
|
<div class="full-line-tag-box" id="action_add_tags">
|
||||||
<strong>{'Tags'|@translate}</strong>
|
<strong>{'Tags'|@translate}</strong>
|
||||||
|
@ -269,7 +257,9 @@ let b_current_picture_id;
|
||||||
<strong>{'Description'|@translate}</strong>
|
<strong>{'Description'|@translate}</strong>
|
||||||
<textarea cols="50" rows="4" name="description" class="description-box" id="description">{$element.DESCRIPTION}</textarea>
|
<textarea cols="50" rows="4" name="description" class="description-box" id="description">{$element.DESCRIPTION}</textarea>
|
||||||
</div>
|
</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 *}
|
{* Plugins anchor 1 *}
|
||||||
<div class="validation-container">
|
<div class="validation-container">
|
||||||
<div class="save-button-container">
|
<div class="save-button-container">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue