Skip to content

Commit

Permalink
feat(galleries): add option to hide/auto-hide text field if image is …
Browse files Browse the repository at this point in the history
…uploaded (#1032)

* make text form disappear on galleries if images are uploaded

* Alter section titles and the help note for writing to be more apparent

* Change it all to a collapse, add a button, fixing copy paste fail I missed

* And now it's all an option.

* SPACING! Forgot to cleanup tabs to spacing

* refactor: fix blade formatting

* refactor: fix PHP styling

* removing the useless else

* fix(galleries): add field to create/edit labels

---------

Co-authored-by: ScuffedNewt <[email protected]>
Co-authored-by: SpeedyD <[email protected]>
Co-authored-by: itinerare <[email protected]>
  • Loading branch information
4 people authored Aug 28, 2024
1 parent 9342742 commit c4bb48e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
19 changes: 19 additions & 0 deletions config/lorekeeper/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,24 @@
*/
'allow_gallery_submissions_on_prompts' => 1,

/*
|--------------------------------------------------------------------------
| Hideable Textarea on Gallery Submissions
|--------------------------------------------------------------------------
|
| Whether or not to be able to hide the textarea on gallery Submissions.
|
| enable: Set to 1 to show a button to hide the textarea.
|
| on_image Set to 1 to auto-hide on image upload- will only work
| if 'enable' is set to 1.
|
*/
'hide_textarea_on_gallery_submissions' => [
'enable' => 0,
'on_image' => 0,
],

/*
|--------------------------------------------------------------------------
| Site Logging Webhook
Expand All @@ -364,4 +382,5 @@
|
*/
'site_logging_webhook' => env('SITE_LOGGING_WEBHOOK', null),

];
35 changes: 28 additions & 7 deletions resources/views/galleries/create_edit_submission.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<h2>Main Content</h2>
<p>Upload an image and/or text as the content of your submission. You <strong>can</strong> upload both in the event that you have an image with accompanying text or vice versa.</p>

<div class="form-group">
{!! Form::label('Image') !!}
<div class="form-group" id="imageForm">
{!! Form::label('image', 'Image Upload', ['class' => 'h5']) !!}
@if ($submission->id && isset($submission->hash) && $submission->hash)
<div class="card mb-2" id="existingImage">
<div class="card-body text-center">
Expand All @@ -58,25 +58,30 @@
</div>

<div class="form-group">
{!! Form::label('Text') !!}
{!! Form::textarea('text', $submission->text ?? old('text'), ['class' => 'form-control wysiwyg']) !!}
{!! Form::label('text', 'Writing / Text', ['class' => 'h5']) !!} {!! add_help('If you have a text submission, you can paste it here. You can also use the WYSIWYG editor to format your text. If you have an image submission, you can leave this blank or add a text to supplement your image submission.') !!}
@if (config('lorekeeper.settings.hide_textarea_on_gallery_submissions.enable'))
<a href="#writingForm" id="writingFormCollapseBtn" class="mx-2 mb-2 btn btn-sm btn-primary" data-toggle="collapse" aria-expanded="false">Hide Textarea</a>
@endif
<div id="writingForm" class="collapse show">
{!! Form::textarea('text', $submission->text ?? old('text'), ['class' => 'form-control wysiwyg']) !!}
</div>
</div>

<div class="row">
<div class="col-md">
<h3>Basic Information</h3>
<div class="form-group">
{!! Form::label('Title') !!} {!! add_help('You <strong>do not</strong> need to indicate that a piece is a trade, gift, for a prompt etc. as this will be automatically added based on your input elsewhere in this form.') !!}
{!! Form::label('title', 'Title', ['class' => 'h5']) !!} {!! add_help('You <strong>do not</strong> need to indicate that a piece is a trade, gift, for a prompt etc. as this will be automatically added based on your input elsewhere in this form.') !!}
{!! Form::text('title', $submission->title ?? old('title'), ['class' => 'form-control']) !!}
</div>

<div class="form-group">
{!! Form::label('Description (Optional)') !!}
{!! Form::label('description', 'Description (Optional)', ['class' => 'h5']) !!}
{!! Form::textarea('description', $submission->description ?? old('description'), ['class' => 'form-control wysiwyg']) !!}
</div>

<div class="form-group">
{!! Form::label('Content Warning (Optional)') !!} {!! add_help(
{!! Form::label('content_warning', 'Content Warning (Optional)', ['class' => 'h5']) !!} {!! add_help(
'Provide a succinct content warning for the piece if necessary. If a content warning is provided, the thumbnail will be replaced with a generic image and the warning displayed under it. The piece will be displayed in full on its page, however.',
) !!}
{!! Form::text('content_warning', $submission->content_warning ?? old('content_warning'), ['class' => 'form-control']) !!}
Expand Down Expand Up @@ -416,11 +421,27 @@ function readURL(input) {
$('#imageContainer').removeClass('hide');
}
reader.readAsDataURL(input.files[0]);
@if (config('lorekeeper.settings.hide_textarea_on_gallery_submissions.enable') && config('lorekeeper.settings.hide_textarea_on_gallery_submissions.on_image'))
// hide text editor if image is uploaded
$('#writingForm').collapse('hide')
@endif
} else {
@if (config('lorekeeper.settings.hide_textarea_on_gallery_submissions.enable') && config('lorekeeper.settings.hide_textarea_on_gallery_submissions.on_image'))
$('#writingForm').collapse('show')
@endif
}
}
$("#mainImage").change(function() {
readURL(this);
});
@if (config('lorekeeper.settings.hide_textarea_on_gallery_submissions.enable'))
$('#writingForm').on('hide.bs.collapse', function() {
$('#writingFormCollapseBtn').text("Show Textarea");
})
$('#writingForm').on('show.bs.collapse', function() {
$('#writingFormCollapseBtn').text("Hide Textarea");
})
@endif
$('.original.gallery-select').selectize();
});
Expand Down

0 comments on commit c4bb48e

Please sign in to comment.