@initsolusidigital/worksuite-shell 0.0.0-stage → 0.3.0

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 (75) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +122 -2
  3. package/package.json +44 -4
  4. package/src/components/ai/AppAssistantDraft.vue +120 -0
  5. package/src/components/ai/AppAssistantWidget.vue +245 -0
  6. package/src/components/ai/AppCitedAnswer.vue +86 -0
  7. package/src/components/approvals/AppApprovalInbox.vue +265 -0
  8. package/src/components/approvals/AppApprovalSubjectModal.vue +197 -0
  9. package/src/components/chat/AppChatBubble.vue +324 -0
  10. package/src/components/chat/AppChatList.vue +249 -0
  11. package/src/components/chat/AppChatPanel.vue +315 -0
  12. package/src/components/chat/AppChatWidget.vue +126 -0
  13. package/src/components/communications/AppChannelBadge.vue +47 -0
  14. package/src/components/communications/AppConversationThread.vue +439 -0
  15. package/src/components/customFields/CustomFieldFilterPanel.vue +50 -0
  16. package/src/components/customFields/CustomFieldInput.vue +422 -0
  17. package/src/components/customFields/CustomFieldValue.vue +129 -0
  18. package/src/components/customFields/CustomFieldsSection.vue +65 -0
  19. package/src/components/customFields/fieldTypes.js +23 -0
  20. package/src/components/dashboard/AppCustomWidget.vue +138 -0
  21. package/src/components/dashboard/AppCustomWidgetForm.vue +173 -0
  22. package/src/components/dashboard/AppDashboardGrid.vue +200 -0
  23. package/src/components/dashboard/AppDashboardToolbar.vue +66 -0
  24. package/src/components/dashboard/AppSubAppsCatalog.vue +89 -0
  25. package/src/components/dataTools/AppImportExport.vue +724 -0
  26. package/src/components/dataTools/AppImportSchemaGuide.vue +130 -0
  27. package/src/components/hrMetrics/AppHrMetricsDashboard.vue +231 -0
  28. package/src/components/hrMetrics/AppHrMetricsEmployees.vue +87 -0
  29. package/src/components/hrMetrics/AppHrMetricsStat.vue +61 -0
  30. package/src/components/kpi/AppKpiAppraisalConfig.vue +284 -0
  31. package/src/components/kpi/AppKpiAppraisals.vue +733 -0
  32. package/src/components/kpi/AppKpiDefinitionModal.vue +317 -0
  33. package/src/components/kpi/AppKpiEntryModal.vue +122 -0
  34. package/src/components/kpi/AppKpiLeaderboard.vue +108 -0
  35. package/src/components/kpi/AppKpiMyCard.vue +134 -0
  36. package/src/components/kpi/AppKpiPeriodPicker.vue +115 -0
  37. package/src/components/kpi/AppKpiReportTable.vue +214 -0
  38. package/src/components/kpi/AppKpiScorecard.vue +242 -0
  39. package/src/components/kpi/AppKpiTargetsModal.vue +299 -0
  40. package/src/components/kpi/AppKpiTeam.vue +221 -0
  41. package/src/components/kpi/AppKpiWeightProfiles.vue +244 -0
  42. package/src/components/kpi/AppKpiWorkspace.vue +479 -0
  43. package/src/components/layout/AppGlobalSearch.vue +149 -0
  44. package/src/components/layout/AppLanguagePopup.vue +94 -0
  45. package/src/components/layout/AppLauncherPopup.vue +147 -0
  46. package/src/components/layout/AppLegalConsentModal.vue +484 -0
  47. package/src/components/layout/AppNavbar.vue +402 -0
  48. package/src/components/layout/AppNotificationContent.vue +173 -0
  49. package/src/components/layout/AppNotificationDrawer.vue +98 -0
  50. package/src/components/layout/AppNotificationPopup.vue +67 -0
  51. package/src/components/layout/AppPlatformBanners.vue +192 -0
  52. package/src/components/layout/AppSidebar.vue +226 -0
  53. package/src/components/layout/AppSidebarNav.vue +119 -0
  54. package/src/components/layout/AppUserMenu.vue +89 -0
  55. package/src/components/layout/AppUserMenuContent.vue +59 -0
  56. package/src/composables/useKpi.js +232 -0
  57. package/src/composables/useLgViewport.js +25 -0
  58. package/src/composables/useNavigation.js +177 -0
  59. package/src/layouts/AppLayout.vue +207 -0
  60. package/src/locales/en.json +1362 -0
  61. package/src/locales/id.json +1396 -0
  62. package/src/pages/auth/AccountBlocked.vue +55 -0
  63. package/src/pages/auth/IdentityRedirect.vue +37 -0
  64. package/src/pages/profile/Layout.vue +210 -0
  65. package/src/pages/profile/partials/AccountSection.vue +139 -0
  66. package/src/pages/profile/partials/ApprovalDelegationSection.vue +389 -0
  67. package/src/pages/profile/partials/DevicesCard.vue +222 -0
  68. package/src/pages/profile/partials/PreferencesSection.vue +87 -0
  69. package/src/pages/profile/partials/SecuritySection.vue +93 -0
  70. package/src/pages/profile/partials/SessionsCard.vue +418 -0
  71. package/src/pages/profile/partials/SessionsSection.vue +58 -0
  72. package/src/pages/profile/partials/SupportAccessSection.vue +173 -0
  73. package/src/pages/profile/partials/TrustedDevicesCard.vue +141 -0
  74. package/src/pages/profile/partials/TwoFactorSection.vue +304 -0
  75. package/src/shellSetup.js +46 -0
