@escalated-dev/escalated 0.7.0 → 0.7.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.
Files changed (179) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +31 -0
  3. package/package.json +12 -6
  4. package/src/components/ActiveChatsPanel.vue +246 -0
  5. package/src/components/ActivityTimeline.stories.js +55 -55
  6. package/src/components/ActivityTimeline.vue +83 -83
  7. package/src/components/AdminDashboard.stories.js +1423 -1095
  8. package/src/components/AgentLoadIndicator.stories.js +37 -37
  9. package/src/components/AgentLoadIndicator.vue +49 -49
  10. package/src/components/AgentPerformanceCard.vue +44 -44
  11. package/src/components/ArticleEditor.vue +82 -82
  12. package/src/components/AssigneeSelect.vue +37 -37
  13. package/src/components/AttachmentList.vue +13 -1
  14. package/src/components/AuditLogEntry.vue +95 -95
  15. package/src/components/BulkActionBar.vue +166 -166
  16. package/src/components/CategoryTree.vue +89 -89
  17. package/src/components/ChartWidget.vue +46 -46
  18. package/src/components/ChatActionBar.vue +226 -0
  19. package/src/components/ChatBubble.vue +162 -0
  20. package/src/components/ChatComposer.vue +308 -0
  21. package/src/components/ChatQueue.vue +222 -0
  22. package/src/components/ChatThread.vue +197 -0
  23. package/src/components/CollisionWarning.stories.js +30 -30
  24. package/src/components/CollisionWarning.vue +68 -68
  25. package/src/components/ConditionalFieldRules.vue +135 -135
  26. package/src/components/ContextPanel.vue +66 -66
  27. package/src/components/ContextPanelSection.vue +65 -65
  28. package/src/components/CustomFieldRenderer.vue +159 -159
  29. package/src/components/EscalatedLayout.vue +29 -6
  30. package/src/components/FileDropzone.vue +57 -57
  31. package/src/components/FollowButton.stories.js +30 -30
  32. package/src/components/FollowButton.vue +88 -88
  33. package/src/components/KeyboardShortcutHelp.vue +213 -213
  34. package/src/components/KnowledgePanel.vue +122 -122
  35. package/src/components/KpiCard.stories.js +32 -32
  36. package/src/components/KpiCard.vue +88 -88
  37. package/src/components/MacroDropdown.vue +150 -150
  38. package/src/components/MentionDropdown.vue +154 -0
  39. package/src/components/MetricComparison.vue +89 -0
  40. package/src/components/PercentileChart.vue +67 -0
  41. package/src/components/PeriodSelector.vue +98 -0
  42. package/src/components/PermissionMatrix.vue +107 -107
  43. package/src/components/PinnedNotes.vue +129 -129
  44. package/src/components/PluginSlot.vue +68 -62
  45. package/src/components/PresenceIndicator.vue +46 -2
  46. package/src/components/PriorityBadge.stories.js +33 -33
  47. package/src/components/PriorityBadge.vue +46 -46
  48. package/src/components/ReplyComposer.vue +81 -18
  49. package/src/components/ReplyThread.vue +40 -2
  50. package/src/components/ReportChart.vue +395 -0
  51. package/src/components/ReportExportButton.vue +108 -0
  52. package/src/components/SatisfactionRating.vue +180 -180
  53. package/src/components/SaveViewDialog.vue +172 -0
  54. package/src/components/SavedViewSidebar.vue +208 -0
  55. package/src/components/ScheduleEditor.vue +104 -104
  56. package/src/components/SideConversation.vue +165 -165
  57. package/src/components/SideConversationList.vue +147 -147
  58. package/src/components/SkillTagManager.vue +79 -79
  59. package/src/components/SlaComplianceChart.vue +46 -53
  60. package/src/components/SlaTimer.stories.js +35 -35
  61. package/src/components/SlaTimer.vue +62 -62
  62. package/src/components/SnoozeButton.vue +247 -0
  63. package/src/components/StatsCard.stories.js +24 -24
  64. package/src/components/StatsCard.vue +58 -58
  65. package/src/components/StatusBadge.stories.js +53 -53
  66. package/src/components/StatusBadge.vue +78 -78
  67. package/src/components/TagSelect.vue +84 -84
  68. package/src/components/TicketFilters.vue +270 -225
  69. package/src/components/TicketLinkPanel.vue +193 -193
  70. package/src/components/TicketList.vue +655 -594
  71. package/src/components/TicketMergeDialog.vue +157 -157
  72. package/src/components/TicketSplitDialog.vue +98 -0
  73. package/src/components/TotpInput.stories.js +9 -9
  74. package/src/components/TotpInput.vue +81 -81
  75. package/src/components/TwoFactorSetup.vue +113 -113
  76. package/src/components/VariableTokenInput.vue +111 -0
  77. package/src/components/WorkflowActionConfig.vue +287 -0
  78. package/src/components/WorkflowActionList.vue +350 -0
  79. package/src/components/WorkflowConditionBuilder.vue +265 -0
  80. package/src/components/WorkflowTriggerSelector.vue +125 -0
  81. package/src/composables/useChat.js +187 -0
  82. package/src/composables/useI18n.js +80 -80
  83. package/src/composables/useKeyboardShortcuts.js +46 -46
  84. package/src/composables/useMentions.js +134 -0
  85. package/src/composables/usePluginExtensions.js +159 -159
  86. package/src/composables/usePluginHooks.js +65 -65
  87. package/src/composables/useRealtime.js +182 -0
  88. package/src/defineEscalatedPlugin.js +76 -76
  89. package/src/index.js +84 -72
  90. package/src/locales/ar.json +727 -0
  91. package/src/locales/de.json +678 -430
  92. package/src/locales/en.json +717 -455
  93. package/src/locales/es.json +679 -430
  94. package/src/locales/fr.json +680 -431
  95. package/src/locales/index.js +12 -2
  96. package/src/locales/it.json +727 -0
  97. package/src/locales/ja.json +727 -0
  98. package/src/locales/ko.json +727 -0
  99. package/src/locales/nl.json +727 -0
  100. package/src/locales/pl.json +727 -0
  101. package/src/locales/pt-BR.json +727 -0
  102. package/src/locales/ru.json +727 -0
  103. package/src/locales/tr.json +727 -0
  104. package/src/locales/zh-CN.json +727 -0
  105. package/src/pages/Admin/ApiTokens/Index.vue +381 -381
  106. package/src/pages/Admin/AuditLog/Index.vue +154 -154
  107. package/src/pages/Admin/BusinessHours/Form.vue +172 -172
  108. package/src/pages/Admin/BusinessHours/Index.vue +113 -113
  109. package/src/pages/Admin/CannedResponses/Index.vue +127 -127
  110. package/src/pages/Admin/Capacity/Index.vue +134 -134
  111. package/src/pages/Admin/CustomFields/Form.vue +195 -195
  112. package/src/pages/Admin/CustomFields/Index.vue +134 -134
  113. package/src/pages/Admin/CustomObjects/Form.vue +202 -202
  114. package/src/pages/Admin/CustomObjects/Index.vue +127 -127
  115. package/src/pages/Admin/CustomObjects/Records.vue +228 -228
  116. package/src/pages/Admin/Departments/Form.vue +75 -75
  117. package/src/pages/Admin/Departments/Index.vue +110 -109
  118. package/src/pages/Admin/EscalationRules/Form.vue +157 -157
  119. package/src/pages/Admin/EscalationRules/Index.vue +178 -178
  120. package/src/pages/Admin/Import/Connect.vue +0 -1
  121. package/src/pages/Admin/Import/Index.vue +1 -1
  122. package/src/pages/Admin/Import/Progress.vue +1 -1
  123. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -142
  124. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -195
  125. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -193
  126. package/src/pages/Admin/Macros/Index.vue +448 -448
  127. package/src/pages/Admin/Plugins/Index.vue +327 -327
  128. package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
  129. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -115
  130. package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
  131. package/src/pages/Admin/Reports/Cohorts.vue +180 -0
  132. package/src/pages/Admin/Reports/Comparison.vue +141 -0
  133. package/src/pages/Admin/Reports/CsatReport.vue +127 -127
  134. package/src/pages/Admin/Reports/Dashboard.vue +36 -21
  135. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
  136. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
  137. package/src/pages/Admin/Reports/SlaReport.vue +162 -166
  138. package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
  139. package/src/pages/Admin/Reports.vue +206 -206
  140. package/src/pages/Admin/Roles/Form.vue +71 -71
  141. package/src/pages/Admin/Roles/Index.vue +122 -122
  142. package/src/pages/Admin/Settings/CsatSettings.vue +165 -165
  143. package/src/pages/Admin/Settings/DataRetention.vue +182 -182
  144. package/src/pages/Admin/Settings/EmailSettings.vue +243 -243
  145. package/src/pages/Admin/Settings/Sandbox.vue +135 -135
  146. package/src/pages/Admin/Settings/SsoSettings.vue +218 -218
  147. package/src/pages/Admin/Settings/TwoFactor.vue +110 -110
  148. package/src/pages/Admin/Settings.vue +1008 -468
  149. package/src/pages/Admin/Skills/Form.vue +53 -53
  150. package/src/pages/Admin/Skills/Index.vue +94 -94
  151. package/src/pages/Admin/SlaPolicies/Form.vue +118 -118
  152. package/src/pages/Admin/SlaPolicies/Index.vue +121 -120
  153. package/src/pages/Admin/Statuses/Form.vue +114 -114
  154. package/src/pages/Admin/Statuses/Index.vue +153 -153
  155. package/src/pages/Admin/Tags/Index.vue +191 -191
  156. package/src/pages/Admin/Tickets/Index.vue +126 -91
  157. package/src/pages/Admin/Tickets/Show.vue +29 -0
  158. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -120
  159. package/src/pages/Admin/Webhooks/Form.vue +110 -110
  160. package/src/pages/Admin/Webhooks/Index.vue +136 -136
  161. package/src/pages/Admin/Workflows/Builder.vue +207 -0
  162. package/src/pages/Admin/Workflows/Index.vue +235 -0
  163. package/src/pages/Admin/Workflows/Logs.vue +286 -0
  164. package/src/pages/Agent/TicketIndex.vue +112 -88
  165. package/src/pages/Agent/TicketShow.vue +192 -60
  166. package/src/pages/Customer/Create.vue +1 -1
  167. package/src/pages/Customer/Index.vue +31 -31
  168. package/src/pages/Customer/KnowledgeBase/Article.vue +4 -2
  169. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -151
  170. package/src/pages/Customer/Show.vue +69 -63
  171. package/src/pages/Guest/Create.vue +40 -15
  172. package/src/pages/Guest/Show.vue +124 -93
  173. package/src/plugin.js +25 -0
  174. package/src/utils/mentionHighlight.js +24 -0
  175. package/src/utils/sanitizeHtml.js +78 -64
  176. package/src/widget/EscalatedWidget.vue +804 -0
  177. package/src/widget/index.js +254 -0
  178. package/src/pages/Admin/Automations/Form.vue +0 -184
  179. package/src/pages/Admin/Automations/Index.vue +0 -129
