@mixd-id/web-scaffold 0.1.230406149 → 0.1.230406150

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406149",
4
+ "version": "0.1.230406150",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -2,6 +2,8 @@
2
2
  import { inject } from 'vue'
3
3
  import {parseBoolean} from "../utils/helpers.mjs";
4
4
 
5
+ let guide, guide2
6
+
5
7
  export const componentMixin = {
6
8
 
7
9
  props: {
@@ -89,17 +91,41 @@ export const componentMixin = {
89
91
  },
90
92
 
91
93
  componentMouseOver(e){
92
- //e.stopPropagation()
93
- //e.preventDefault()
94
+ e.stopPropagation()
95
+ e.preventDefault()
94
96
 
95
- //this.lastStyle.position = this.$el.style.position
96
- //this.$el.style.position = 'relative'
97
+ this.lastStyle.position = this.$el.style.position
98
+ this.$el.style.position = 'relative'
97
99
 
98
- //this.$el.appendChild(this.getGuide())
100
+ this.$el.appendChild(this.getGuide())
99
101
  },
100
102
 
101
103
  componentMouseOut(e){
102
- //this.$el.style.position = this.lastStyle.position
104
+ this.$el.style.position = this.lastStyle.position
105
+ },
106
+
107
+ getGuide(){
108
+ if(!guide){
109
+ guide = document.createElement('div')
110
+ guide.className = "absolute top-0 left-0 right-0 bottom-0 border-[3px] border-blue-600" +
111
+ " pointer-events-none"
112
+ }
113
+
114
+ return guide
115
+ },
116
+
117
+ getGuide2(){
118
+ if(!guide2){
119
+ guide2 = document.createElement('div')
120
+ guide2.className = "absolute top-0 left-0 right-0 bottom-0 border-[3px] border-blue-600" +
121
+ " pointer-events-none"
122
+ }
123
+
124
+ return guide2
125
+ },
126
+
127
+ select(){
128
+ this.$el.appendChild(this.getGuide2())
103
129
  },
104
130
 
105
131
  },
@@ -115,16 +141,19 @@ export const componentMixin = {
115
141
  if('edit-mode' in this.$route.query){
116
142
  this.editMode = true
117
143
  this.editModeClick = inject('editModeClick', () => {})
144
+ this.editRegisterComponent = inject('editRegisterComponent', () => {})
118
145
 
119
146
  if(parseBoolean(this.editSelectable)){
120
147
  this.$el.addEventListener('click', this.componentClick)
121
148
  this.$el.addEventListener('mouseover', this.componentMouseOver)
122
149
  this.$el.addEventListener('mouseout', this.componentMouseOut)
123
150
  }
151
+
152
+ this.editRegisterComponent(this.uid, this)
124
153
  }
125
154
  },
126
155
 
127
- unmounted() {
156
+ unmounted(){
128
157
  this.$el.removeEventListener('click', this.componentClick)
129
158
  },
130
159
 
@@ -51,7 +51,7 @@
51
51
  <p>{{ review.details ?? review.text }}</p>
52
52
  </div>
53
53
  <div v-if="review.imageUrl">
54
- <Image :src="imageSrc(review.imageUrl)" class="w-[80px] aspect-square rounded-lg" />
54
+ <Image :src="imageSrc(review.imageUrl)" class="w-[80px] aspect-square rounded-lg" edit-selectable="false" />
55
55
  </div>
56
56
  </div>
57
57
  <div class="flex flex-row gap-2">
@@ -35,6 +35,14 @@
35
35
 
36
36
  export default{
37
37
 
38
+ inject: [ 'alert', 'socketEmit2' ],
39
+
40
+ props: {
41
+
42
+ useDatasource: String
43
+
44
+ },
45
+
38
46
  methods: {
39
47
 
40
48
  apply(datasource){
@@ -47,21 +55,26 @@ export default{
47
55
  },
48
56
 
49
57
  open(){
58
+ this.load()
50
59
  this.isOpen = true
51
60
  },
52
61
 
62
+ load(){
63
+ if(this.useDatasource){
64
+ this.socketEmit2(this.useDatasource, {})
65
+ .then(res => {
66
+ this.datasources = res
67
+ })
68
+ .catch(err => this.alert(err))
69
+ }
70
+ },
71
+
53
72
  },
54
73
 
55
74
  data(){
56
75
  return {
57
76
  isOpen: false,
58
-
59
- datasources: [
60
- { label:"Product", name:"product.load", params:{} },
61
- { label:"Warehouse", name:"warehouse.load", params:{} },
62
- { label:"Variant", name:"variant.load", params:{} },
63
- { label:"Customer", name:"customer.load", params:{} },
64
- ],
77
+ datasources: null
65
78
  }
66
79
  },
67
80
 
@@ -165,7 +165,7 @@
165
165
  @change="saveLayout">
166
166
  <template #default="{ item }">
167
167
  <component :is="`${(item ?? {}).type}Item`" :item="item"
168
- @click="store.selectedComponent = [ item.uid ]"/>
168
+ @click="select(item.uid)"/>
169
169
  </template>
170
170
  </TreeView>
171
171
  </div>
@@ -185,7 +185,7 @@
185
185
  @change="saveLayout">
186
186
  <template #default="{ item }">
187
187
  <component :is="`${(item ?? {}).type}Item`" :item="item"
188
- @click="store.selectedComponent = [ item.uid ]"/>
188
+ @click="select(item.uid)"/>
189
189
  </template>
190
190
  </TreeView>
191
191
  </div>
@@ -205,7 +205,7 @@
205
205
  @change="save">
206
206
  <template #default="{ item }">
207
207
  <component :is="`${(item ?? {}).type}Item`" :item="item"
208
- @click="store.selectedComponent = [ item.uid ]"/>
208
+ @click="select(item.uid)"/>
209
209
  </template>
210
210
  </TreeView>
211
211
  </div>
@@ -236,7 +236,9 @@
236
236
  </button>
237
237
  </div>
238
238
 
239
- <WebDatasourceSelector ref="webDatasourceSelector" @apply="addDatasource"/>
239
+ <WebDatasourceSelector ref="webDatasourceSelector"
240
+ @apply="addDatasource"
241
+ :use-datasource="useDatasource" />
240
242
 
241
243
  </div>
242
244
 
@@ -567,7 +569,7 @@ export default{
567
569
 
568
570
  const comp = this.findItemByUid(this.currentItem.uid)
569
571
  comp.items.splice(comp.items.indexOf(comp.item) + 1, 0, item)
570
- this.store.selectedComponent = [ item.uid ]
572
+ this.select(item.uid)
571
573
  comp.type === 'components' ? this.save() : this.saveLayout()
572
574
  }
573
575
  catch(e){
@@ -912,7 +914,7 @@ export default{
912
914
  break
913
915
 
914
916
  case 'component-click':
915
- this.store.selectedComponent = [ uid ]
917
+ this.select(uid)
916
918
  break
917
919
  }
918
920
  },
@@ -1019,6 +1021,15 @@ export default{
1019
1021
  }*/
1020
1022
  },
1021
1023
 
1024
+ select(uid){
1025
+ this.store.selectedComponent = [ uid ]
1026
+
1027
+ this.$refs.iframe.contentWindow.postMessage({
1028
+ action: 'select',
1029
+ uid
1030
+ }, '*')
1031
+ }
1032
+
1022
1033
  },
1023
1034
 
1024
1035
  computed: {