@@ -0,0 +1,284 @@
1
+ <script setup>
2
+ // Konfigurasi penilaian — master ASPEK (rubrik 1–5) + bobot NILAI AKHIR (KPI vs aspek).
3
+ // Kontrak `kp1-kpi-tracking.md` (aspek & bobot nilai akhir); tulis = `kpis,can_configure`.
4
+ //
5
+ // **Rubrik wajib lima tingkat** (`"1".."5"`): penilai memilih angka sambil membaca kalimat di
6
+ // sampingnya, jadi satu tingkat kosong berarti satu angka yang dipilih tanpa ukuran apa pun.
7
+ //
8
+ // **`applies_to`** menentukan siapa yang dinilai dengan aspek ini: `all` (semua) · `department`
9
+ // (anggota satu departemen — `department_id` wajib) · `leader` (orang yang memimpin orang lain).
10
+ // Siklus yang SUDAH dibuat tak ikut berubah; penilai menyegarkannya lewat "Segarkan aspek".
11
+ //
12
+ // ⚠️ Aspek yang sudah dipakai menilai tak bisa dihapus (422 `has_data`) — jalan keluarnya
13
+ // Nonaktifkan, dan pesannya mengatakan itu. Bobot Σ ≠ 100 → 422 `weights_not_100`.
14
+ import { ref, computed, onMounted } from 'vue'
15
+ import { useI18n } from 'vue-i18n'
16
+ import { Plus, ArrowUp, ArrowDown, Sparkles } from '@lucide/vue'
17
+ import { kpiApi, kpiAspectsApi } from '@initsolusidigital/worksuite-core/api/endpoints/kpi.js'
18
+ import { useFormSubmit } from '@initsolusidigital/worksuite-core/composables/useFormSubmit.js'
19
+ import { normalizeApiError } from '@initsolusidigital/worksuite-core/api/errors.js'
20
+ import AppCard from '@initsolusidigital/worksuite-ui/AppCard.vue'
21
+ import AppBadge from '@initsolusidigital/worksuite-ui/AppBadge.vue'
22
+ import AppButton from '@initsolusidigital/worksuite-ui/AppButton.vue'
23
+ import AppAlert from '@initsolusidigital/worksuite-ui/AppAlert.vue'
24
+ import AppInput from '@initsolusidigital/worksuite-ui/AppInput.vue'
25
+ import AppTextarea from '@initsolusidigital/worksuite-ui/AppTextarea.vue'
26
+ import AppCombobox from '@initsolusidigital/worksuite-ui/AppCombobox.vue'
27
+ import AppModal from '@initsolusidigital/worksuite-ui/AppModal.vue'
28
+ import AppSpinner from '@initsolusidigital/worksuite-ui/AppSpinner.vue'
29
+ import AppEmptyState from '@initsolusidigital/worksuite-ui/AppEmptyState.vue'
30
+
31
+ const props = defineProps({
32
+ companyId: { type: String, required: true },
33
+ /** Departemen `{value,label}` untuk aspek ber-`applies_to: department`. */
34
+ departments: { type: Array, default: () => [] },
35
+ })
36
+
37
+ const { t } = useI18n()
38
+ // Tiga instance terpisah: galat bobot, aksi daftar, dan form aspek tak boleh saling menimpa.
39
+ // Di-destructure karena template TIDAK meng-unwrap ref yang bersarang di objek biasa —
40
+ // `formErrors.name` akan selalu undefined dan galat per kotak tak pernah tampil.
41
+ const { fieldErrors: bobotErrors, formError: bobotError, saving: bobotSaving, submit: submitBobot } = useFormSubmit()
42
+ const { formError: aksiError, saving: aksiSaving, submit: submitAksi } = useFormSubmit()
43
+ const { fieldErrors: formErrors, formError, saving: formSaving, submit: submitForm, clearErrors } = useFormSubmit()
44
+ const rubrikErr = ref({})
45
+
46
+ const aspects = ref([])
47
+ const loading = ref(false)
48
+ const loadError = ref('')
49
+ const weights = ref({ final_kpi_weight: '', final_aspect_weight: '' })
50
+ const weightsErr = ref('')
51
+
52
+ const editing = ref(null)
53
+ const draft = ref(null)
54
+
55
+ const RUBRIK = ['1', '2', '3', '4', '5']
56
+ const appliesOptions = computed(() => ['all', 'department', 'leader']
57
+ .map(v => ({ value: v, label: t(`kpi.aspects.appliesTo.${v}`) })))
58
+ const namaDept = (id) => props.departments.find(d => d.value === id)?.label ?? id
59
+
60
+ const totalBobot = computed(() => (Number(weights.value.final_kpi_weight) || 0) + (Number(weights.value.final_aspect_weight) || 0))
61
+
62
+ async function muat() {
63
+ loading.value = true
64
+ loadError.value = ''
65
+ try {
66
+ const [a, s] = await Promise.all([
67
+ kpiAspectsApi.getList(props.companyId, { include_inactive: 1 }),
68
+ kpiApi.settings(props.companyId),
69
+ ])
70
+ const daftar = a.data.data?.data ?? a.data.data ?? []
71
+ aspects.value = [...daftar].sort((x, y) => (x.order ?? 0) - (y.order ?? 0))
72
+ const st = s.data.data ?? {}
73
+ weights.value = { final_kpi_weight: st.final_kpi_weight ?? '', final_aspect_weight: st.final_aspect_weight ?? '' }
74
+ } catch (err) {
75
+ const e = normalizeApiError(err)
76
+ loadError.value = e.isForbidden ? t('kpi.noPermission') : (e.backendMessage || t('common.serverError'))
77
+ } finally {
78
+ loading.value = false
79
+ }
80
+ }
81
+
82
+ async function simpanBobot() {
83
+ weightsErr.value = ''
84
+ if (Math.abs(totalBobot.value - 100) > 0.005) { weightsErr.value = t('kpi.aspects.errWeights'); return }
85
+ await submitBobot(
86
+ () => kpiApi.updateSettings(props.companyId, {
87
+ final_kpi_weight: Number(weights.value.final_kpi_weight),
88
+ final_aspect_weight: Number(weights.value.final_aspect_weight),
89
+ }),
90
+ {
91
+ successKey: 'common.saveSuccess',
92
+ onError: (e) => { if (e.reason === 'weights_not_100') { weightsErr.value = t('kpi.aspects.errWeights'); bobotError.value = '' } },
93
+ },
94
+ )
95
+ }
96
+
97
+ function buka(a) {
98
+ editing.value = a ?? {}
99
+ draft.value = {
100
+ name: a?.name ?? '',
101
+ description: a?.description ?? '',
102
+ applies_to: a?.applies_to ?? 'all',
103
+ department_id: a?.department_id ?? '',
104
+ order: a?.order ?? (aspects.value.length + 1),
105
+ rubric: Object.fromEntries(RUBRIK.map(k => [k, a?.rubric?.[k] ?? ''])),
106
+ }
107
+ }
108
+ function tutup() { editing.value = null; draft.value = null; rubrikErr.value = {}; clearErrors() }
109
+
110
+ async function simpanAspek() {
111
+ const d = draft.value
112
+ const kosong = RUBRIK.filter(k => !d.rubric[k]?.trim())
113
+ const payload = {
114
+ name: d.name?.trim(),
115
+ description: d.description?.trim() || null,
116
+ applies_to: d.applies_to,
117
+ department_id: d.applies_to === 'department' ? (d.department_id || null) : null,
118
+ order: Number(d.order) || 0,
119
+ rubric: Object.fromEntries(RUBRIK.map(k => [k, d.rubric[k]?.trim()])),
120
+ }
121
+ rubrikErr.value = Object.fromEntries(kosong.map(k => [k, t('kpi.aspects.errRubric')]))
122
+ if (kosong.length) { formError.value = t('common.checkRequired'); return }
123
+ const ok = await submitForm(
124
+ () => (editing.value.id
125
+ ? kpiAspectsApi.update(props.companyId, editing.value.id, payload)
126
+ : kpiAspectsApi.create(props.companyId, payload)),
127
+ {
128
+ require: d.applies_to === 'department' ? ['name', 'department_id'] : ['name'],
129
+ requireIn: d,
130
+ successKey: editing.value.id ? 'common.saveSuccess' : 'common.createSuccess',
131
+ },
132
+ )
133
+ if (ok) { tutup(); await muat() }
134
+ }
135
+
136
+ async function setAktif(a, aktif) {
137
+ const ok = await submitAksi(() => kpiAspectsApi.update(props.companyId, a.id, { is_active: aktif }), { successKey: 'common.saveSuccess' })
138
+ if (ok) await muat()
139
+ }
140
+
141
+ async function geser(i, arah) {
142
+ const j = i + arah
143
+ if (j < 0 || j >= aspects.value.length) return
144
+ const a = aspects.value[i]
145
+ const b = aspects.value[j]
146
+ // Urutan ditulis ulang 1..n untuk kedua baris: nilai `order` lama bisa kembar (bawaan 0),
147
+ // dan menukar dua angka kembar tak menggeser apa pun.
148
+ const urut = aspects.value.map((x, k) => ({ id: x.id, order: k + 1 }))
149
+ urut[i].order = j + 1
150
+ urut[j].order = i + 1
151
+ const ok = await submitAksi(async () => {
152
+ await kpiAspectsApi.update(props.companyId, a.id, { order: urut[i].order })
153
+ return kpiAspectsApi.update(props.companyId, b.id, { order: urut[j].order })
154
+ }, { successKey: 'common.saveSuccess' })
155
+ if (ok) await muat()
156
+ }
157
+
158
+ async function hapus(a) {
159
+ const ok = await submitAksi(() => kpiAspectsApi.remove(props.companyId, a.id), {
160
+ successKey: 'common.deleteSuccess',
161
+ onError: (e) => { if (e.reason === 'has_data') aksiError.value = t('kpi.aspects.errHasData', { name: a.name }) },
162
+ })
163
+ if (ok) await muat()
164
+ }
165
+
166
+ async function pasangBawaan() {
167
+ const ok = await submitAksi(() => kpiAspectsApi.installDefaults(props.companyId), { successKey: 'kpi.aspects.defaultsInstalled' })
168
+ if (ok) await muat()
169
+ }
170
+
171
+ onMounted(muat)
172
+ </script>
173
+
174
+ <template>
175
+ <div class="space-y-6">
176
+ <AppAlert v-if="loadError" variant="error">{{ loadError }}</AppAlert>
177
+ <div v-else-if="loading" class="py-12 text-center"><AppSpinner /></div>
178
+
179
+ <template v-else>
180
+ <!-- Bobot nilai akhir -->
181
+ <AppCard :title="t('kpi.aspects.weightsTitle')" :description="t('kpi.aspects.weightsHint')" title-tag="h3">
182
+ <AppAlert v-if="bobotError" variant="error" class="mb-3">{{ bobotError }}</AppAlert>
183
+ <div class="flex flex-wrap items-end gap-3">
184
+ <div class="w-40">
185
+ <AppInput v-model="weights.final_kpi_weight" type="number" step="any" :label="t('kpi.aspects.kpiWeight')" :error="weightsErr || bobotErrors.final_kpi_weight" />
186
+ </div>
187
+ <div class="w-40">
188
+ <AppInput v-model="weights.final_aspect_weight" type="number" step="any" :label="t('kpi.aspects.aspectWeight')" :error="bobotErrors.final_aspect_weight" />
189
+ </div>
190
+ <span class="pb-2.5 text-sm tabular-nums" :class="Math.abs(totalBobot - 100) < 0.005 ? 'text-gray-500 dark:text-gray-400' : 'text-red-600 dark:text-red-400'">
191
+ Σ {{ totalBobot }}
192
+ </span>
193
+ <AppButton size="lg" :loading="bobotSaving" @click="simpanBobot">{{ t('common.save') }}</AppButton>
194
+ </div>
195
+ </AppCard>
196
+
197
+ <!-- Master aspek -->
198
+ <AppCard :title="t('kpi.aspects.title')" :description="t('kpi.aspects.subtitle')" padding="none" title-tag="h3">
199
+ <template #actions>
200
+ <div class="flex flex-wrap items-center gap-2">
201
+ <AppButton variant="secondary" size="sm" :loading="aksiSaving" @click="pasangBawaan">
202
+ <Sparkles class="w-4 h-4" />{{ t('kpi.aspects.installDefaults') }}
203
+ </AppButton>
204
+ <AppButton size="sm" @click="buka(null)"><Plus class="w-4 h-4" />{{ t('kpi.aspects.add') }}</AppButton>
205
+ </div>
206
+ </template>
207
+
208
+ <AppAlert v-if="aksiError" variant="error" class="m-4">{{ aksiError }}</AppAlert>
209
+
210
+ <div v-if="!aspects.length" class="p-6">
211
+ <AppEmptyState :label="t('kpi.aspects.empty')" :description="t('kpi.aspects.emptyHint')" />
212
+ </div>
213
+
214
+ <ul v-else class="divide-y divide-gray-100 dark:divide-gray-700">
215
+ <li v-for="(a, i) in aspects" :key="a.id" class="px-6 py-4 flex flex-wrap items-start gap-3" :data-kpi-aspect="a.name">
216
+ <div class="flex flex-col gap-0.5 shrink-0">
217
+ <button type="button" class="p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30" :disabled="i === 0" :aria-label="t('kpi.aspects.moveUp')" @click="geser(i, -1)"><ArrowUp class="w-3.5 h-3.5" /></button>
218
+ <button type="button" class="p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30" :disabled="i === aspects.length - 1" :aria-label="t('kpi.aspects.moveDown')" @click="geser(i, 1)"><ArrowDown class="w-3.5 h-3.5" /></button>
219
+ </div>
220
+ <div class="min-w-0 grow">
221
+ <div class="flex flex-wrap items-center gap-1.5">
222
+ <span class="text-sm font-medium text-gray-900 dark:text-white">{{ a.name }}</span>
223
+ <AppBadge color="blue">
224
+ {{ a.applies_to === 'department' ? t('kpi.aspects.appliesToDept', { name: namaDept(a.department_id) }) : t(`kpi.aspects.appliesTo.${a.applies_to}`) }}
225
+ </AppBadge>
226
+ <AppBadge v-if="a.is_active === false" color="gray">{{ t('kpi.definitions.inactive') }}</AppBadge>
227
+ </div>
228
+ <p v-if="a.description" class="text-xs text-gray-500 dark:text-gray-400 mt-0.5">{{ a.description }}</p>
229
+ <ol class="mt-1.5 grid gap-0.5 text-xs text-gray-600 dark:text-gray-300">
230
+ <li v-for="k in RUBRIK" :key="k"><span class="font-medium tabular-nums">{{ k }}</span> — {{ a.rubric?.[k] || '—' }}</li>
231
+ </ol>
232
+ </div>
233
+ <div class="flex items-center gap-1 shrink-0">
234
+ <AppButton variant="ghost" size="sm" @click="buka(a)">{{ t('common.edit') }}</AppButton>
235
+ <AppButton variant="ghost" size="sm" @click="setAktif(a, a.is_active === false)">
236
+ {{ a.is_active === false ? t('kpi.aspects.activate') : t('kpi.aspects.deactivate') }}
237
+ </AppButton>
238
+ <AppButton variant="danger" size="sm" @click="hapus(a)">{{ t('common.delete') }}</AppButton>
239
+ </div>
240
+ </li>
241
+ </ul>
242
+ </AppCard>
243
+ </template>
244
+
245
+ <AppModal v-if="draft" :title="editing?.id ? t('kpi.aspects.editTitle') : t('kpi.aspects.add')" size="lg" @close="tutup">
246
+ <div class="space-y-4">
247
+ <AppAlert v-if="formError" variant="error">{{ formError }}</AppAlert>
248
+ <div class="grid grid-cols-1 sm:grid-cols-[1fr_6rem] gap-4">
249
+ <AppInput v-model="draft.name" :label="t('kpi.aspects.fieldName')" :error="formErrors.name" required />
250
+ <AppInput v-model="draft.order" type="number" :label="t('kpi.aspects.fieldOrder')" :error="formErrors.order" />
251
+ </div>
252
+ <AppTextarea v-model="draft.description" :label="t('kpi.form.fieldDescription')" :rows="2" :error="formErrors.description" />
253
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
254
+ <AppCombobox v-model="draft.applies_to" :label="t('kpi.aspects.fieldAppliesTo')" :options="appliesOptions" :error="formErrors.applies_to" hide-clear required />
255
+ <AppCombobox
256
+ v-if="draft.applies_to === 'department'"
257
+ v-model="draft.department_id"
258
+ :label="t('kpi.aspects.fieldDepartment')"
259
+ :options="departments"
260
+ :error="formErrors.department_id"
261
+ required
262
+ />
263
+ </div>
264
+ <div class="space-y-2">
265
+ <p class="text-sm font-medium text-gray-700 dark:text-gray-300">{{ t('kpi.aspects.fieldRubric') }}</p>
266
+ <p class="text-xs text-gray-500 dark:text-gray-400 -mt-1">{{ t('kpi.aspects.rubricHint') }}</p>
267
+ <AppInput
268
+ v-for="k in RUBRIK"
269
+ :key="k"
270
+ v-model="draft.rubric[k]"
271
+ :label="t('kpi.aspects.rubricLevel', { n: k })"
272
+ :error="formErrors[`rubric.${k}`] || rubrikErr[k]"
273
+ required
274
+ />
275
+ <p v-if="formErrors.rubric" class="text-xs text-red-600 dark:text-red-400">{{ formErrors.rubric }}</p>
276
+ </div>
277
+ </div>
278
+ <template #footer>
279
+ <AppButton variant="secondary" @click="tutup">{{ t('common.cancel') }}</AppButton>
280
+ <AppButton :loading="formSaving" @click="simpanAspek">{{ t('common.save') }}</AppButton>
281
+ </template>
282
+ </AppModal>
283
+ </div>
284
+ </template>