@mixd-id/web-scaffold 0.1.230406245 → 0.1.230406246
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 +1 -1
- package/src/components/Button.vue +1 -1
- package/src/components/ImportModal.vue +2 -2
- package/src/components/ListItem.vue +0 -1
- package/src/components/TextWithTag.vue +196 -0
- package/src/components/Textbox.vue +3 -2
- package/src/components/TreeView.vue +0 -1
- package/src/index.js +1 -0
- package/src/utils/importer.js +9 -1
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
28
|
<div class="flex-1 p-5 flex flex-col items-center justify-center" v-if="step === 1">
|
|
29
|
-
<button type="button" @click="$refs.uploader.click()" class="rounded-3xl w-[
|
|
29
|
+
<button type="button" @click="$refs.uploader.click()" class="rounded-3xl w-[160px] bg-base-300 px-6 aspect-square flex items-center justify-center text-center border-dashed border-[3px] border-text-100">
|
|
30
30
|
<div class="text-xl" v-if="!isLoading">
|
|
31
31
|
Click to <br />
|
|
32
32
|
<span class="text-primary text-lg">Upload</span>
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<label v-else>{{ key.text }}</label>
|
|
56
56
|
</div>
|
|
57
57
|
<div class="flex-1">
|
|
58
|
-
<Dropdown v-model="importData.keys[index].value">
|
|
58
|
+
<Dropdown v-model="importData.keys[index].value" :class="key.required ? 'w-full' : 'w-[210px]'">
|
|
59
59
|
<option disabled selected>Pilih Kolom</option>
|
|
60
60
|
<option v-for="column in importData.columns" :value="column">{{ column }}</option>
|
|
61
61
|
</Dropdown>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.comp">
|
|
3
|
+
|
|
4
|
+
<p contenteditable="true" spellcheck="false" class="flex-1" ref="html" v-html="html" @input="onInput"></p>
|
|
5
|
+
|
|
6
|
+
<div class="flex flex-row bg-base-300">
|
|
7
|
+
<div class="flex-1 flex flex-row gap-2 overflow-x-auto p-1" :class="$style.noScrollbar">
|
|
8
|
+
<button type="button" v-for="item in viewedItems" :class="$style.tag2" class="text-xs" @click="add(item)">{{ item.text ?? item.value }}</button>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="p-1 flex items-center justify-center">
|
|
11
|
+
<button type="button" class="p-1" @click="$refs.modal.open()">
|
|
12
|
+
<svg width="14" height="14" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z"/></svg>
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<Modal ref="modal" width="360" height="360">
|
|
18
|
+
<template v-slot:head>
|
|
19
|
+
<div class="relative p-5 pb-0">
|
|
20
|
+
<h3>Select Tag</h3>
|
|
21
|
+
<div class="absolute top-0 right-0 p-2">
|
|
22
|
+
<button type="button" class="p-2" @click="$refs.modal.close()">
|
|
23
|
+
<svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
|
|
24
|
+
<path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
|
|
25
|
+
</svg>
|
|
26
|
+
</button>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
<div class="flex-1 p-5 flex flex-col gap-6">
|
|
31
|
+
|
|
32
|
+
<div v-for="(group, key) in groupedItems">
|
|
33
|
+
<div>
|
|
34
|
+
<label>{{ key }}</label>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="flex flex-row flex-wrap gap-2">
|
|
37
|
+
<button v-for="item in group"
|
|
38
|
+
type="button"
|
|
39
|
+
:class="$style.tag2"
|
|
40
|
+
@click="add(item)" class="p-3">
|
|
41
|
+
{{ item.text ?? item.value }}
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
</Modal>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
import groupBy from "lodash/groupBy";
|
|
53
|
+
|
|
54
|
+
export default{
|
|
55
|
+
|
|
56
|
+
emits: [ 'update:modelValue' ],
|
|
57
|
+
|
|
58
|
+
props:{
|
|
59
|
+
|
|
60
|
+
modelValue: String,
|
|
61
|
+
|
|
62
|
+
items: Array,
|
|
63
|
+
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
computed:{
|
|
67
|
+
|
|
68
|
+
groupedItems(){
|
|
69
|
+
return groupBy(this.items ?? [], 'group')
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
viewedItems(){
|
|
73
|
+
return (this.items ?? []).slice(0, 6)
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
data(){
|
|
79
|
+
return {
|
|
80
|
+
html: '',
|
|
81
|
+
isInternal: false
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
methods: {
|
|
86
|
+
|
|
87
|
+
insertElement(newNode){
|
|
88
|
+
let selection = window.getSelection();
|
|
89
|
+
if (selection.rangeCount === 0) return;
|
|
90
|
+
|
|
91
|
+
let range = selection.getRangeAt(0);
|
|
92
|
+
if(range.commonAncestorContainer.parentNode !== this.$refs.html) return
|
|
93
|
+
|
|
94
|
+
let currentNode = range.startContainer;
|
|
95
|
+
|
|
96
|
+
if (currentNode.nodeType === Node.TEXT_NODE) {
|
|
97
|
+
let offset = range.startOffset;
|
|
98
|
+
currentNode = currentNode.splitText(offset);
|
|
99
|
+
range.setStart(currentNode, 0);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
range.insertNode(newNode);
|
|
103
|
+
range.setStartAfter(newNode);
|
|
104
|
+
range.setEndAfter(newNode);
|
|
105
|
+
selection.removeAllRanges();
|
|
106
|
+
selection.addRange(range);
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
add(item){
|
|
110
|
+
this.$refs.modal.close()
|
|
111
|
+
|
|
112
|
+
const el = document.createElement('span')
|
|
113
|
+
el.setAttribute('contenteditable', 'false')
|
|
114
|
+
el.setAttribute('class', this.$style.tag)
|
|
115
|
+
el.setAttribute('data-value', item.value)
|
|
116
|
+
el.textContent = item.text ?? item.value
|
|
117
|
+
|
|
118
|
+
this.insertElement(el)
|
|
119
|
+
this.onInput()
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
remove(e){
|
|
123
|
+
e.target.parentNode.removeChild(e.target)
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
onInput(){
|
|
127
|
+
|
|
128
|
+
const arr = []
|
|
129
|
+
for(let i = 0 ; i < this.$refs.html.childNodes.length ; i++){
|
|
130
|
+
if(this.$refs.html.childNodes[i].nodeType === 3){
|
|
131
|
+
arr.push(this.$refs.html.childNodes[i].textContent)
|
|
132
|
+
}
|
|
133
|
+
else if(this.$refs.html.childNodes[i].nodeType === 1 && this.$refs.html.childNodes[i].classList.contains(this.$style.tag)){
|
|
134
|
+
arr.push(this.$refs.html.childNodes[i].getAttribute('data-value'))
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.$emit('update:modelValue', arr.join(''))
|
|
138
|
+
|
|
139
|
+
this.isInternal = true
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
watch: {
|
|
145
|
+
|
|
146
|
+
modelValue: {
|
|
147
|
+
immediate: true,
|
|
148
|
+
handler(val){
|
|
149
|
+
if(this.isInternal){
|
|
150
|
+
this.isInternal = false
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let html = val
|
|
155
|
+
for(let item of this.items){
|
|
156
|
+
html = html.replaceAll(item.value, `<span class="${this.$style.tag}" contenteditable="false" @click="remove" data-value="${item.value}">${item.text ?? item.value}</span>`, 'gi')
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
this.html = html
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<style module>
|
|
170
|
+
|
|
171
|
+
.comp{
|
|
172
|
+
@apply border-[1px] border-text-200 bg-base-50 rounded-lg min-w-[100px];
|
|
173
|
+
@apply flex flex-col gap-2;
|
|
174
|
+
@apply overflow-hidden;
|
|
175
|
+
@apply divide-y divide-text-100;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.comp p{
|
|
179
|
+
@apply outline-none leading-8 p-2;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.comp .tag{
|
|
183
|
+
@apply bg-primary text-white p-1 rounded-lg whitespace-nowrap;
|
|
184
|
+
@apply font-mono text-xs;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.tag2{
|
|
188
|
+
@apply bg-text-50 p-1 rounded-lg px-2 cursor-pointer;
|
|
189
|
+
@apply hover:bg-primary hover:text-white;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.noScrollbar::-webkit-scrollbar{
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
</style>
|
|
@@ -173,8 +173,9 @@ export default{
|
|
|
173
173
|
<style module>
|
|
174
174
|
|
|
175
175
|
.textbox{
|
|
176
|
-
@apply flex items-center
|
|
177
|
-
|
|
176
|
+
@apply flex items-center;
|
|
177
|
+
@apply border-[1px] border-text-200 bg-base-50 rounded-lg;
|
|
178
|
+
@apply overflow-hidden;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
.textbox.readonly{
|
package/src/index.js
CHANGED
|
@@ -475,6 +475,7 @@ export default{
|
|
|
475
475
|
app.component('FBLogin', defineAsyncComponent(() => import("./components/FBLogin.vue")))
|
|
476
476
|
app.component('GSignIn', defineAsyncComponent(() => import("./components/GSignIn.vue")))
|
|
477
477
|
app.component('DayTimeRange', defineAsyncComponent(() => import("./components/DayTimeRange.vue")))
|
|
478
|
+
app.component('TextWithTag', defineAsyncComponent(() => import("./components/TextWithTag.vue")))
|
|
478
479
|
|
|
479
480
|
app.component('AhrefSetting', defineAsyncComponent(() => import("./widgets/AhrefSetting.vue")))
|
|
480
481
|
app.component('ArticleSetting', defineAsyncComponent(() => import("./widgets/ArticleSetting.vue")))
|
package/src/utils/importer.js
CHANGED
|
@@ -113,7 +113,15 @@ const importRequest = async(req) => {
|
|
|
113
113
|
|
|
114
114
|
const worksheet = workbook.worksheets[0]
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
const row = worksheet.getRow(2)
|
|
117
|
+
let isInfoRow = false
|
|
118
|
+
row.eachCell(cell => {
|
|
119
|
+
if(cell.value.trim().startsWith('***')){
|
|
120
|
+
isInfoRow = true
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
let rowStart = isInfoRow ? 3 : 2
|
|
117
125
|
const header = worksheet.getRow(1)
|
|
118
126
|
const columnAddress = {}
|
|
119
127
|
header.eachCell((cell, index) => {
|