s.uuid === $event))"
+ />
+
f.submitter_uuid === this.selectedSubmitter.uuid)
+ }
},
methods: {
onDragstart (fieldType) {
this.$emit('set-drag', fieldType)
},
+ removeSubmitter (submitter) {
+ [...this.fields].forEach((field) => {
+ if (field.submitter_uuid === submitter.uuid) {
+ this.removeField(field)
+ }
+ })
+
+ this.submitters.splice(this.submitters.indexOf(submitter), 1)
+
+ if (this.selectedSubmitter === submitter) {
+ this.$emit('change-submitter', this.submitters[0])
+ }
+ },
move (field, direction) {
const currentIndex = this.fields.indexOf(field)
@@ -95,11 +128,15 @@ export default {
this.fields.splice(currentIndex + direction, 0, field)
}
},
+ removeField (field) {
+ this.fields.splice(this.fields.indexOf(field), 1)
+ },
addField (type, area = null) {
const field = {
name: '',
uuid: v4(),
required: true,
+ submitter_uuid: this.selectedSubmitter.uuid,
type
}
diff --git a/app/javascript/template_builder/page.vue b/app/javascript/template_builder/page.vue
index e3559b2b..d25e5e09 100644
--- a/app/javascript/template_builder/page.vue
+++ b/app/javascript/template_builder/page.vue
@@ -18,14 +18,15 @@
:ref="setAreaRefs"
:area="item.area"
:field="item.field"
- @start-resize="showMask = true"
- @stop-resize="showMask = false"
- @start-drag="showMask = true"
- @stop-drag="showMask = false"
+ @start-resize="[showMask = true, isResize = true]"
+ @stop-resize="[showMask = false, isResize = false]"
+ @start-drag="[showMask = true, isMove = true]"
+ @stop-drag="[showMask = false, isMove = false]"
@remove="$emit('remove-area', item)"
/>
@@ -33,7 +34,8 @@
v-show="isDrag || showMask"
id="mask"
ref="mask"
- class="top-0 bottom-0 left-0 right-0 absolute"
+ class="top-0 bottom-0 left-0 right-0 absolute z-10"
+ :class="{ 'cursor-grab': isDrag || isMove, ' cursor-nwse-resize': isResize }"
@pointermove="onPointermove"
@dragover.prevent
@drop="onDrop"
@@ -60,10 +62,9 @@ export default {
required: false,
default: () => []
},
- selectedArea: {
+ selectedSubmitter: {
type: Object,
- required: false,
- default: () => ({})
+ required: true
},
isDrag: {
type: Boolean,
@@ -80,6 +81,8 @@ export default {
return {
areaRefs: [],
showMask: false,
+ isMove: false,
+ isResize: false,
newArea: null
}
},
diff --git a/app/models/template.rb b/app/models/template.rb
index 0c9d378e..80a46e9c 100644
--- a/app/models/template.rb
+++ b/app/models/template.rb
@@ -10,6 +10,7 @@
# name :string not null
# schema :string not null
# slug :string not null
+# submitters :string not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :bigint not null
@@ -27,15 +28,19 @@
# fk_rails_... (author_id => users.id)
#
class Template < ApplicationRecord
+ DEFAULT_SUBMITTER_NAME = 'Submitter 1'
+
belongs_to :author, class_name: 'User'
belongs_to :account
attribute :fields, :string, default: -> { [] }
attribute :schema, :string, default: -> { [] }
+ attribute :submitters, :string, default: -> { [{ name: DEFAULT_SUBMITTER_NAME, uuid: SecureRandom.uuid }] }
attribute :slug, :string, default: -> { SecureRandom.base58(8) }
serialize :fields, JSON
serialize :schema, JSON
+ serialize :submitters, JSON
has_many_attached :documents
diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb
index 00816516..6716731e 100644
--- a/app/views/shared/_navbar.html.erb
+++ b/app/views/shared/_navbar.html.erb
@@ -7,7 +7,7 @@
<%= link_to 'Settings', settings_storage_index_path, class: 'font-medium text-lg' %>
-