@antelopejs/dms-lang 0.0.6 → 0.1.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.
- package/README.md +12 -6
- package/dist/pages/actions.d.ts +7 -0
- package/dist/pages/actions.js +15 -0
- package/dist/pages/actions.js.map +1 -0
- package/dist/pages/component-action.d.ts +2 -0
- package/dist/pages/component-action.js +10 -0
- package/dist/pages/component-action.js.map +1 -0
- package/dist/pages/header-actions.d.ts +9 -0
- package/dist/pages/header-actions.js +146 -0
- package/dist/pages/header-actions.js.map +1 -0
- package/dist/pages/index.d.ts +6 -0
- package/dist/pages/index.js +6 -0
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/language.d.ts +10 -0
- package/dist/pages/language.js +89 -0
- package/dist/pages/language.js.map +1 -0
- package/dist/pages/languages-table.d.ts +2 -0
- package/dist/pages/languages-table.js +120 -0
- package/dist/pages/languages-table.js.map +1 -0
- package/dist/pages/module.d.ts +7 -1
- package/dist/pages/module.js +28 -2
- package/dist/pages/module.js.map +1 -1
- package/dist/pages/overview.d.ts +2 -1
- package/dist/pages/overview.js +83 -8
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/page-actions.d.ts +6 -0
- package/dist/pages/page-actions.js +10 -0
- package/dist/pages/page-actions.js.map +1 -0
- package/dist/pages/quick-actions.d.ts +1 -0
- package/dist/pages/quick-actions.js +56 -0
- package/dist/pages/quick-actions.js.map +1 -0
- package/dist/pages/translations.d.ts +7 -1
- package/dist/pages/translations.js +47 -10
- package/dist/pages/translations.js.map +1 -1
- package/dist/pages/workspace-guard.d.ts +1 -0
- package/dist/pages/workspace-guard.js +35 -0
- package/dist/pages/workspace-guard.js.map +1 -0
- package/dist/pages/workspace.d.ts +18 -0
- package/dist/pages/workspace.js +162 -0
- package/dist/pages/workspace.js.map +1 -0
- package/dist/pages/workspaces.d.ts +14 -0
- package/dist/pages/workspaces.js +88 -0
- package/dist/pages/workspaces.js.map +1 -0
- package/dist/routes/publicLocales.d.ts +3 -2
- package/dist/routes/publicLocales.js +39 -18
- package/dist/routes/publicLocales.js.map +1 -1
- package/dist/routes/translations.d.ts +59 -63
- package/dist/routes/translations.js +400 -119
- package/dist/routes/translations.js.map +1 -1
- package/dist/utils/announce.d.ts +9 -0
- package/dist/utils/announce.js +29 -0
- package/dist/utils/announce.js.map +1 -0
- package/dist/utils/blocks.d.ts +8 -0
- package/dist/utils/blocks.js +213 -0
- package/dist/utils/blocks.js.map +1 -0
- package/dist/utils/body.d.ts +1 -0
- package/dist/utils/body.js +21 -0
- package/dist/utils/body.js.map +1 -0
- package/dist/utils/cache.d.ts +3 -0
- package/dist/utils/cache.js +32 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/catalog.d.ts +7 -0
- package/dist/utils/catalog.js +62 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/coverage.d.ts +2 -0
- package/dist/utils/coverage.js +11 -0
- package/dist/utils/coverage.js.map +1 -0
- package/dist/utils/dialogs.d.ts +7 -0
- package/dist/utils/dialogs.js +103 -0
- package/dist/utils/dialogs.js.map +1 -0
- package/dist/utils/errors.d.ts +40 -0
- package/dist/utils/errors.js +60 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/export.d.ts +17 -0
- package/dist/utils/export.js +129 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/json.d.ts +10 -1
- package/dist/utils/json.js +127 -19
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/key-stores.d.ts +3 -0
- package/dist/utils/key-stores.js +24 -0
- package/dist/utils/key-stores.js.map +1 -0
- package/dist/utils/keys.d.ts +23 -0
- package/dist/utils/keys.js +252 -0
- package/dist/utils/keys.js.map +1 -0
- package/dist/utils/languages.d.ts +27 -0
- package/dist/utils/languages.js +121 -0
- package/dist/utils/languages.js.map +1 -0
- package/dist/utils/locale-codes.d.ts +5 -0
- package/dist/utils/locale-codes.js +56 -0
- package/dist/utils/locale-codes.js.map +1 -0
- package/dist/utils/locale-discovery.d.ts +1 -0
- package/dist/utils/locale-discovery.js +19 -1
- package/dist/utils/locale-discovery.js.map +1 -1
- package/dist/utils/message-check.d.ts +1 -0
- package/dist/utils/message-check.js +93 -0
- package/dist/utils/message-check.js.map +1 -0
- package/dist/utils/message-syntax.d.ts +6 -0
- package/dist/utils/message-syntax.js +38 -0
- package/dist/utils/message-syntax.js.map +1 -0
- package/dist/utils/namespaces.d.ts +12 -0
- package/dist/utils/namespaces.js +52 -0
- package/dist/utils/namespaces.js.map +1 -0
- package/dist/utils/notices.d.ts +4 -0
- package/dist/utils/notices.js +60 -0
- package/dist/utils/notices.js.map +1 -0
- package/dist/utils/own.d.ts +2 -3
- package/dist/utils/own.js +17 -57
- package/dist/utils/own.js.map +1 -1
- package/dist/utils/public-url.d.ts +8 -0
- package/dist/utils/public-url.js +87 -0
- package/dist/utils/public-url.js.map +1 -0
- package/dist/utils/registry.d.ts +3 -1
- package/dist/utils/registry.js +26 -10
- package/dist/utils/registry.js.map +1 -1
- package/dist/utils/resolve.d.ts +18 -15
- package/dist/utils/resolve.js +98 -151
- package/dist/utils/resolve.js.map +1 -1
- package/dist/utils/review.d.ts +5 -0
- package/dist/utils/review.js +64 -0
- package/dist/utils/review.js.map +1 -0
- package/dist/utils/snippets.d.ts +7 -0
- package/dist/utils/snippets.js +129 -0
- package/dist/utils/snippets.js.map +1 -0
- package/dist/utils/summary.d.ts +23 -0
- package/dist/utils/summary.js +65 -0
- package/dist/utils/summary.js.map +1 -0
- package/dist/utils/tree.d.ts +2 -17
- package/dist/utils/tree.js +21 -126
- package/dist/utils/tree.js.map +1 -1
- package/dist/utils/workspaces.d.ts +45 -15
- package/dist/utils/workspaces.js +256 -164
- package/dist/utils/workspaces.js.map +1 -1
- package/dist/validation/key.schema.d.ts +71 -0
- package/dist/validation/key.schema.js +67 -0
- package/dist/validation/key.schema.js.map +1 -0
- package/dist/validation/query.schema.d.ts +17 -0
- package/dist/validation/query.schema.js +44 -0
- package/dist/validation/query.schema.js.map +1 -0
- package/dist/validation/validate.d.ts +2 -0
- package/dist/validation/validate.js +24 -0
- package/dist/validation/validate.js.map +1 -0
- package/dist/validation/workspace.schema.d.ts +145 -0
- package/dist/validation/workspace.schema.js +83 -0
- package/dist/validation/workspace.schema.js.map +1 -0
- package/frontend-vue/app/build/components/KeyAddModal.vue +340 -0
- package/frontend-vue/app/build/components/KeyEditorDrawer.vue +951 -0
- package/frontend-vue/app/build/components/KeyRenameModal.vue +172 -0
- package/frontend-vue/app/build/components/LanguageAddModal.vue +199 -0
- package/frontend-vue/app/build/components/LanguagePicker.vue +233 -0
- package/frontend-vue/app/build/components/LocaleTile.vue +52 -0
- package/frontend-vue/app/build/components/PlaceholderText.vue +42 -0
- package/frontend-vue/app/build/components/ShortcutKbds.vue +22 -0
- package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +193 -0
- package/frontend-vue/app/build/components/WorkspaceRenameModal.vue +107 -0
- package/frontend-vue/app/build/components/form/FormFieldRow.vue +70 -0
- package/frontend-vue/app/build/components/form/FormRows.vue +25 -0
- package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +44 -0
- package/frontend-vue/app/build/components/matrix/MatrixCell.vue +488 -0
- package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +177 -0
- package/frontend-vue/app/build/components/matrix/MatrixGroupHeader.vue +57 -0
- package/frontend-vue/app/build/components/matrix/MatrixKeyCell.vue +83 -0
- package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +167 -0
- package/frontend-vue/app/build/components/queue/QueueActions.vue +60 -0
- package/frontend-vue/app/build/components/queue/QueueDone.vue +185 -0
- package/frontend-vue/app/build/components/queue/QueueEditor.vue +374 -0
- package/frontend-vue/app/build/components/queue/QueueHeader.vue +162 -0
- package/frontend-vue/app/build/components/queue/QueueUpNext.vue +61 -0
- package/frontend-vue/app/build/composables/useCellEditor.ts +324 -0
- package/frontend-vue/app/build/composables/useCellMoves.ts +155 -0
- package/frontend-vue/app/build/composables/useCellSaves.ts +339 -0
- package/frontend-vue/app/build/composables/useKeyPanel.ts +284 -0
- package/frontend-vue/app/build/composables/useKeySaves.ts +280 -0
- package/frontend-vue/app/build/composables/useMatrixFilters.ts +213 -0
- package/frontend-vue/app/build/composables/useMatrixRows.ts +104 -0
- package/frontend-vue/app/build/composables/useMatrixView.ts +181 -0
- package/frontend-vue/app/build/composables/useQueueContext.ts +31 -0
- package/frontend-vue/app/build/composables/useQueueEditing.ts +53 -0
- package/frontend-vue/app/build/composables/useQueueOrphans.ts +54 -0
- package/frontend-vue/app/build/composables/useQueueSave.ts +290 -0
- package/frontend-vue/app/build/composables/useQueueShortcuts.ts +106 -0
- package/frontend-vue/app/build/composables/useQueueToasts.ts +99 -0
- package/frontend-vue/app/components/LanguageNamespaces.vue +77 -0
- package/frontend-vue/app/components/NamespaceCoverage.vue +222 -0
- package/frontend-vue/app/components/TranslationMatrix.vue +809 -0
- package/frontend-vue/app/components/TranslationQueue.vue +212 -0
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +81 -0
- package/frontend-vue/app/components/WorkspaceGeneral.vue +232 -0
- package/frontend-vue/app/components/WorkspaceList.vue +454 -0
- package/frontend-vue/app/components/WorkspaceScope.vue +384 -0
- package/frontend-vue/app/composables/translation/useFirstRun.ts +8 -0
- package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +221 -133
- package/frontend-vue/app/composables/translation/useKeyActions.ts +224 -0
- package/frontend-vue/app/composables/translation/useLangFormat.ts +10 -0
- package/frontend-vue/app/composables/translation/useLangLinks.ts +80 -0
- package/frontend-vue/app/composables/translation/useLanguageActions.ts +159 -0
- package/frontend-vue/app/composables/translation/useLanguageQueue.ts +232 -0
- package/frontend-vue/app/composables/translation/useLocaleNames.ts +166 -0
- package/frontend-vue/app/composables/translation/useMutationToast.ts +51 -17
- package/frontend-vue/app/composables/translation/useQueueDrafts.ts +115 -0
- package/frontend-vue/app/composables/translation/useQueueSession.ts +182 -0
- package/frontend-vue/app/composables/translation/useServedConfirm.ts +152 -0
- package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +259 -0
- package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +46 -15
- package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +322 -70
- package/frontend-vue/app/composables/translation/useWorkspaceNameCheck.ts +55 -0
- package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +129 -0
- package/frontend-vue/app/config/shortcuts-registry.ts +72 -0
- package/frontend-vue/app/types/lang.ts +130 -0
- package/frontend-vue/app/utils/boundedCache.ts +22 -0
- package/frontend-vue/app/utils/download.ts +16 -0
- package/frontend-vue/app/utils/keySaveErrors.ts +61 -0
- package/frontend-vue/app/utils/keySaves.ts +108 -0
- package/frontend-vue/app/utils/languages.ts +272 -0
- package/frontend-vue/app/utils/matrixExport.ts +47 -0
- package/frontend-vue/app/utils/queueDrafts.ts +115 -0
- package/frontend-vue/app/utils/queuePass.ts +145 -0
- package/frontend-vue/app/utils/queueView.ts +22 -0
- package/frontend-vue/app/utils/shortcuts.ts +75 -0
- package/frontend-vue/app/utils/translations.ts +756 -0
- package/frontend-vue/app/utils/workspaceBackup.ts +119 -0
- package/frontend-vue/app/utils/workspaces.ts +45 -0
- package/frontend-vue/dms.frontend.build.ts +5 -0
- package/frontend-vue/dms.frontend.ts +9 -20
- package/frontend-vue/i18n/locales/lang-en-GB.json +792 -69
- package/frontend-vue/i18n/locales/lang-fr-FR.json +792 -69
- package/frontend-vue/package.json +10 -5
- package/package.json +10 -8
- package/dist/utils/mutations.d.ts +0 -3
- package/dist/utils/mutations.js +0 -35
- package/dist/utils/mutations.js.map +0 -1
- package/frontend-vue/app/build/components/pages/lang/TranslationMatrix.vue +0 -284
- package/frontend-vue/app/components/LanguageAddModal.vue +0 -78
- package/frontend-vue/app/components/WorkspaceEndpoint.vue +0 -29
- package/frontend-vue/app/components/WorkspaceSelector.vue +0 -180
- package/frontend-vue/app/components/WorkspaceStatus.vue +0 -24
- package/frontend-vue/app/composables/translation/useLanguageCatalog.ts +0 -90
- package/frontend-vue/app/composables/translation/useLocaleMeta.ts +0 -18
- package/frontend-vue/app/composables/translation/useTranslationProgress.ts +0 -73
- package/frontend-vue/app/custom-pages/lang/overview.vue +0 -397
- package/frontend-vue/app/custom-pages/lang/translations.vue +0 -498
- package/frontend-vue/app/plugins/workspace-sidebar-widget.ts +0 -12
|
@@ -0,0 +1,951 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useMediaQuery } from '@vueuse/core'
|
|
3
|
+
import type { FlatTranslationRow } from '../../types/lang'
|
|
4
|
+
import {
|
|
5
|
+
storedText,
|
|
6
|
+
type ExpectedText,
|
|
7
|
+
type SaveState,
|
|
8
|
+
} from '../../utils/keySaves'
|
|
9
|
+
import type { CellHold } from '../composables/useCellSaves'
|
|
10
|
+
import {
|
|
11
|
+
clearsBaseText,
|
|
12
|
+
useEditStarts,
|
|
13
|
+
useKeySaves,
|
|
14
|
+
useSaveStates,
|
|
15
|
+
} from '../composables/useKeySaves'
|
|
16
|
+
import {
|
|
17
|
+
checkMessage,
|
|
18
|
+
escapeMessage,
|
|
19
|
+
formatTokens,
|
|
20
|
+
hasBlockingIssue,
|
|
21
|
+
isLocaleValueMissing,
|
|
22
|
+
messageIssueText,
|
|
23
|
+
NAMESPACE_SEPARATOR,
|
|
24
|
+
placeholdersOf,
|
|
25
|
+
replacePlaceholder,
|
|
26
|
+
stringValue,
|
|
27
|
+
type MessageIssue,
|
|
28
|
+
} from '../../utils/translations'
|
|
29
|
+
import LocaleTile from './LocaleTile.vue'
|
|
30
|
+
import PlaceholderText from './PlaceholderText.vue'
|
|
31
|
+
import ShortcutKbds from './ShortcutKbds.vue'
|
|
32
|
+
import { KEY_PANEL_KEYS } from '../../utils/shortcuts'
|
|
33
|
+
|
|
34
|
+
interface Props {
|
|
35
|
+
keys: string[]
|
|
36
|
+
/** The workspace the panel reads and saves, frozen while a key shows. */
|
|
37
|
+
workspace: string
|
|
38
|
+
startIndex: number
|
|
39
|
+
editable: boolean
|
|
40
|
+
manageKeys: boolean
|
|
41
|
+
/** A key the workspace does not hold yet (a module key being overridden). */
|
|
42
|
+
seed?: FlatTranslationRow
|
|
43
|
+
/** Language whose field gets the focus when a key opens. */
|
|
44
|
+
focusLocale?: string
|
|
45
|
+
/** Text typed elsewhere (a matrix cell) for the key that opens. */
|
|
46
|
+
initialDrafts?: Record<string, string>
|
|
47
|
+
open?: boolean
|
|
48
|
+
/** A read-only module key can be overridden in the project files. */
|
|
49
|
+
canOverride?: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface Emits {
|
|
53
|
+
close: []
|
|
54
|
+
'update:open': [open: boolean]
|
|
55
|
+
navigate: [key: string]
|
|
56
|
+
override: [key: string]
|
|
57
|
+
/** Texts that could not be saved as the panel closed, handed to their cells. */
|
|
58
|
+
keep: [holds: CellHold[]]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface KnownInherited {
|
|
62
|
+
key: string
|
|
63
|
+
inherited: FlatTranslationRow['inherited']
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type FieldStatus = 'missing' | 'inherited' | 'overridden' | 'outdated' | 'done'
|
|
67
|
+
|
|
68
|
+
const WIDE_SCREEN_QUERY = '(min-width: 1024px)'
|
|
69
|
+
const BASE_MISSING_LABEL = 'dms_lang.matrix.source_missing'
|
|
70
|
+
const FIELD_STATUS_LABELS: Record<FieldStatus, string> = {
|
|
71
|
+
missing: 'dms_lang.matrix.missing',
|
|
72
|
+
inherited: 'dms_lang.drawer.inherited',
|
|
73
|
+
overridden: 'dms_lang.drawer.overridden',
|
|
74
|
+
outdated: 'dms_lang.drawer.outdated',
|
|
75
|
+
done: '',
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
79
|
+
seed: undefined,
|
|
80
|
+
focusLocale: undefined,
|
|
81
|
+
initialDrafts: undefined,
|
|
82
|
+
open: true,
|
|
83
|
+
canOverride: false,
|
|
84
|
+
})
|
|
85
|
+
const emit = defineEmits<Emits>()
|
|
86
|
+
|
|
87
|
+
const { t } = useI18n()
|
|
88
|
+
const toast = useToast()
|
|
89
|
+
const { flatOf } = useWorkspaceFlat()
|
|
90
|
+
const { nativeName } = useLocaleNames()
|
|
91
|
+
const { renameKey, deleteKey, revertToModule } = useKeyActions()
|
|
92
|
+
const { reportFailure } = useMutationToast()
|
|
93
|
+
const saves = useKeySaves()
|
|
94
|
+
|
|
95
|
+
const isOpen = ref(props.open)
|
|
96
|
+
const workspace = ref(props.workspace)
|
|
97
|
+
const flat = computed(() => flatOf(workspace.value))
|
|
98
|
+
const currentKey = ref(props.keys[props.startIndex] ?? '')
|
|
99
|
+
const drafts = ref<Record<string, string>>({})
|
|
100
|
+
const editStarts = useEditStarts()
|
|
101
|
+
const knownInherited = ref<KnownInherited | null>(null)
|
|
102
|
+
const fieldStates = ref<Record<string, SaveState>>({})
|
|
103
|
+
const fieldErrors = ref<Record<string, string>>({})
|
|
104
|
+
const blocked = ref<Record<string, boolean>>({})
|
|
105
|
+
const states = useSaveStates(fieldStates)
|
|
106
|
+
const isWide = useMediaQuery(WIDE_SCREEN_QUERY)
|
|
107
|
+
const body = useTemplateRef<HTMLElement>('body')
|
|
108
|
+
let isClosing = false
|
|
109
|
+
let queue: Promise<unknown> = Promise.resolve()
|
|
110
|
+
|
|
111
|
+
const key = computed(() => currentKey.value)
|
|
112
|
+
const position = computed(() => props.keys.indexOf(key.value))
|
|
113
|
+
const storedRow = computed(() =>
|
|
114
|
+
flat.value.rows.find((entry) => entry.key === key.value),
|
|
115
|
+
)
|
|
116
|
+
const isStored = computed(() => storedRow.value !== undefined)
|
|
117
|
+
const row = computed<FlatTranslationRow>(
|
|
118
|
+
() =>
|
|
119
|
+
storedRow.value ??
|
|
120
|
+
(props.seed?.key === key.value ? props.seed : undefined) ?? {
|
|
121
|
+
key: key.value,
|
|
122
|
+
values: {},
|
|
123
|
+
inherited: knownInheritedOf(key.value),
|
|
124
|
+
},
|
|
125
|
+
)
|
|
126
|
+
const base = computed(() => flat.value.defaultLocale)
|
|
127
|
+
const baseText = computed(() => draftOf(base.value))
|
|
128
|
+
const locales = computed(() => [
|
|
129
|
+
base.value,
|
|
130
|
+
...flat.value.locales.filter((code) => code !== base.value),
|
|
131
|
+
])
|
|
132
|
+
const crumbs = computed(() =>
|
|
133
|
+
key.value.split(NAMESPACE_SEPARATOR).slice(0, -1).join(' › '),
|
|
134
|
+
)
|
|
135
|
+
const changedCodes = computed(() => locales.value.filter(isChanged))
|
|
136
|
+
const missingCount = computed(
|
|
137
|
+
() => locales.value.filter((code) => statusOf(code) === 'missing').length,
|
|
138
|
+
)
|
|
139
|
+
const issueCount = computed(
|
|
140
|
+
() => locales.value.filter((code) => issuesOf(code).length > 0).length,
|
|
141
|
+
)
|
|
142
|
+
const hasInherited = computed(() =>
|
|
143
|
+
Object.values(row.value.inherited ?? {}).some(
|
|
144
|
+
(value) => !isLocaleValueMissing(value),
|
|
145
|
+
),
|
|
146
|
+
)
|
|
147
|
+
const pendingCount = computed(() => locales.value.filter(isWaiting).length)
|
|
148
|
+
const isBusy = computed(() =>
|
|
149
|
+
Object.values(fieldStates.value).includes('saving'),
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
useUnsavedChanges({ dirty: () => changedCodes.value.length > 0 })
|
|
153
|
+
|
|
154
|
+
function ownOf(code: string): string {
|
|
155
|
+
return isStored.value ? stringValue(row.value.values[code]) : ''
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function inheritedOf(code: string): string {
|
|
159
|
+
const inherited = row.value.inherited?.[code]
|
|
160
|
+
if (!isLocaleValueMissing(inherited)) return stringValue(inherited)
|
|
161
|
+
return isStored.value ? '' : stringValue(row.value.values[code])
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function baselineOf(code: string): string {
|
|
165
|
+
return ownOf(code) || inheritedOf(code)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function draftOf(code: string): string {
|
|
169
|
+
return drafts.value[code] ?? baselineOf(code)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function isChanged(code: string): boolean {
|
|
173
|
+
const draft = drafts.value[code]
|
|
174
|
+
if (draft === undefined || draft === baselineOf(code)) return false
|
|
175
|
+
return Boolean(draft.trim()) || Boolean(ownOf(code))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function storedOf(code: string): string | null {
|
|
179
|
+
return ownOf(code) || null
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function expectedOf(code: string): ExpectedText {
|
|
183
|
+
return editStarts.has(code) ? editStarts.of(code) : storedOf(code)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function hasConflict(code: string): boolean {
|
|
187
|
+
return (
|
|
188
|
+
isChanged(code) &&
|
|
189
|
+
editStarts.has(code) &&
|
|
190
|
+
editStarts.of(code) !== storedOf(code)
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function isWaiting(code: string): boolean {
|
|
195
|
+
return (
|
|
196
|
+
hasConflict(code) ||
|
|
197
|
+
fieldStates.value[code] === 'error' ||
|
|
198
|
+
blocked.value[code] === true
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function saveStateOf(code: string): SaveState {
|
|
203
|
+
return blocked.value[code] ? 'error' : states.stateOf(code)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function startEdit(code: string) {
|
|
207
|
+
editStarts.begin(code, storedOf(code))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function statusOf(code: string): FieldStatus {
|
|
211
|
+
if (!draftOf(code).trim()) return 'missing'
|
|
212
|
+
if (isChanged(code)) return 'done'
|
|
213
|
+
if (!ownOf(code) && inheritedOf(code)) return 'inherited'
|
|
214
|
+
if (ownOf(code) && row.value.inherited?.[code]) return 'overridden'
|
|
215
|
+
if (row.value.outdated?.includes(code)) return 'outdated'
|
|
216
|
+
return 'done'
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function issuesOf(code: string): MessageIssue[] {
|
|
220
|
+
return checkMessage(code === base.value ? '' : baseText.value, draftOf(code))
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function issueOfKind(code: string, kind: MessageIssue['kind']) {
|
|
224
|
+
return issuesOf(code).find((issue) => issue.kind === kind)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function setFieldState(code: string, state: SaveState, error = '') {
|
|
228
|
+
states.setState(code, state)
|
|
229
|
+
fieldErrors.value = { ...fieldErrors.value, [code]: error }
|
|
230
|
+
blocked.value = { ...blocked.value, [code]: false }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function block(code: string) {
|
|
234
|
+
setFieldState(code, 'idle')
|
|
235
|
+
blocked.value = { ...blocked.value, [code]: true }
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function setDraft(code: string, value: string) {
|
|
239
|
+
startEdit(code)
|
|
240
|
+
drafts.value = { ...drafts.value, [code]: value }
|
|
241
|
+
if (blocked.value[code]) setFieldState(code, 'idle')
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function discardDraft(code: string) {
|
|
245
|
+
const { [code]: _dropped, ...rest } = drafts.value
|
|
246
|
+
drafts.value = rest
|
|
247
|
+
editStarts.end(code)
|
|
248
|
+
setFieldState(code, 'idle')
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function overwrite(code: string) {
|
|
252
|
+
editStarts.set(code, storedOf(code))
|
|
253
|
+
save([code])
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function fieldInput(code: string): HTMLTextAreaElement | null {
|
|
257
|
+
return (
|
|
258
|
+
body.value?.querySelector<HTMLTextAreaElement>(
|
|
259
|
+
`[data-locale="${code}"] textarea`,
|
|
260
|
+
) ?? null
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function focusField(code?: string, caret?: number) {
|
|
265
|
+
if (!code) return
|
|
266
|
+
await nextTick()
|
|
267
|
+
const input = fieldInput(code)
|
|
268
|
+
if (!input) return
|
|
269
|
+
input.scrollIntoView({ block: 'nearest' })
|
|
270
|
+
input.focus()
|
|
271
|
+
if (caret !== undefined) input.setSelectionRange(caret, caret)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function insertAtCaret(code: string, token: string) {
|
|
275
|
+
const input = fieldInput(code)
|
|
276
|
+
const current = draftOf(code)
|
|
277
|
+
const start = input?.selectionStart ?? current.length
|
|
278
|
+
const end = input?.selectionEnd ?? current.length
|
|
279
|
+
setDraft(code, `${current.slice(0, start)}${token}${current.slice(end)}`)
|
|
280
|
+
focusField(code, start + token.length)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function rewrite(code: string, value: string) {
|
|
284
|
+
setDraft(code, value)
|
|
285
|
+
focusField(code)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function knownInheritedOf(path: string) {
|
|
289
|
+
return knownInherited.value?.key === path
|
|
290
|
+
? knownInherited.value.inherited
|
|
291
|
+
: undefined
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function settle(codes: string[], values: Record<string, string>) {
|
|
295
|
+
const rest = { ...drafts.value }
|
|
296
|
+
for (const code of codes) {
|
|
297
|
+
const isDone = rest[code] === values[code]
|
|
298
|
+
if (isDone) delete rest[code]
|
|
299
|
+
if (isDone) editStarts.end(code)
|
|
300
|
+
else editStarts.set(code, storedText(values[code]))
|
|
301
|
+
setFieldState(code, 'idle')
|
|
302
|
+
states.flashSaved(code)
|
|
303
|
+
}
|
|
304
|
+
drafts.value = rest
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function collect(codes: string[]) {
|
|
308
|
+
const values: Record<string, string> = {}
|
|
309
|
+
const expected: Record<string, ExpectedText> = {}
|
|
310
|
+
for (const code of codes.filter(isChanged)) {
|
|
311
|
+
if (hasConflict(code)) continue
|
|
312
|
+
if (hasBlockingIssue(issuesOf(code))) {
|
|
313
|
+
block(code)
|
|
314
|
+
continue
|
|
315
|
+
}
|
|
316
|
+
values[code] = draftOf(code)
|
|
317
|
+
expected[code] = expectedOf(code)
|
|
318
|
+
}
|
|
319
|
+
return { values, expected }
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function isClearingBase(codes: string[]): boolean {
|
|
323
|
+
const code = base.value
|
|
324
|
+
const stored = inheritedOf(code) ? '' : ownOf(code)
|
|
325
|
+
return (
|
|
326
|
+
codes.includes(code) &&
|
|
327
|
+
isChanged(code) &&
|
|
328
|
+
clearsBaseText(code, base.value, draftOf(code), stored)
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async function confirmBaseClear(codes: string[]) {
|
|
333
|
+
if (!isClearingBase(codes)) return
|
|
334
|
+
if (!(await saves.confirmClearBase(key.value))) discardDraft(base.value)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async function persist(codes: string[]): Promise<boolean> {
|
|
338
|
+
const path = key.value
|
|
339
|
+
const target = workspace.value
|
|
340
|
+
await confirmBaseClear(codes)
|
|
341
|
+
if (key.value !== path) return false
|
|
342
|
+
const { values, expected } = collect(codes)
|
|
343
|
+
const sent = Object.keys(values)
|
|
344
|
+
const isHeld = codes.some((code) => blocked.value[code] || hasConflict(code))
|
|
345
|
+
if (!sent.length) return !isHeld
|
|
346
|
+
sent.forEach((code) => setFieldState(code, 'saving'))
|
|
347
|
+
const outcome = await saves.write({
|
|
348
|
+
workspace: target,
|
|
349
|
+
key: path,
|
|
350
|
+
values,
|
|
351
|
+
expected,
|
|
352
|
+
})
|
|
353
|
+
if (outcome.status === 'failed') {
|
|
354
|
+
sent.forEach((code) => setFieldState(code, 'error', outcome.message))
|
|
355
|
+
return false
|
|
356
|
+
}
|
|
357
|
+
if (key.value === path) settle(sent, values)
|
|
358
|
+
return !isHeld
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function save(codes: string[]): Promise<boolean> {
|
|
362
|
+
const run = queue.then(() => persist(codes))
|
|
363
|
+
queue = run.catch(() => undefined)
|
|
364
|
+
return run
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function onFieldBlur(code: string) {
|
|
368
|
+
if (document.hasFocus() && isChanged(code)) save([code])
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
async function flush(): Promise<boolean> {
|
|
372
|
+
await queue
|
|
373
|
+
return save(changedCodes.value)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function takeDrafts(typed: Record<string, string> | undefined) {
|
|
377
|
+
for (const code of Object.keys(typed ?? {})) startEdit(code)
|
|
378
|
+
drafts.value = { ...drafts.value, ...typed }
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function show(path: string) {
|
|
382
|
+
workspace.value = props.workspace
|
|
383
|
+
currentKey.value = path
|
|
384
|
+
fieldStates.value = {}
|
|
385
|
+
fieldErrors.value = {}
|
|
386
|
+
blocked.value = {}
|
|
387
|
+
drafts.value = {}
|
|
388
|
+
editStarts.clear()
|
|
389
|
+
if (path === props.keys[props.startIndex]) takeDrafts(props.initialDrafts)
|
|
390
|
+
focusField(props.focusLocale)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
async function go(step: number) {
|
|
394
|
+
const next =
|
|
395
|
+
props.keys[(position.value < 0 ? props.startIndex : position.value) + step]
|
|
396
|
+
if (next === undefined) return
|
|
397
|
+
if (!(await flush())) return
|
|
398
|
+
show(next)
|
|
399
|
+
emit('navigate', next)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
async function saveAndNext() {
|
|
403
|
+
if (!(await flush())) return
|
|
404
|
+
if (position.value < props.keys.length - 1) go(1)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function finish() {
|
|
408
|
+
isOpen.value = false
|
|
409
|
+
emit('update:open', false)
|
|
410
|
+
emit('close')
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async function requestClose() {
|
|
414
|
+
if (isClosing || !isOpen.value) return
|
|
415
|
+
isClosing = true
|
|
416
|
+
const isSaved = await flush()
|
|
417
|
+
isClosing = false
|
|
418
|
+
if (isSaved) finish()
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function blockingText(code: string): string {
|
|
422
|
+
return issuesOf(code)
|
|
423
|
+
.filter((issue) => issue.severity === 'error')
|
|
424
|
+
.map((issue) => messageIssueText(issue, t))
|
|
425
|
+
.join(' ')
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function holdOf(code: string): CellHold {
|
|
429
|
+
const isConflict = hasConflict(code)
|
|
430
|
+
const target = { workspace: workspace.value, key: key.value, code }
|
|
431
|
+
const message = isConflict
|
|
432
|
+
? t('dms_lang.drawer.conflict')
|
|
433
|
+
: fieldErrors.value[code] || blockingText(code)
|
|
434
|
+
const expected = isConflict ? storedOf(code) : expectedOf(code)
|
|
435
|
+
return { ...target, draft: draftOf(code), message, isConflict, expected }
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async function closeFromOutside() {
|
|
439
|
+
const isSaved = await flush()
|
|
440
|
+
isOpen.value = false
|
|
441
|
+
if (!isSaved) emit('keep', changedCodes.value.map(holdOf))
|
|
442
|
+
emit('close')
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function onToggle(open: boolean) {
|
|
446
|
+
if (!open) requestClose()
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function onDismissAttempt() {
|
|
450
|
+
if (!isWide.value) requestClose()
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function onEscape() {
|
|
454
|
+
const panel = body.value?.closest('[role="dialog"]')
|
|
455
|
+
if (isWide.value && !panel?.contains(document.activeElement)) return
|
|
456
|
+
requestClose()
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function onOpenAutoFocus(event: Event) {
|
|
460
|
+
if (!props.focusLocale) return
|
|
461
|
+
event.preventDefault()
|
|
462
|
+
focusField(props.focusLocale)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
async function rename() {
|
|
466
|
+
if (!(await flush())) return
|
|
467
|
+
const renamed = await renameKey(key.value)
|
|
468
|
+
if (renamed) finish()
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
async function markReviewed(code: string) {
|
|
472
|
+
const path = key.value
|
|
473
|
+
const outcome = await saves.markReviewed(
|
|
474
|
+
{ workspace: workspace.value, key: path },
|
|
475
|
+
code,
|
|
476
|
+
)
|
|
477
|
+
if (outcome.status === 'failed') return reportFailure(outcome.error)
|
|
478
|
+
toast.add({
|
|
479
|
+
title: t('dms_lang.drawer.reviewed', { code, key: path }),
|
|
480
|
+
color: 'success',
|
|
481
|
+
icon: 'i-ph-check',
|
|
482
|
+
})
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async function remove() {
|
|
486
|
+
if (!(await flush())) return
|
|
487
|
+
const isDone = hasInherited.value
|
|
488
|
+
? await revertToModule(key.value)
|
|
489
|
+
: await deleteKey(key.value)
|
|
490
|
+
if (isDone) finish()
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function stayOnKey() {
|
|
494
|
+
toast.add({
|
|
495
|
+
title: t('dms_lang.drawer.stays_title', { key: key.value }),
|
|
496
|
+
description: t('dms_lang.drawer.stays_description'),
|
|
497
|
+
color: 'warning',
|
|
498
|
+
icon: 'i-ph-warning',
|
|
499
|
+
})
|
|
500
|
+
const waiting = locales.value.find(isWaiting)
|
|
501
|
+
if (waiting) fieldInput(waiting)?.scrollIntoView({ block: 'nearest' })
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
watch(
|
|
505
|
+
() =>
|
|
506
|
+
[props.keys[props.startIndex], props.initialDrafts, props.workspace] as const,
|
|
507
|
+
async ([target, , next], _previous, onCleanup) => {
|
|
508
|
+
if (target === undefined) return
|
|
509
|
+
if (target === key.value && next === workspace.value) {
|
|
510
|
+
takeDrafts(props.initialDrafts)
|
|
511
|
+
return focusField(props.focusLocale)
|
|
512
|
+
}
|
|
513
|
+
let isSuperseded = false
|
|
514
|
+
onCleanup(() => (isSuperseded = true))
|
|
515
|
+
const isSaved = await flush()
|
|
516
|
+
if (isSuperseded) return
|
|
517
|
+
if (isSaved) show(target)
|
|
518
|
+
else stayOnKey()
|
|
519
|
+
emit('navigate', key.value)
|
|
520
|
+
},
|
|
521
|
+
)
|
|
522
|
+
|
|
523
|
+
watch(
|
|
524
|
+
() => props.focusLocale,
|
|
525
|
+
(code) => focusField(code),
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
watch(
|
|
529
|
+
storedRow,
|
|
530
|
+
(stored) => {
|
|
531
|
+
if (stored?.inherited && Object.keys(stored.inherited).length)
|
|
532
|
+
knownInherited.value = { key: stored.key, inherited: stored.inherited }
|
|
533
|
+
},
|
|
534
|
+
{ immediate: true },
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
watch(
|
|
538
|
+
() => props.open,
|
|
539
|
+
(open) => {
|
|
540
|
+
if (open && !isOpen.value) {
|
|
541
|
+
isOpen.value = true
|
|
542
|
+
show(props.keys[props.startIndex] ?? key.value)
|
|
543
|
+
} else if (!open && isOpen.value) closeFromOutside()
|
|
544
|
+
},
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
onMounted(() => show(key.value))
|
|
548
|
+
</script>
|
|
549
|
+
|
|
550
|
+
<template>
|
|
551
|
+
<USlideover
|
|
552
|
+
:open="isOpen"
|
|
553
|
+
:title="key"
|
|
554
|
+
:modal="!isWide"
|
|
555
|
+
:overlay="!isWide"
|
|
556
|
+
:dismissible="false"
|
|
557
|
+
:content="{
|
|
558
|
+
onOpenAutoFocus,
|
|
559
|
+
onEscapeKeyDown: onEscape,
|
|
560
|
+
}"
|
|
561
|
+
:ui="{ content: 'sm:max-w-xl', body: 'space-y-3' }"
|
|
562
|
+
@update:open="onToggle"
|
|
563
|
+
@close:prevent="onDismissAttempt"
|
|
564
|
+
>
|
|
565
|
+
<template #title>
|
|
566
|
+
<span class="font-mono break-all">{{ key }}</span>
|
|
567
|
+
</template>
|
|
568
|
+
<template #description>
|
|
569
|
+
<span class="block space-y-2">
|
|
570
|
+
<DmsEyebrow
|
|
571
|
+
as="span"
|
|
572
|
+
:label="
|
|
573
|
+
crumbs
|
|
574
|
+
? $t('dms_lang.drawer.eyebrow', { path: crumbs })
|
|
575
|
+
: $t('dms_lang.drawer.key')
|
|
576
|
+
"
|
|
577
|
+
size="xs"
|
|
578
|
+
truncate
|
|
579
|
+
/>
|
|
580
|
+
<span class="flex flex-wrap items-center gap-1.5">
|
|
581
|
+
<DmsStatusPill
|
|
582
|
+
v-if="missingCount"
|
|
583
|
+
dot="none"
|
|
584
|
+
tone="warning"
|
|
585
|
+
size="sm"
|
|
586
|
+
:label="$t('dms_lang.drawer.missing', missingCount)"
|
|
587
|
+
/>
|
|
588
|
+
<DmsStatusPill
|
|
589
|
+
v-if="issueCount"
|
|
590
|
+
dot="none"
|
|
591
|
+
tone="error"
|
|
592
|
+
size="sm"
|
|
593
|
+
icon="i-ph-warning"
|
|
594
|
+
:label="$t('dms_lang.drawer.issues', issueCount)"
|
|
595
|
+
/>
|
|
596
|
+
<span
|
|
597
|
+
v-if="placeholdersOf(baseText).length"
|
|
598
|
+
class="text-dimmed inline-flex items-center gap-1.5 text-xs"
|
|
599
|
+
>
|
|
600
|
+
<UIcon name="i-ph-brackets-curly" class="size-3.5" />
|
|
601
|
+
{{ $t('dms_lang.drawer.placeholders') }}
|
|
602
|
+
<PlaceholderText :text="formatTokens(placeholdersOf(baseText))" />
|
|
603
|
+
</span>
|
|
604
|
+
</span>
|
|
605
|
+
</span>
|
|
606
|
+
</template>
|
|
607
|
+
<template #actions>
|
|
608
|
+
<UButton
|
|
609
|
+
icon="i-ph-caret-up"
|
|
610
|
+
color="neutral"
|
|
611
|
+
variant="ghost"
|
|
612
|
+
size="xs"
|
|
613
|
+
:disabled="position <= 0"
|
|
614
|
+
:aria-label="$t('dms_lang.drawer.previous')"
|
|
615
|
+
@click="go(-1)"
|
|
616
|
+
/>
|
|
617
|
+
<UButton
|
|
618
|
+
icon="i-ph-caret-down"
|
|
619
|
+
color="neutral"
|
|
620
|
+
variant="ghost"
|
|
621
|
+
size="xs"
|
|
622
|
+
:disabled="position < 0 || position >= props.keys.length - 1"
|
|
623
|
+
:aria-label="$t('dms_lang.drawer.next')"
|
|
624
|
+
@click="go(1)"
|
|
625
|
+
/>
|
|
626
|
+
</template>
|
|
627
|
+
|
|
628
|
+
<template #body>
|
|
629
|
+
<div ref="body" class="space-y-4">
|
|
630
|
+
<div
|
|
631
|
+
v-for="code in locales"
|
|
632
|
+
:key="`${key}-${code}`"
|
|
633
|
+
:data-locale="code"
|
|
634
|
+
class="space-y-1.5"
|
|
635
|
+
>
|
|
636
|
+
<div class="flex items-center gap-2 text-sm">
|
|
637
|
+
<LocaleTile :code="code" size="sm" :is-base="code === base" />
|
|
638
|
+
<span class="text-highlighted font-medium">
|
|
639
|
+
{{ nativeName(code) }}
|
|
640
|
+
</span>
|
|
641
|
+
<span class="text-dimmed font-mono text-xs">{{ code }}</span>
|
|
642
|
+
<DmsStatusPill
|
|
643
|
+
v-if="code === base"
|
|
644
|
+
dot="none"
|
|
645
|
+
tone="neutral"
|
|
646
|
+
size="sm"
|
|
647
|
+
:label="$t('dms_lang.common.base')"
|
|
648
|
+
/>
|
|
649
|
+
<span class="ml-auto inline-flex items-center gap-1.5 text-xs">
|
|
650
|
+
<span
|
|
651
|
+
v-if="hasConflict(code)"
|
|
652
|
+
class="text-error inline-flex items-center gap-1 font-medium"
|
|
653
|
+
>
|
|
654
|
+
<UIcon name="i-ph-warning" class="size-3.5" />
|
|
655
|
+
{{ $t('dms_lang.drawer.conflict') }}
|
|
656
|
+
</span>
|
|
657
|
+
<template v-else-if="saveStateOf(code) !== 'idle'">
|
|
658
|
+
<DmsSaveStatus
|
|
659
|
+
:state="saveStateOf(code)"
|
|
660
|
+
@retry="save([code])"
|
|
661
|
+
/>
|
|
662
|
+
<UButton
|
|
663
|
+
v-if="saveStateOf(code) === 'error'"
|
|
664
|
+
size="xs"
|
|
665
|
+
color="neutral"
|
|
666
|
+
variant="link"
|
|
667
|
+
:label="$t('dms_lang.drawer.discard')"
|
|
668
|
+
@click="discardDraft(code)"
|
|
669
|
+
/>
|
|
670
|
+
</template>
|
|
671
|
+
<span
|
|
672
|
+
v-else-if="statusOf(code) === 'missing'"
|
|
673
|
+
class="text-warning font-mono font-semibold uppercase"
|
|
674
|
+
>
|
|
675
|
+
{{
|
|
676
|
+
$t(
|
|
677
|
+
code === base
|
|
678
|
+
? BASE_MISSING_LABEL
|
|
679
|
+
: FIELD_STATUS_LABELS.missing,
|
|
680
|
+
)
|
|
681
|
+
}}
|
|
682
|
+
</span>
|
|
683
|
+
<template v-else-if="statusOf(code) !== 'done'">
|
|
684
|
+
<span
|
|
685
|
+
:class="
|
|
686
|
+
statusOf(code) === 'outdated'
|
|
687
|
+
? 'text-warning font-medium'
|
|
688
|
+
: 'text-dimmed'
|
|
689
|
+
"
|
|
690
|
+
>
|
|
691
|
+
{{ $t(FIELD_STATUS_LABELS[statusOf(code)]) }}
|
|
692
|
+
</span>
|
|
693
|
+
<UButton
|
|
694
|
+
v-if="statusOf(code) === 'overridden' && props.editable"
|
|
695
|
+
size="xs"
|
|
696
|
+
color="neutral"
|
|
697
|
+
variant="link"
|
|
698
|
+
:label="$t('dms_lang.drawer.use_module')"
|
|
699
|
+
@click="(setDraft(code, ''), save([code]))"
|
|
700
|
+
/>
|
|
701
|
+
<UButton
|
|
702
|
+
v-else-if="statusOf(code) === 'outdated' && props.editable"
|
|
703
|
+
size="xs"
|
|
704
|
+
color="neutral"
|
|
705
|
+
variant="link"
|
|
706
|
+
icon="i-ph-check"
|
|
707
|
+
:label="$t('dms_lang.drawer.mark_reviewed')"
|
|
708
|
+
@click="markReviewed(code)"
|
|
709
|
+
/>
|
|
710
|
+
</template>
|
|
711
|
+
<UIcon
|
|
712
|
+
v-else-if="code !== base && !issuesOf(code).length"
|
|
713
|
+
name="i-ph-check"
|
|
714
|
+
class="text-success size-4"
|
|
715
|
+
/>
|
|
716
|
+
</span>
|
|
717
|
+
</div>
|
|
718
|
+
<UTextarea
|
|
719
|
+
v-if="props.editable"
|
|
720
|
+
:model-value="draftOf(code)"
|
|
721
|
+
autoresize
|
|
722
|
+
:rows="1"
|
|
723
|
+
:maxrows="10"
|
|
724
|
+
class="w-full"
|
|
725
|
+
:color="issuesOf(code).length ? 'error' : undefined"
|
|
726
|
+
:highlight="issuesOf(code).length > 0"
|
|
727
|
+
@update:model-value="(value: string) => setDraft(code, value)"
|
|
728
|
+
@blur="onFieldBlur(code)"
|
|
729
|
+
@keydown.meta.enter.prevent="saveAndNext"
|
|
730
|
+
@keydown.ctrl.enter.prevent="saveAndNext"
|
|
731
|
+
/>
|
|
732
|
+
<div
|
|
733
|
+
v-else
|
|
734
|
+
class="border-default rounded-md border bg-(--dms-bg-muted) px-3 py-2 text-sm"
|
|
735
|
+
>
|
|
736
|
+
<PlaceholderText v-if="draftOf(code)" :text="draftOf(code)" />
|
|
737
|
+
<span v-else class="text-dimmed">—</span>
|
|
738
|
+
<p
|
|
739
|
+
v-if="row.overrides?.[code]"
|
|
740
|
+
class="text-dimmed border-default mt-2 border-t pt-2 text-xs"
|
|
741
|
+
>
|
|
742
|
+
{{ $t('dms_lang.drawer.project_value') }}
|
|
743
|
+
<PlaceholderText
|
|
744
|
+
:text="row.overrides[code]"
|
|
745
|
+
class="text-default"
|
|
746
|
+
/>
|
|
747
|
+
</p>
|
|
748
|
+
</div>
|
|
749
|
+
<div
|
|
750
|
+
v-if="hasConflict(code)"
|
|
751
|
+
class="border-error/40 space-y-1.5 rounded-md border px-3 py-2 text-xs"
|
|
752
|
+
>
|
|
753
|
+
<p class="text-dimmed">
|
|
754
|
+
<template v-if="ownOf(code)">
|
|
755
|
+
{{ $t('dms_lang.drawer.conflict_value') }}
|
|
756
|
+
<PlaceholderText :text="ownOf(code)" class="text-default" />
|
|
757
|
+
</template>
|
|
758
|
+
<template v-else>
|
|
759
|
+
{{ $t('dms_lang.drawer.conflict_empty') }}
|
|
760
|
+
</template>
|
|
761
|
+
</p>
|
|
762
|
+
<p class="text-dimmed">{{ $t('dms_lang.drawer.conflict_help') }}</p>
|
|
763
|
+
<div class="flex flex-wrap gap-1.5">
|
|
764
|
+
<UButton
|
|
765
|
+
size="xs"
|
|
766
|
+
color="error"
|
|
767
|
+
variant="soft"
|
|
768
|
+
:label="$t('dms_lang.drawer.overwrite')"
|
|
769
|
+
@mousedown.prevent
|
|
770
|
+
@click="overwrite(code)"
|
|
771
|
+
/>
|
|
772
|
+
<UButton
|
|
773
|
+
size="xs"
|
|
774
|
+
color="neutral"
|
|
775
|
+
variant="outline"
|
|
776
|
+
:label="$t('dms_lang.drawer.discard')"
|
|
777
|
+
@mousedown.prevent
|
|
778
|
+
@click="discardDraft(code)"
|
|
779
|
+
/>
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
782
|
+
<p v-else-if="fieldErrors[code]" class="text-error text-xs">
|
|
783
|
+
{{ fieldErrors[code] }}
|
|
784
|
+
</p>
|
|
785
|
+
<div
|
|
786
|
+
v-if="props.editable && issuesOf(code).length"
|
|
787
|
+
class="space-y-1 text-xs"
|
|
788
|
+
>
|
|
789
|
+
<div
|
|
790
|
+
v-for="issue in issuesOf(code)"
|
|
791
|
+
:key="issue.kind"
|
|
792
|
+
class="flex flex-wrap items-center gap-x-3 gap-y-1"
|
|
793
|
+
>
|
|
794
|
+
<span
|
|
795
|
+
:class="
|
|
796
|
+
issue.severity === 'error' ? 'text-error' : 'text-warning'
|
|
797
|
+
"
|
|
798
|
+
>
|
|
799
|
+
{{ messageIssueText(issue, t) }}
|
|
800
|
+
<template v-if="issue.kind === 'missing'">
|
|
801
|
+
{{
|
|
802
|
+
$t(
|
|
803
|
+
'dms_lang.drawer.issue_help',
|
|
804
|
+
{ tokens: formatTokens(issue.tokens) },
|
|
805
|
+
issue.count,
|
|
806
|
+
)
|
|
807
|
+
}}
|
|
808
|
+
</template>
|
|
809
|
+
</span>
|
|
810
|
+
<template v-if="issue.kind === 'missing'">
|
|
811
|
+
<UButton
|
|
812
|
+
v-for="token in issue.tokens"
|
|
813
|
+
:key="token"
|
|
814
|
+
size="xs"
|
|
815
|
+
color="error"
|
|
816
|
+
variant="soft"
|
|
817
|
+
:label="
|
|
818
|
+
$t('dms_lang.drawer.insert', {
|
|
819
|
+
token: formatTokens([token]),
|
|
820
|
+
})
|
|
821
|
+
"
|
|
822
|
+
@mousedown.prevent
|
|
823
|
+
@click="insertAtCaret(code, formatTokens([token]))"
|
|
824
|
+
/>
|
|
825
|
+
<UButton
|
|
826
|
+
v-if="
|
|
827
|
+
issue.tokens.length === 1 &&
|
|
828
|
+
issueOfKind(code, 'extra')?.tokens.length === 1
|
|
829
|
+
"
|
|
830
|
+
size="xs"
|
|
831
|
+
color="error"
|
|
832
|
+
variant="soft"
|
|
833
|
+
:label="
|
|
834
|
+
$t('dms_lang.message_issue.replace', {
|
|
835
|
+
token: formatTokens(issue.tokens),
|
|
836
|
+
})
|
|
837
|
+
"
|
|
838
|
+
@mousedown.prevent
|
|
839
|
+
@click="
|
|
840
|
+
rewrite(
|
|
841
|
+
code,
|
|
842
|
+
replacePlaceholder(
|
|
843
|
+
draftOf(code),
|
|
844
|
+
issueOfKind(code, 'extra')?.tokens[0] ?? '',
|
|
845
|
+
issue.tokens[0],
|
|
846
|
+
),
|
|
847
|
+
)
|
|
848
|
+
"
|
|
849
|
+
/>
|
|
850
|
+
</template>
|
|
851
|
+
<UButton
|
|
852
|
+
v-else-if="
|
|
853
|
+
issue.severity === 'error' &&
|
|
854
|
+
escapeMessage(draftOf(code)) !== draftOf(code)
|
|
855
|
+
"
|
|
856
|
+
size="xs"
|
|
857
|
+
color="error"
|
|
858
|
+
variant="soft"
|
|
859
|
+
icon="i-ph-magic-wand"
|
|
860
|
+
:label="$t('dms_lang.message_issue.escape')"
|
|
861
|
+
@mousedown.prevent
|
|
862
|
+
@click="rewrite(code, escapeMessage(draftOf(code)))"
|
|
863
|
+
/>
|
|
864
|
+
</div>
|
|
865
|
+
</div>
|
|
866
|
+
<p
|
|
867
|
+
v-else-if="
|
|
868
|
+
props.editable &&
|
|
869
|
+
code !== base &&
|
|
870
|
+
baseText &&
|
|
871
|
+
statusOf(code) === 'missing'
|
|
872
|
+
"
|
|
873
|
+
class="text-dimmed text-xs"
|
|
874
|
+
>
|
|
875
|
+
{{ $t('dms_lang.drawer.reference') }}
|
|
876
|
+
<PlaceholderText :text="baseText" />
|
|
877
|
+
</p>
|
|
878
|
+
</div>
|
|
879
|
+
</div>
|
|
880
|
+
</template>
|
|
881
|
+
|
|
882
|
+
<template #footer>
|
|
883
|
+
<div class="w-full space-y-2">
|
|
884
|
+
<div
|
|
885
|
+
v-if="props.editable"
|
|
886
|
+
class="text-dimmed flex items-center justify-between gap-2 text-xs"
|
|
887
|
+
>
|
|
888
|
+
<span aria-live="polite">
|
|
889
|
+
<template v-if="isBusy">
|
|
890
|
+
{{ $t('dms_lang.drawer.saving') }}
|
|
891
|
+
</template>
|
|
892
|
+
<span v-else-if="pendingCount" class="text-error">
|
|
893
|
+
{{ $t('dms_lang.drawer.unsaved_count', pendingCount) }}
|
|
894
|
+
</span>
|
|
895
|
+
<template v-else>{{ $t('dms_lang.drawer.autosave') }}</template>
|
|
896
|
+
</span>
|
|
897
|
+
<span class="hidden items-center gap-1 sm:inline-flex">
|
|
898
|
+
<ShortcutKbds :keys="KEY_PANEL_KEYS.saveNext" />
|
|
899
|
+
{{ $t('dms_lang.drawer.save_next') }}
|
|
900
|
+
</span>
|
|
901
|
+
</div>
|
|
902
|
+
<div class="flex w-full items-center gap-2">
|
|
903
|
+
<template v-if="props.manageKeys && isStored">
|
|
904
|
+
<UButton
|
|
905
|
+
v-if="!hasInherited"
|
|
906
|
+
icon="i-ph-pencil-simple"
|
|
907
|
+
color="neutral"
|
|
908
|
+
variant="ghost"
|
|
909
|
+
size="sm"
|
|
910
|
+
:label="$t('dms_lang.drawer.rename')"
|
|
911
|
+
@click="rename"
|
|
912
|
+
/>
|
|
913
|
+
<UButton
|
|
914
|
+
:icon="
|
|
915
|
+
hasInherited ? 'i-ph-arrow-counter-clockwise' : 'i-ph-trash'
|
|
916
|
+
"
|
|
917
|
+
:color="hasInherited ? 'neutral' : 'error'"
|
|
918
|
+
variant="ghost"
|
|
919
|
+
size="sm"
|
|
920
|
+
:label="
|
|
921
|
+
hasInherited
|
|
922
|
+
? $t('dms_lang.drawer.revert_module')
|
|
923
|
+
: $t('dms_lang.drawer.delete')
|
|
924
|
+
"
|
|
925
|
+
@click="remove"
|
|
926
|
+
/>
|
|
927
|
+
</template>
|
|
928
|
+
<UButton
|
|
929
|
+
v-if="!props.editable && props.canOverride"
|
|
930
|
+
icon="i-ph-git-fork"
|
|
931
|
+
color="neutral"
|
|
932
|
+
variant="outline"
|
|
933
|
+
size="sm"
|
|
934
|
+
:label="$t('dms_lang.override.action')"
|
|
935
|
+
@click="emit('override', key)"
|
|
936
|
+
/>
|
|
937
|
+
<div class="flex-1" />
|
|
938
|
+
<UButton
|
|
939
|
+
v-if="props.editable"
|
|
940
|
+
icon="i-ph-check"
|
|
941
|
+
size="sm"
|
|
942
|
+
:loading="isBusy"
|
|
943
|
+
:disabled="!changedCodes.length"
|
|
944
|
+
:label="$t('dms_lang.drawer.save')"
|
|
945
|
+
@click="flush()"
|
|
946
|
+
/>
|
|
947
|
+
</div>
|
|
948
|
+
</div>
|
|
949
|
+
</template>
|
|
950
|
+
</USlideover>
|
|
951
|
+
</template>
|