[*add]/[delete::image/images]0 #%index;

%include;css %include.hed;
%message_to_wizard; %include.perso_header; %( Logic for variables: file_name must be defined mode="note" then only the note file is updated carrousel is “on” if we are dealing with “others” images %) %random.init; %define;alert_header() %if;("http" in portrait or "http" in portrait_saved) WARNING %elseif;(evar.mode="others") %if;(evar.em="SND_IMAGE_C_OK")[*image received]%if;(evar.notes!="") [with note]%end; %elseif;(evar.em="DEL_IMAGE_C_OK")[*image deleted]%sp; %if;(evar.delete!="on")[and] [saved]1%end; %elseif;(evar.em="RESET_IMAGE_C_OK")[*image/images]0 [restored]1%nn; %end; %else; %if;(evar.em="SND_IMAGE_C_OK")%if;(evar.mode="note")[*note] [update]%else;[*portrait] [uploaded]0%end;%nn; %elseif;(evar.em="DEL_IMAGE_C_OK")[*portrait] [deleted]0%if;(evar.delete!="on") [and] [saved]0%end;%nn; %elseif;(evar.em="RESET_IMAGE_C_OK")[*portrait] [restored]0%nn; %end;%nn; %end; %end; %define;alert_content() %if;("http" in portrait or "http" in portrait_saved) Update image field with MOD_IND %elseif;(evar.mode="others" or evar.mode="note") `%if;(evar.em="RESET_IMAGE_C_OK")images%X;%carrousel;%X;old%X;%evar.file_name; > %end;images%X;%carrousel;%if;(evar.delete="on")%X;old%end;%X;%nn; %if;(evar.notes!="")%evar.file_name_2;.txt%else;%evar.file_name;%end;` %else; %if;(evar.em="SND_IMAGE_C_OK" or evar.em="RESET_IMAGE_C_OK") `%evar.file_name;` %if;(evar.em="RESET_IMAGE_C_OK")`%portraits_store;%X;old%X;%portrait_saved;` <%end;> `%portraits_store;%X;%portrait;`%nn; %(%if;(evar.em="DEL IMAGE_C_OK" or evar.em="RESET_IMAGE_C_OK")%portrait;%else;%evar.file_name;%end;%) %elseif;(evar.em="DEL_IMAGE_C_OK") %if;(evar.delete!="on")`portrait%X;%portrait_saved;` > `portraits%X;old%X;%portrait_saved;` %else;`portraits%X;saved%X;%carrousel;(.gif/jpg/png)`%end; %end; %end; %end; %define;alert_color() %if;("http" in portrait or "http" in portrait_saved)danger %elseif;(evar.mode="note")primary %elseif;(evar.em="SND_IMAGE_C_OK" or evar.em="RESET_IMAGE_C_OK")success %elseif;(evar.em="DEL_IMAGE_C_OK" and evar.delete="on")danger %else;warning %end; %end; %let;portraits_store; %if;(bvar.reorg="on")%base.name;.gwb%X;documents%X;portraits%nn; %else;images%X;%base.name;%nn; %end;%nn; %in; %let;saved_portraits_store; %if;(bvar.reorg="on")%base.name;.gwb%X;documents%X;portraits%nn; %else;images%X;%base.name;%X;old%nn; %end;%nn; %in; %let;images_store; %if;(bvar.reorg="on")%base.name;.gwb%X;documents%X;images%nn; %else;src%X;%base.name;%X;images%nn; %end;%nn; %in; %if;(wizard)
%( *** Col 1 *** %)

# %(%) %if;(has_portrait)[*modify portrait]%else;[*add portrait]%end;

%if;(cgi)%end;
[*select] [image/images]0
%nn; %if;(has_portrait and has_old_portrait)[*previous portrait]%end;

# %(%)[*add image]

%if;(cgi)%end; %( file_name is automatically provided by the type="file" item %) %( file_name_2 is used when updating the note file after selection %) %( with the radiobutton of the old folder content (right column) %)
%nn; [*select] [image/images]0%nn;
%(TODO: print only if old img already exists%)
[*previous image]

# %(%)[*source/sources]0

%( TODO re-activate disable for send, source and note %)

# %(%)[*note/notes]0

%include;toolbar
%( *** Col 2 *** image cache disabled with a kch=%random.bits; %)
%if;(has_portrait or has_old_portrait)

# [*portrait]0

%if;has_portrait;
`%portraits_store;%X;``%nn; %if;has_portrait_url;%carrousel;.url%else;%portrait_name;%end;` %nn;
%end; %if;has_old_portrait;
%nn; `%saved_portraits_store;%X;``%if;has_old_portrait_url;%carrousel;.url%else;%portrait_saved_name;%end;`
%end;

%nn; |  | [*warning refresh]%nn;

%end; %if;(has_carrousel)

# [*image/images]1

`%images_store;%X;%carrousel;%X;`
(%carrousel_img_nbr; %if;(carrousel_img_nbr>1)[image/images]1%else;[image/images]0%end;)
%foreach;img_in_carrousel;
`%carrousel_img;`
%end; %end; %if;(carrousel_old_img_nbr>0)

# [*saved images]1

`%images_store%X;%carrousel;%X;old%X;`
(%carrousel_old_img_nbr; %if;(carrousel_old_img_nbr>1)[image/images]1%else;[image/images]0%end;)
%foreach;img_in_carrousel_old;
`%carrousel_img;`
%end;

%nn; |  | [*warning refresh]%nn;

%end;
%if;(evar.em!="")
%apply;alert_header()[:] %apply;alert_content()
%end; %end; %base_trailer; %include;copyr
%include;js %define;input_snd(xxx,yyy) $('.xxx').change(function() { %(replace input label with file name, then enable send button if input is non empty%) let fileName = $(this).val().split('\\').pop(); $(this).next('.custom-file-label').addClass("selected").html(fileName); $('.yyy').attr('disabled', false); %if;("yyy"="snd-btn-others") $('textarea').attr('disabled', false); $('textarea').focus(); %end; }); %end;
%( Possible heavier futur script to manage multiple files inputs https://github.com/Johann-S/bs-custom-file-input/blob/master/dist/bs-custom-file-input.min.js
%)