@afeefa/vue-app 0.0.249 → 0.0.251

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- 0.0.249
1
+ 0.0.251
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.249",
3
+ "version": "0.0.251",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -22,14 +22,19 @@
22
22
  </template>
23
23
 
24
24
  <v-card v-if="modal">
25
- <v-card-title v-if="title">
25
+ <v-card-title
26
+ v-if="title"
27
+ :style="{ cursor: draggable ? 'move' : 'default' }"
28
+ @mousedown="startDrag"
29
+ >
26
30
  <v-icon
27
31
  v-if="icon"
28
32
  :color="icon.color"
29
33
  class="mr-2"
30
34
  size="1.5rem"
31
- v-text="icon.icon"
32
- />
35
+ >
36
+ {{ icon.icon }}
37
+ </v-icon>
33
38
 
34
39
  {{ title }}
35
40
  </v-card-title>
@@ -51,7 +56,7 @@ import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
51
56
  import { CancelOnEscMixin } from '@a-vue/services/escape/CancelOnEscMixin'
52
57
 
53
58
  @Component({
54
- props: ['show', 'icon', 'title', 'beforeClose', 'anchorPosition', 'screenCentered']
59
+ props: ['show', 'icon', 'title', 'beforeClose', 'anchorPosition', 'screenCentered', {draggable: true}]
55
60
  })
56
61
  export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentWidthMixin, CancelOnEscMixin) {
57
62
  modalId = randomCssClass(10)
@@ -59,6 +64,11 @@ export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentW
59
64
  modal = false
60
65
  position = null
61
66
 
67
+ dragStartX = 0
68
+ dragStartY = 0
69
+ initialLeft = 0
70
+ initialTop = 0
71
+
62
72
  cwm_maxWidth_ = 1000
63
73
 
64
74
  created () {
@@ -95,6 +105,42 @@ export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentW
95
105
  }, true) // capture phase, stop event before v-dialog receives it
96
106
  }
97
107
 
108
+ startDrag (event) {
109
+ if (!this.draggable) {
110
+ return
111
+ }
112
+
113
+ this.dragStartX = event.clientX
114
+ this.dragStartY = event.clientY
115
+
116
+ const dialog = document.querySelector('.' + this.modalId)
117
+ const rect = dialog.getBoundingClientRect()
118
+ this.initialLeft = rect.left
119
+ this.initialTop = rect.top
120
+
121
+ document.addEventListener('mousemove', this.onDrag)
122
+ document.addEventListener('mouseup', this.stopDrag)
123
+ }
124
+
125
+ onDrag (event) {
126
+ const deltaX = event.clientX - this.dragStartX
127
+ const deltaY = event.clientY - this.dragStartY
128
+
129
+ const dialog = document.querySelector('.' + this.modalId)
130
+ if (dialog) {
131
+ dialog.style.left = `${this.initialLeft + deltaX}px`
132
+ dialog.style.top = `${this.initialTop + deltaY}px`
133
+ }
134
+ }
135
+
136
+ stopDrag () {
137
+ document.removeEventListener('mousemove', this.onDrag)
138
+ document.removeEventListener('mouseup', this.stopDrag)
139
+
140
+ // remove from position watching if has been dragged once
141
+ this.urp_unregisterPositionWatchers()
142
+ }
143
+
98
144
  coe_cancelOnEsc () {
99
145
  this.cancel()
100
146
  return false // stop esc propagation
@@ -201,7 +247,6 @@ export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentW
201
247
  }
202
248
  </script>
203
249
 
204
-
205
250
  <style lang="scss" scoped>
206
251
  .v-card__title {
207
252
  padding: .8rem 1rem !important;
@@ -32,6 +32,16 @@
32
32
  gap-2
33
33
  justify-end
34
34
  >
35
+ <v-btn
36
+ ref="deleteButton"
37
+ v-if="deleteButton && modelToEdit.id"
38
+ small
39
+ color="error"
40
+ @click="handleDelete"
41
+ >
42
+ Löschen
43
+ </v-btn>
44
+
35
45
  <v-btn
36
46
  small
37
47
  @click="close"
@@ -62,7 +72,7 @@ import { Component, Vue, Watch } from '@a-vue'
62
72
  import { DialogEvent } from '@a-vue/events'
63
73
 
64
74
  @Component({
65
- props: ['model', 'createModelToEdit', 'show', {reset: true, valid: true, forceChanged: false, forceActive: false}]
75
+ props: ['model', 'createModelToEdit', 'show', {deleteButton: false, reset: true, valid: true, forceChanged: false, forceActive: false}]
66
76
  })
67
77
  export default class EditModal extends Vue {
68
78
  show_ = false
@@ -137,6 +147,19 @@ export default class EditModal extends Vue {
137
147
  this.show_ = false
138
148
  }
139
149
 
150
+ async handleDelete () {
151
+ const result = await this.$events.dispatch(new DialogEvent(DialogEvent.SHOW, {
152
+ anchor: this.$refs.form,
153
+ title: 'Löschen bestätigen',
154
+ message: 'Soll dieser Eintrag wirklich gelöscht werden?',
155
+ yesButton: 'Löschen'
156
+ }))
157
+ if (result === DialogEvent.RESULT_YES) {
158
+ this.$emit('delete', this.ignoreChangesOnClose, this.close)
159
+ this.show_ = false
160
+ }
161
+ }
162
+
140
163
  /**
141
164
  * hook to allow to leave a just created (saved) model
142
165
  */