allow to disable stamp logo

This commit is contained in:
Pete Matsyburka
2024-03-14 14:09:43 +02:00
parent a963ef53d3
commit 0171b0c2dd
4 changed files with 38 additions and 9 deletions
+25 -4
View File
@@ -202,7 +202,7 @@
</label>
</div>
<li
v-if="field.type != 'phone'"
v-if="field.type != 'phone' && field.type != 'stamp'"
@click.stop
>
<label class="cursor-pointer py-1.5">
@@ -215,6 +215,20 @@
<span class="label-text">{{ t('required') }}</span>
</label>
</li>
<li
v-if="field.type == 'stamp'"
@click.stop
>
<label class="cursor-pointer py-1.5">
<input
:checked="field.preferences?.with_logo != false"
type="checkbox"
class="toggle toggle-xs"
@change="[field.preferences ||= {}, field.preferences.with_logo = field.preferences.with_logo == false, save()]"
>
<span class="label-text">{{ t('with_logo') }}</span>
</label>
</li>
<li
v-if="field.type == 'checkbox'"
@click.stop
@@ -257,8 +271,13 @@
<span class="label-text">{{ t('read_only') }}</span>
</label>
</li>
<hr class="pb-0.5 mt-0.5">
<li>
<hr
v-if="field.type != 'stamp'"
class="pb-0.5 mt-0.5"
>
<li
v-if="field.type != 'stamp'"
>
<label
class="label-text cursor-pointer text-center w-full flex items-center"
@click="isShowDescriptionModal = !isShowDescriptionModal"
@@ -271,7 +290,9 @@
</span>
</label>
</li>
<li>
<li
v-if="field.type != 'stamp'"
>
<label
class="label-text cursor-pointer text-center w-full flex items-center"
@click="isShowConditionsModal = !isShowConditionsModal"
+1
View File
@@ -1,6 +1,7 @@
const en = {
description: 'Description',
display_title: 'Display title',
with_logo: 'With logo',
unchecked: 'Unchecked',
equal: 'Equal',
not_equal: 'Not equal',
+9 -4
View File
@@ -13,8 +13,8 @@ module Submitters
module_function
def call(submitter)
image = generate_stamp_image(submitter)
def call(submitter, with_logo: true)
image = generate_stamp_image(submitter, with_logo:)
image_data = image.write_to_buffer('.png')
@@ -30,8 +30,13 @@ module Submitters
)
end
def generate_stamp_image(submitter)
logo = Vips::Image.new_from_buffer(load_logo(submitter).read, '')
def generate_stamp_image(submitter, with_logo: true)
logo =
if with_logo
Vips::Image.new_from_buffer(load_logo(submitter).read, '')
else
Vips::Image.new_from_buffer(TRANSPARENT_PIXEL, '').resize(WIDTH)
end
logo = logo.resize([WIDTH / logo.width.to_f, HEIGHT / logo.height.to_f].min)
+3 -1
View File
@@ -78,7 +78,9 @@ module Submitters
next if field['submitter_uuid'] != submitter.uuid
if field['type'] == 'stamp'
acc[field['uuid']] ||= Submitters::CreateStampAttachment.call(submitter).uuid
acc[field['uuid']] ||=
Submitters::CreateStampAttachment.call(submitter,
with_logo: field.dig('preferences', 'with_logo') != false).uuid
next
end