mirror of
https://github.com/flarum/core.git
synced 2025-08-07 08:56:38 +02:00
chore: allow extensibility of bool gambit
This commit is contained in:
@@ -71,7 +71,7 @@ export type KeyValueGambitSuggestion = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type GroupedGambitSuggestion = {
|
export type GroupedGambitSuggestion = {
|
||||||
group: 'is' | 'has' | string;
|
group: 'is' | 'has' | 'allows' | string;
|
||||||
key: string | string[];
|
key: string | string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,8 +82,16 @@ export abstract class BooleanGambit implements IGambit<GambitType.Grouped> {
|
|||||||
abstract key(): string | string[];
|
abstract key(): string | string[];
|
||||||
abstract filterKey(): string;
|
abstract filterKey(): string;
|
||||||
|
|
||||||
|
booleanKey(): 'is' | 'has' | 'allows' {
|
||||||
|
return 'is';
|
||||||
|
}
|
||||||
|
|
||||||
|
groupKey(): string {
|
||||||
|
return app.translator.trans('core.lib.gambits.group_keys.' + this.booleanKey(), {}, true);
|
||||||
|
}
|
||||||
|
|
||||||
pattern(): string {
|
pattern(): string {
|
||||||
const is = app.translator.trans('core.lib.gambits.boolean_key', {}, true);
|
const is = this.groupKey();
|
||||||
let key = this.key();
|
let key = this.key();
|
||||||
|
|
||||||
if (Array.isArray(key)) {
|
if (Array.isArray(key)) {
|
||||||
@@ -102,7 +110,7 @@ export abstract class BooleanGambit implements IGambit<GambitType.Grouped> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fromFilter(value: string, negate: boolean): string {
|
fromFilter(value: string, negate: boolean): string {
|
||||||
const is = app.translator.trans('core.lib.gambits.boolean_key', {}, true);
|
const is = this.groupKey();
|
||||||
const key = this.key();
|
const key = this.key();
|
||||||
|
|
||||||
return `${negate ? '-' : ''}${is}:${key}`;
|
return `${negate ? '-' : ''}${is}:${key}`;
|
||||||
@@ -110,7 +118,7 @@ export abstract class BooleanGambit implements IGambit<GambitType.Grouped> {
|
|||||||
|
|
||||||
suggestion() {
|
suggestion() {
|
||||||
return {
|
return {
|
||||||
group: app.translator.trans('core.lib.gambits.boolean_key', {}, true),
|
group: this.groupKey(),
|
||||||
key: this.key(),
|
key: this.key(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -733,7 +733,10 @@ core:
|
|||||||
|
|
||||||
# These translations are used by gambits. Gambit keys must be in snake_case, no spaces.
|
# These translations are used by gambits. Gambit keys must be in snake_case, no spaces.
|
||||||
gambits:
|
gambits:
|
||||||
boolean_key: is
|
group_keys:
|
||||||
|
allows: allows
|
||||||
|
has: has
|
||||||
|
is: is
|
||||||
discussions:
|
discussions:
|
||||||
author:
|
author:
|
||||||
key: author
|
key: author
|
||||||
|
Reference in New Issue
Block a user