@escalated-dev/escalated 0.8.0 → 0.11.1
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/LICENSE +21 -21
- package/README.md +388 -361
- package/package.json +85 -84
- package/src/components/ActiveChatsPanel.vue +246 -246
- package/src/components/AdminDashboard.stories.js +1423 -1423
- package/src/components/AttachmentList.vue +65 -65
- package/src/components/ChatActionBar.vue +226 -226
- package/src/components/ChatBubble.vue +162 -162
- package/src/components/ChatComposer.vue +308 -308
- package/src/components/ChatQueue.vue +222 -222
- package/src/components/ChatThread.vue +197 -197
- package/src/components/CustomTicketActions.stories.js +71 -0
- package/src/components/CustomTicketActions.vue +101 -0
- package/src/components/EscalatedLayout.vue +628 -604
- package/src/components/FollowButton.vue +20 -1
- package/src/components/MentionDropdown.vue +154 -154
- package/src/components/MetricComparison.vue +89 -89
- package/src/components/PercentileChart.vue +67 -67
- package/src/components/PeriodSelector.vue +98 -98
- package/src/components/PresenceIndicator.vue +228 -213
- package/src/components/ReplyComposer.vue +336 -336
- package/src/components/ReplyThread.vue +153 -153
- package/src/components/ReportChart.vue +395 -395
- package/src/components/ReportExportButton.vue +108 -108
- package/src/components/SaveViewDialog.vue +172 -172
- package/src/components/SavedViewSidebar.vue +208 -208
- package/src/components/SkillTagManager.vue +3 -0
- package/src/components/SnoozeButton.vue +247 -247
- package/src/components/TicketFilters.vue +270 -270
- package/src/components/TicketList.vue +655 -655
- package/src/components/TicketSidebar.vue +4 -0
- package/src/components/TicketSplitDialog.vue +98 -98
- package/src/components/TicketSubjects.stories.js +63 -0
- package/src/components/TicketSubjects.vue +107 -0
- package/src/components/TwoFactorSetup.vue +1 -37
- package/src/components/VariableTokenInput.vue +111 -111
- package/src/components/WorkflowActionConfig.vue +287 -287
- package/src/components/WorkflowActionList.vue +350 -350
- package/src/components/WorkflowConditionBuilder.vue +265 -265
- package/src/components/WorkflowTriggerSelector.vue +125 -125
- package/src/components/admin/newsletters/AnalyticsTiles.stories.js +14 -0
- package/src/components/admin/newsletters/AnalyticsTiles.vue +55 -0
- package/src/components/admin/newsletters/DeliveriesTable.stories.js +28 -0
- package/src/components/admin/newsletters/DeliveriesTable.vue +104 -0
- package/src/components/admin/newsletters/DynamicFilterBuilder.stories.js +11 -0
- package/src/components/admin/newsletters/DynamicFilterBuilder.vue +53 -0
- package/src/components/admin/newsletters/ListMemberTable.stories.js +12 -0
- package/src/components/admin/newsletters/ListMemberTable.vue +53 -0
- package/src/components/admin/newsletters/MarkdownEditor.stories.js +6 -0
- package/src/components/admin/newsletters/MarkdownEditor.vue +53 -0
- package/src/components/admin/newsletters/MergeFieldDropdown.stories.js +6 -0
- package/src/components/admin/newsletters/MergeFieldDropdown.vue +84 -0
- package/src/components/admin/newsletters/PreviewIframe.stories.js +7 -0
- package/src/components/admin/newsletters/PreviewIframe.vue +40 -0
- package/src/components/admin/newsletters/SummaryTiles.stories.js +8 -0
- package/src/components/admin/newsletters/SummaryTiles.vue +63 -0
- package/src/composables/useChat.js +187 -187
- package/src/composables/useI18n.js +102 -102
- package/src/composables/useMentions.js +134 -134
- package/src/composables/usePermissions.js +31 -0
- package/src/composables/useRealtime.js +182 -182
- package/src/index.js +85 -84
- package/src/locales/README.md +13 -13
- package/src/locales/ar.json +727 -727
- package/src/locales/de.json +690 -690
- package/src/locales/en.json +889 -729
- package/src/locales/es.json +691 -691
- package/src/locales/fr.json +691 -691
- package/src/locales/index.js +16 -16
- package/src/locales/it.json +727 -727
- package/src/locales/ja.json +727 -727
- package/src/locales/ko.json +727 -727
- package/src/locales/nl.json +727 -727
- package/src/locales/pl.json +727 -727
- package/src/locales/pt-BR.json +727 -727
- package/src/locales/ru.json +727 -727
- package/src/locales/tr.json +727 -727
- package/src/locales/zh-CN.json +727 -727
- package/src/pages/Admin/Automations/Form.vue +280 -0
- package/src/pages/Admin/Automations/Index.vue +230 -0
- package/src/pages/Admin/Newsletters/Compose.vue +192 -0
- package/src/pages/Admin/Newsletters/Edit.vue +24 -0
- package/src/pages/Admin/Newsletters/Index.vue +141 -0
- package/src/pages/Admin/Newsletters/Lists/Create.vue +64 -0
- package/src/pages/Admin/Newsletters/Lists/Index.vue +59 -0
- package/src/pages/Admin/Newsletters/Lists/Show.vue +53 -0
- package/src/pages/Admin/Newsletters/Settings.vue +85 -0
- package/src/pages/Admin/Newsletters/Show.vue +140 -0
- package/src/pages/Admin/Newsletters/Templates/Create.vue +11 -0
- package/src/pages/Admin/Newsletters/Templates/Index.vue +54 -0
- package/src/pages/Admin/Newsletters/Templates/Show.vue +65 -0
- package/src/pages/Admin/Newsletters/usePreview.js +44 -0
- package/src/pages/Admin/Plugins/Index.vue +10 -2
- package/src/pages/Admin/Reports/AgentDetail.vue +132 -132
- package/src/pages/Admin/Reports/AgentRanking.vue +246 -246
- package/src/pages/Admin/Reports/Cohorts.vue +180 -180
- package/src/pages/Admin/Reports/Comparison.vue +141 -141
- package/src/pages/Admin/Reports/Dashboard.vue +226 -226
- package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -164
- package/src/pages/Admin/Reports/ResponseTimes.vue +164 -164
- package/src/pages/Admin/Reports/SlaTrends.vue +183 -183
- package/src/pages/Admin/Settings/DatabaseConnection.vue +228 -0
- package/src/pages/Admin/Settings/PublicTickets.vue +163 -0
- package/src/pages/Admin/Settings/SsoSettings.vue +157 -4
- package/src/pages/Admin/Settings/TwoFactor.vue +32 -6
- package/src/pages/Admin/Settings.vue +1008 -1008
- package/src/pages/Admin/Skills/Form.vue +30 -10
- package/src/pages/Admin/Tickets/Index.vue +126 -126
- package/src/pages/Admin/Tickets/Show.vue +254 -249
- package/src/pages/Admin/Users/Index.vue +145 -145
- package/src/pages/Admin/Webhooks/DeliveryLog.vue +1 -2
- package/src/pages/Admin/Workflows/Builder.vue +207 -207
- package/src/pages/Admin/Workflows/Form.vue +24 -0
- package/src/pages/Admin/Workflows/Index.vue +235 -235
- package/src/pages/Admin/Workflows/Logs.vue +286 -286
- package/src/pages/Agent/TicketIndex.vue +112 -112
- package/src/pages/Agent/TicketShow.vue +547 -494
- package/src/pages/Customer/Index.vue +56 -56
- package/src/pages/Customer/KnowledgeBase/Article.vue +129 -129
- package/src/pages/Plugin/Page.vue +61 -0
- package/src/plugin.js +175 -175
- package/src/utils/mentionHighlight.js +24 -24
- package/src/widget/EscalatedWidget.vue +804 -804
- package/src/widget/index.js +254 -254
|
@@ -1,265 +1,265 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { computed } from 'vue';
|
|
3
|
-
|
|
4
|
-
const props = defineProps({
|
|
5
|
-
modelValue: {
|
|
6
|
-
type: Object,
|
|
7
|
-
default: () => ({ match: 'all', conditions: [] }),
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const emit = defineEmits(['update:modelValue']);
|
|
12
|
-
|
|
13
|
-
const fields = [
|
|
14
|
-
{
|
|
15
|
-
value: 'status',
|
|
16
|
-
label: 'Status',
|
|
17
|
-
type: 'enum',
|
|
18
|
-
options: [
|
|
19
|
-
'open',
|
|
20
|
-
'in_progress',
|
|
21
|
-
'waiting_on_customer',
|
|
22
|
-
'waiting_on_agent',
|
|
23
|
-
'escalated',
|
|
24
|
-
'resolved',
|
|
25
|
-
'closed',
|
|
26
|
-
'reopened',
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
{ value: 'priority', label: 'Priority', type: 'enum', options: ['low', 'medium', 'high', 'urgent', 'critical'] },
|
|
30
|
-
{
|
|
31
|
-
value: 'type',
|
|
32
|
-
label: 'Type',
|
|
33
|
-
type: 'enum',
|
|
34
|
-
options: ['question', 'problem', 'incident', 'task', 'feature_request'],
|
|
35
|
-
},
|
|
36
|
-
{ value: 'channel', label: 'Channel', type: 'enum', options: ['web', 'email', 'chat', 'api', 'phone'] },
|
|
37
|
-
{ value: 'tags', label: 'Tags', type: 'text' },
|
|
38
|
-
{ value: 'department', label: 'Department', type: 'text' },
|
|
39
|
-
{ value: 'assigned_agent', label: 'Assigned Agent', type: 'text' },
|
|
40
|
-
{ value: 'subject', label: 'Subject', type: 'text' },
|
|
41
|
-
{ value: 'hours_since_created', label: 'Hours Since Created', type: 'number' },
|
|
42
|
-
{ value: 'hours_since_updated', label: 'Hours Since Updated', type: 'number' },
|
|
43
|
-
{ value: 'reply_count', label: 'Reply Count', type: 'number' },
|
|
44
|
-
{ value: 'custom_field', label: 'Custom Field', type: 'text' },
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
const operatorsByType = {
|
|
48
|
-
enum: [
|
|
49
|
-
{ value: 'equals', label: 'equals' },
|
|
50
|
-
{ value: 'not_equals', label: 'not equals' },
|
|
51
|
-
{ value: 'in', label: 'in' },
|
|
52
|
-
],
|
|
53
|
-
text: [
|
|
54
|
-
{ value: 'equals', label: 'equals' },
|
|
55
|
-
{ value: 'not_equals', label: 'not equals' },
|
|
56
|
-
{ value: 'contains', label: 'contains' },
|
|
57
|
-
{ value: 'is_empty', label: 'is empty' },
|
|
58
|
-
{ value: 'matches', label: 'matches' },
|
|
59
|
-
],
|
|
60
|
-
number: [
|
|
61
|
-
{ value: 'equals', label: 'equals' },
|
|
62
|
-
{ value: 'not_equals', label: 'not equals' },
|
|
63
|
-
{ value: 'greater_than', label: 'greater than' },
|
|
64
|
-
{ value: 'less_than', label: 'less than' },
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const data = computed(() => props.modelValue);
|
|
69
|
-
|
|
70
|
-
function update(patch) {
|
|
71
|
-
emit('update:modelValue', { ...data.value, ...patch });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function toggleMatch() {
|
|
75
|
-
update({ match: data.value.match === 'all' ? 'any' : 'all' });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function addCondition() {
|
|
79
|
-
const conditions = [...(data.value.conditions || []), { field: 'status', operator: 'equals', value: '' }];
|
|
80
|
-
update({ conditions });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function removeCondition(index) {
|
|
84
|
-
const conditions = data.value.conditions.filter((_, i) => i !== index);
|
|
85
|
-
update({ conditions });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function updateCondition(index, patch) {
|
|
89
|
-
const conditions = data.value.conditions.map((c, i) => (i === index ? { ...c, ...patch } : c));
|
|
90
|
-
update({ conditions });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function getFieldConfig(fieldValue) {
|
|
94
|
-
return fields.find((f) => f.value === fieldValue) || fields[0];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function getOperators(fieldValue) {
|
|
98
|
-
const field = getFieldConfig(fieldValue);
|
|
99
|
-
return operatorsByType[field.type] || operatorsByType.text;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function onFieldChange(index, newField) {
|
|
103
|
-
const operators = getOperators(newField);
|
|
104
|
-
updateCondition(index, { field: newField, operator: operators[0].value, value: '' });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const previewText = computed(() => {
|
|
108
|
-
if (!data.value.conditions?.length) return '';
|
|
109
|
-
const joiner = data.value.match === 'all' ? ' AND ' : ' OR ';
|
|
110
|
-
return data.value.conditions
|
|
111
|
-
.map((c) => {
|
|
112
|
-
const field = getFieldConfig(c.field);
|
|
113
|
-
const opLabel =
|
|
114
|
-
(operatorsByType[field.type] || []).find((o) => o.value === c.operator)?.label || c.operator;
|
|
115
|
-
if (c.operator === 'is_empty') return `${field.label} is empty`;
|
|
116
|
-
const val = Array.isArray(c.value) ? `[${c.value.join(', ')}]` : c.value;
|
|
117
|
-
return `${field.label} ${opLabel} ${val}`;
|
|
118
|
-
})
|
|
119
|
-
.join(joiner);
|
|
120
|
-
});
|
|
121
|
-
</script>
|
|
122
|
-
|
|
123
|
-
<template>
|
|
124
|
-
<div class="space-y-4">
|
|
125
|
-
<!-- Match type toggle -->
|
|
126
|
-
<div class="flex items-center gap-3">
|
|
127
|
-
<span class="text-sm text-[var(--esc-panel-text-muted)]">Match:</span>
|
|
128
|
-
<button
|
|
129
|
-
type="button"
|
|
130
|
-
class="rounded-lg px-3 py-1.5 text-xs font-semibold transition-colors"
|
|
131
|
-
:class="
|
|
132
|
-
data.match === 'all'
|
|
133
|
-
? 'bg-amber-500/20 text-amber-400'
|
|
134
|
-
: 'bg-[var(--esc-panel-hover)] text-[var(--esc-panel-text-muted)] hover:text-[var(--esc-panel-text-secondary)]'
|
|
135
|
-
"
|
|
136
|
-
@click="toggleMatch"
|
|
137
|
-
>
|
|
138
|
-
All conditions (AND)
|
|
139
|
-
</button>
|
|
140
|
-
<button
|
|
141
|
-
type="button"
|
|
142
|
-
class="rounded-lg px-3 py-1.5 text-xs font-semibold transition-colors"
|
|
143
|
-
:class="
|
|
144
|
-
data.match === 'any'
|
|
145
|
-
? 'bg-amber-500/20 text-amber-400'
|
|
146
|
-
: 'bg-[var(--esc-panel-hover)] text-[var(--esc-panel-text-muted)] hover:text-[var(--esc-panel-text-secondary)]'
|
|
147
|
-
"
|
|
148
|
-
@click="toggleMatch"
|
|
149
|
-
>
|
|
150
|
-
Any condition (OR)
|
|
151
|
-
</button>
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
<!-- Condition rows -->
|
|
155
|
-
<div class="space-y-2">
|
|
156
|
-
<div
|
|
157
|
-
v-for="(condition, i) in data.conditions"
|
|
158
|
-
:key="i"
|
|
159
|
-
class="flex flex-wrap items-center gap-2 rounded-lg border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)] p-3"
|
|
160
|
-
>
|
|
161
|
-
<!-- Field -->
|
|
162
|
-
<select
|
|
163
|
-
:value="condition.field"
|
|
164
|
-
class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
165
|
-
@change="onFieldChange(i, $event.target.value)"
|
|
166
|
-
>
|
|
167
|
-
<option v-for="f in fields" :key="f.value" :value="f.value">{{ f.label }}</option>
|
|
168
|
-
</select>
|
|
169
|
-
|
|
170
|
-
<!-- Operator -->
|
|
171
|
-
<select
|
|
172
|
-
:value="condition.operator"
|
|
173
|
-
class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
174
|
-
@change="updateCondition(i, { operator: $event.target.value })"
|
|
175
|
-
>
|
|
176
|
-
<option v-for="op in getOperators(condition.field)" :key="op.value" :value="op.value">
|
|
177
|
-
{{ op.label }}
|
|
178
|
-
</option>
|
|
179
|
-
</select>
|
|
180
|
-
|
|
181
|
-
<!-- Value (contextual) -->
|
|
182
|
-
<template v-if="condition.operator !== 'is_empty'">
|
|
183
|
-
<!-- Enum select for enum fields -->
|
|
184
|
-
<select
|
|
185
|
-
v-if="getFieldConfig(condition.field).type === 'enum' && condition.operator !== 'in'"
|
|
186
|
-
:value="condition.value"
|
|
187
|
-
class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
188
|
-
@change="updateCondition(i, { value: $event.target.value })"
|
|
189
|
-
>
|
|
190
|
-
<option value="">Select...</option>
|
|
191
|
-
<option v-for="opt in getFieldConfig(condition.field).options" :key="opt" :value="opt">
|
|
192
|
-
{{ opt }}
|
|
193
|
-
</option>
|
|
194
|
-
</select>
|
|
195
|
-
|
|
196
|
-
<!-- Multi-select for "in" operator on enum fields -->
|
|
197
|
-
<select
|
|
198
|
-
v-else-if="getFieldConfig(condition.field).type === 'enum' && condition.operator === 'in'"
|
|
199
|
-
:value="condition.value"
|
|
200
|
-
multiple
|
|
201
|
-
class="min-h-[60px] rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
202
|
-
@change="
|
|
203
|
-
updateCondition(i, { value: Array.from($event.target.selectedOptions, (o) => o.value) })
|
|
204
|
-
"
|
|
205
|
-
>
|
|
206
|
-
<option v-for="opt in getFieldConfig(condition.field).options" :key="opt" :value="opt">
|
|
207
|
-
{{ opt }}
|
|
208
|
-
</option>
|
|
209
|
-
</select>
|
|
210
|
-
|
|
211
|
-
<!-- Number input -->
|
|
212
|
-
<input
|
|
213
|
-
v-else-if="getFieldConfig(condition.field).type === 'number'"
|
|
214
|
-
type="number"
|
|
215
|
-
:value="condition.value"
|
|
216
|
-
placeholder="0"
|
|
217
|
-
class="w-24 rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none focus:ring-1 focus:ring-[var(--esc-panel-border-input)]"
|
|
218
|
-
@input="updateCondition(i, { value: $event.target.value })"
|
|
219
|
-
/>
|
|
220
|
-
|
|
221
|
-
<!-- Text input (default) -->
|
|
222
|
-
<input
|
|
223
|
-
v-else
|
|
224
|
-
type="text"
|
|
225
|
-
:value="condition.value"
|
|
226
|
-
placeholder="Value"
|
|
227
|
-
class="flex-1 rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none focus:ring-1 focus:ring-[var(--esc-panel-border-input)]"
|
|
228
|
-
@input="updateCondition(i, { value: $event.target.value })"
|
|
229
|
-
/>
|
|
230
|
-
</template>
|
|
231
|
-
|
|
232
|
-
<!-- Remove button -->
|
|
233
|
-
<button
|
|
234
|
-
type="button"
|
|
235
|
-
class="ml-auto flex h-7 w-7 items-center justify-center rounded-lg text-rose-400 transition-colors hover:bg-rose-500/10 hover:text-rose-300"
|
|
236
|
-
@click="removeCondition(i)"
|
|
237
|
-
>
|
|
238
|
-
<svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
239
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
|
240
|
-
</svg>
|
|
241
|
-
</button>
|
|
242
|
-
</div>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
<!-- Add condition button -->
|
|
246
|
-
<button
|
|
247
|
-
type="button"
|
|
248
|
-
class="flex items-center gap-1.5 rounded-lg border border-dashed border-[var(--esc-panel-border)] px-3 py-2 text-xs text-[var(--esc-panel-text-muted)] transition-colors hover:border-amber-500/50 hover:text-amber-400"
|
|
249
|
-
@click="addCondition"
|
|
250
|
-
>
|
|
251
|
-
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
252
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
|
253
|
-
</svg>
|
|
254
|
-
Add Condition
|
|
255
|
-
</button>
|
|
256
|
-
|
|
257
|
-
<!-- Preview -->
|
|
258
|
-
<div
|
|
259
|
-
v-if="previewText"
|
|
260
|
-
class="rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2.5 text-xs text-amber-300"
|
|
261
|
-
>
|
|
262
|
-
<span class="font-medium">Preview:</span> When {{ previewText }}
|
|
263
|
-
</div>
|
|
264
|
-
</div>
|
|
265
|
-
</template>
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: Object,
|
|
7
|
+
default: () => ({ match: 'all', conditions: [] }),
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const emit = defineEmits(['update:modelValue']);
|
|
12
|
+
|
|
13
|
+
const fields = [
|
|
14
|
+
{
|
|
15
|
+
value: 'status',
|
|
16
|
+
label: 'Status',
|
|
17
|
+
type: 'enum',
|
|
18
|
+
options: [
|
|
19
|
+
'open',
|
|
20
|
+
'in_progress',
|
|
21
|
+
'waiting_on_customer',
|
|
22
|
+
'waiting_on_agent',
|
|
23
|
+
'escalated',
|
|
24
|
+
'resolved',
|
|
25
|
+
'closed',
|
|
26
|
+
'reopened',
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{ value: 'priority', label: 'Priority', type: 'enum', options: ['low', 'medium', 'high', 'urgent', 'critical'] },
|
|
30
|
+
{
|
|
31
|
+
value: 'type',
|
|
32
|
+
label: 'Type',
|
|
33
|
+
type: 'enum',
|
|
34
|
+
options: ['question', 'problem', 'incident', 'task', 'feature_request'],
|
|
35
|
+
},
|
|
36
|
+
{ value: 'channel', label: 'Channel', type: 'enum', options: ['web', 'email', 'chat', 'api', 'phone'] },
|
|
37
|
+
{ value: 'tags', label: 'Tags', type: 'text' },
|
|
38
|
+
{ value: 'department', label: 'Department', type: 'text' },
|
|
39
|
+
{ value: 'assigned_agent', label: 'Assigned Agent', type: 'text' },
|
|
40
|
+
{ value: 'subject', label: 'Subject', type: 'text' },
|
|
41
|
+
{ value: 'hours_since_created', label: 'Hours Since Created', type: 'number' },
|
|
42
|
+
{ value: 'hours_since_updated', label: 'Hours Since Updated', type: 'number' },
|
|
43
|
+
{ value: 'reply_count', label: 'Reply Count', type: 'number' },
|
|
44
|
+
{ value: 'custom_field', label: 'Custom Field', type: 'text' },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const operatorsByType = {
|
|
48
|
+
enum: [
|
|
49
|
+
{ value: 'equals', label: 'equals' },
|
|
50
|
+
{ value: 'not_equals', label: 'not equals' },
|
|
51
|
+
{ value: 'in', label: 'in' },
|
|
52
|
+
],
|
|
53
|
+
text: [
|
|
54
|
+
{ value: 'equals', label: 'equals' },
|
|
55
|
+
{ value: 'not_equals', label: 'not equals' },
|
|
56
|
+
{ value: 'contains', label: 'contains' },
|
|
57
|
+
{ value: 'is_empty', label: 'is empty' },
|
|
58
|
+
{ value: 'matches', label: 'matches' },
|
|
59
|
+
],
|
|
60
|
+
number: [
|
|
61
|
+
{ value: 'equals', label: 'equals' },
|
|
62
|
+
{ value: 'not_equals', label: 'not equals' },
|
|
63
|
+
{ value: 'greater_than', label: 'greater than' },
|
|
64
|
+
{ value: 'less_than', label: 'less than' },
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const data = computed(() => props.modelValue);
|
|
69
|
+
|
|
70
|
+
function update(patch) {
|
|
71
|
+
emit('update:modelValue', { ...data.value, ...patch });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function toggleMatch() {
|
|
75
|
+
update({ match: data.value.match === 'all' ? 'any' : 'all' });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function addCondition() {
|
|
79
|
+
const conditions = [...(data.value.conditions || []), { field: 'status', operator: 'equals', value: '' }];
|
|
80
|
+
update({ conditions });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function removeCondition(index) {
|
|
84
|
+
const conditions = data.value.conditions.filter((_, i) => i !== index);
|
|
85
|
+
update({ conditions });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function updateCondition(index, patch) {
|
|
89
|
+
const conditions = data.value.conditions.map((c, i) => (i === index ? { ...c, ...patch } : c));
|
|
90
|
+
update({ conditions });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getFieldConfig(fieldValue) {
|
|
94
|
+
return fields.find((f) => f.value === fieldValue) || fields[0];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getOperators(fieldValue) {
|
|
98
|
+
const field = getFieldConfig(fieldValue);
|
|
99
|
+
return operatorsByType[field.type] || operatorsByType.text;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function onFieldChange(index, newField) {
|
|
103
|
+
const operators = getOperators(newField);
|
|
104
|
+
updateCondition(index, { field: newField, operator: operators[0].value, value: '' });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const previewText = computed(() => {
|
|
108
|
+
if (!data.value.conditions?.length) return '';
|
|
109
|
+
const joiner = data.value.match === 'all' ? ' AND ' : ' OR ';
|
|
110
|
+
return data.value.conditions
|
|
111
|
+
.map((c) => {
|
|
112
|
+
const field = getFieldConfig(c.field);
|
|
113
|
+
const opLabel =
|
|
114
|
+
(operatorsByType[field.type] || []).find((o) => o.value === c.operator)?.label || c.operator;
|
|
115
|
+
if (c.operator === 'is_empty') return `${field.label} is empty`;
|
|
116
|
+
const val = Array.isArray(c.value) ? `[${c.value.join(', ')}]` : c.value;
|
|
117
|
+
return `${field.label} ${opLabel} ${val}`;
|
|
118
|
+
})
|
|
119
|
+
.join(joiner);
|
|
120
|
+
});
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<template>
|
|
124
|
+
<div class="space-y-4">
|
|
125
|
+
<!-- Match type toggle -->
|
|
126
|
+
<div class="flex items-center gap-3">
|
|
127
|
+
<span class="text-sm text-[var(--esc-panel-text-muted)]">Match:</span>
|
|
128
|
+
<button
|
|
129
|
+
type="button"
|
|
130
|
+
class="rounded-lg px-3 py-1.5 text-xs font-semibold transition-colors"
|
|
131
|
+
:class="
|
|
132
|
+
data.match === 'all'
|
|
133
|
+
? 'bg-amber-500/20 text-amber-400'
|
|
134
|
+
: 'bg-[var(--esc-panel-hover)] text-[var(--esc-panel-text-muted)] hover:text-[var(--esc-panel-text-secondary)]'
|
|
135
|
+
"
|
|
136
|
+
@click="toggleMatch"
|
|
137
|
+
>
|
|
138
|
+
All conditions (AND)
|
|
139
|
+
</button>
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
142
|
+
class="rounded-lg px-3 py-1.5 text-xs font-semibold transition-colors"
|
|
143
|
+
:class="
|
|
144
|
+
data.match === 'any'
|
|
145
|
+
? 'bg-amber-500/20 text-amber-400'
|
|
146
|
+
: 'bg-[var(--esc-panel-hover)] text-[var(--esc-panel-text-muted)] hover:text-[var(--esc-panel-text-secondary)]'
|
|
147
|
+
"
|
|
148
|
+
@click="toggleMatch"
|
|
149
|
+
>
|
|
150
|
+
Any condition (OR)
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<!-- Condition rows -->
|
|
155
|
+
<div class="space-y-2">
|
|
156
|
+
<div
|
|
157
|
+
v-for="(condition, i) in data.conditions"
|
|
158
|
+
:key="i"
|
|
159
|
+
class="flex flex-wrap items-center gap-2 rounded-lg border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)] p-3"
|
|
160
|
+
>
|
|
161
|
+
<!-- Field -->
|
|
162
|
+
<select
|
|
163
|
+
:value="condition.field"
|
|
164
|
+
class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
165
|
+
@change="onFieldChange(i, $event.target.value)"
|
|
166
|
+
>
|
|
167
|
+
<option v-for="f in fields" :key="f.value" :value="f.value">{{ f.label }}</option>
|
|
168
|
+
</select>
|
|
169
|
+
|
|
170
|
+
<!-- Operator -->
|
|
171
|
+
<select
|
|
172
|
+
:value="condition.operator"
|
|
173
|
+
class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
174
|
+
@change="updateCondition(i, { operator: $event.target.value })"
|
|
175
|
+
>
|
|
176
|
+
<option v-for="op in getOperators(condition.field)" :key="op.value" :value="op.value">
|
|
177
|
+
{{ op.label }}
|
|
178
|
+
</option>
|
|
179
|
+
</select>
|
|
180
|
+
|
|
181
|
+
<!-- Value (contextual) -->
|
|
182
|
+
<template v-if="condition.operator !== 'is_empty'">
|
|
183
|
+
<!-- Enum select for enum fields -->
|
|
184
|
+
<select
|
|
185
|
+
v-if="getFieldConfig(condition.field).type === 'enum' && condition.operator !== 'in'"
|
|
186
|
+
:value="condition.value"
|
|
187
|
+
class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
188
|
+
@change="updateCondition(i, { value: $event.target.value })"
|
|
189
|
+
>
|
|
190
|
+
<option value="">Select...</option>
|
|
191
|
+
<option v-for="opt in getFieldConfig(condition.field).options" :key="opt" :value="opt">
|
|
192
|
+
{{ opt }}
|
|
193
|
+
</option>
|
|
194
|
+
</select>
|
|
195
|
+
|
|
196
|
+
<!-- Multi-select for "in" operator on enum fields -->
|
|
197
|
+
<select
|
|
198
|
+
v-else-if="getFieldConfig(condition.field).type === 'enum' && condition.operator === 'in'"
|
|
199
|
+
:value="condition.value"
|
|
200
|
+
multiple
|
|
201
|
+
class="min-h-[60px] rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none"
|
|
202
|
+
@change="
|
|
203
|
+
updateCondition(i, { value: Array.from($event.target.selectedOptions, (o) => o.value) })
|
|
204
|
+
"
|
|
205
|
+
>
|
|
206
|
+
<option v-for="opt in getFieldConfig(condition.field).options" :key="opt" :value="opt">
|
|
207
|
+
{{ opt }}
|
|
208
|
+
</option>
|
|
209
|
+
</select>
|
|
210
|
+
|
|
211
|
+
<!-- Number input -->
|
|
212
|
+
<input
|
|
213
|
+
v-else-if="getFieldConfig(condition.field).type === 'number'"
|
|
214
|
+
type="number"
|
|
215
|
+
:value="condition.value"
|
|
216
|
+
placeholder="0"
|
|
217
|
+
class="w-24 rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none focus:ring-1 focus:ring-[var(--esc-panel-border-input)]"
|
|
218
|
+
@input="updateCondition(i, { value: $event.target.value })"
|
|
219
|
+
/>
|
|
220
|
+
|
|
221
|
+
<!-- Text input (default) -->
|
|
222
|
+
<input
|
|
223
|
+
v-else
|
|
224
|
+
type="text"
|
|
225
|
+
:value="condition.value"
|
|
226
|
+
placeholder="Value"
|
|
227
|
+
class="flex-1 rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-2 py-1.5 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none focus:ring-1 focus:ring-[var(--esc-panel-border-input)]"
|
|
228
|
+
@input="updateCondition(i, { value: $event.target.value })"
|
|
229
|
+
/>
|
|
230
|
+
</template>
|
|
231
|
+
|
|
232
|
+
<!-- Remove button -->
|
|
233
|
+
<button
|
|
234
|
+
type="button"
|
|
235
|
+
class="ml-auto flex h-7 w-7 items-center justify-center rounded-lg text-rose-400 transition-colors hover:bg-rose-500/10 hover:text-rose-300"
|
|
236
|
+
@click="removeCondition(i)"
|
|
237
|
+
>
|
|
238
|
+
<svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
239
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
|
240
|
+
</svg>
|
|
241
|
+
</button>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<!-- Add condition button -->
|
|
246
|
+
<button
|
|
247
|
+
type="button"
|
|
248
|
+
class="flex items-center gap-1.5 rounded-lg border border-dashed border-[var(--esc-panel-border)] px-3 py-2 text-xs text-[var(--esc-panel-text-muted)] transition-colors hover:border-amber-500/50 hover:text-amber-400"
|
|
249
|
+
@click="addCondition"
|
|
250
|
+
>
|
|
251
|
+
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
252
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
|
253
|
+
</svg>
|
|
254
|
+
Add Condition
|
|
255
|
+
</button>
|
|
256
|
+
|
|
257
|
+
<!-- Preview -->
|
|
258
|
+
<div
|
|
259
|
+
v-if="previewText"
|
|
260
|
+
class="rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2.5 text-xs text-amber-300"
|
|
261
|
+
>
|
|
262
|
+
<span class="font-medium">Preview:</span> When {{ previewText }}
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
</template>
|