A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/signumsoftware/framework/commit/e11a04d81947b89e1b732f4f88f350cbf690010f below:

more on MultiPropertySetter · signumsoftware/framework@e11a04d · GitHub

File tree Expand file treeCollapse file tree 11 files changed

+168

-50

lines changed

Filter options

Expand file treeCollapse file tree 11 files changed

+168

-50

lines changed Original file line number Diff line number Diff line change

@@ -500,14 +500,24 @@ internal static Type BuildLite(this Type type)

500 500

static readonly MethodInfo miLike = ReflectionTools.GetMethodInfo((string s) => s.Like(s));

501 501

static readonly MethodInfo miDistinctNullable = ReflectionTools.GetMethodInfo((string s) => LinqHints.DistinctNull<int>(null, null)).GetGenericMethodDefinition();

502 502

static readonly MethodInfo miDistinct = ReflectionTools.GetMethodInfo((string s) => LinqHints.DistinctNull<string>(null, null)).GetGenericMethodDefinition();

503 +

static readonly MethodInfo miEquals = ReflectionTools.GetMethodInfo(() => object.Equals(null, null));

503 504 504 505

public static Expression GetCompareExpression(FilterOperation operation, Expression left, Expression right, bool inMemory = false)

505 506

{

506 507

switch (operation)

507 508

{

508 -

case FilterOperation.EqualTo: return Expression.Equal(left, right);

509 +

case FilterOperation.EqualTo:

510 +

{

511 +

if (inMemory)

512 +

return Expression.Call(null, miEquals, left, right);

513 + 514 +

return Expression.Equal(left, right);

515 +

}

509 516

case FilterOperation.DistinctTo:

510 517

{

518 +

if (inMemory)

519 +

return Expression.Not(Expression.Call(null, miEquals, left, right));

520 + 511 521

var t = left.Type.UnNullify();

512 522

var mi = t.IsValueType ? miDistinctNullable : miDistinct;

513 523

return Expression.Call(mi.MakeGenericMethod(t), left.Nullify(), right.Nullify());

Original file line number Diff line number Diff line change

@@ -42,6 +42,8 @@ public enum OperationMessage

42 42 43 43

Predictate,

44 44

Setters,

45 +

[Description("Add setter")]

46 +

AddSetter,

45 47

}

46 48 47 49

public enum SynchronizerMessage

Original file line number Diff line number Diff line change

@@ -6,6 +6,7 @@

6 6

using Signum.Engine.Maps;

7 7

using Signum.Engine.Operations;

8 8

using Signum.Entities;

9 +

using Signum.Entities.DynamicQuery;

9 10

using Signum.Entities.Reflection;

10 11

using Signum.React.Facades;

11 12

using Signum.React.Filters;

@@ -258,7 +259,8 @@ public class MultiOperationRequest : BaseOperationRequest

258 259

public class PropertySetter

259 260

{

260 261

public string Property;

261 -

public PropertyOperation Operation;

262 +

public PropertyOperation? Operation;

263 +

public FilterOperation? FilterOperation;

262 264

public object? Value;

263 265

public string? EntityType;

264 266

public List<PropertySetter>? Predicate;

@@ -338,8 +340,8 @@ public static void SetSetters(ModifiableEntity entity, List<PropertySetter> sett

338 340

{

339 341

case PropertyOperation.AddElement:

340 342

{

341 -

var item = (ModifiableEntity)Activator.CreateInstance(pr.Type.ElementType()!)!;

342 -

SetSetters(item, setter.Setters!, pr);

343 +

var item = (ModifiableEntity)Activator.CreateInstance(elementPr.Type)!;

344 +

SetSetters(item, setter.Setters!, elementPr);

343 345

((IList)mlist).Add(item);

344 346

}

345 347

break;

@@ -359,7 +361,7 @@ public static void SetSetters(ModifiableEntity entity, List<PropertySetter> sett

359 361

var toRemove = ((IEnumerable<object>)mlist).Where(predicate.Compile()).ToList();

360 362

foreach (var item in toRemove)

361 363

{

362 -

((IList)mlist).Add(item);

364 +

((IList)mlist).Remove(item);

363 365

}

364 366

}

365 367

break;

@@ -407,7 +409,6 @@ private static void SetProperty(ModifiableEntity entity, PropertyRoute pr, Prope

407 409

return pr.PropertyInfo!.GetValue(subEntity);

408 410

}

409 411 410 -

static MethodInfo miEquals = ReflectionTools.GetMethodInfo(() => object.Equals(null, null));

411 412 412 413

static Expression<Func<object, bool>> GetPredicate(List<PropertySetter> predicate, PropertyRoute mainRoute, JsonSerializer serializer)

413 414

{

@@ -422,7 +423,7 @@ static Expression<Func<object, bool>> GetPredicate(List<PropertySetter> predicat

422 423

var left = Expression.Invoke(lambda, param);

423 424

object? objClean = ConvertObject(p.Value, pr, serializer);

424 425 425 -

return (Expression)Expression.Call(null, miEquals, left, Expression.Constant(objClean));

426 +

return (Expression)QueryUtils.GetCompareExpression(p.FilterOperation!.Value, left, Expression.Constant(objClean), inMemory: true);

426 427 427 428

}).Aggregate((a, b) => Expression.AndAlso(a, b));

428 429 Original file line number Diff line number Diff line change

@@ -182,6 +182,17 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer

182 182

WriteJsonProperty(writer, serializer, mod, kvp.Key, kvp.Value, tup.pr);

183 183

}

184 184 185 +

var readonlyProps = PropertyConverter.GetPropertyConverters(value!.GetType())

186 +

.Where(kvp => kvp.Value.PropertyValidator?.IsPropertyReadonly(mod) == true)

187 +

.Select(a => a.Key)

188 +

.ToList();

189 + 190 +

if (readonlyProps.Any())

191 +

{

192 +

writer.WritePropertyName("readonlyProperties");

193 +

serializer.Serialize(writer, readonlyProps);

194 +

}

195 + 185 196

if (mod.Mixins.Any())

186 197

{

187 198

writer.WritePropertyName("mixins");

Original file line number Diff line number Diff line change

@@ -1,4 +1,4 @@

1 -

import { TypeReference, PseudoType, QueryKey, getLambdaMembers, QueryTokenString } from './Reflection';

1 +

import { TypeReference, PseudoType, QueryKey, getLambdaMembers, QueryTokenString, tryGetTypeInfos } from './Reflection';

2 2

import { Lite, Entity } from './Signum.Entities';

3 3

import { PaginationMode, OrderType, FilterOperation, FilterType, ColumnOptionsMode, UniqueType, SystemTimeMode, FilterGroupOperation, PinnedFilterActive } from './Signum.Entities.DynamicQuery';

4 4

import { SearchControlProps, SearchControlLoaded } from "./Search";

@@ -421,6 +421,34 @@ export function isList(fo: FilterOperation) {

421 421

}

422 422 423 423 424 +

export function getFilterType(tr: TypeReference): FilterType | null {

425 +

if (tr.name == "number")

426 +

return "Integer";

427 + 428 +

if (tr.name == "decmial")

429 +

return "Decimal";

430 + 431 +

if (tr.name == "boolean")

432 +

return "Boolean";

433 + 434 +

if (tr.name == "string")

435 +

return "String";

436 + 437 +

if (tr.name == "dateTime")

438 +

return "DateTime";

439 + 440 +

if (tr.name == "Guid")

441 +

return "Guid";

442 + 443 +

if (tr.isEmbedded)

444 +

return "Embedded";

445 + 446 +

if (tr.isLite || tryGetTypeInfos(tr)[0]?.name)

447 +

return "Lite";

448 + 449 +

return null;

450 +

}

451 + 424 452

export const filterOperations: { [a: string /*FilterType*/]: FilterOperation[] } = {};

425 453

filterOperations["String"] = [

426 454

"Contains",

Original file line number Diff line number Diff line change

@@ -98,8 +98,8 @@ export function taskSetFormat(lineBase: LineBaseController<any>, state: LineBase

98 98

}

99 99

}

100 100 101 -

tasks.push(taskSetReadOnly);

102 -

export function taskSetReadOnly(lineBase: LineBaseController<any>, state: LineBaseProps) {

101 +

tasks.push(taskSetReadOnlyProperty);

102 +

export function taskSetReadOnlyProperty(lineBase: LineBaseController<any>, state: LineBaseProps) {

103 103

if (!state.ctx.readOnly &&

104 104

state.ctx.propertyRoute &&

105 105

state.ctx.propertyRoute.propertyRouteType == "Field" &&

@@ -108,6 +108,14 @@ export function taskSetReadOnly(lineBase: LineBaseController<any>, state: LineBa

108 108

}

109 109

}

110 110 111 +

tasks.push(taskSetReadOnly);

112 +

export function taskSetReadOnly(lineBase: LineBaseController<any>, state: LineBaseProps) {

113 +

if (!state.ctx.readOnly &&

114 +

state.ctx.binding.getIsReadonly()) {

115 +

state.ctx.readOnly = true;

116 +

}

117 +

}

118 + 111 119

tasks.push(taskSetMandatory);

112 120

export function taskSetMandatory(lineBase: LineBaseController<any>, state: LineBaseProps) {

113 121

if (state.ctx.propertyRoute && state.mandatory == undefined &&

Original file line number Diff line number Diff line change

@@ -19,6 +19,7 @@ import { ContextualItemsContext } from './SearchControl/ContextualItems';

19 19

import { BsColor, KeyCodes } from "./Components/Basic";

20 20

import { IconProp } from "@fortawesome/fontawesome-svg-core";

21 21

import Notify from './Frames/Notify';

22 +

import { FilterOperation } from "./Signum.Entities.DynamicQuery";

22 23 23 24

export namespace Options {

24 25

export function maybeReadonly(ti: TypeInfo) {

@@ -454,11 +455,14 @@ export namespace Defaults {

454 455

return oi.key.endsWith(".Save");

455 456

}

456 457 457 -

export function defaultSetterConfig(oi: OperationInfo): SettersConfig {

458 -

if (!oi.canBeModified)

458 +

export function defaultSetterConfig(coc: ContextualOperationContext<Entity>): SettersConfig {

459 +

if (!coc.operationInfo.canBeModified)

459 460

return "No";

460 461 461 -

return isSave(oi) ? "Mandatory" : "Optional";

462 +

if (coc.context.lites.length == 1) //Will create too much noise

463 +

return "No";

464 + 465 +

return isSave(coc.operationInfo) ? "Mandatory" : "Optional";

462 466

}

463 467 464 468

export function getColor(oi: OperationInfo): BsColor {

@@ -580,7 +584,8 @@ export namespace API {

580 584 581 585

export interface PropertySetter {

582 586

property: string;

583 -

operation: PropertyOperation;

587 +

operation?: PropertyOperation;

588 +

filterOperation?: FilterOperation;

584 589

value?: any;

585 590

entityType?: string;

586 591

predicate?: PropertySetter[];

Original file line number Diff line number Diff line change

@@ -88,7 +88,7 @@ export function getEntityOperationsContextualItems(ctx: ContextualItemsContext<E

88 88

coc.entityOperationSettings = eos;

89 89 90 90

const visibleByDefault =

91 -

(!oi.canBeModified || (coc.settings?.settersConfig ?? Defaults.defaultSetterConfig(oi)) != "No") &&

91 +

(!oi.canBeModified || (coc.settings?.settersConfig ?? Defaults.defaultSetterConfig(coc)) != "No") &&

92 92

(oi.operationType != OperationType.ConstructorFrom || ctx.lites.length == 1);

93 93 94 94

if (eos == undefined ? visibleByDefault :

@@ -335,7 +335,7 @@ export function defaultContextualClick(coc: ContextualOperationContext<any>, ...

335 335

if (!coc.operationInfo.canBeModified)

336 336

return Promise.resolve([]);

337 337 338 -

var settersConfig = coc.settings?.settersConfig ?? Defaults.defaultSetterConfig(coc.operationInfo);

338 +

var settersConfig = coc.settings?.settersConfig ?? Defaults.defaultSetterConfig(coc);

339 339 340 340

if (settersConfig == "No")

341 341

return Promise.resolve([]);

@@ -345,7 +345,7 @@ export function defaultContextualClick(coc: ContextualOperationContext<any>, ...

345 345

if (!onlyType)

346 346

return Promise.resolve([]);

347 347 348 -

return MultiPropertySetterModal.show(getTypeInfo(onlyType), coc.context.lites, coc.operationInfo);

348 +

return MultiPropertySetterModal.show(getTypeInfo(onlyType), coc.context.lites, coc.operationInfo, settersConfig == "Mandatory");

349 349

}

350 350

}

351 351

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4