@adminforth/i18n 3.1.4 → 3.1.5

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 CHANGED
@@ -20,5 +20,5 @@ custom/package.json
20
20
  custom/pnpm-lock.yaml
21
21
  custom/tsconfig.json
22
22
 
23
- sent 45,486 bytes received 305 bytes 91,582.00 bytes/sec
24
- total size is 44,318 speedup is 0.97
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
- websocket.unsubscribe('/translation_progress');
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.getPublicConfig();
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
- onMounted(async () => {
139
- await loadPage(0);
138
+ let unsubscribeFromTaskUpdates: () => void;
139
+ let unsubscribeFromTaskErrors: () => void;
140
140
 
141
- websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
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
- websocket.unsubscribe(`/background-jobs-task-update/${props.job.id}`);
160
- websocket.unsubscribe(`/background-jobs-task-error/${props.job.id}`);
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
- websocket.unsubscribe('/translation_progress');
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.getPublicConfig();
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
- onMounted(async () => {
139
- await loadPage(0);
138
+ let unsubscribeFromTaskUpdates: () => void;
139
+ let unsubscribeFromTaskErrors: () => void;
140
140
 
141
- websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
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
- websocket.unsubscribe(`/background-jobs-task-update/${props.job.id}`);
160
- websocket.unsubscribe(`/background-jobs-task-error/${props.job.id}`);
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* ({ record, oldRecord }) {
284
- const futureRecord = Object.assign(Object.assign({}, oldRecord), record);
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
- record[this.options.completedFieldName] = futureCompletedFieldValue;
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
@@ -907,7 +907,7 @@ export default class I18nPlugin extends I18nBase {
907
907
  result = yield this.adminforth.updateResourceRecord({
908
908
  resource,
909
909
  recordId,
910
- record: updateRecord,
910
+ updates: updateRecord,
911
911
  oldRecord,
912
912
  adminUser
913
913
  });
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 ({ record, oldRecord }: { record: any, oldRecord: any }): Promise<{ ok: boolean, error?: string }> => {
336
- const futureRecord = { ...oldRecord, ...record };
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
- record[this.options.completedFieldName] = futureCompletedFieldValue;
340
+ updates[this.options.completedFieldName] = futureCompletedFieldValue;
341
341
  return { ok: true };
342
342
  });
343
343
 
@@ -1129,7 +1129,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
1129
1129
  result = await this.adminforth.updateResourceRecord({
1130
1130
  resource,
1131
1131
  recordId,
1132
- record: updateRecord,
1132
+ updates: updateRecord,
1133
1133
  oldRecord,
1134
1134
  adminUser
1135
1135
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
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": "^3.8.2",
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",