mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
Add Japanese document (#1186)
* Fixed invalid url link. * Update docs/features/side-navigation.md Co-Authored-By: Suzana Dirla <dirla.silvia.suzana@gmail.com> * Initial japanese translation.
This commit is contained in:
committed by
Suzana Dirla
parent
21ffcaf013
commit
d67f95cfff
69
docs/ja/extending/creating-custom-evaluators.md
Normal file
69
docs/ja/extending/creating-custom-evaluators.md
Normal file
@@ -0,0 +1,69 @@
|
||||
---
|
||||
Title: カスタムエバリュエータの作成
|
||||
---
|
||||
|
||||
# カスタムエバリュエータの作成
|
||||
|
||||
ルールエバリュエータは、`RuleContext` 参照とオプションの `RuleParameter` インスタンスのリストを受け取るプレーンな JavaScript (または TypeScript) 関数です。
|
||||
|
||||
アプリケーションは、評価関数に特別な
|
||||
[RuleEvaluator](https://github.com/Alfresco/alfresco-ng2-components/blob/development/lib/extensions/src/lib/config/rule.extensions.ts)
|
||||
タイプエイリアスを提供します:
|
||||
|
||||
```ts
|
||||
export type RuleEvaluator = (context: RuleContext, ...args: any[]) => boolean;
|
||||
```
|
||||
|
||||
ユーザーが 1 つまたは複数のノードを選択したかどうかを確認する関数を作成します。
|
||||
|
||||
```ts
|
||||
export function hasSelection(
|
||||
context: RuleContext,
|
||||
...args: RuleParameter[]
|
||||
): boolean {
|
||||
return !context.selection.isEmpty;
|
||||
}
|
||||
```
|
||||
|
||||
`context` は、[RuleContext](https://github.com/Alfresco/alfresco-ng2-components/blob/development/lib/extensions/src/lib/config/rule.extensions.ts) 型の特別なインスタンスへの参照であり、
|
||||
各エバリュエータがランタイムエンティティにアクセスできるようにします。
|
||||
|
||||
```ts
|
||||
export interface RuleContext {
|
||||
selection: SelectionState;
|
||||
navigation: NavigationState;
|
||||
permissions: NodePermissions;
|
||||
|
||||
getEvaluator(key: string): RuleEvaluator;
|
||||
}
|
||||
```
|
||||
|
||||
`SelectionState` インターフェイスはグローバルな選択状態に関する情報を公開します:
|
||||
|
||||
```ts
|
||||
export interface SelectionState {
|
||||
count: number;
|
||||
nodes: MinimalNodeEntity[];
|
||||
libraries: SiteEntry[];
|
||||
isEmpty: boolean;
|
||||
first?: MinimalNodeEntity;
|
||||
last?: MinimalNodeEntity;
|
||||
folder?: MinimalNodeEntity;
|
||||
file?: MinimalNodeEntity;
|
||||
library?: SiteEntry;
|
||||
}
|
||||
```
|
||||
|
||||
次に、先ほど作成した関数を `ExtensionService` で登録し、一意の識別子を付けます:
|
||||
|
||||
```ts
|
||||
extensions.setEvaluators({
|
||||
'plugin1.rules.hasSelection': hasSelection
|
||||
});
|
||||
```
|
||||
|
||||
これで、`plugin1.rules.hasSelection` エバリュエータをインラインルールリファレンスとして使用したり、
|
||||
`core.every` のような複合ルールの一部として使用したりできます。
|
||||
|
||||
**Tip:** 実行時に再利用される独自のエントリを登録する方法の詳細については、
|
||||
[登録](/extending/registration) セクションを参照してください。
|
Reference in New Issue
Block a user