@adminforth/i18n 3.1.4 → 3.1.6
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/build.log +2 -2
- package/custom/BulkActionButton.vue +4 -2
- package/custom/LanguageUnderLogin.vue +1 -1
- package/custom/TranslationJobViewComponent.vue +9 -6
- package/dist/custom/BulkActionButton.vue +4 -2
- package/dist/custom/LanguageUnderLogin.vue +1 -1
- package/dist/custom/TranslationJobViewComponent.vue +9 -6
- package/dist/index.js +6 -4
- package/index.ts +6 -4
- package/package.json +2 -2
package/build.log
CHANGED
|
@@ -20,5 +20,5 @@ custom/package.json
|
|
|
20
20
|
custom/pnpm-lock.yaml
|
|
21
21
|
custom/tsconfig.json
|
|
22
22
|
|
|
23
|
-
sent 45,
|
|
24
|
-
total size is 44,
|
|
23
|
+
sent 45,755 bytes received 305 bytes 92,120.00 bytes/sec
|
|
24
|
+
total size is 44,587 speedup is 0.97
|
|
@@ -98,8 +98,10 @@
|
|
|
98
98
|
const allChecked = computed(() => Object.values(checkedLanguages.value).every(Boolean));
|
|
99
99
|
const noneChecked = computed(() => Object.values(checkedLanguages.value).every(value => !value));
|
|
100
100
|
|
|
101
|
+
let unsubscribeFromTranslationProgress: () => void;
|
|
102
|
+
|
|
101
103
|
onMounted(() => {
|
|
102
|
-
websocket.subscribe('/translation_progress', (data) => {
|
|
104
|
+
unsubscribeFromTranslationProgress = websocket.subscribe('/translation_progress', (data) => {
|
|
103
105
|
adminforth.list.refresh();
|
|
104
106
|
});
|
|
105
107
|
for (const lang of props.meta.supportedLanguages) {
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
});
|
|
109
111
|
|
|
110
112
|
onUnmounted( () => {
|
|
111
|
-
|
|
113
|
+
unsubscribeFromTranslationProgress();
|
|
112
114
|
} )
|
|
113
115
|
|
|
114
116
|
function selectAll() {
|
|
@@ -45,7 +45,7 @@ watch(() => selectedLanguage.value, async (newVal) => {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
await setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, newVal);
|
|
48
|
-
coreStore.
|
|
48
|
+
coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false });
|
|
49
49
|
coreStore.getLoginFormConfig();
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -135,10 +135,12 @@ async function loadPage(targetPage: number) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
let unsubscribeFromTaskUpdates: () => void;
|
|
139
|
+
let unsubscribeFromTaskErrors: () => void;
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
onMounted(async () => {
|
|
142
|
+
// subscribe before the first await, so onUnmounted always has something to unsubscribe
|
|
143
|
+
unsubscribeFromTaskUpdates = websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
|
|
142
144
|
const indexOnPage = data.taskIndex - currentOffset.value;
|
|
143
145
|
if (indexOnPage >= 0 && indexOnPage < translationTasks.value.length) {
|
|
144
146
|
if (data.state) {
|
|
@@ -149,15 +151,16 @@ onMounted(async () => {
|
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
});
|
|
152
|
-
websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
|
|
154
|
+
unsubscribeFromTaskErrors = websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
|
|
153
155
|
console.log('Error received for task', data);
|
|
154
156
|
});
|
|
155
157
|
|
|
158
|
+
await loadPage(0);
|
|
156
159
|
});
|
|
157
160
|
|
|
158
161
|
onUnmounted(() => {
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
unsubscribeFromTaskUpdates();
|
|
163
|
+
unsubscribeFromTaskErrors();
|
|
161
164
|
});
|
|
162
165
|
|
|
163
166
|
|
|
@@ -98,8 +98,10 @@
|
|
|
98
98
|
const allChecked = computed(() => Object.values(checkedLanguages.value).every(Boolean));
|
|
99
99
|
const noneChecked = computed(() => Object.values(checkedLanguages.value).every(value => !value));
|
|
100
100
|
|
|
101
|
+
let unsubscribeFromTranslationProgress: () => void;
|
|
102
|
+
|
|
101
103
|
onMounted(() => {
|
|
102
|
-
websocket.subscribe('/translation_progress', (data) => {
|
|
104
|
+
unsubscribeFromTranslationProgress = websocket.subscribe('/translation_progress', (data) => {
|
|
103
105
|
adminforth.list.refresh();
|
|
104
106
|
});
|
|
105
107
|
for (const lang of props.meta.supportedLanguages) {
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
});
|
|
109
111
|
|
|
110
112
|
onUnmounted( () => {
|
|
111
|
-
|
|
113
|
+
unsubscribeFromTranslationProgress();
|
|
112
114
|
} )
|
|
113
115
|
|
|
114
116
|
function selectAll() {
|
|
@@ -45,7 +45,7 @@ watch(() => selectedLanguage.value, async (newVal) => {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
await setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, newVal);
|
|
48
|
-
coreStore.
|
|
48
|
+
coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false });
|
|
49
49
|
coreStore.getLoginFormConfig();
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -135,10 +135,12 @@ async function loadPage(targetPage: number) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
let unsubscribeFromTaskUpdates: () => void;
|
|
139
|
+
let unsubscribeFromTaskErrors: () => void;
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
onMounted(async () => {
|
|
142
|
+
// subscribe before the first await, so onUnmounted always has something to unsubscribe
|
|
143
|
+
unsubscribeFromTaskUpdates = websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
|
|
142
144
|
const indexOnPage = data.taskIndex - currentOffset.value;
|
|
143
145
|
if (indexOnPage >= 0 && indexOnPage < translationTasks.value.length) {
|
|
144
146
|
if (data.state) {
|
|
@@ -149,15 +151,16 @@ onMounted(async () => {
|
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
});
|
|
152
|
-
websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
|
|
154
|
+
unsubscribeFromTaskErrors = websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
|
|
153
155
|
console.log('Error received for task', data);
|
|
154
156
|
});
|
|
155
157
|
|
|
158
|
+
await loadPage(0);
|
|
156
159
|
});
|
|
157
160
|
|
|
158
161
|
onUnmounted(() => {
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
unsubscribeFromTaskUpdates();
|
|
163
|
+
unsubscribeFromTaskErrors();
|
|
161
164
|
});
|
|
162
165
|
|
|
163
166
|
|
package/dist/index.js
CHANGED
|
@@ -280,10 +280,10 @@ export default class I18nPlugin extends I18nBase {
|
|
|
280
280
|
return { ok: true };
|
|
281
281
|
}));
|
|
282
282
|
// also add edit hook beforeSave to update completedFieldName
|
|
283
|
-
resourceConfig.hooks.edit.beforeSave.push((_a) => __awaiter(this, [_a], void 0, function* ({
|
|
284
|
-
const futureRecord = Object.assign(Object.assign({}, oldRecord),
|
|
283
|
+
resourceConfig.hooks.edit.beforeSave.push((_a) => __awaiter(this, [_a], void 0, function* ({ updates, oldRecord }) {
|
|
284
|
+
const futureRecord = Object.assign(Object.assign({}, oldRecord), updates);
|
|
285
285
|
const futureCompletedFieldValue = yield this.computeCompletedFieldValue(futureRecord);
|
|
286
|
-
|
|
286
|
+
updates[this.options.completedFieldName] = futureCompletedFieldValue;
|
|
287
287
|
return { ok: true };
|
|
288
288
|
}));
|
|
289
289
|
// add list hook to support filtering by fully_translated virtual field
|
|
@@ -860,6 +860,7 @@ export default class I18nPlugin extends I18nBase {
|
|
|
860
860
|
server.endpoint({
|
|
861
861
|
method: 'POST',
|
|
862
862
|
path: `/plugin/${this.pluginInstanceId}/update-field`,
|
|
863
|
+
agent: { hiddenFromAgents: true },
|
|
863
864
|
request_schema: updateFieldBodySchema,
|
|
864
865
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, response }) {
|
|
865
866
|
const data = body;
|
|
@@ -907,7 +908,7 @@ export default class I18nPlugin extends I18nBase {
|
|
|
907
908
|
result = yield this.adminforth.updateResourceRecord({
|
|
908
909
|
resource,
|
|
909
910
|
recordId,
|
|
910
|
-
|
|
911
|
+
updates: updateRecord,
|
|
911
912
|
oldRecord,
|
|
912
913
|
adminUser
|
|
913
914
|
});
|
|
@@ -945,6 +946,7 @@ export default class I18nPlugin extends I18nBase {
|
|
|
945
946
|
server.endpoint({
|
|
946
947
|
method: 'POST',
|
|
947
948
|
path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
|
|
949
|
+
agent: { hiddenFromAgents: true },
|
|
948
950
|
request_schema: getFilteredIdsBodySchema,
|
|
949
951
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, query, cookies, requestUrl, response }) {
|
|
950
952
|
var _b, _c;
|
package/index.ts
CHANGED
|
@@ -332,12 +332,12 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
|
|
|
332
332
|
});
|
|
333
333
|
|
|
334
334
|
// also add edit hook beforeSave to update completedFieldName
|
|
335
|
-
resourceConfig.hooks.edit.beforeSave.push(async ({
|
|
336
|
-
const futureRecord = { ...oldRecord, ...
|
|
335
|
+
resourceConfig.hooks.edit.beforeSave.push(async ({ updates, oldRecord }: { updates: any, oldRecord: any }): Promise<{ ok: boolean, error?: string }> => {
|
|
336
|
+
const futureRecord = { ...oldRecord, ...updates };
|
|
337
337
|
|
|
338
338
|
const futureCompletedFieldValue = await this.computeCompletedFieldValue(futureRecord);
|
|
339
339
|
|
|
340
|
-
|
|
340
|
+
updates[this.options.completedFieldName] = futureCompletedFieldValue;
|
|
341
341
|
return { ok: true };
|
|
342
342
|
});
|
|
343
343
|
|
|
@@ -1071,6 +1071,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
|
|
|
1071
1071
|
server.endpoint({
|
|
1072
1072
|
method: 'POST',
|
|
1073
1073
|
path: `/plugin/${this.pluginInstanceId}/update-field`,
|
|
1074
|
+
agent: { hiddenFromAgents: true },
|
|
1074
1075
|
request_schema: updateFieldBodySchema,
|
|
1075
1076
|
handler: async ({ body, adminUser, headers, response }) => {
|
|
1076
1077
|
const data = body as z.infer<typeof updateFieldBodySchema>;
|
|
@@ -1129,7 +1130,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
|
|
|
1129
1130
|
result = await this.adminforth.updateResourceRecord({
|
|
1130
1131
|
resource,
|
|
1131
1132
|
recordId,
|
|
1132
|
-
|
|
1133
|
+
updates: updateRecord,
|
|
1133
1134
|
oldRecord,
|
|
1134
1135
|
adminUser
|
|
1135
1136
|
});
|
|
@@ -1175,6 +1176,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
|
|
|
1175
1176
|
server.endpoint({
|
|
1176
1177
|
method: 'POST',
|
|
1177
1178
|
path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
|
|
1179
|
+
agent: { hiddenFromAgents: true },
|
|
1178
1180
|
request_schema: getFilteredIdsBodySchema,
|
|
1179
1181
|
handler: async ({ body, adminUser, headers, query, cookies, requestUrl, response }) => {
|
|
1180
1182
|
const resource = this.resourceConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/i18n",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.10.7",
|
|
46
|
-
"adminforth": "^
|
|
46
|
+
"adminforth": "^4.7.3",
|
|
47
47
|
"i18n-iso-countries": "^7.13.0",
|
|
48
48
|
"semantic-release": "^24.2.1",
|
|
49
49
|
"semantic-release-slack-bot": "^4.0.2",
|