Skip to content

Commit

Permalink
Merge branch 'master' into correspondence/notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreass2 authored Oct 8, 2024
2 parents 6146249 + 156755b commit 5010725
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
22 changes: 19 additions & 3 deletions content/altinn-studio/reference/logic/dynamic/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,30 @@ Dynamics are events that happen on the client side. These can be separated in tw
- Calculations - do calculations on the client side, and update the fields with new value.
- Show/hide fields - decide if fields should be hidden or displayed based on form values.

Rules used for javascript-based dynamics can be added and changed directly in the _RuleHandler_ file containing the rules.

{{% panel theme="warning" %}}
⚠️ Since we are moving more and more of this functionality over to [dynamic expressions](../expressions), the file
_RuleHandler.js_ is not a part of new apps as of 7th October 2024.
If you do not find the file in the `App/ui/form`-folder, you can add it there. As a minimum, the file should contain the following:

```javascript
var ruleHandlerObject = {};
var ruleHandlerHelper = {};

var conditionalRuleHandlerObject = {};
var conditionalRuleHandlerHelper = {};
```

{{% /panel %}}

There are two ways to add and change dynamics for an Altinn App:
1. Directly in Altinn Studio under _Lage_-tab. Select _Rediger dynamikk_ in the right menu.
2. In a local development environment by working in the file `RuleHandler.js` which can be found in the `App/ui` folder.
1. Directly in Altinn Studio, in the app repository. Select "Open repository" in the profile menu for the app, and navigate to `App/ui/form` and open `RuleHandler.js` in the browser.
2. In a local development environment by working in the file `RuleHandler.js` which can be found in the `App/ui/form` folder.

All dynamics are written as JavaScript functions in the _RuleHandler_ file.
Functions that are defined in this file can be configured to run for selected fields in the app.


{{%notice info%}}
The dynamic code to show/hide fields or perform calculations should be set up so that it handles possible errors in the input gracefully.
It should, for instance, handle empty fields or strings where you expect numbers without crashing.
Expand Down
23 changes: 20 additions & 3 deletions content/altinn-studio/reference/logic/dynamic/_index.nb.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,27 @@ Dynamikk er hendelser som skjer på klient-siden. Disse kan deles opp i to kateg
- Beregning - kjøre beregninger på klient-side, og oppdatere felter med ny verdi
- Vis/skjul felter - bestemme om felter skal vises eller skjules basert på verdier i skjema.

Det er to måter å legge til og endre dynamikkregler for en Altinn App.
1. Direkte i Altinn Studio under _Lage_-fanen. Velg _Rediger dynamikk_ i høyre-menyen.
2. I lokalt utviklingsmiljø ved å jobbe i filen `RuleHandler.js` som finnes i `App/ui`-mappen .
Dynamikkregler via javascript for en Altinn App redigeres direkte i _RuleHandler_-filen.

{{% panel theme="warning" %}}
⚠️ Fordi vi flytter mer og mer av denne funksjonaliteten over til [dynamiske uttrykk](../expressions), følger ikke filen
_RuleHandler.js_ med i nye apper (per 7. oktober 2024).
Dersom du ikke finner filen i `App/ui/form`-mappen, kan du legge til filen der.
Som et minimum bør filen inneholde følgende:

```javascript
var ruleHandlerObject = {};
var ruleHandlerHelper = {};

var conditionalRuleHandlerObject = {};
var conditionalRuleHandlerHelper = {};
```

{{% /panel %}}

Det er to måter å legge til og endre dynamikkregler for en Altinn App.
1. Direkte i Altinn Studio, på appens filområde. Velg "Åpne repository" i profil-menyen øverst til høyre, og naviger til `App/ui/form`, og velg filen `RuleHandler.js`.
2. I lokalt utviklingsmiljø ved å jobbe i filen `RuleHandler.js` som finnes i `App/ui/form`-mappen .

All dynamikk skrives som funksjoner i JavaScript i _RuleHandler_-filen.
Funksjonene som er definert i denne filen kan videre konfigureres til å kjøres for feltene i skjemaet.
Expand Down

0 comments on commit 5010725

Please sign in to comment.