@adminforth/i18n 2.5.0 → 2.5.1
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/dist/index.js +7 -1
- package/index.ts +14 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Filters, suggestIfTypo, AdminForthDataTypes, RAMLock, filtersTools, AdminForthFilterOperators } from "adminforth";
|
|
10
|
+
import { Filters, suggestIfTypo, AdminForthDataTypes, RAMLock, filtersTools, AdminForthFilterOperators, interpretResource, ActionCheckSource, AllowedActionsEnum } from "adminforth";
|
|
11
11
|
import { I18nBase, getCountryCodeFromLangCode, getPrimaryLanguageCode, requiresSlavicPlurals, SLAVIC_PLURAL_EXAMPLES, SLAVIC_PLURAL_FORMS, SLAVIC_PLURAL_FORMS_HINT, SOURCE_LANGUAGE } from './base.js';
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
import iso6391 from 'iso-639-1';
|
|
@@ -896,6 +896,12 @@ export default class I18nPlugin extends I18nBase {
|
|
|
896
896
|
oldValue[field] = reviewed;
|
|
897
897
|
updateRecord[this.options.reviewedCheckboxesFieldName] = Object.assign({}, oldValue);
|
|
898
898
|
}
|
|
899
|
+
const { allowedActions } = yield interpretResource(adminUser, resource, { requestBody: body, newRecord: updateRecord, oldRecord, pk: recordId }, ActionCheckSource.EditRequest, this.adminforth);
|
|
900
|
+
const editAllowed = allowedActions[AllowedActionsEnum.edit];
|
|
901
|
+
if (editAllowed !== true) {
|
|
902
|
+
result = { error: typeof editAllowed === 'string' ? editAllowed : 'You do not have permission to edit this record' };
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
899
905
|
result = yield this.adminforth.updateResourceRecord({
|
|
900
906
|
resource,
|
|
901
907
|
recordId,
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AdminForth, { Filters, suggestIfTypo, AdminForthDataTypes, RAMLock, filtersTools, AdminForthFilterOperators } from "adminforth";
|
|
1
|
+
import AdminForth, { Filters, suggestIfTypo, AdminForthDataTypes, RAMLock, filtersTools, AdminForthFilterOperators, interpretResource, ActionCheckSource, AllowedActionsEnum } from "adminforth";
|
|
2
2
|
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthResource, BeforeLoginConfirmationFunction, AdminForthConfigMenuItem, AdminUser } from "adminforth";
|
|
3
3
|
import type { PluginOptions, SupportedLanguage } from './types.js';
|
|
4
4
|
import { I18nBase, getCountryCodeFromLangCode, getPrimaryLanguageCode, requiresSlavicPlurals, SLAVIC_PLURAL_EXAMPLES, SLAVIC_PLURAL_FORMS, SLAVIC_PLURAL_FORMS_HINT, SOURCE_LANGUAGE } from './base.js';
|
|
@@ -1110,6 +1110,19 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
|
|
|
1110
1110
|
updateRecord[this.options.reviewedCheckboxesFieldName] = { ...oldValue };
|
|
1111
1111
|
}
|
|
1112
1112
|
|
|
1113
|
+
const { allowedActions } = await interpretResource(
|
|
1114
|
+
adminUser,
|
|
1115
|
+
resource,
|
|
1116
|
+
{ requestBody: body, newRecord: updateRecord, oldRecord, pk: recordId },
|
|
1117
|
+
ActionCheckSource.EditRequest,
|
|
1118
|
+
this.adminforth
|
|
1119
|
+
);
|
|
1120
|
+
const editAllowed = allowedActions[AllowedActionsEnum.edit];
|
|
1121
|
+
if (editAllowed !== true) {
|
|
1122
|
+
result = { error: typeof editAllowed === 'string' ? editAllowed : 'You do not have permission to edit this record' };
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1113
1126
|
result = await this.adminforth.updateResourceRecord({
|
|
1114
1127
|
resource,
|
|
1115
1128
|
recordId,
|