-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0722d95
commit 65054d7
Showing
5 changed files
with
38 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65054d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CellOperationButton
andcommonOnClick
Thanks to the effort of @rezanos this commit finished a very welcome feature to the
SearchControl
: Adding simple operation buttons inside of a column's cell!How to use it?
The way it works is by having a two new types of QueryToken that can only be added as columns (not available for Filters or Orders):
OperationsToken
: EveryEntity
has a new token named[Operations]
that serves as a container, to keep all the available operations together (explained below).OperationToken
: Represents one operation that can be added as column. This operation has to be elegible for CellOperation, this means:What makes an operation elegible for CellOperation?
For performance reasons, not every operation can be shown in a cell:
CanExecute
(orCanDelete
/CanConstruct
) defined.CanExecuteExpresion
(orCanDeleteExpression
/CanConstructExpression
respectively).This new
CanExecuteExpression
variants are required to make the query efficient, avoiding retrieving every entity in the result just to evaluateCanExecute
.So in most of the cases just replace
CanExecute
byCanExecuteExpression
to make it appear.Just select Ship and voilà! An operation button directly in the column:
Not that the button is automatically disabled depending on the state or the
CanExecuteExpression
, showing the reasons in aTooltip
.How to Customize the button.
There is a new
cell
block of typeCellOperationSettings
inEntityOperationSettings
to customize an operation when shown in a cell:Similarly to
contextual
, if you override values only in theEntityOperationSettings
they will be used by default forCellOperationSettings
too. So this code has identical results.For
isVisible
/onClick
, the same function can not be used so easily, because one takes anEntityOperationContext<T>
, while insice cell it takes aCellOperationContext<T>
.This means that, on top of overriding
contextual.click
, now you need to overridecell.click
?Presenting
commonOnClick
To solve this duplication we have added a a new field to
EntityOperationSettings
:This field
commonOnClick
can be used to override all threeonClicks
at the same time and accepts the union ofEntityOperationContext<T> | ContextualOperationContext<T> | CellOperationContext<T>
as an argument. Bold move @rezanos!!.. and with some small touches is actually enought in many cases.And what if we need the entity?
Easy!, just use
getEntity
method.The
getEntity
method only realy retrieves the entity for theCellOperationContext
case, the other ones (EntityOperationContext
andContextualOperationContext
) just returns the already-retrieved one.Finally, what about
contextualFromMany
?Since the framework can not know if you are using
getEntity
in yourcommonOnClick
, is risky to reuse if forcontextualFromMany
too, so you will need to make this duplicationHow to update?
There are two small breaking changes to make this feature work:
defaultContextualClick
has been renamed todefaultClick
inContextualOperationSettings
, to allow for the union neede incommonOnClick
.commonOnClick
instead 😇.In this message and this commit you have many examples of this refactoring.
2 . In C# the following extension methods have been removed:
Because they are often used in
CanExecute
CanExecuteExpression
but could end-up retrieving the full entity. Instead use the static method defined inModifiableEntity
(orEntity
for short):This means that if you have code like this:
Enjoy!
65054d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect,
65054d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great document, Comprehensive and attractive 😆
Thanks @olmobrutall, 🙏
65054d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.