@antelopejs/dms-lang 0.7.3-next.135.g5e93dc1 → 0.7.3-next.136.g7c92ec0
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/frontend-vue/.prettierignore +1 -0
- package/frontend-vue/app/build/components/KeyEditorDrawer.vue +4 -6
- package/frontend-vue/app/build/components/KeyStatus.vue +0 -2
- package/frontend-vue/app/build/components/LanguagePicker.vue +7 -4
- package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +10 -8
- package/frontend-vue/app/build/components/form/FormFieldRow.vue +4 -2
- package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +1 -5
- package/frontend-vue/app/build/components/matrix/MatrixCell.vue +15 -12
- package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +7 -1
- package/frontend-vue/app/build/composables/useCellEditor.ts +1 -1
- package/frontend-vue/app/build/composables/useCellMoves.ts +7 -7
- package/frontend-vue/app/build/composables/useCellSaves.ts +4 -4
- package/frontend-vue/app/build/composables/useKeyPanel.ts +19 -15
- package/frontend-vue/app/build/composables/useKeySaves.ts +24 -18
- package/frontend-vue/app/build/composables/useMatrixView.ts +6 -5
- package/frontend-vue/app/build/composables/useQueueShortcuts.ts +9 -7
- package/frontend-vue/app/build/composables/useQueueToasts.ts +5 -4
- package/frontend-vue/app/build/matrix/MatrixDoneBanner.vue +0 -1
- package/frontend-vue/app/build/matrix/MatrixFooter.vue +0 -1
- package/frontend-vue/app/build/matrix/MatrixLanguageHeader.vue +0 -1
- package/frontend-vue/app/build/matrix/MatrixNoRows.vue +1 -1
- package/frontend-vue/app/components/WorkspaceGeneral.vue +4 -7
- package/frontend-vue/app/components/WorkspaceList.vue +4 -7
- package/frontend-vue/app/components/WorkspaceScope.vue +1 -1
- package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +24 -7
- package/frontend-vue/app/composables/translation/useKeyActions.ts +8 -8
- package/frontend-vue/app/composables/translation/useLangLinks.ts +7 -7
- package/frontend-vue/app/composables/translation/useLanguageActions.ts +6 -4
- package/frontend-vue/app/composables/translation/useLanguageQueue.ts +0 -1
- package/frontend-vue/app/composables/translation/useLocaleNames.ts +5 -2
- package/frontend-vue/app/composables/translation/useMutationToast.ts +27 -21
- package/frontend-vue/app/composables/translation/useQueueSession.ts +0 -1
- package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +2 -46
- package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +0 -3
- package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +23 -12
- package/frontend-vue/app/composables/translation/useWorkspaceLabel.ts +0 -1
- package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +0 -8
- package/frontend-vue/app/composables/translation/useWorkspaceTypes.ts +47 -0
- package/frontend-vue/app/utils/download.ts +3 -1
- package/frontend-vue/app/utils/keySaveErrors.ts +65 -16
- package/frontend-vue/app/utils/keySaves.ts +13 -11
- package/frontend-vue/app/utils/matrixExport.ts +2 -2
- package/frontend-vue/app/utils/queueDrafts.ts +1 -1
- package/frontend-vue/app/utils/shortcuts.ts +6 -10
- package/frontend-vue/app/utils/translations.ts +46 -45
- package/frontend-vue/app/utils/workspaceBackup.ts +22 -14
- package/frontend-vue/dms.frontend.ts +4 -5
- package/frontend-vue/eslint.config.mjs +16 -15
- package/frontend-vue/package.json +1 -1
- package/frontend-vue/tsconfig.json +6 -0
- package/package.json +4 -4
|
@@ -266,7 +266,6 @@ function overwrite(code: string) {
|
|
|
266
266
|
save([code])
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
// Labels a language's field with its name, for assistive technologies.
|
|
270
269
|
function fieldIdOf(code: string): string {
|
|
271
270
|
return `${fieldIds}-${code}`
|
|
272
271
|
}
|
|
@@ -293,11 +292,13 @@ function knownInheritedOf(path: string) {
|
|
|
293
292
|
|
|
294
293
|
function settle(codes: string[], values: Record<string, string>) {
|
|
295
294
|
const rest = new Map(Object.entries(drafts.value))
|
|
295
|
+
const texts = new Map(Object.entries(values))
|
|
296
296
|
for (const code of codes) {
|
|
297
|
-
const
|
|
297
|
+
const text = texts.get(code)
|
|
298
|
+
const isDone = rest.get(code) === text
|
|
298
299
|
if (isDone) rest.delete(code)
|
|
299
300
|
if (isDone) editStarts.end(code)
|
|
300
|
-
else editStarts.set(code, storedText(
|
|
301
|
+
else editStarts.set(code, storedText(text ?? ''))
|
|
301
302
|
setFieldState(code, 'idle')
|
|
302
303
|
states.flashSaved(code)
|
|
303
304
|
}
|
|
@@ -515,9 +516,6 @@ watch(
|
|
|
515
516
|
},
|
|
516
517
|
)
|
|
517
518
|
|
|
518
|
-
// The drawer's X, Escape and a click outside close it through its guards:
|
|
519
|
-
// the panel saves first and stays open on what it could not save, the
|
|
520
|
-
// field that holds it saying why.
|
|
521
519
|
if (props.containerId)
|
|
522
520
|
onScopeDispose(useLeaveGuard().addGuard(props.containerId, flush))
|
|
523
521
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import PlaceholderText from './PlaceholderText.vue'
|
|
3
3
|
|
|
4
|
-
// Under the key in the DMS row header of the key panel: what the key
|
|
5
|
-
// misses, its issues and its base text's placeholders.
|
|
6
4
|
interface Props {
|
|
7
5
|
missingCount: number
|
|
8
6
|
issueCount: number
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { VNode } from 'vue'
|
|
2
3
|
import { useLocaleNames } from '../../composables/translation/useLocaleNames'
|
|
3
4
|
import type { SelectMenuItem } from '@nuxt/ui'
|
|
4
5
|
import { typedLocaleCode, type LanguageOption } from '../../utils/languages'
|
|
@@ -24,10 +25,13 @@ interface Emits {
|
|
|
24
25
|
|
|
25
26
|
interface Slots {
|
|
26
27
|
/** What the list says when the search finds nothing. */
|
|
27
|
-
empty?: () =>
|
|
28
|
+
empty?: () => VNode[]
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
const STEP_KEYS
|
|
31
|
+
const STEP_KEYS = new Map([
|
|
32
|
+
['ArrowDown', 1],
|
|
33
|
+
['ArrowUp', -1],
|
|
34
|
+
])
|
|
31
35
|
const LISTBOX_ID = 'language-picker-options'
|
|
32
36
|
|
|
33
37
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -83,7 +87,6 @@ function optionId(value: string): string {
|
|
|
83
87
|
return `${LISTBOX_ID}-${value}`
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
/** Typing a code the list offers picks it. */
|
|
87
90
|
watch(search, () => {
|
|
88
91
|
if (!props.isOpen) return
|
|
89
92
|
const exact = typedLocaleCode(search.value)
|
|
@@ -92,7 +95,7 @@ watch(search, () => {
|
|
|
92
95
|
})
|
|
93
96
|
|
|
94
97
|
function step(event: KeyboardEvent) {
|
|
95
|
-
const delta = STEP_KEYS
|
|
98
|
+
const delta = STEP_KEYS.get(event.key)
|
|
96
99
|
const list = free.value
|
|
97
100
|
if (!delta || !list.length) return
|
|
98
101
|
event.preventDefault()
|
|
@@ -72,10 +72,10 @@ function close(workspace: string | null) {
|
|
|
72
72
|
|
|
73
73
|
function detailsOf(): WorkspaceDetails {
|
|
74
74
|
const text = description.value.trim()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const details: WorkspaceDetails = {}
|
|
76
|
+
if (text) details.description = text
|
|
77
|
+
if (type.value) details.type = type.value
|
|
78
|
+
return details
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/** The backup with the details as the form leaves them: a field emptied clears the backup's. */
|
|
@@ -88,10 +88,12 @@ function importOf(backup: WorkspaceBackup) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function send(id: string): Promise<
|
|
92
|
-
if (!props.backup)
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
async function send(id: string): Promise<void> {
|
|
92
|
+
if (!props.backup) {
|
|
93
|
+
await createWorkspace(id, { code: base.value }, detailsOf())
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
await importWorkspace(id, importOf(props.backup))
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
async function submit() {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { VNode } from 'vue'
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* One field of a hand-built form, drawn as a DMS form draws its rows
|
|
4
6
|
* (`FormEntries` / `FormFieldControl`): a `DmsFieldRow` holding the label,
|
|
@@ -25,9 +27,9 @@ interface FormFieldRowControl {
|
|
|
25
27
|
|
|
26
28
|
interface FormFieldRowSlots {
|
|
27
29
|
/** The control; bind `id` onto it. */
|
|
28
|
-
default?: (control: FormFieldRowControl) =>
|
|
30
|
+
default?: (control: FormFieldRowControl) => VNode[]
|
|
29
31
|
/** Inline after the label (a badge). */
|
|
30
|
-
'label-extra'?: () =>
|
|
32
|
+
'label-extra'?: () => VNode[]
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const props = withDefaults(defineProps<FormFieldRowProps>(), {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useWorkspaceTypes } from '../../../composables/translation/
|
|
3
|
-
/**
|
|
4
|
-
* What a workspace is for: its free description and its type, as rows of a
|
|
5
|
-
* hand-built form (`FormRows`).
|
|
6
|
-
*/
|
|
2
|
+
import { useWorkspaceTypes } from '../../../composables/translation/useWorkspaceTypes'
|
|
7
3
|
import type { WorkspaceType } from '../../../types/lang'
|
|
8
4
|
import FormFieldRow from './FormFieldRow.vue'
|
|
9
5
|
|
|
@@ -170,21 +170,24 @@ function openPanel() {
|
|
|
170
170
|
emit('openPanel', props.rowKey, props.code, draft.value)
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
const KEY_HANDLERS
|
|
174
|
-
Escape
|
|
175
|
-
Tab
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
const KEY_HANDLERS = new Map<string, KeyHandler>([
|
|
174
|
+
['Escape', () => cancel],
|
|
175
|
+
['Tab', (event) => () => commit(event.shiftKey ? 'previous' : 'next')],
|
|
176
|
+
[
|
|
177
|
+
'Enter',
|
|
178
|
+
(event) => {
|
|
179
|
+
if (event.altKey) return undefined
|
|
180
|
+
const hasModifier = event.ctrlKey || event.metaKey
|
|
181
|
+
if (hasModifier && event.shiftKey) return openPanel
|
|
182
|
+
if (hasModifier) return () => commit('stay')
|
|
183
|
+
return event.shiftKey ? undefined : () => commit('down')
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
])
|
|
184
187
|
|
|
185
188
|
function onKeydown(event: KeyboardEvent) {
|
|
186
189
|
if (event.isComposing) return
|
|
187
|
-
const action = KEY_HANDLERS
|
|
190
|
+
const action = KEY_HANDLERS.get(event.key)?.(event)
|
|
188
191
|
if (!action) return
|
|
189
192
|
event.preventDefault()
|
|
190
193
|
event.stopPropagation()
|
|
@@ -27,6 +27,12 @@ interface Props {
|
|
|
27
27
|
const SEARCH_DELAY_MS = 200
|
|
28
28
|
const ANY_LANGUAGE = '*'
|
|
29
29
|
const ALL_NAMESPACES = '*'
|
|
30
|
+
const FILTER_ORDER: TranslationFilter[] = [
|
|
31
|
+
'all',
|
|
32
|
+
'missing',
|
|
33
|
+
'complete',
|
|
34
|
+
'issues',
|
|
35
|
+
]
|
|
30
36
|
const FILTER_LABELS: Record<TranslationFilter, string> = {
|
|
31
37
|
all: 'dms_lang.matrix.filter_all',
|
|
32
38
|
missing: 'dms_lang.matrix.filter_missing',
|
|
@@ -43,7 +49,7 @@ const { formatCount } = useLangFormat()
|
|
|
43
49
|
const searchInput = ref(filters.value.search)
|
|
44
50
|
|
|
45
51
|
const filterItems = computed(() =>
|
|
46
|
-
|
|
52
|
+
FILTER_ORDER.map((value) => ({
|
|
47
53
|
value,
|
|
48
54
|
label: t(
|
|
49
55
|
value === 'missing' && props.countedLanguages > 1
|
|
@@ -126,7 +126,7 @@ function moveFrom(
|
|
|
126
126
|
move: CellMove,
|
|
127
127
|
) {
|
|
128
128
|
const target = context.options.targetOf({ key, code }, move)
|
|
129
|
-
if (target) nextTick(() => startEdit(context, target.key, target.code))
|
|
129
|
+
if (target) void nextTick(() => startEdit(context, target.key, target.code))
|
|
130
130
|
else if (move !== 'stay') context.options.onMoveEnd({ key, code })
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -21,12 +21,12 @@ type MoveTarget = (options: CellMovesOptions, cell: CellRef) => CellRef | null
|
|
|
21
21
|
|
|
22
22
|
const TYPING_FIELDS = 'input, textarea, select, [contenteditable]'
|
|
23
23
|
const GRID_CELL = 'td[data-row]'
|
|
24
|
-
const ARROW_STEPS
|
|
25
|
-
ArrowUp
|
|
26
|
-
ArrowDown
|
|
27
|
-
ArrowLeft
|
|
28
|
-
ArrowRight
|
|
29
|
-
|
|
24
|
+
const ARROW_STEPS = new Map<string, [number, number]>([
|
|
25
|
+
['ArrowUp', [-1, 0]],
|
|
26
|
+
['ArrowDown', [1, 0]],
|
|
27
|
+
['ArrowLeft', [0, -1]],
|
|
28
|
+
['ArrowRight', [0, 1]],
|
|
29
|
+
])
|
|
30
30
|
|
|
31
31
|
function navigableCodes(options: CellMovesOptions, code: string): string[] {
|
|
32
32
|
const base = options.baseLocale()
|
|
@@ -126,7 +126,7 @@ export function focusNeighbourCell(
|
|
|
126
126
|
event: KeyboardEvent,
|
|
127
127
|
grid: HTMLElement | undefined,
|
|
128
128
|
) {
|
|
129
|
-
const step = ARROW_STEPS
|
|
129
|
+
const step = ARROW_STEPS.get(event.key)
|
|
130
130
|
const cell =
|
|
131
131
|
event.target instanceof HTMLElement
|
|
132
132
|
? event.target.closest<HTMLElement>(GRID_CELL)
|
|
@@ -161,12 +161,12 @@ function useCellReports(
|
|
|
161
161
|
retry: (address: CellAddress) => void,
|
|
162
162
|
discard: (address: CellAddress) => void,
|
|
163
163
|
) {
|
|
164
|
-
const
|
|
164
|
+
const presenter = useApiErrorPresenter()
|
|
165
165
|
const { reportFailure } = useMutationToast()
|
|
166
166
|
|
|
167
167
|
return {
|
|
168
|
-
conflict(address: CellAddress, error:
|
|
169
|
-
presentError(error, {
|
|
168
|
+
conflict(address: CellAddress, error: Error) {
|
|
169
|
+
presenter.presentError(error, {
|
|
170
170
|
fallbackKey: 'dms_lang.matrix.conflict',
|
|
171
171
|
params: { ...address },
|
|
172
172
|
actions: [
|
|
@@ -181,7 +181,7 @@ function useCellReports(
|
|
|
181
181
|
],
|
|
182
182
|
})
|
|
183
183
|
},
|
|
184
|
-
failure(address: CellAddress, error:
|
|
184
|
+
failure(address: CellAddress, error: Error, canRetry = true) {
|
|
185
185
|
reportFailure(error, {
|
|
186
186
|
fallbackKey: 'dms_lang.matrix.save_failed',
|
|
187
187
|
params: { ...address },
|
|
@@ -37,7 +37,22 @@ export interface PanelOptions {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
type DrawerOverlay = ReturnType<ReturnType<typeof useDrawer>['open']>
|
|
40
|
-
|
|
40
|
+
interface PanelProps {
|
|
41
|
+
keys: string[]
|
|
42
|
+
startIndex: number
|
|
43
|
+
workspace: string
|
|
44
|
+
editable: boolean
|
|
45
|
+
manageKeys: boolean
|
|
46
|
+
canOverride: boolean
|
|
47
|
+
seed: FlatTranslationRow | undefined
|
|
48
|
+
focusLocale: string | undefined
|
|
49
|
+
initialDrafts: Record<string, string> | undefined
|
|
50
|
+
onNavigate: (key: string) => void
|
|
51
|
+
onOverride: (key: string) => void
|
|
52
|
+
onKeep: (holds: CellHold[]) => void
|
|
53
|
+
onHeader: (header: KeyPanelHeader) => void
|
|
54
|
+
open: boolean
|
|
55
|
+
}
|
|
41
56
|
|
|
42
57
|
interface PendingSwitch {
|
|
43
58
|
key: string
|
|
@@ -48,7 +63,7 @@ interface PanelState {
|
|
|
48
63
|
shownWorkspace: string
|
|
49
64
|
drawer: DrawerOverlay | null
|
|
50
65
|
/** The props the open panel's body was last given. */
|
|
51
|
-
props: PanelProps
|
|
66
|
+
props: Partial<PanelProps>
|
|
52
67
|
pendingSwitch: PendingSwitch | null
|
|
53
68
|
isDisposed: boolean
|
|
54
69
|
}
|
|
@@ -66,15 +81,9 @@ interface PanelContext {
|
|
|
66
81
|
|
|
67
82
|
const KEY_QUERY = 'key'
|
|
68
83
|
const DRAWER_DIRECTION = 'right'
|
|
69
|
-
// Every key opens the same drawer, under one id: the DMS keeps the width the
|
|
70
|
-
// user drags it to under its `sizeKey`, on this device. One panel is open at
|
|
71
|
-
// a time, so the id stays unique.
|
|
72
84
|
const DRAWER_ID = 'dms-lang-key-panel'
|
|
73
85
|
const POSITION_LABEL = '$dms_lang.drawer.position'
|
|
74
86
|
|
|
75
|
-
// The key keeps its look in the DMS row header: in mono, wrapped only after
|
|
76
|
-
// its separators, the namespaces above it after its place among the keys,
|
|
77
|
-
// what it misses, its issues and its placeholders under them.
|
|
78
87
|
const KEY_LOOK = {
|
|
79
88
|
titleClass: 'font-mono',
|
|
80
89
|
titleBreakAfter: NAMESPACE_SEPARATOR,
|
|
@@ -137,7 +146,7 @@ function dropSeed(context: PanelContext, key: string) {
|
|
|
137
146
|
if (dropped) context.seeds.value = rest
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
function propsFor(context: PanelContext, request: PanelRequest)
|
|
149
|
+
function propsFor(context: PanelContext, request: PanelRequest) {
|
|
141
150
|
const { options } = context
|
|
142
151
|
const keys = options.keys()
|
|
143
152
|
const index = keys.indexOf(request.key)
|
|
@@ -160,7 +169,7 @@ function propsFor(context: PanelContext, request: PanelRequest): PanelProps {
|
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
/** Changes some of the open panel's props, keeping the others. */
|
|
163
|
-
function patchPanel(context: PanelContext, props: PanelProps) {
|
|
172
|
+
function patchPanel(context: PanelContext, props: Partial<PanelProps>) {
|
|
164
173
|
const { state } = context
|
|
165
174
|
state.props = { ...state.props, ...props }
|
|
166
175
|
state.drawer?.patch({ componentOptions: state.props })
|
|
@@ -198,8 +207,6 @@ function show(context: PanelContext, request: PanelRequest): Promise<boolean> {
|
|
|
198
207
|
if (state.drawer) return switchKey(context, request)
|
|
199
208
|
context.shownKey.value = request.key
|
|
200
209
|
state.props = propsFor(context, request)
|
|
201
|
-
// The DMS row header names the key; the body hands over its place among
|
|
202
|
-
// the keys as it shows one (`onHeader`).
|
|
203
210
|
state.drawer = context.drawers.open({
|
|
204
211
|
direction: DRAWER_DIRECTION,
|
|
205
212
|
containerId: DRAWER_ID,
|
|
@@ -240,9 +247,6 @@ function onClosed(context: PanelContext) {
|
|
|
240
247
|
if (!state.isDisposed) dropSeed(context, context.shownKey.value)
|
|
241
248
|
context.shownKey.value = ''
|
|
242
249
|
if (state.isDisposed || !route.query[KEY_QUERY]) return
|
|
243
|
-
// Replaced, not left by going Back: a history step back renders the page
|
|
244
|
-
// anew (Inertia restores it from the history), which would fold the
|
|
245
|
-
// matrix's groups and lose its scroll.
|
|
246
250
|
void context.router.replace(linkWithKey(context, undefined))
|
|
247
251
|
}
|
|
248
252
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Ref } from 'vue'
|
|
2
2
|
import type { FlatTranslationRow, KeyRowResponse } from '../../types/lang'
|
|
3
3
|
import {
|
|
4
|
+
isKeySaveError,
|
|
4
5
|
keySaveFailure,
|
|
5
6
|
type KeySaveFailure,
|
|
6
7
|
type KeySaveFailureKind,
|
|
@@ -45,7 +46,7 @@ export interface KeyWriteFailed {
|
|
|
45
46
|
message: string
|
|
46
47
|
/** What the write expected: a later attempt expects the same. */
|
|
47
48
|
expected: Record<string, ExpectedText>
|
|
48
|
-
error:
|
|
49
|
+
error: Error
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export type KeyWriteOutcome = KeyWriteSaved | KeyWriteFailed
|
|
@@ -54,7 +55,7 @@ interface KeySaveContext {
|
|
|
54
55
|
updateKey: ReturnType<typeof useI18nWorkspaces>['updateKey']
|
|
55
56
|
postReviewed: ReturnType<typeof useI18nWorkspaces>['markReviewed']
|
|
56
57
|
translations: ReturnType<typeof useWorkspaceFlat>
|
|
57
|
-
errorMessage: (error:
|
|
58
|
+
errorMessage: (error: Error) => string
|
|
58
59
|
translate: ApiMessageTranslate
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -74,10 +75,12 @@ function applyCurrent(
|
|
|
74
75
|
row: FlatTranslationRow,
|
|
75
76
|
failure: KeySaveFailure,
|
|
76
77
|
): FlatTranslationRow {
|
|
77
|
-
const current = Object.entries(failure.current).map(
|
|
78
|
-
code,
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const current = Object.entries(failure.current).map(
|
|
79
|
+
([code, value]): [string, string | undefined] => [
|
|
80
|
+
code,
|
|
81
|
+
savedText(value) ?? undefined,
|
|
82
|
+
],
|
|
83
|
+
)
|
|
81
84
|
return { ...row, values: { ...row.values, ...Object.fromEntries(current) } }
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -85,19 +88,17 @@ const FAILURE_CHANGES: Partial<Record<KeySaveFailureKind, FailureChange>> = {
|
|
|
85
88
|
conflict: applyCurrent,
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
function textsOf(values: Record<string, string>)
|
|
91
|
+
function textsOf(values: Record<string, string>) {
|
|
89
92
|
return Object.fromEntries(
|
|
90
93
|
Object.entries(values).map(([code, text]) => [code, storedText(text)]),
|
|
91
94
|
)
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
function checksOf(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
100
|
-
return checks.length ? Object.fromEntries(checks) : undefined
|
|
97
|
+
function checksOf(expected: Record<string, ExpectedText>) {
|
|
98
|
+
const checks: Record<string, string | null> = {}
|
|
99
|
+
for (const [code, text] of Object.entries(expected))
|
|
100
|
+
if (text !== undefined) checks[code] = text
|
|
101
|
+
return Object.keys(checks).length ? checks : undefined
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
function applyResponse(
|
|
@@ -113,9 +114,12 @@ function failed(
|
|
|
113
114
|
context: KeySaveContext,
|
|
114
115
|
target: KeyTarget,
|
|
115
116
|
expected: Record<string, ExpectedText>,
|
|
116
|
-
error:
|
|
117
|
+
error: Error,
|
|
117
118
|
): KeyWriteFailed {
|
|
118
|
-
const failure = keySaveFailure(
|
|
119
|
+
const failure = keySaveFailure(
|
|
120
|
+
isKeySaveError(error) ? error : undefined,
|
|
121
|
+
context.translate,
|
|
122
|
+
)
|
|
119
123
|
const change = FAILURE_CHANGES[failure.kind]
|
|
120
124
|
const row = context.translations
|
|
121
125
|
.flatOf(target.workspace)
|
|
@@ -143,7 +147,8 @@ async function send(
|
|
|
143
147
|
checksOf(expected),
|
|
144
148
|
)
|
|
145
149
|
return applyResponse(context, request, response)
|
|
146
|
-
} catch (
|
|
150
|
+
} catch (caught) {
|
|
151
|
+
const error = caught instanceof Error ? caught : new Error(String(caught))
|
|
147
152
|
return failed(context, request, expected, error)
|
|
148
153
|
}
|
|
149
154
|
}
|
|
@@ -182,7 +187,8 @@ async function markReviewed(
|
|
|
182
187
|
code,
|
|
183
188
|
])
|
|
184
189
|
return applyResponse(context, target, response)
|
|
185
|
-
} catch (
|
|
190
|
+
} catch (caught) {
|
|
191
|
+
const error = caught instanceof Error ? caught : new Error(String(caught))
|
|
186
192
|
return failed(context, target, {}, error)
|
|
187
193
|
}
|
|
188
194
|
}
|
|
@@ -33,9 +33,7 @@ function filtersOf(
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function queryOf(
|
|
37
|
-
filters: MatrixFilterState,
|
|
38
|
-
): Record<string, string | undefined> {
|
|
36
|
+
function queryOf(filters: MatrixFilterState) {
|
|
39
37
|
return {
|
|
40
38
|
[QUERY_NAMES.filter]:
|
|
41
39
|
filters.filter === DEFAULT_FILTER ? undefined : filters.filter,
|
|
@@ -46,8 +44,11 @@ function queryOf(
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
function sameFilters(a: MatrixFilterState, b: MatrixFilterState): boolean {
|
|
49
|
-
return (
|
|
50
|
-
|
|
47
|
+
return (
|
|
48
|
+
a.filter === b.filter &&
|
|
49
|
+
a.missingIn === b.missingIn &&
|
|
50
|
+
a.namespace === b.namespace &&
|
|
51
|
+
a.search === b.search
|
|
51
52
|
)
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -33,10 +33,11 @@ function isFocusElsewhere(
|
|
|
33
33
|
targets: QueueShortcutTargets,
|
|
34
34
|
): boolean {
|
|
35
35
|
if (isFocusInsideOverlay(active)) return true
|
|
36
|
-
|
|
36
|
+
if (!active) return false
|
|
37
|
+
return isTypingTarget(active) && !targets.root()?.contains(active)
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
function savingBindings(actions: QueueShortcutActions)
|
|
40
|
+
function savingBindings(actions: QueueShortcutActions) {
|
|
40
41
|
return {
|
|
41
42
|
[shortcutName(QUEUE_KEYS.saveNext)]: {
|
|
42
43
|
usingInput: IN_FIELD,
|
|
@@ -52,14 +53,14 @@ function savingBindings(actions: QueueShortcutActions): ShortcutBindings {
|
|
|
52
53
|
function movingBindings(
|
|
53
54
|
actions: QueueShortcutActions,
|
|
54
55
|
browse: (action: () => void) => () => void,
|
|
55
|
-
)
|
|
56
|
+
) {
|
|
56
57
|
return {
|
|
57
58
|
[shortcutName(QUEUE_KEYS.skip)]: { handler: browse(actions.skip) },
|
|
58
59
|
[shortcutName(QUEUE_KEYS.previous)]: { handler: browse(actions.previous) },
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
function leavingBindings(field: HTMLElement)
|
|
63
|
+
function leavingBindings(field: HTMLElement) {
|
|
63
64
|
return {
|
|
64
65
|
[shortcutName(QUEUE_KEYS.leaveField)]: {
|
|
65
66
|
usingInput: IN_FIELD,
|
|
@@ -94,12 +95,13 @@ export function useQueueShortcuts(
|
|
|
94
95
|
if (!actions.isActive() || isFocusElsewhere(active.value, targets))
|
|
95
96
|
return {}
|
|
96
97
|
const field = targets.field()
|
|
97
|
-
const
|
|
98
|
-
return {
|
|
98
|
+
const base = {
|
|
99
99
|
...savingBindings(actions),
|
|
100
100
|
...movingBindings(actions, browse),
|
|
101
|
-
...(isInField ? leavingBindings(field) : {}),
|
|
102
101
|
}
|
|
102
|
+
if (field && active.value === field)
|
|
103
|
+
return { ...base, ...leavingBindings(field) }
|
|
104
|
+
return base
|
|
103
105
|
})
|
|
104
106
|
defineShortcuts(bindings)
|
|
105
107
|
return { isBrowsing: () => isBrowsing }
|
|
@@ -49,17 +49,18 @@ function copyAction(context: ToastContext, draftText: string) {
|
|
|
49
49
|
function announceDeleted(context: ToastContext, key: string, draftText = '') {
|
|
50
50
|
const { t, toast } = context
|
|
51
51
|
const hasDraft = !!draftText.trim()
|
|
52
|
-
|
|
52
|
+
const notice = {
|
|
53
53
|
title: t('dms_lang.queue.deleted_title', { key }),
|
|
54
54
|
description: t(
|
|
55
55
|
hasDraft
|
|
56
56
|
? 'dms_lang.queue.deleted_draft'
|
|
57
57
|
: 'dms_lang.queue.deleted_description',
|
|
58
58
|
),
|
|
59
|
-
color: 'warning',
|
|
59
|
+
color: 'warning' as const,
|
|
60
60
|
icon: 'i-ph-trash',
|
|
61
|
-
|
|
62
|
-
})
|
|
61
|
+
}
|
|
62
|
+
if (hasDraft) toast.add({ ...notice, ...copyAction(context, draftText) })
|
|
63
|
+
else toast.add(notice)
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
function showStep({ t, toast }: ToastContext, step: QueueStep | undefined) {
|
|
@@ -3,7 +3,6 @@ import { MATRIX_KEYS } from '../../utils/shortcuts'
|
|
|
3
3
|
import ShortcutKbds from '../components/ShortcutKbds.vue'
|
|
4
4
|
import type { MatrixCounts } from '../composables/useMatrixFilters'
|
|
5
5
|
|
|
6
|
-
/** The foot of the matrix: what is left to translate, and the keyboard shortcuts of its cells. */
|
|
7
6
|
defineProps<{
|
|
8
7
|
counts: MatrixCounts
|
|
9
8
|
countedLabel: string
|
|
@@ -3,7 +3,6 @@ import type { LanguageCoverage } from '../../types/lang'
|
|
|
3
3
|
import { coverageTone } from '../../utils/coverage'
|
|
4
4
|
import LocaleTile from '../components/LocaleTile.vue'
|
|
5
5
|
|
|
6
|
-
/** The head of a language column of the matrix: the language, its missing texts and its coverage. */
|
|
7
6
|
defineProps<{
|
|
8
7
|
column: LanguageCoverage
|
|
9
8
|
columnSiblings: string[]
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useLanguageActions } from '../composables/translation/useLanguageActions'
|
|
3
3
|
import { useLocaleNames } from '../composables/translation/useLocaleNames'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
useWorkspaceTypes,
|
|
7
|
-
} from '../composables/translation/useWorkspaceActions'
|
|
4
|
+
import { useWorkspaceActions } from '../composables/translation/useWorkspaceActions'
|
|
5
|
+
import { useWorkspaceTypes } from '../composables/translation/useWorkspaceTypes'
|
|
8
6
|
import { useWorkspaceContext } from '../composables/translation/useWorkspaceContext'
|
|
9
7
|
import { useWorkspaceRoute } from '../composables/translation/useWorkspaceRoute'
|
|
10
8
|
import UButton from '@nuxt/ui/components/Button.vue'
|
|
@@ -100,8 +98,7 @@ function saveType(type: WorkspaceType) {
|
|
|
100
98
|
void track('type', () => updateDetails(workspaceId.value, { type }))
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
function pickType(
|
|
104
|
-
const type = typeOf(value)
|
|
101
|
+
function pickType(type: WorkspaceType | undefined) {
|
|
105
102
|
if (type && type !== current.value?.type) saveType(type)
|
|
106
103
|
}
|
|
107
104
|
|
|
@@ -194,7 +191,7 @@ usePageHeaderActions(() =>
|
|
|
194
191
|
:model-value="current?.type"
|
|
195
192
|
:items="typeItems"
|
|
196
193
|
:disabled="!canEditDetails"
|
|
197
|
-
@update:model-value="pickType"
|
|
194
|
+
@update:model-value="(value: unknown) => pickType(typeOf(value))"
|
|
198
195
|
/>
|
|
199
196
|
<template #label-extra>
|
|
200
197
|
<DmsSaveStatus
|