From e9705497df53fbfd6965bd7e0ba448c2726a2e96 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Cano Date: Fri, 14 Apr 2023 10:30:07 +0200 Subject: [PATCH] simpler PinnedFilters in SearchControl --- .../UserQueries/UserQueryEntity.cs | 15 +- Signum.Entities/DynamicQuery/Filter.cs | 36 +- Signum.Entities/EnumMessages.cs | 24 +- .../Translations/Signum.Entities.en.xml | 38 +- .../Authorization/ActiveDirectoryClient.tsx | 2 +- .../Authorization/AuthAdminClient.tsx | 4 +- .../Chart/Templates/ChartRequestView.tsx | 5 +- .../Dashboard/View/CombinedUserChartPart.tsx | 2 +- .../Dashboard/View/UserChartPart.tsx | 2 +- .../Workflow/Case/Case.tsx | 2 +- Signum.React/Scripts/FindOptions.ts | 10 +- Signum.React/Scripts/Finder.tsx | 4 +- .../Scripts/SearchControl/FilterBuilder.css | 12 + .../Scripts/SearchControl/FilterBuilder.tsx | 438 +++++++++++------- .../SearchControl/PinnedFilterBuilder.tsx | 36 +- .../Scripts/SearchControl/SearchControl.tsx | 1 + .../SearchControl/SearchControlLoaded.tsx | 56 ++- .../Scripts/Signum.Entities.DynamicQuery.ts | 8 +- Signum.React/Scripts/Signum.Entities.ts | 10 +- 19 files changed, 425 insertions(+), 280 deletions(-) diff --git a/Signum.Entities.Extensions/UserQueries/UserQueryEntity.cs b/Signum.Entities.Extensions/UserQueries/UserQueryEntity.cs index 51587f62aa..138ab20c13 100644 --- a/Signum.Entities.Extensions/UserQueries/UserQueryEntity.cs +++ b/Signum.Entities.Extensions/UserQueries/UserQueryEntity.cs @@ -454,11 +454,20 @@ internal PinnedQueryFilterEmbedded FromXml(XElement p, IFromXmlContext ctx) Label = p.Attribute("Label")?.Value; Column = p.Attribute("Column")?.Value.ToInt(); Row = p.Attribute("Row")?.Value.ToInt(); - Active = p.Attribute("Active")?.Value.ToEnum() ?? (p.Attribute("DisableOnNull")?.Value.ToBool() == true ? PinnedFilterActive.WhenHasValue : PinnedFilterActive.Always); + Active = ModernizeActive(p.Attribute("Active")?.Value)?.ToEnum() ?? PinnedFilterActive.Always; SplitText = p.Attribute("SplitText")?.Value.ToBool() ?? false; return this; } + private string? ModernizeActive(string? str) => str switch + { + "Checkbox_StartChecked" => "Checkbox_Checked", + "Checkbox_StartUnchecked" => "Checkbox_Unchecked", + "NotCheckbox_StartChecked" => "NotCheckbox_Checked", + "NotCheckbox_StartUnchecked" => "NotCheckbox_Unchecked", + _ => str + }; + internal XElement ToXml(IToXmlContext ctx) { return new XElement("Pinned", @@ -488,10 +497,10 @@ public static List ToFilterList(this IEnumerable fi if (filter.Pinned != null) { - if (filter.Pinned.Active == PinnedFilterActive.Checkbox_StartUnchecked) + if (filter.Pinned.Active == PinnedFilterActive.Checkbox_Unchecked) return null; - if (filter.Pinned.Active == PinnedFilterActive.NotCheckbox_StartChecked) + if (filter.Pinned.Active == PinnedFilterActive.NotCheckbox_Checked) return null; if (filter.Pinned.SplitText && !filter.ValueString.HasText()) diff --git a/Signum.Entities/DynamicQuery/Filter.cs b/Signum.Entities/DynamicQuery/Filter.cs index 3d753f0612..24ded49c08 100644 --- a/Signum.Entities/DynamicQuery/Filter.cs +++ b/Signum.Entities/DynamicQuery/Filter.cs @@ -379,24 +379,42 @@ public override IEnumerable GetKeywords() [InTypeScript(true), DescriptionOptions(DescriptionOptions.Members | DescriptionOptions.Description)] public enum FilterOperation { + [Description("equal to")] EqualTo, + [Description("distinct to")] DistinctTo, + [Description("greater than")] GreaterThan, + [Description("greater than or equal")] GreaterThanOrEqual, + [Description("less than")] LessThan, + [Description("less than or equal")] LessThanOrEqual, + [Description("contains")] Contains, + [Description("starts with")] StartsWith, + [Description("ends with")] EndsWith, + [Description("like")] Like, + [Description("not contains")] NotContains, + [Description("not starts with")] NotStartsWith, + [Description("not ends with")] NotEndsWith, + [Description("not like")] NotLike, + [Description("is in")] IsIn, + [Description("is not in")] IsNotIn, + [Description("complex condition")] ComplexCondition, //Full Text Search + [Description("free text")] FreeText, //Full Text Search } @@ -491,7 +509,7 @@ public override IEnumerable GetKeywords() return this.SearchCondition.Split(" "); return this.SearchCondition.Split(new string[] { "AND", "OR", "NOT", "NEAR", "(", ")", "*" }, StringSplitOptions.RemoveEmptyEntries) - .Select(a => a.Trim(' ').Trim('\'', '"')) + .Select(a => a.Trim(' ', '\r', '\n', '\t').Trim('"')) .Where(a => a.Length > 0); } } @@ -533,14 +551,14 @@ public enum PinnedFilterActive { Always, WhenHasValue, - [Description("Checkbox (start checked)")] - Checkbox_StartChecked, - [Description("Checkbox (start unchecked)")] - Checkbox_StartUnchecked, - [Description("Not Checkbox (start checked)")] - NotCheckbox_StartChecked, - [Description("Not Checkbox (start unchecked)")] - NotCheckbox_StartUnchecked, + [Description("Checkbox (checked)")] + Checkbox_Checked, + [Description("Checkbox (unchecked)")] + Checkbox_Unchecked, + [Description("Not Checkbox (checked)")] + NotCheckbox_Checked, + [Description("Not Checkbox (unchecked)")] + NotCheckbox_Unchecked, } [InTypeScript(true), DescriptionOptions(DescriptionOptions.Members | DescriptionOptions.Description)] diff --git a/Signum.Entities/EnumMessages.cs b/Signum.Entities/EnumMessages.cs index 0a3c54a1d6..a41c197dbc 100644 --- a/Signum.Entities/EnumMessages.cs +++ b/Signum.Entities/EnumMessages.cs @@ -169,6 +169,10 @@ public enum SearchMessage AddFilter, [Description("Add group")] AddGroup, + + [Description("Group Prefix")] + GroupPrefix, + [Description("Add value")] AddValue, [Description("Delete filter")] @@ -253,10 +257,20 @@ public enum SearchMessage ReturnNewEntity, [Description("Do you want to return the new {0} ({1})?")] DoYouWantToSelectTheNew01_G, - [Description("Show pinned filter options")] - ShowPinnedFiltersOptions, - [Description("Hide pinned filter options")] - HidePinnedFiltersOptions, + [Description("Edit pinned filters")] + EditPinnedFilters, + + [Description("Pin filter")] + PinFilter, + [Description("Unpin filter")] + UnpinFilter, + + [Description("Is Active")] + IsActive, + + [Description("Split")] + Split, + [Description("Summary header")] SummaryHeader, [Description("Summary header must be an aggregate (like Sum, Count, etc..)")] @@ -275,8 +289,6 @@ public enum SearchMessage MoreThanOne0Selected, CombineRowsWith, - PinnFilter, - UnpinnFilter, SwitchViewMode, } diff --git a/Signum.Entities/Translations/Signum.Entities.en.xml b/Signum.Entities/Translations/Signum.Entities.en.xml index a8dc401824..7095204dfb 100644 --- a/Signum.Entities/Translations/Signum.Entities.en.xml +++ b/Signum.Entities/Translations/Signum.Entities.en.xml @@ -7,12 +7,6 @@ - - - - - - @@ -24,28 +18,8 @@ - - - - - - - - - - - - - - - - - - + - - - @@ -67,14 +41,6 @@ - - - - - - - - @@ -84,4 +50,4 @@ - \ No newline at end of file + diff --git a/Signum.React.Extensions/Authorization/ActiveDirectoryClient.tsx b/Signum.React.Extensions/Authorization/ActiveDirectoryClient.tsx index 21f2e65e32..6830e54b50 100644 --- a/Signum.React.Extensions/Authorization/ActiveDirectoryClient.tsx +++ b/Signum.React.Extensions/Authorization/ActiveDirectoryClient.tsx @@ -97,7 +97,7 @@ export function start(options: { routes: RouteObject[], adGroups: boolean }) { ], }, { - pinned: { label: () => ActiveDirectoryMessage.OnlyActiveUsers.niceToString(), active: "Checkbox_StartChecked", column: 2, row: 0 }, + pinned: { label: () => ActiveDirectoryMessage.OnlyActiveUsers.niceToString(), active: "Checkbox_Checked", column: 2, row: 0 }, token: "AccountEnabled", operation: "EqualTo", value: true }, { token: "CreationType", operation: "DistinctTo", value: "Invitation" } diff --git a/Signum.React.Extensions/Authorization/AuthAdminClient.tsx b/Signum.React.Extensions/Authorization/AuthAdminClient.tsx index 7e35427a42..6e4e37094f 100644 --- a/Signum.React.Extensions/Authorization/AuthAdminClient.tsx +++ b/Signum.React.Extensions/Authorization/AuthAdminClient.tsx @@ -75,7 +75,7 @@ export function start(options: { routes: RouteObject[], types: boolean; properti { token: UserEntity.token(a => a.state), value: UserState.value("Active"), - pinned: { label: () => AuthAdminMessage.OnlyActive.niceToString(), column: 2, active: "Checkbox_StartChecked" }, + pinned: { label: () => AuthAdminMessage.OnlyActive.niceToString(), column: 2, active: "Checkbox_Checked" }, }, ], entityFormatter: new Finder.EntityFormatter((row, cols, sc) => !row.entity || !Navigator.isViewable(row.entity.EntityType, { isSearch: true }) ? undefined : a.entity.isTrivialMerge), value: false, - pinned: { active: "NotCheckbox_StartUnchecked", label: ()=> AuthAdminMessage.IncludeTrivialMerges.niceToString(), column: 2 } + pinned: { active: "NotCheckbox_Unchecked", label: ()=> AuthAdminMessage.IncludeTrivialMerges.niceToString(), column: 2 } } ], extraButtons: scl => [isPermissionAuthorized(BasicPermission.AdminRules) && { diff --git a/Signum.React.Extensions/Chart/Templates/ChartRequestView.tsx b/Signum.React.Extensions/Chart/Templates/ChartRequestView.tsx index df709aa958..f24b4690a3 100644 --- a/Signum.React.Extensions/Chart/Templates/ChartRequestView.tsx +++ b/Signum.React.Extensions/Chart/Templates/ChartRequestView.tsx @@ -126,9 +126,10 @@ export default function ChartRequestView(p: ChartRequestViewProps) { p.onFiltersChanged(cr.filterOptions); } - function handlePinnedFilterChanged() { + function handlePinnedFilterChanged(fop: FilterOptionParsed[], avoidSearch?: boolean) { handleFiltersChanged(); - handleOnDrawClick(); + if (!avoidSearch) + handleOnDrawClick(); } function handleOnFullScreen(e: React.MouseEvent) { diff --git a/Signum.React.Extensions/Dashboard/View/CombinedUserChartPart.tsx b/Signum.React.Extensions/Dashboard/View/CombinedUserChartPart.tsx index a774233519..6c9336a4cf 100644 --- a/Signum.React.Extensions/Dashboard/View/CombinedUserChartPart.tsx +++ b/Signum.React.Extensions/Dashboard/View/CombinedUserChartPart.tsx @@ -158,7 +158,7 @@ export default function CombinedUserChartPart(p: PanelPartContentProps fop.dashboardBehaviour == null} - onFiltersChanged={() => info.makeQuery!()} extraSmall={true} /> + onFiltersChanged={(fpo, avoidSearch) => !avoidSearch && info.makeQuery!()} extraSmall={true} /> )} {p.content.allowChangeShowData &&