-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 2b79cc3
Showing
12 changed files
with
20,790 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const base = require("@mendix/pluggable-widgets-tools/configs/eslint.js.base.json"); | ||
|
||
module.exports = { | ||
...base | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
* text=auto | ||
*.ts text eol=lf | ||
*.tsx text eol=lf | ||
*.js text eol=lf | ||
*.jsx text eol=lf | ||
*.css text eol=lf | ||
*.scss text eol=lf | ||
*.json text eol=lf | ||
*.xml text eol=lf | ||
*.md text eol=lf | ||
*.gitattributes eol=lf | ||
*.gitignore eol=lf | ||
*.png binary | ||
*.jpg binary | ||
*.gif binary |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dist/ | ||
node_modules/ | ||
../ | ||
*.log | ||
.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2021 Objectivity | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## IfElse | ||
Tiny widget that enhances Conditional Visibility feature adding the **else/otherwise** case | ||
|
||
## Typical usage scenario | ||
A very often development situation is that: | ||
- you have some **condition** | ||
- **if** it is **true**, display some content | ||
- **otherwise**, display some other content | ||
|
||
In Mendix development a common pattern in this case is to use the [Conditional Visibility feature](https://docs.mendix.com/refguide/common-widget-properties#visibility-properties). However, you have to **duplicate the logic**, repeating your condition **twice**: | ||
- first for the **true case**: `the condition...` | ||
- and then for the **otherwise case**, with additional **negation**: `not(the condition...)` | ||
|
||
This can be **cumbersome and error-prone**, especially if your condition is **complicated**. For example you can have two containers with Visibility set to: | ||
- `$currentObject/Name = 'Some name' and ($currentObject/SearchChangedDate > [%BeginOfCurrentDay%] or $currentObject/SomeAssociatedEntity != empty`) | ||
- `not($currentObject/Name = 'Some name' and ($currentObject/SearchChangedDate > [%BeginOfCurrentDay%] or $currentObject/SomeAssociatedEntity != empty)`) | ||
|
||
As you can see, it is **not immediately apparent** that the two are **related**. Readability and maintainability is low and it will be **easy to make a mistake** when changing something in future (e.g. extending the condition). | ||
|
||
The solution is to use this widget, providing the condition once and two containers for both cases inside. | ||
|
||
## Usage | ||
- Put the widget where you need it | ||
- Set the `If` expression to your **condition** | ||
- Fill the `Then` placeholder with content for **true case** | ||
- Fill the `Else` placeholder with content for **otherwise case** | ||
|
||
The **content can be anything**, e.g. a simple Text widget or a complex Container with a DataGrid or any other Mendix element. | ||
|
||
## Demo project | ||
[ObjectivityCommons](https://objectivitycommons-sandbox.mxapps.io/) > _Test_ button > _IfElse widget_ section |
Oops, something went wrong.