redesign image editor

- remove zoom
- separate setting public/private from edit form
- prevent assigning image without it has been published
- prevent publishing image without licence
- show buttons depending on license state
- reload view on state change
- gray out not-selected images
This commit is contained in:
Milan
2019-10-05 14:21:33 +02:00
parent f0be286f47
commit edb2aa29d7
8 changed files with 204 additions and 133 deletions

View File

@@ -53,6 +53,10 @@ input.field{
box-shadow: 0 5px 11px 0 rgba(0,0,0,.18),0 4px 15px 0 rgba(0,0,0,.15);
}
#content div.image.inactive{
opacity:0.5;
}
#imageEditor{
min-height:800px;
height:100%;
@@ -67,7 +71,7 @@ input.field{
}
#content label{
margin-top:1rem;
margin-top: 1rem;
text-transform: uppercase;
color:#333;
color:#999;
}

View File

@@ -229,6 +229,13 @@ sub show_image {
# print STDERR
$template_params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'image' } );
my $label_key = 'label_assign_to_'.$params->{target};
$template_params->{label_assign_to_by_label} = $template_params->{loc}->{$label_key};
$label_key = 'label_warn_not_public_'.$params->{target};
$template_params->{label_warn_not_public_by_label} = $template_params->{loc}->{$label_key};
$template_params = uac::set_template_permissions( $permissions, $template_params );
$template_params->{no_results} = 1 if scalar @$results == 0;

View File

