Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiuszwoznicki committed May 18, 2021
0 parents commit 2b79cc3
Show file tree
Hide file tree
Showing 12 changed files with 20,790 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
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
};
15 changes: 15 additions & 0 deletions .gitattributes
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
node_modules/
../
*.log
.env
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../
21 changes: 21 additions & 0 deletions LICENSE
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.
31 changes: 31 additions & 0 deletions README.md
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
Loading

0 comments on commit 2b79cc3

Please sign in to comment.