@adminforth/i18n
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -134,3 +134,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
// add virtual field for incomplete | ||
resourceConfig.columns.push({ | ||
resourceConfig.columns.unshift({ | ||
name: 'fully_translated', | ||
@@ -261,2 +261,24 @@ label: 'Fully translated', | ||
; | ||
// if there is menu item with resourceId, add .badge function showing number of untranslated strings | ||
const addBadgeCountToMenuItem = (menuItem) => { | ||
console.log('🪲menuItem, registring ', menuItem); | ||
menuItem.badge = () => __awaiter(this, void 0, void 0, function* () { | ||
const resource = adminforth.resource(menuItem.resourceId); | ||
const count = yield resource.count([Filters.NEQ(this.options.completedFieldName, this.fullCompleatedFieldValue)]); | ||
return `${count}`; | ||
}); | ||
menuItem.badgeTooltip = 'Untranslated count'; | ||
}; | ||
adminforth.config.menu.forEach((menuItem) => { | ||
if (menuItem.resourceId === resourceConfig.resourceId) { | ||
addBadgeCountToMenuItem(menuItem); | ||
} | ||
if (menuItem.children) { | ||
menuItem.children.forEach((child) => { | ||
if (child.resourceId === resourceConfig.resourceId) { | ||
addBadgeCountToMenuItem(child); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
@@ -263,0 +285,0 @@ } |
29
index.ts
import AdminForth, { AdminForthPlugin, Filters, suggestIfTypo, AdminForthDataTypes } from "adminforth"; | ||
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthResource, BeforeLoginConfirmationFunction } from "adminforth"; | ||
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthResource, BeforeLoginConfirmationFunction, AdminForthConfigMenuItem } from "adminforth"; | ||
import type { PluginOptions } from './types.js'; | ||
@@ -150,3 +150,3 @@ import iso6391, { LanguageCode } from 'iso-639-1'; | ||
// add virtual field for incomplete | ||
resourceConfig.columns.push({ | ||
resourceConfig.columns.unshift({ | ||
name: 'fully_translated', | ||
@@ -298,2 +298,27 @@ label: 'Fully translated', | ||
}; | ||
// if there is menu item with resourceId, add .badge function showing number of untranslated strings | ||
const addBadgeCountToMenuItem = (menuItem: AdminForthConfigMenuItem) => { | ||
console.log('🪲menuItem, registring ', menuItem); | ||
menuItem.badge = async () => { | ||
const resource = adminforth.resource(menuItem.resourceId); | ||
const count = await resource.count([Filters.NEQ(this.options.completedFieldName, this.fullCompleatedFieldValue)]); | ||
return `${count}`; | ||
}; | ||
menuItem.badgeTooltip = 'Untranslated count'; | ||
} | ||
adminforth.config.menu.forEach((menuItem) => { | ||
if (menuItem.resourceId === resourceConfig.resourceId) { | ||
addBadgeCountToMenuItem(menuItem); | ||
} | ||
if (menuItem.children) { | ||
menuItem.children.forEach((child) => { | ||
if (child.resourceId === resourceConfig.resourceId) { | ||
addBadgeCountToMenuItem(child); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -300,0 +325,0 @@ |
{ | ||
"name": "@adminforth/i18n", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5463435
4970