Skip to content

Commit d00da3c

Browse files
committed
Patch: Show updated attachment fields correctly
1 parent 18e59e0 commit d00da3c

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/Views/shared/attach_files_script.blade.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
var input = $(this),
1717
files = $(this).prop('files');
1818
19-
var n_existent = $('#' + $(this).data('attach-id') + ' .jquery_attachment_block').length;
19+
var n_existent = $('.jquery_attachment_block').length;
2020
2121
for(var i=0,file;file=files[i];i++) {
2222
var num = n_existent + i;
@@ -29,7 +29,7 @@
2929
+'<div class="media-body check_related_text">'
3030
+'<div><span id="new_attachment_'+num+'_display_new_filename">'+file.name+'</span> <s id="new_attachment_'+num+'_display_original_filename"></s>'
3131
32-
// Button
32+
// Edit button
3333
+'<button type="button" role="button" class="btn btn-light btn-xs edit_attachment"';
3434
3535
if ($('#'+$(this).data('attach-id')).data('new-attachment-modal-id')){
@@ -123,8 +123,13 @@
123123
$(editdiv).find('#attachment_form_prefix').val(prefix);
124124
125125
if ($(this).attr('data-modal-id')){
126+
// Showing modal
126127
$('#'+$(this).data('modal-id')).modal('show');
128+
129+
// Pass back-div
130+
$(editdiv).find('.attachment_form_submit').attr('data-back-div', $(this).closest('.attached_list').prop('id'));
127131
}else{
132+
// Switching visible form inside modal
128133
$(editdiv).show();
129134
$('#'+$(this).data('back-div')).hide();
130135
}
@@ -180,18 +185,20 @@
180185
}else{
181186
$('#'+prefix+'display_original_filename').text(' - '+original_filename);
182187
}
183-
$('#'+$(this).data('back-div')).find('#'+prefix+'display_new_filename').text(new_filename);
188+
189+
$('#'+$(this).attr('data-back-div')).find('#'+prefix+'display_new_filename').text(new_filename);
190+
184191
if ($(fieldset).find('#attachment_form_description').val() != ""){
185-
$('#'+$(this).data('back-div')).find('#'+prefix+'display_description').text($(fieldset).find('#attachment_form_description').val());
192+
$('#'+$(this).attr('data-back-div')).find('#'+prefix+'display_description').text($(fieldset).find('#attachment_form_description').val());
186193
}else{
187-
$('#'+$(this).data('back-div')).find('#'+prefix+'display_description').text($('#'+prefix+'display_description').data('mimetype'));
194+
$('#'+$(this).attr('data-back-div')).find('#'+prefix+'display_description').text($('#'+prefix+'display_description').data('mimetype'));
188195
}
189196
190197
if ($(fieldset).find('#hide_modal_id').length){
191198
$('#'+$(fieldset).find('#hide_modal_id').val()).modal('hide');
192199
}else{
193-
$('#'+$(this).data('edit-div')).hide();
194-
$('#'+$(this).data('back-div')).show();
200+
$('#'+$(this).attr('data-edit-div')).hide();
201+
$('#'+$(this).attr('data-back-div')).show();
195202
}
196203
197204
e.preventDefault();

0 commit comments

Comments
 (0)