Skip to content

Commit

Permalink
fix field drawings on tablets
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBTurchyn authored and omohokcoj committed Dec 9, 2024
1 parent 46edc7d commit c2014a1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/javascript/template_builder/area.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
/>
<span
v-if="field?.type && editable"
class="h-4 w-4 md:h-2.5 md:w-2.5 -right-1 rounded-full -bottom-1 border-gray-400 bg-white shadow-md border absolute cursor-nwse-resize"
class="h-4 w-4 lg:h-2.5 lg:w-2.5 -right-1 rounded-full -bottom-1 border-gray-400 bg-white shadow-md border absolute cursor-nwse-resize"
@mousedown.stop="startResize"
@touchstart="startTouchResize"
/>
Expand Down
20 changes: 13 additions & 7 deletions app/javascript/template_builder/builder.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<div
style="max-width: 1600px"
class="mx-auto pl-3 md:pl-4 h-full"
class="mx-auto pl-3 h-full"
:class="isMobile ? 'pl-4' : 'md:pl-4'"
>
<div
v-if="pendingFieldAttachmentUuids.length && editable"
Expand Down Expand Up @@ -163,7 +164,7 @@
<div
id="main_container"
class="flex"
:class="$slots.buttons || withTitle ? 'md:max-h-[calc(100%_-_60px)]' : 'md:max-h-[100%]'"
:class="$slots.buttons || withTitle ? (isMobile ? 'max-h-[calc(100%_-_60px)]' : 'md:max-h-[calc(100%_-_60px)]') : (isMobile ? 'max-h-[100%]' : 'md:max-h-[100%]')"
>
<div
v-if="withDocumentsList"
Expand Down Expand Up @@ -219,7 +220,8 @@
</div>
<div
id="pages_container"
class="w-full overflow-y-hidden md:overflow-y-auto overflow-x-hidden mt-0.5 pt-0.5"
class="w-full overflow-y-hidden overflow-x-hidden mt-0.5 pt-0.5"
:class="isMobile ? 'overflow-y-auto' : 'md:overflow-y-auto'"
>
<div
ref="documents"
Expand Down Expand Up @@ -320,7 +322,7 @@
</div>
</div>
<div
v-if="withFieldsList"
v-if="withFieldsList && !isMobile"
id="fields_list_container"
class="relative w-80 flex-none mt-1 pr-4 pl-0.5 hidden md:block"
:class="drawField ? 'overflow-hidden' : 'overflow-y-auto overflow-x-hidden'"
Expand Down Expand Up @@ -379,14 +381,14 @@
</div>
</div>
</div>
<div class="sticky bottom-0">
<div class="sticky bottom-0 z-10">
<MobileDrawField
v-if="drawField && isBreakpointLg"
v-if="drawField && (isBreakpointLg || isMobile)"
:draw-field="drawField"
:fields="template.fields"
:submitters="template.submitters"
:selected-submitter="selectedSubmitter"
class="md:hidden"
:class="{ 'md:hidden': !isMobile }"
:editable="editable"
@cancel="[drawField = null, drawOption = null]"
@change-submitter="[selectedSubmitter = $event, drawField.submitter_uuid = $event.uuid]"
Expand All @@ -397,6 +399,7 @@
:default-fields="[...defaultRequiredFields, ...defaultFields]"
:default-required-fields="defaultRequiredFields"
:field-types="fieldTypes"
:class="{ 'md:hidden': !isMobile }"
:selected-submitter="selectedSubmitter"
@select="startFieldDraw($event)"
/>
Expand Down Expand Up @@ -696,6 +699,9 @@ export default {
language () {
return this.locale.split('-')[0].toLowerCase()
},
isMobile () {
return /android|iphone|ipad/i.test(navigator.userAgent)
},
defaultDateFormat () {
const isUsBrowser = Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US')
const isUsTimezone = new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/)
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/template_builder/mobile_draw_field.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="absolute text-center w-full bottom-0 pr-3 mb-4">
<span class="w-full bg-base-200 px-4 py-2 rounded-md inline-flex space-x-2 mx-auto items-center justify-between mb-2 z-20 md:hidden">
<span class="w-full bg-base-200 px-4 py-2 rounded-md inline-flex space-x-2 mx-auto items-center justify-between mb-2 z-20">
<div class="flex items-center space-x-2">
<component
:is="fieldIcons[drawField.type]"
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/template_builder/mobile_fields.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<span
class="dropdown dropdown-top dropdown-end absolute bottom-4 right-4 z-10 md:hidden"
class="dropdown dropdown-top dropdown-end absolute bottom-4 right-4 z-10"
>
<label
class="btn btn-neutral text-white btn-circle btn-lg group"
Expand All @@ -12,9 +12,10 @@
height="28"
/>
<IconX
class="hidden group-focus:inline"
width="28"
height="28"
class="hidden group-focus:inline p-3"
width="64"
height="50"
@click="closeDropdown"
/>
</label>
<ul
Expand Down

0 comments on commit c2014a1

Please sign in to comment.