@@ -1,7 +1,4 @@
var windowOffsetX=0;
var windowOffsetY=0;
// get current selected tab by tabs-id
function getSelectedTab(id){
var selector = '#'+id+" li.ui-tabs-active a";
@@ -10,13 +7,15 @@ function getSelectedTab(id){
}
function setActiveImage(elem){
if ( !elem ) elem = $('div.images div.image').first();
$('div.image').removeClass("active");
$('div.image').addClass("inactive");
elem.addClass("active");
elem.removeClass("inactive");
}
if (elem){
$(elem).addClass("active");
}else{
$('div.images div.image').first().addClass("active");
}
function updateActiveImage(){
$('div.images div.image.active').click();
}
// open dialog to show or edit image properties
@@ -63,13 +62,23 @@ function searchImage(target, project_id, studio_id, series_id, event_id, pid){
load(url);
}
// disable public, save and update form on success
function depublishImage(id, filename){
$('#save_img_'+id+' input[name="public"]').val("0");
saveImage(id, filename);
}
// enable public and save and update form on success
function publishImage(id, filename){
$('#save_img_'+id+' input[name="public"]').val("1");
saveImage(id, filename);
}
// save image
function saveImage(id, filename) {
$('#imageEditor #status').html('');
console.log("save image "+id);
console.log("save image "+id+" ");
var url='image.cgi?save_image='+filename+'&project_id='+project_id+'&studio_id='+studio_id;
$.post(
@@ -77,22 +86,21 @@ function saveImage(id, filename) {
$("#save_img_"+id).serialize(),
function(data){
var errorFound=0;
var lines=data.split(/\n/);
for (index in lines){
var line=lines[index];
if(contains(line,'ERROR:')){
//add error field
if( $('#imageEditor #status .error').length==0 ){
$('#imageEditor #status').append('<div class="error"></div>');
data.split(/\n/).forEach(
function(line){
if(contains(line, 'ERROR:')){
//add error field
if( $('#imageEditor #status .error').length==0 ){
$('#imageEditor #status').append('<div class="error"></div>');
}
$('#imageEditor #status div.error').append(line);
errorFound++;
}
$('#imageEditor #status div.error').append(line);
errorFound++;
}
};
//console.log(data);
}
);
if (errorFound==0){
$('#imageEditor #status').append('<div class="ok">saved</div>');
updateActiveImage();
}
hideImageDetails('img_'+id, filename);
}
@@ -128,30 +136,6 @@ function hideImageDetails(id, filename){
return false;
}
// zoom all images in
function increaseImageSize(){
var value=$('#content div.image').css('width');
value=value.replace(/[^0-9]/g,'');
if(value>200)return;
value=parseInt(value*1.3);
$('#content div.image').css('width', value+'px');
$('#content div.image div').css('width', (value-12)+'px');
$('#content div.image').css('height', value+'px');
$('#content div.image').css('background-size', value+'px');
}
// zoom all images out
function decreaseImageSize(){
var value=$('#content div.image').css('width');
value=value.replace(/[^0-9]/g,'');
if(value<50)return;
value=parseInt(value/1.3);
$('#content div.image').css('width', value+'px');
$('#content div.image div').css('width', (value-12)+'px');
$('#content div.image').css('height', value+'px');
$('#content div.image').css('background-size', value+'px');
}
function selectImage( searchValue, imageUrl, target, project_id, studio_id, series_id, event_id, pid){
searchValue = searchValue.replace(/[^a-zA-Z0-9]/g,'%');
@@ -205,10 +189,8 @@ $(document).ready(
$('div.images').on( 'click', 'div.image', function(){
var elem = $(this);
console.log(elem)
var filename = elem.attr("filename");
elem = elem.parent();
console.log(elem)
var target = elem.attr("target");
var projectId = elem.attr("projectId");
var studioId = elem.attr("studioId");

View File

@@ -8,7 +8,7 @@ msgid "tab_edit"
msgstr "Bearbeiten"
msgid "tab_upload"
msgstr "Hochladen"
msgstr "Neues Bild"
msgid "button_upload"
msgstr "Hochladen"
@@ -16,18 +16,24 @@ msgstr "Hochladen"
msgid "button_search"
msgstr "Suchen"
msgid "button_zoom_in"
msgstr "Vergrößern"
msgid "button_zoom_out"
msgstr "Verkleinern"
msgid "button_save"
msgstr "Speichern"
msgid "button_delete"
msgstr "Löschen"
msgid "button_properties"
msgstr "Eigenschaften"
msgid "button_publish"
msgstr "Veröffentlichen"
msgid "button_depublish"
msgstr "Depublizieren"
msgid "label_warn_unknown_licence"
msgstr "Kann nicht veröffentlicht werden, da keine Lizenz angegeben wurde"
msgid "label_name"
msgstr "Name"
@@ -64,9 +70,37 @@ msgstr "veröffentlicht"
msgid "label_file"
msgstr "Datei"
msgid "label_licence_missing"
msgstr "bitte eintragen"
msgid "label_name_required"
msgstr "Bitte Feld eintragen"
msgid "label_licence_required"
msgstr "Bild kann ohne Lizenzangabe nicht veröffentlicht werden"
msgid "label_mandatory_field"
msgstr "bitte füllen Sie dieses Feld aus"
msgid "label_assign_to_event"
msgstr "Dieses Bild für Sendung nutzen"
msgid "label_assign_to_series"
msgstr "Dieses Bild für Sendereihe nutzen"
msgid "label_assign_to_studio"
msgstr "Dieses Bild für Studio nutzen"
msgid "label_assign_to_project"
msgstr "Dieses Bild für Projekt nutzen"
msgid "label_warn_not_public_event"
msgstr "Kann Sendung nicht zugewiesen werden, da nicht veröffentlicht"
msgid "label_warn_not_public_series"
msgstr "Kann Sendereihe nicht zugewiesen werden, da nicht veröffentlicht"
msgid "label_warn_not_public_studio"
msgstr "Kann Studio nicht zugewiesen werden, da nicht veröffentlicht"
msgid "label_warn_not_public_project"
msgstr "Kann Projekt nicht zugewiesen werden, da nicht veröffentlicht"
msgid "select_image"
msgstr "Dieses Bild zuweisen"

View File

@@ -1,3 +1,4 @@
msgid "region"
msgstr "en"
@@ -16,18 +17,24 @@ msgstr "upload"
msgid "button_search"
msgstr "search"
msgid "button_zoom_in"
msgstr "zoom in"
msgid "button_zoom_out"
msgstr "zoom out"
msgid "button_save"
msgstr "save"
msgid "button_delete"
msgstr "delete"
msgid "button_properties"
msgstr "properties"
msgid "button_publish"
msgstr "publish"
msgid "button_depublish"
msgstr "hold back"
msgid "label_warn_unknown_licence"
msgstr "Cannot be pusblished without setting a licence"
msgid "label_name"
msgstr "name"
@@ -64,9 +71,36 @@ msgstr "published"
msgid "label_file"
msgstr "file"
msgid "label_licence_missing"
msgid "label_name_required"
msgstr "please fill in"
msgid "select_image"
msgstr "select this image"
msgid "label_licence_required"
msgstr "image cannot be published without license"
msgid "label_mandatory_field"
msgstr "please fill in"
msgid "label_assign_to_event"
msgstr "use image for event"
msgid "label_assign_to_series"
msgstr "use image for series"
msgid "label_assign_to_studio"
msgstr "use image for studio"
msgid "label_assign_to_project"
msgstr "use image for project"
msgid "label_warn_not_public_event"
msgstr "Cannot be assigned to event without have been published"
msgid "label_warn_not_public_series"
msgstr "Cannot be assigned to series without have been published"
msgid "label_warn_not_public_studio"
msgstr "Cannot be assigned to studio without have been published"
msgid "label_warn_not_public_project"
msgstr "Cannot be assigned to project without have been published"

View File

@@ -9,9 +9,25 @@ found no image
<TMPL_LOOP images>
<TMPL_IF filename>
<div id="imageEditor" class="editor">
<button onclick="assignImage('<TMPL_VAR filename escape=none>', '<TMPL_VAR .target>', '<TMPL_VAR .project_id>', '<TMPL_VAR .studio_id>', '<TMPL_VAR .series_id>', '<TMPL_VAR .event_id>', '<TMPL_VAR .pid>'); return false"><TMPL_VAR .loc.select_image></button/>
<TMPL_IF public>
<button onclick="assignImage('<TMPL_VAR filename escape=none>', '<TMPL_VAR .target>', '<TMPL_VAR .project_id>', '<TMPL_VAR .studio_id>', '<TMPL_VAR .series_id>', '<TMPL_VAR .event_id>', '<TMPL_VAR .pid>'); return false">
<TMPL_VAR .label_assign_to_by_label>
</button>
<button onclick="depublishImage('<TMPL_VAR id>', '<TMPL_VAR filename escape=none>'); return false;"><TMPL_VAR .loc.button_depublish></button>
<TMPL_ELSE>
<div class="warn"><TMPL_VAR .label_warn_not_public_by_label></div>
<TMPL_IF missing_licence>
<div class="warn"><TMPL_VAR .loc.label_warn_unknown_licence></div>
<TMPL_ELSE>
<button onclick="publishImage('<TMPL_VAR id>', '<TMPL_VAR filename escape=none>'); return false;"><TMPL_VAR .loc.button_publish></button>
</TMPL_IF>
</TMPL_IF>
<div class="panel-body">
<div id="status"></div>
<form id="save_img_<TMPL_VAR id>"
method="post"
@@ -21,18 +37,16 @@ found no image
<input type="hidden" name="project_id" value="<TMPL_VAR .project_id>">
<input type="hidden" name="studio_id" value="<TMPL_VAR .studio_id>">
<input type="hidden" class="public" name="public" <TMPL_IF public>checked="checked" value="1"<TMPL_ELSE>value="0"</TMPL_IF> /><br>
<label><TMPL_VAR .loc.label_name></label><br>
<input value="<TMPL_VAR name escape=none>" name="update_name" class="field" placeholder="<TMPL_VAR .loc.label_name>"><br>
<label><TMPL_VAR .loc.label_description></label><br>
<textarea class="field" name="update_description" cols="50" rows=5 placeholder="<TMPL_VAR .loc.label_description>"><TMPL_VAR description escape=none></textarea><br>
<input value="<TMPL_VAR name escape=none>" name="update_name" class="field" placeholder="<TMPL_VAR .loc.label_mandatory_field>"><br>
<label><TMPL_VAR .loc.label_author>/<TMPL_VAR .loc.label_licence></label><br>
<input name="licence" value="<TMPL_VAR licence>" class="field<TMPL_IF missing_licence> error</TMPL_IF>" placeholder="<TMPL_VAR .loc.label_licence_missing>"/><br>
<input name="licence" value="<TMPL_VAR licence>" class="field<TMPL_IF missing_licence> error</TMPL_IF>" placeholder="<TMPL_VAR .loc.label_mandatory_field>" required/><br>
<label><TMPL_VAR .loc.label_public></label>
<input type="checkbox" name="public" <TMPL_IF public>checked="checked" value="1"<TMPL_ELSE>value="0"</TMPL_IF> /><br>
<label><TMPL_VAR .loc.label_description></label><br>
<textarea class="field" name="update_description" cols="50" rows="5" ><TMPL_VAR description escape=none></textarea><br>
<TMPL_IF name="update_image">
<input type="hidden" name="save_image" value="<TMPL_VAR filename escape=none>" />
@@ -43,10 +57,12 @@ found no image
<button onclick="askDeleteImage('img_<TMPL_VAR id escape=none>','<TMPL_VAR filename escape=none>');return false;"><TMPL_VAR .loc.button_delete></button>
</TMPL_IF>
<div id="status" ></div>
<TMPL_VAR .loc.label_created_at> <TMPL_VAR created_at> <TMPL_VAR .loc.label_created_by> <TMPL_VAR created_by><br>
<TMPL_VAR .loc.label_modified_at> <TMPL_VAR modified_at> <TMPL_VAR .loc.label_modified_by> <TMPL_VAR modified_by><br>
<TMPL_VAR .loc.label_link>: {{<TMPL_VAR filename escape=none>|<TMPL_VAR name>}}<br>
<button onclick='$("#save_img_<TMPL_VAR id> #properties").show();return false;'><TMPL_VAR .loc.button_properties></button>
<div id="properties" style="display:none">
<TMPL_VAR .loc.label_created_at> <TMPL_VAR created_at> <TMPL_VAR .loc.label_created_by> <TMPL_VAR created_by><br>
<TMPL_VAR .loc.label_modified_at> <TMPL_VAR modified_at> <TMPL_VAR .loc.label_modified_by> <TMPL_VAR modified_by><br>
<TMPL_VAR .loc.label_link>: {{<TMPL_VAR filename escape=none>|<TMPL_VAR name>}}<br>
</div>
</form>

View File

@@ -37,29 +37,29 @@
</tr>
<tr>
<td>Name: </td>
<td><input value="<TMPL_VAR name escape=none>" name="name" size="40" maxlength="100" required> </td>
</tr>
<tr>
<td>Beschreibung: </td>
<td><textarea name="description" cols="50" rows=5><TMPL_VAR description escape=none></textarea></td>
<td><label><TMPL_VAR .loc.label_name></label></td>
<td><input value="<TMPL_VAR name escape=none>" name="name" size="40" maxlength="100" placeholder="<TMPL_VAR .loc.label_name_required>" required> </td>
</tr>
<tr>
<td><label><TMPL_VAR .loc.label_author>/<TMPL_VAR .loc.label_licence></label></td>
<td><input name="licence" value="<TMPL_VAR licence>" placeholder="<TMPL_VAR .loc.label_licence_missing>" required /></td>
</tr>
<tr>
<td><label><TMPL_VAR .loc.label_public></label></td>
<td><input type="checkbox" name="public" <TMPL_IF public>checked="checked" value="1"<TMPL_ELSE>value="0"</TMPL_IF> /></td>
<td><input name="licence" size="40" value="<TMPL_VAR licence>" placeholder="<TMPL_VAR .loc.label_licence_required>" required /></td>
</tr>
<tr>
<td>Datei</td>
<td><input type="file" name="image" accept="image/*" maxlength="2000000" size="10" required/> </td>
<td><label><TMPL_VAR .loc.label_file></label></td>
<td><input type="file" name="image" accept="image/*" maxlength="2000000" size="10" required /></td>
</tr>
<tr>
<td><label><TMPL_VAR .loc.label_description></label></td>
<td><textarea name="description" cols="50" rows=5><TMPL_VAR description escape=none ></textarea></td>
</tr>
<tr>
<td></td>
<td>
<button onclick="uploadImage();return false">Hochladen</button>
<button onclick="uploadImage();return false" ><TMPL_VAR .loc.button_upload></button>
</td>
</tr>
</table>

View File

@@ -1,5 +1,5 @@
<link type="text/css" href="css/image_manager.css" rel="stylesheet"/>
<link type="text/css" href="css/image.css" rel="stylesheet"/>
<script src="js/image.js" type="text/javascript"></script>
<script src="js/page_leave_handler.js" type="text/javascript"></script>
@@ -72,49 +72,43 @@
</div>
<div id="imageList">
<div style="float:right">
<button onclick="decreaseImageSize();return false;" title="<TMPL_VAR .loc.button_zoom_out>">-</button>
<button onclick="increaseImageSize();return false;" title="<TMPL_VAR .loc.button_zoom_in>">+</button>
</div>
<form id="image_manager" action="image.cgi">
<input name="search" value="<TMPL_VAR search escape=none>" style="width:20em;">
<input type="hidden" name="filename" value="<TMPL_VAR filename escape=none>">
<button onclick="searchImage('<TMPL_VAR target>', '<TMPL_VAR .project_id>', '<TMPL_VAR .studio_id>', '<TMPL_VAR .series_id>', '<TMPL_VAR .event_id>', '<TMPL_VAR .pid>'); return false;"><TMPL_VAR .loc.button_search></button>
</form>
<TMPL_VAR count> <TMPL_VAR .loc.label_search_hits><br />
<div style="clear:both;display: flex; flex-direction: row;">
<div class="images"
style="overflow-y:scroll"
target="<TMPL_VAR .target>"
projectId="<TMPL_VAR .project_id>"
studioId="<TMPL_VAR .studio_id>"
seriesId="<TMPL_VAR .series_id>"
eventId="<TMPL_VAR .event_id>"
pid="<TMPL_VAR .pid>"
>
<TMPL_LOOP images>
<div class="image"
id="img_<TMPL_VAR id>"
style="background-image:url('show-image.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR .studio_id>&type=icon&filename=<TMPL_VAR filename>')"
title="<TMPL_VAR description>"
filename="<TMPL_VAR filename>"
>
<div class="label"><TMPL_VAR name></div>
</div>
</TMPL_LOOP>
<div style="clear:both; display:flex; flex-direction:row;">
<div>
<form id="image_manager" action="image.cgi">
<input name="search" value="<TMPL_VAR search escape=none>" style="width:20em;">
<input type="hidden" name="filename" value="<TMPL_VAR filename escape=none>">
<button onclick="searchImage('<TMPL_VAR target>', '<TMPL_VAR .project_id>', '<TMPL_VAR .studio_id>', '<TMPL_VAR .series_id>', '<TMPL_VAR .event_id>', '<TMPL_VAR .pid>'); return false;"><TMPL_VAR .loc.button_search></button>
</form>
<TMPL_VAR count> <TMPL_VAR .loc.label_search_hits><br />
<div class="images"
style="overflow-y:scroll"
target="<TMPL_VAR .target>"
projectId="<TMPL_VAR .project_id>"
studioId="<TMPL_VAR .studio_id>"
seriesId="<TMPL_VAR .series_id>"
eventId="<TMPL_VAR .event_id>"
pid="<TMPL_VAR .pid>"
>
<TMPL_LOOP images>
<div class="image"
id="img_<TMPL_VAR id>"
style="background-image:url('show-image.cgi?project_id=<TMPL_VAR .project_id>&studio_id=<TMPL_VAR .studio_id>&type=icon&filename=<TMPL_VAR filename>')"
title="<TMPL_VAR description>"
filename="<TMPL_VAR filename>"
>
<div class="label"><TMPL_VAR name></div>
</div>
</TMPL_LOOP>
</div>
</div>
<div id="img_editor" >
</div>
</div>
</div>
</TMPL_IF>
</main>
</main>
</center>
</body>