@@ -1,448 +1,448 @@
1
- <script setup>
2
- import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
- import { useForm, router } from '@inertiajs/vue3';
4
- import { ref, computed } from 'vue';
5
-
6
- defineProps({ macros: Array });
7
-
8
- const showForm = ref(false);
9
- const editingMacro = ref(null);
10
-
11
- const form = useForm({
12
- name: '',
13
- description: '',
14
- is_shared: false,
15
- actions: [],
16
- });
17
-
18
- const actionTypes = [
19
- { value: 'status', label: 'Set Status' },
20
- { value: 'priority', label: 'Set Priority' },
21
- { value: 'assign', label: 'Assign To' },
22
- { value: 'tags', label: 'Add Tags' },
23
- { value: 'department', label: 'Move to Department' },
24
- { value: 'reply', label: 'Send Reply' },
25
- { value: 'note', label: 'Add Internal Note' },
26
- ];
27
-
28
- const statusOptions = ['open', 'in_progress', 'waiting_on_customer', 'resolved', 'closed'];
29
- const priorityOptions = ['low', 'medium', 'high', 'urgent', 'critical'];
30
-
31
- function addAction() {
32
- form.actions.push({ type: 'status', value: '', order: form.actions.length });
33
- }
34
-
35
- function removeAction(index) {
36
- form.actions.splice(index, 1);
37
- form.actions.forEach((a, i) => {
38
- a.order = i;
39
- });
40
- }
41
-
42
- function moveAction(index, direction) {
43
- const newIndex = index + direction;
44
- if (newIndex < 0 || newIndex >= form.actions.length) return;
45
- const temp = form.actions[index];
46
- form.actions[index] = form.actions[newIndex];
47
- form.actions[newIndex] = temp;
48
- form.actions.forEach((a, i) => {
49
- a.order = i;
50
- });
51
- }
52
-
53
- function create() {
54
- form.post(route('escalated.admin.macros.store'), {
55
- onSuccess: () => {
56
- form.reset();
57
- showForm.value = false;
58
- },
59
- });
60
- }
61
-
62
- function startEdit(macro) {
63
- editingMacro.value = macro.id;
64
- form.name = macro.name;
65
- form.description = macro.description || '';
66
- form.is_shared = macro.is_shared || false;
67
- form.actions = (macro.actions || []).map((a, i) => ({
68
- type: a.type,
69
- value: a.value || '',
70
- order: a.order ?? i,
71
- }));
72
- showForm.value = true;
73
- }
74
-
75
- function update() {
76
- form.put(route('escalated.admin.macros.update', editingMacro.value), {
77
- onSuccess: () => {
78
- editingMacro.value = null;
79
- form.reset();
80
- showForm.value = false;
81
- },
82
- });
83
- }
84
-
85
- function destroy(id) {
86
- if (confirm('Delete this macro? This cannot be undone.')) {
87
- router.delete(route('escalated.admin.macros.destroy', id));
88
- }
89
- }
90
-
91
- function cancelEdit() {
92
- editingMacro.value = null;
93
- form.reset();
94
- showForm.value = false;
95
- }
96
-
97
- function handleSubmit() {
98
- if (editingMacro.value) {
99
- update();
100
- } else {
101
- create();
102
- }
103
- }
104
-
105
- const inputClass =
106
- 'w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 placeholder-neutral-600 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
107
- const selectClass =
108
- 'rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
109
- </script>
110
-
111
- <template>
112
- <EscalatedLayout title="Macros">
113
- <!-- Top bar -->
114
- <div class="mb-4 flex items-center justify-between">
115
- <p class="text-sm text-[var(--esc-panel-text-muted)]">Macros automate repetitive actions on tickets.</p>
116
- <button
117
- :class="
118
- showForm
119
- ? 'rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-4 py-2 text-sm font-medium text-[var(--esc-panel-text-secondary)] transition-colors hover:bg-[var(--esc-panel-hover)]'
120
- : 'rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-4 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)]'
121
- "
122
- @click="showForm ? cancelEdit() : (showForm = true)"
123
- >
124
- {{ showForm ? 'Cancel' : 'Create Macro' }}
125
- </button>
126
- </div>
127
-
128
- <!-- Create/Edit form -->
129
- <form
130
- v-if="showForm"
131
- class="mb-6 space-y-4 rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)] p-5"
132
- @submit.prevent="handleSubmit"
133
- >
134
- <div class="grid grid-cols-2 gap-4">
135
- <div>
136
- <label class="mb-1 block text-sm font-medium text-[var(--esc-panel-text-secondary)]">Name</label>
137
- <input
138
- v-model="form.name"
139
- type="text"
140
- required
141
- placeholder="e.g., Close & Thank"
142
- :class="inputClass"
143
- />
144
- </div>
145
- <div>
146
- <label class="mb-1 block text-sm font-medium text-[var(--esc-panel-text-secondary)]"
147
- >Description</label
148
- >
149
- <input
150
- v-model="form.description"
151
- type="text"
152
- placeholder="Optional description"
153
- :class="inputClass"
154
- />
155
- </div>
156
- </div>
157
-
158
- <div class="flex items-center gap-3">
159
- <label class="flex items-center gap-2">
160
- <input
161
- v-model="form.is_shared"
162
- type="checkbox"
163
- class="rounded border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface)] text-cyan-500 focus:ring-[var(--esc-panel-border-input)]"
164
- />
165
- <span class="text-sm text-[var(--esc-panel-text-secondary)]">Shared with all agents</span>
166
- </label>
167
- </div>
168
-
169
- <!-- Action builder -->
170
- <div>
171
- <div class="mb-2 flex items-center justify-between">
172
- <label class="text-sm font-medium text-[var(--esc-panel-text-secondary)]">Actions</label>
173
- <button
174
- type="button"
175
- class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-3 py-1.5 text-xs font-medium text-[var(--esc-panel-text-tertiary)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-secondary)]"
176
- @click="addAction"
177
- >
178
- + Add Action
179
- </button>
180
- </div>
181
-
182
- <div
183
- v-if="!form.actions.length"
184
- class="rounded-lg border border-dashed border-[var(--esc-panel-border-input)] px-4 py-6 text-center"
185
- >
186
- <p class="text-sm text-[var(--esc-panel-text-muted)]">
187
- No actions yet. Add actions to define what this macro does.
188
- </p>
189
- </div>
190
-
191
- <div v-else class="space-y-2">
192
- <div
193
- v-for="(action, index) in form.actions"
194
- :key="index"
195
- class="flex items-center gap-2 rounded-lg border border-[var(--esc-panel-border)] bg-[var(--esc-panel-hover)] p-3"
196
- >
197
- <!-- Order controls -->
198
- <div class="flex flex-col gap-0.5">
199
- <button
200
- type="button"
201
- :disabled="index === 0"
202
- class="rounded p-0.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-tertiary)] disabled:opacity-30"
203
- @click="moveAction(index, -1)"
204
- >
205
- <svg
206
- class="h-3.5 w-3.5"
207
- fill="none"
208
- stroke="currentColor"
209
- stroke-width="2"
210
- viewBox="0 0 24 24"
211
- >
212
- <path
213
- stroke-linecap="round"
214
- stroke-linejoin="round"
215
- d="M4.5 15.75l7.5-7.5 7.5 7.5"
216
- />
217
- </svg>
218
- </button>
219
- <button
220
- type="button"
221
- :disabled="index === form.actions.length - 1"
222
- class="rounded p-0.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-tertiary)] disabled:opacity-30"
223
- @click="moveAction(index, 1)"
224
- >
225
- <svg
226
- class="h-3.5 w-3.5"
227
- fill="none"
228
- stroke="currentColor"
229
- stroke-width="2"
230
- viewBox="0 0 24 24"
231
- >
232
- <path
233
- stroke-linecap="round"
234
- stroke-linejoin="round"
235
- d="M19.5 8.25l-7.5 7.5-7.5-7.5"
236
- />
237
- </svg>
238
- </button>
239
- </div>
240
-
241
- <!-- Action number -->
242
- <span
243
- class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--esc-panel-hover)] text-xs font-semibold text-[var(--esc-panel-text-muted)]"
244
- >
245
- {{ index + 1 }}
246
- </span>
247
-
248
- <!-- Type dropdown -->
249
- <select v-model="action.type" :class="selectClass">
250
- <option v-for="at in actionTypes" :key="at.value" :value="at.value">{{ at.label }}</option>
251
- </select>
252
-
253
- <!-- Value input (context-dependent) -->
254
- <select v-if="action.type === 'status'" v-model="action.value" :class="[selectClass, 'flex-1']">
255
- <option value="">Select status...</option>
256
- <option v-for="s in statusOptions" :key="s" :value="s">{{ s.replace(/_/g, ' ') }}</option>
257
- </select>
258
-
259
- <select
260
- v-else-if="action.type === 'priority'"
261
- v-model="action.value"
262
- :class="[selectClass, 'flex-1']"
263
- >
264
- <option value="">Select priority...</option>
265
- <option v-for="p in priorityOptions" :key="p" :value="p">{{ p }}</option>
266
- </select>
267
-
268
- <input
269
- v-else-if="action.type === 'assign'"
270
- v-model="action.value"
271
- type="text"
272
- placeholder="Agent ID or email"
273
- :class="[inputClass, 'flex-1']"
274
- />
275
-
276
- <input
277
- v-else-if="action.type === 'tags'"
278
- v-model="action.value"
279
- type="text"
280
- placeholder="Comma-separated tag names"
281
- :class="[inputClass, 'flex-1']"
282
- />
283
-
284
- <input
285
- v-else-if="action.type === 'department'"
286
- v-model="action.value"
287
- type="text"
288
- placeholder="Department ID or name"
289
- :class="[inputClass, 'flex-1']"
290
- />
291
-
292
- <textarea
293
- v-else-if="action.type === 'reply' || action.type === 'note'"
294
- v-model="action.value"
295
- rows="2"
296
- :placeholder="action.type === 'reply' ? 'Reply message...' : 'Note content...'"
297
- :class="[inputClass, 'flex-1']"
298
- >
299
- </textarea>
300
-
301
- <input
302
- v-else
303
- v-model="action.value"
304
- type="text"
305
- placeholder="Value"
306
- :class="[inputClass, 'flex-1']"
307
- />
308
-
309
- <!-- Remove -->
310
- <button
311
- type="button"
312
- class="shrink-0 rounded-lg p-1.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-rose-500/10 hover:text-rose-400"
313
- @click="removeAction(index)"
314
- >
315
- <svg
316
- class="h-4 w-4"
317
- fill="none"
318
- stroke="currentColor"
319
- stroke-width="1.5"
320
- viewBox="0 0 24 24"
321
- >
322
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
323
- </svg>
324
- </button>
325
- </div>
326
- </div>
327
- </div>
328
-
329
- <!-- Submit -->
330
- <div class="flex justify-end">
331
- <button
332
- type="submit"
333
- :disabled="form.processing"
334
- class="rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-5 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)] disabled:opacity-50"
335
- >
336
- {{ editingMacro ? 'Update Macro' : 'Create Macro' }}
337
- </button>
338
- </div>
339
- </form>
340
-
341
- <!-- Macros table -->
342
- <div class="overflow-hidden rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)]">
343
- <table class="min-w-full divide-y divide-[var(--esc-panel-border)]">
344
- <thead>
345
- <tr class="bg-[var(--esc-panel-hover)]">
346
- <th
347
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
348
- >
349
- Name
350
- </th>
351
- <th
352
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
353
- >
354
- Description
355
- </th>
356
- <th
357
- class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
358
- >
359
- Actions
360
- </th>
361
- <th
362
- class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
363
- >
364
- Shared
365
- </th>
366
- <th
367
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
368
- >
369
- Creator
370
- </th>
371
- <th
372
- class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
373
- ></th>
374
- </tr>
375
- </thead>
376
- <tbody class="divide-y divide-[var(--esc-panel-border)]">
377
- <tr v-if="!macros?.length">
378
- <td colspan="6" class="px-4 py-12 text-center">
379
- <svg
380
- class="mx-auto mb-3 h-8 w-8 text-[var(--esc-panel-text-muted)]"
381
- fill="none"
382
- stroke="currentColor"
383
- stroke-width="1.5"
384
- viewBox="0 0 24 24"
385
- >
386
- <path
387
- stroke-linecap="round"
388
- stroke-linejoin="round"
389
- d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"
390
- />
391
- </svg>
392
- <p class="text-sm text-[var(--esc-panel-text-muted)]">No macros yet</p>
393
- <p class="mt-1 text-xs text-[var(--esc-panel-text-muted)]">
394
- Create macros to automate repetitive ticket actions
395
- </p>
396
- </td>
397
- </tr>
398
- <tr
399
- v-for="macro in macros"
400
- :key="macro.id"
401
- class="transition-colors hover:bg-[var(--esc-panel-hover)]"
402
- >
403
- <td class="px-4 py-3">
404
- <span class="text-sm font-medium text-[var(--esc-panel-text-secondary)]">{{
405
- macro.name
406
- }}</span>
407
- </td>
408
- <td class="px-4 py-3">
409
- <span class="text-sm text-[var(--esc-panel-text-tertiary)]">{{
410
- macro.description || '--'
411
- }}</span>
412
- </td>
413
- <td class="px-4 py-3 text-center">
414
- <span
415
- class="inline-flex items-center rounded-full bg-[var(--esc-panel-hover)] px-2 py-0.5 text-xs font-medium text-[var(--esc-panel-text-tertiary)] ring-1 ring-[var(--esc-panel-border)]"
416
- >
417
- {{ macro.actions?.length || 0 }}
418
- </span>
419
- </td>
420
- <td class="px-4 py-3 text-center">
421
- <span
422
- v-if="macro.is_shared"
423
- class="inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20"
424
- >
425
- Shared
426
- </span>
427
- <span v-else class="text-xs text-[var(--esc-panel-text-muted)]">Private</span>
428
- </td>
429
- <td class="px-4 py-3 text-sm text-[var(--esc-panel-text-tertiary)]">
430
- {{ macro.creator?.name || macro.user?.name || '--' }}
431
- </td>
432
- <td class="px-4 py-3 text-right text-sm">
433
- <button
434
- class="text-[var(--esc-panel-text-secondary)] hover:text-[var(--esc-panel-text)]"
435
- @click="startEdit(macro)"
436
- >
437
- Edit
438
- </button>
439
- <button class="ml-3 text-rose-400 hover:text-rose-300" @click="destroy(macro.id)">
440
- Delete
441
- </button>
442
- </td>
443
- </tr>
444
- </tbody>
445
- </table>
446
- </div>
447
- </EscalatedLayout>
448
- </template>
1
+ <script setup>
2
+ import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
+ import { useForm, router } from '@inertiajs/vue3';
4
+ import { ref } from 'vue';
5
+
6
+ defineProps({ macros: Array });
7
+
8
+ const showForm = ref(false);
9
+ const editingMacro = ref(null);
10
+
11
+ const form = useForm({
12
+ name: '',
13
+ description: '',
14
+ is_shared: false,
15
+ actions: [],
16
+ });
17
+
18
+ const actionTypes = [
19
+ { value: 'status', label: 'Set Status' },
20
+ { value: 'priority', label: 'Set Priority' },
21
+ { value: 'assign', label: 'Assign To' },
22
+ { value: 'tags', label: 'Add Tags' },
23
+ { value: 'department', label: 'Move to Department' },
24
+ { value: 'reply', label: 'Send Reply' },
25
+ { value: 'note', label: 'Add Internal Note' },
26
+ ];
27
+
28
+ const statusOptions = ['open', 'in_progress', 'waiting_on_customer', 'resolved', 'closed'];
29
+ const priorityOptions = ['low', 'medium', 'high', 'urgent', 'critical'];
30
+
31
+ function addAction() {
32
+ form.actions.push({ type: 'status', value: '', order: form.actions.length });
33
+ }
34
+
35
+ function removeAction(index) {
36
+ form.actions.splice(index, 1);
37
+ form.actions.forEach((a, i) => {
38
+ a.order = i;
39
+ });
40
+ }
41
+
42
+ function moveAction(index, direction) {
43
+ const newIndex = index + direction;
44
+ if (newIndex < 0 || newIndex >= form.actions.length) return;
45
+ const temp = form.actions[index];
46
+ form.actions[index] = form.actions[newIndex];
47
+ form.actions[newIndex] = temp;
48
+ form.actions.forEach((a, i) => {
49
+ a.order = i;
50
+ });
51
+ }
52
+
53
+ function create() {
54
+ form.post(route('escalated.admin.macros.store'), {
55
+ onSuccess: () => {
56
+ form.reset();
57
+ showForm.value = false;
58
+ },
59
+ });
60
+ }
61
+
62
+ function startEdit(macro) {
63
+ editingMacro.value = macro.id;
64
+ form.name = macro.name;
65
+ form.description = macro.description || '';
66
+ form.is_shared = macro.is_shared || false;
67
+ form.actions = (macro.actions || []).map((a, i) => ({
68
+ type: a.type,
69
+ value: a.value || '',
70
+ order: a.order ?? i,
71
+ }));
72
+ showForm.value = true;
73
+ }
74
+
75
+ function update() {
76
+ form.put(route('escalated.admin.macros.update', editingMacro.value), {
77
+ onSuccess: () => {
78
+ editingMacro.value = null;
79
+ form.reset();
80
+ showForm.value = false;
81
+ },
82
+ });
83
+ }
84
+
85
+ function destroy(id) {
86
+ if (confirm('Delete this macro? This cannot be undone.')) {
87
+ router.delete(route('escalated.admin.macros.destroy', id));
88
+ }
89
+ }
90
+
91
+ function cancelEdit() {
92
+ editingMacro.value = null;
93
+ form.reset();
94
+ showForm.value = false;
95
+ }
96
+
97
+ function handleSubmit() {
98
+ if (editingMacro.value) {
99
+ update();
100
+ } else {
101
+ create();
102
+ }
103
+ }
104
+
105
+ const inputClass =
106
+ 'w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 placeholder-neutral-600 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
107
+ const selectClass =
108
+ 'rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
109
+ </script>
110
+
111
+ <template>
112
+ <EscalatedLayout title="Macros">
113
+ <!-- Top bar -->
114
+ <div class="mb-4 flex items-center justify-between">
115
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">Macros automate repetitive actions on tickets.</p>
116
+ <button
117
+ :class="
118
+ showForm
119
+ ? 'rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-4 py-2 text-sm font-medium text-[var(--esc-panel-text-secondary)] transition-colors hover:bg-[var(--esc-panel-hover)]'
120
+ : 'rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-4 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)]'
121
+ "
122
+ @click="showForm ? cancelEdit() : (showForm = true)"
123
+ >
124
+ {{ showForm ? 'Cancel' : 'Create Macro' }}
125
+ </button>
126
+ </div>
127
+
128
+ <!-- Create/Edit form -->
129
+ <form
130
+ v-if="showForm"
131
+ class="mb-6 space-y-4 rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)] p-5"
132
+ @submit.prevent="handleSubmit"
133
+ >
134
+ <div class="grid grid-cols-2 gap-4">
135
+ <div>
136
+ <label class="mb-1 block text-sm font-medium text-[var(--esc-panel-text-secondary)]">Name</label>
137
+ <input
138
+ v-model="form.name"
139
+ type="text"
140
+ required
141
+ placeholder="e.g., Close & Thank"
142
+ :class="inputClass"
143
+ />
144
+ </div>
145
+ <div>
146
+ <label class="mb-1 block text-sm font-medium text-[var(--esc-panel-text-secondary)]"
147
+ >Description</label
148
+ >
149
+ <input
150
+ v-model="form.description"
151
+ type="text"
152
+ placeholder="Optional description"
153
+ :class="inputClass"
154
+ />
155
+ </div>
156
+ </div>
157
+
158
+ <div class="flex items-center gap-3">
159
+ <label class="flex items-center gap-2">
160
+ <input
161
+ v-model="form.is_shared"
162
+ type="checkbox"
163
+ class="rounded border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface)] text-cyan-500 focus:ring-[var(--esc-panel-border-input)]"
164
+ />
165
+ <span class="text-sm text-[var(--esc-panel-text-secondary)]">Shared with all agents</span>
166
+ </label>
167
+ </div>
168
+
169
+ <!-- Action builder -->
170
+ <div>
171
+ <div class="mb-2 flex items-center justify-between">
172
+ <label class="text-sm font-medium text-[var(--esc-panel-text-secondary)]">Actions</label>
173
+ <button
174
+ type="button"
175
+ class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-3 py-1.5 text-xs font-medium text-[var(--esc-panel-text-tertiary)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-secondary)]"
176
+ @click="addAction"
177
+ >
178
+ + Add Action
179
+ </button>
180
+ </div>
181
+
182
+ <div
183
+ v-if="!form.actions.length"
184
+ class="rounded-lg border border-dashed border-[var(--esc-panel-border-input)] px-4 py-6 text-center"
185
+ >
186
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">
187
+ No actions yet. Add actions to define what this macro does.
188
+ </p>
189
+ </div>
190
+
191
+ <div v-else class="space-y-2">
192
+ <div
193
+ v-for="(action, index) in form.actions"
194
+ :key="index"
195
+ class="flex items-center gap-2 rounded-lg border border-[var(--esc-panel-border)] bg-[var(--esc-panel-hover)] p-3"
196
+ >
197
+ <!-- Order controls -->
198
+ <div class="flex flex-col gap-0.5">
199
+ <button
200
+ type="button"
201
+ :disabled="index === 0"
202
+ class="rounded p-0.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-tertiary)] disabled:opacity-30"
203
+ @click="moveAction(index, -1)"
204
+ >
205
+ <svg
206
+ class="h-3.5 w-3.5"
207
+ fill="none"
208
+ stroke="currentColor"
209
+ stroke-width="2"
210
+ viewBox="0 0 24 24"
211
+ >
212
+ <path
213
+ stroke-linecap="round"
214
+ stroke-linejoin="round"
215
+ d="M4.5 15.75l7.5-7.5 7.5 7.5"
216
+ />
217
+ </svg>
218
+ </button>
219
+ <button
220
+ type="button"
221
+ :disabled="index === form.actions.length - 1"
222
+ class="rounded p-0.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-tertiary)] disabled:opacity-30"
223
+ @click="moveAction(index, 1)"
224
+ >
225
+ <svg
226
+ class="h-3.5 w-3.5"
227
+ fill="none"
228
+ stroke="currentColor"
229
+ stroke-width="2"
230
+ viewBox="0 0 24 24"
231
+ >
232
+ <path
233
+ stroke-linecap="round"
234
+ stroke-linejoin="round"
235
+ d="M19.5 8.25l-7.5 7.5-7.5-7.5"
236
+ />
237
+ </svg>
238
+ </button>
239
+ </div>
240
+
241
+ <!-- Action number -->
242
+ <span
243
+ class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--esc-panel-hover)] text-xs font-semibold text-[var(--esc-panel-text-muted)]"
244
+ >
245
+ {{ index + 1 }}
246
+ </span>
247
+
248
+ <!-- Type dropdown -->
249
+ <select v-model="action.type" :class="selectClass">
250
+ <option v-for="at in actionTypes" :key="at.value" :value="at.value">{{ at.label }}</option>
251
+ </select>
252
+
253
+ <!-- Value input (context-dependent) -->
254
+ <select v-if="action.type === 'status'" v-model="action.value" :class="[selectClass, 'flex-1']">
255
+ <option value="">Select status...</option>
256
+ <option v-for="s in statusOptions" :key="s" :value="s">{{ s.replace(/_/g, ' ') }}</option>
257
+ </select>
258
+
259
+ <select
260
+ v-else-if="action.type === 'priority'"
261
+ v-model="action.value"
262
+ :class="[selectClass, 'flex-1']"
263
+ >
264
+ <option value="">Select priority...</option>
265
+ <option v-for="p in priorityOptions" :key="p" :value="p">{{ p }}</option>
266
+ </select>
267
+
268
+ <input
269
+ v-else-if="action.type === 'assign'"
270
+ v-model="action.value"
271
+ type="text"
272
+ placeholder="Agent ID or email"
273
+ :class="[inputClass, 'flex-1']"
274
+ />
275
+
276
+ <input
277
+ v-else-if="action.type === 'tags'"
278
+ v-model="action.value"
279
+ type="text"
280
+ placeholder="Comma-separated tag names"
281
+ :class="[inputClass, 'flex-1']"
282
+ />
283
+
284
+ <input
285
+ v-else-if="action.type === 'department'"
286
+ v-model="action.value"
287
+ type="text"
288
+ placeholder="Department ID or name"
289
+ :class="[inputClass, 'flex-1']"
290
+ />
291
+
292
+ <textarea
293
+ v-else-if="action.type === 'reply' || action.type === 'note'"
294
+ v-model="action.value"
295
+ rows="2"
296
+ :placeholder="action.type === 'reply' ? 'Reply message...' : 'Note content...'"
297
+ :class="[inputClass, 'flex-1']"
298
+ >
299
+ </textarea>
300
+
301
+ <input
302
+ v-else
303
+ v-model="action.value"
304
+ type="text"
305
+ placeholder="Value"
306
+ :class="[inputClass, 'flex-1']"
307
+ />
308
+
309
+ <!-- Remove -->
310
+ <button
311
+ type="button"
312
+ class="shrink-0 rounded-lg p-1.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-rose-500/10 hover:text-rose-400"
313
+ @click="removeAction(index)"
314
+ >
315
+ <svg
316
+ class="h-4 w-4"
317
+ fill="none"
318
+ stroke="currentColor"
319
+ stroke-width="1.5"
320
+ viewBox="0 0 24 24"
321
+ >
322
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
323
+ </svg>
324
+ </button>
325
+ </div>
326
+ </div>
327
+ </div>
328
+
329
+ <!-- Submit -->
330
+ <div class="flex justify-end">
331
+ <button
332
+ type="submit"
333
+ :disabled="form.processing"
334
+ class="rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-5 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)] disabled:opacity-50"
335
+ >
336
+ {{ editingMacro ? 'Update Macro' : 'Create Macro' }}
337
+ </button>
338
+ </div>
339
+ </form>
340
+
341
+ <!-- Macros table -->
342
+ <div class="overflow-hidden rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)]">
343
+ <table class="min-w-full divide-y divide-[var(--esc-panel-border)]">
344
+ <thead>
345
+ <tr class="bg-[var(--esc-panel-hover)]">
346
+ <th
347
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
348
+ >
349
+ Name
350
+ </th>
351
+ <th
352
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
353
+ >
354
+ Description
355
+ </th>
356
+ <th
357
+ class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
358
+ >
359
+ Actions
360
+ </th>
361
+ <th
362
+ class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
363
+ >
364
+ Shared
365
+ </th>
366
+ <th
367
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
368
+ >
369
+ Creator
370
+ </th>
371
+ <th
372
+ class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
373
+ ></th>
374
+ </tr>
375
+ </thead>
376
+ <tbody class="divide-y divide-[var(--esc-panel-border)]">
377
+ <tr v-if="!macros?.length">
378
+ <td colspan="6" class="px-4 py-12 text-center">
379
+ <svg
380
+ class="mx-auto mb-3 h-8 w-8 text-[var(--esc-panel-text-muted)]"
381
+ fill="none"
382
+ stroke="currentColor"
383
+ stroke-width="1.5"
384
+ viewBox="0 0 24 24"
385
+ >
386
+ <path
387
+ stroke-linecap="round"
388
+ stroke-linejoin="round"
389
+ d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"
390
+ />
391
+ </svg>
392
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">No macros yet</p>
393
+ <p class="mt-1 text-xs text-[var(--esc-panel-text-muted)]">
394
+ Create macros to automate repetitive ticket actions
395
+ </p>
396
+ </td>
397
+ </tr>
398
+ <tr
399
+ v-for="macro in macros"
400
+ :key="macro.id"
401
+ class="transition-colors hover:bg-[var(--esc-panel-hover)]"
402
+ >
403
+ <td class="px-4 py-3">
404
+ <span class="text-sm font-medium text-[var(--esc-panel-text-secondary)]">{{
405
+ macro.name
406
+ }}</span>
407
+ </td>
408
+ <td class="px-4 py-3">
409
+ <span class="text-sm text-[var(--esc-panel-text-tertiary)]">{{
410
+ macro.description || '--'
411
+ }}</span>
412
+ </td>
413
+ <td class="px-4 py-3 text-center">
414
+ <span
415
+ class="inline-flex items-center rounded-full bg-[var(--esc-panel-hover)] px-2 py-0.5 text-xs font-medium text-[var(--esc-panel-text-tertiary)] ring-1 ring-[var(--esc-panel-border)]"
416
+ >
417
+ {{ macro.actions?.length || 0 }}
418
+ </span>
419
+ </td>
420
+ <td class="px-4 py-3 text-center">
421
+ <span
422
+ v-if="macro.is_shared"
423
+ class="inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20"
424
+ >
425
+ Shared
426
+ </span>
427
+ <span v-else class="text-xs text-[var(--esc-panel-text-muted)]">Private</span>
428
+ </td>
429
+ <td class="px-4 py-3 text-sm text-[var(--esc-panel-text-tertiary)]">
430
+ {{ macro.creator?.name || macro.user?.name || '--' }}
431
+ </td>
432
+ <td class="px-4 py-3 text-right text-sm">
433
+ <button
434
+ class="text-[var(--esc-panel-text-secondary)] hover:text-[var(--esc-panel-text)]"
435
+ @click="startEdit(macro)"
436
+ >
437
+ Edit
438
+ </button>
439
+ <button class="ml-3 text-rose-400 hover:text-rose-300" @click="destroy(macro.id)">
440
+ Delete
441
+ </button>
442
+ </td>
443
+ </tr>
444
+ </tbody>
445
+ </table>
446
+ </div>
447
+ </EscalatedLayout>
448
+ </template>