maxLevel | 1 |
---|
AkcjaAkcje formularza to komponenty użytkownika, umożliwiające wykonywanie dowolnych akcji na formularzu zadania w reakcji na działania użytkownika, zmiany danych czy też inne zdarzenia formularza. Przykładowe akcje mogą np. - przeprowadzać obliczenia matematyczne np. przeliczać kwoty netto, sumować wartości, obliczać kursy
- dodawać komentarze
- wyświetlać komunikaty
- komunikować się z serwerem w celu pobrania danych
- dowolnie zmieniać wartości zmiennych zadania (poprzez FormAPI)
Stworzone akcje dostępne są w edytorze procesów i mogą być łatwo wykorzystane w procesie biznesowym umożliwiając tym samym realizacje logiki biznesowej. Ich zachowanie może być dodatkowo konfigurowane za pomocą parametrów. Info |
---|
W tworzonych akcjach po stronie przeglądarki wspierany jest standard ECMAScript 6. |
Definiowanie akcjiAkcje tworzone są w oparciu o ich definicję stworzoną przez użytkownika. Definicja taka musi zawierać następujące elementy: - Adnotację
Javadoc |
---|
displayValue | @Actions |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.Actions |
---|
| (jeżeli akcja nie jest definiowana we wtyczce, musi ona pochodzić z pakietu com.suncode ) - Adnotację
Javadoc |
---|
displayValue | @ActionsScript |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.ActionsScript |
---|
|
|
...
- przekazującą ścieżkę do skryptu (z classpath) zawierającego implementację w języku JavaScript lub ścieżkę wraz z fragmentami, w których skrypt zostanie umieszczony (np. w przypadku umieszczenia akcji w historii procesów). W pierwszym przypadku podajemy tylko ścieżkę, w drugim ścieżka ląduje w parametrze value, zaś fragmenty w obiekcie fragments. Dostępne wartości dla fragmentów można znaleźć w klasie
Javadoc |
---|
displayValue | ActionUIFragment |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionUIFragment |
---|
| . - Publiczną metodę oznaczoną adnotacją
Javadoc |
---|
displayValue | @Define |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.component.annotation.Define |
---|
| z jednym parametrem Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionDefinitionBuilder |
---|
| (w jednej klasie @Actions może być zdefiniowanych wiele różnych akcji)
Akcja może również dostarczać skrypt, który buduje wygląd parametrów podczas jej definiowania w PWE. W tym celu należy dodać kolejną adnotację dla klasy Javadoc |
---|
displayValue | @ComponentsFormScript |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.component.annotation.ComponentsFormScript |
---|
| z przekazaną ścieżką do skryptu (z classpath).Przykładowa definicja przedstawiona jest poniżej: Code Block |
---|
language | java |
---|
linenumbers | true |
---|
| @Actions
@ActionsScript( "actions/example.js" )
@ComponentsFormScript( "actions/example-form.js" )
public class ExampleActions
{
@Define
public void |
|
...
action( ActionDefinitionBuilder action )
{
|
|
...
Teraz wykorzystując obiekt Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form..ActionDefinitionBuilder definiujemy akcję:
...
language | java |
---|
linenumbers | true |
---|
...
...
...
...
...
...
...
...
...
...
...
hide-variables" )
.name( " |
|
...
...
hide-variables.name" )
.description( " |
|
...
...
...
...
...
...
...
...
...
...
.category( Categories.TEST )
. |
|
...
...
ActionDestination.button() )
. |
|
...
...
...
...
...
...
...
...
...
...
...
...
...
VARIABLE_ARRAY )
.create();
} |
|
...
Akcja musi być zdefiniowana po stronie serwera. W tym celu należy utworzyć klasę i oznaczyć ją adnotacją
Javadoc |
---|
displayValue | @Action |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.Action |
---|
|
. Adnotacja ta sprawia, że system będzie szukał definicji akcji w tej klasie. Dodatkowo należy dodać adnotację Javadoc |
---|
displayValue | @ActionScript |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.ActionScript |
---|
|
i jako jej wartość podać relatywną ścieżkę do skryptu z implementacją akcji. W tak przygotowanej klasie należy teraz dodać definicję akcji. W tym celu trzeba dodać metodę i oznaczyć ją adnotacją Javadoc |
---|
displayValue | @DefineAction |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation.DefineAction |
---|
|
. Metoda musi przyjmować jeden parametr typu Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionDefinitionBuilder |
---|
|
. W implementacji metody należy za pomocą przekazanego builder'a zdefiniować wszystkie własności akcji....
Przykładowa definicja dla akcji umieszczonej zarówno na formularzu, jak i w historii: Code Block |
---|
@Actions
@ActionsScript( value = "actions/example.js", fragments = { ActionUIFragment.FORM, ActionUIFragment.HISTORY } )
public class ExampleActions |
Elementy docelowe (destination)Elementy docelowe wskazywane są na etapie tworzenia definicji akcji w metodzie destination() . Określają one, do jakich elementów formularza może być dodana akcja: Element | Opis | Przykłady akcji | Wybór w PWE |
---|
ActionDestination.form() | Formularz Akcja dodana do formularza inicjowana jest metodą formInit . | Akcje w których nie można wskazać głównego elementu np. - ukrywanie wielu zmiennych jednocześnie
| Image Modified | ActionDestination.variable() | Zmienna Akcja dodana do zmiennej formularza inicjowana jest metodą variableInit w parametrze otrzymując obiekt tej zmiennej ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.variable.Variable |
---|
| ). | Akcje w których można jednoznacznie wskazać zmienną, której akcje dotyczy (w największym stopniu) np. - ukrywanie zmiennej
- walidacja zmiennej na żywo (np. pokazanie komunikatu bez akceptacji)
| Image Modified |
|
...
ActionDestination.variableSet() | Tabelka dynamiczna Akcja dodana do zmiennej formularza inicjowana jest metodą variableSetInit w parametrze otrzymując obiekt tabelki dynamicznej ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.VariableSet |
---|
| ). | Akcje które dotyczą tabelki dynamicznej i potrzebują jej identyfikator np. - nadanie tytułu tabelce na podstawie obliczeń
- import danych do tabelki (akcja dodaje przycisk do tabelki)
| Image Modified | ActionDestination.button() | Przycisk Akcja dodana do przycisku formularza inicjowana jest metodą buttonInit w parametrze otrzymując obiekt przycisku ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.Button |
---|
| ). | Akcje których źródłem jest przycisk np. - dodawanie komentarza przed akceptacją
- wyświetlanie komunikatów po kliknięciu przycisku
| Image Modified |
|
Image Removed
ActionDestination.dtButton() | Przycisk na tabeli Akcja dodana do przycisku na tabeli formularza inicjowana jest metodą dtButtonInit w parametrze otrzymując obiekt przycisku ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.DtButton |
---|
| ). | | Akcja dodawana jest na poziomie dodawania/edytowania przycisku tabeli formularza: Image Added
| ActionDestination.label() | Etykieta Akcja dodana do etykiety na formularza inicjowana jest metodą labelInit w parametrze otrzymując obiekt etykiety ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.Label |
---|
| ). | | Image Added
|
Inicjalizacja akcji Warning |
---|
Funkcjonalność jeszcze niedostępna. |
Twórca procesu w akcji określić może jej typ inicjalizacji. Dostępne typy: - Brak inicjalizacji (NONE)
- Pojedyncza inicjalizacja (SINGLE)
- Ciągła inicjalizacja (CONTINUOUS)
Wybrany parametr jest możliwy do odczytu w akcji w funkcji getInitializationType. Ustawienie tego parametru NIE WPŁYWA na działanie akcji, jeżeli nie zaimplementował tego twórca akcji. Przypisanie elementu docelowego do parametru (bindTo)Wybrany element docelowy akcji może zostać przekazany do parametru akcji poprzez podanie w parametrze bindTo identyfikatora parametru docelowego. Np. Code Block |
---|
| ActionDestination.variable( "text" ); // 'text' to identyfikator parametru akcji |
Z tak skonfigurowaną akcją, jeżeli dodamy ją do dowolnej zmiennej, zmienna to zostanie automatycznie ustawiona jako wartość parametru. W zależności od elementu docelowego w parametr wpisane zostaną: Element docelowy | Przypisana wartość |
---|
Zmienna | Zmienna | Tabelka dynamiczna | Identyfikator tabelki dynamicznej | Przycisk | Identyfikator przycisku (nazwa akcji) |
Implementacja akcjiZdefiniowana na serwerze akcja formularza musi zostać zarejestrowana i zaimplementowana po stronie przeglądarki. Rejestrację umożliwia klasa Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Actions |
---|
| za pomocą metody Jsdoc |
---|
displayValue | create |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Actions.html#method_create |
---|
| . Pierwszym parametrem metody jest id akcji (id musi odpowiadać tej akcji, która została zdefiniowana na serwerze), drugim parametrem jest obiekt implementacji akcji: Code Block |
---|
language | js |
---|
linenumbers | true |
---|
| PW.FormActions.create('hide-variables', {
init: function(){
this.variables = this.get("variables");
this.variablesNames = [];
},
enable: function(){
this.hideVariables();
},
disable: function(){
this.showVariables();
},
hideVariables: function() {
this.setVariablesVisibility(false);
},
showVariables: function() {
this.setVariablesVisibility(true);
},
setVariablesVisibility: function(visible) {
PW.each(this.variables, function(variable){
if(visible){
variable.show();
}
else{
variable.hide();
}
}, this);
}
}); |
Akcje domyślneW celu ułatwienia tworzenia akcji które reagują na domyślne zdarzenia elementów docelowych możliwe jest zdefiniowanie tzw. akcji domyślnych. |
...
Twórca akcji może zadeklarować funkcje, które wykonają się automatycznie, jeżeli wystąpi zdarzenie skojarzone z elementem docelowym akcji np. jeżeli akcja dodana jest do przycisku, to klikniecie w ten przycisk spowoduje wywołanie zdefiniowanej akcji domyślnej. Info |
---|
Akcje domyślne są wywoływane tylko jeżeli warunek wykonania akcji jest spełniony. Parametry wywołania akcji domyślnej są takie same jak parametry zdarzeń, które są źródłem wywołania akcji domyślnej. |
Zdarzenia domyślne w zależności od elementu docelowego akcji: Element docelowy | Nazwa funkcji | Domyślne zdarzenie | Opis |
---|
ActionDestination.button() | button | click ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.Button |
---|
| ) | Funkcja wywoływana jest po kliknięciu na przycisk, do którego dodana jest akcja. Tip |
---|
Można przerwać akceptację formularza poprzez zwrócenie false : Code Block |
---|
| defaultActions: {
button: function(button){
// do some job
return false;
}
} |
|
| ActionDestination.variable() | variable | change ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.variable.Variable |
---|
| ) | Funkcja wywoływana jest po zmianie wartości zmiennej, do której dodana jest akcja. | ActionDestination.variableSet() | variableSet | change ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.VariableSet |
---|
| ) | Funkcja wywoływana jest jeżeli zmieni się wartość jakiejkolwiek zmiennej należącej do tabeli dynamicznej, do której dodana jest akcja. | ActionDestination.form() | form | enable ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Action |
---|
| ) | Funkcja wywoływana jest, jeżeli zostanie spełniony warunek dla akcji. | ActionDestination.dtButton() | dtButton | click ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.DtButton |
---|
| ) | Funkcja wywoływana jest po kliknięciu na przycisk w tabeli, do którego dodana jest akcja. |
Poniżej przykładowa implementacja akcji pokazującej skonfigurowaną wiadomość. W zależności od elementu docelowego wiadomość pokaże się przy naciśnięciu przycisku, zmianie wartości zmiennej lub zmianie danych w tabelce. Code Block |
---|
PW.FormActions.create('message', {
// domyślne akcje
defaultActions: {
button: function(button){
this.showMsg();
},
variable: function(variable, newValue, oldValue){
this.showMsg();
},
variableSet: function(variableSet, added, updated, removed){
this.showMsg();
},
dtButton: function(button){
this.showMsg();
},
},
showMsg: function(){
ServiceFactory.getMessageService().showSuccess(this.get('msg'));
}
}); |
|
...
Własności
- id - unikalny w obrębie całego systemu identyfikator akcji,
- name - nazwa akcji (obsługuje tłumaczenia),
- description - opis akcji (obsługuje tłumaczenia),
- icon - ikona akcji,
- category - kategoria, do której należy akcja (może być wiele),
- destination - element formularza, dla którego dostępna jest akcja (może być wiele)
- parameters - parametry akcji.
Kategorie
Kategorie ułatwiają podział oraz wyszukiwanie akcji. Opisywane są one za pomocą interfejsu
Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionCategory |
---|
|
. Dostępna jest podstawowa implementacja tego interfejsu Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionCategories |
---|
|
, która udostępnia podstawowe kategorie. Tworząc akcję można skorzystać z tych kategorii. W przypadku braku jakiejś kategorii można ją dodać do tej implementacji bądź stworzyć własną.Elementy formularza (destination)
Akcja może być zdefiniowana dla konkretnych elementów formularza. Definicji dokonujemy za pomocą klasy . Dostępne są następujące elementy:
- FORM (ActionDestination.form()) - cały formularz zadania,
- VARIABLE (ActionDestination.variable(parameter)) - zmienna formularza,
- VARIABLESET (ActionDestination.variableset(parameter)) - tabelka dynamiczna,
- BUTTON (ActionDestination.button(parameter)) - przycisk formularza.
Dla wszystkich elementów formularza poza FORM podczas definicji należy podać id parametru akcji (jeżeli akcja posiada parametry). Umożliwia to automatyczne podpięcie danego elementu do tego parametru podczas wyboru akcji w PlusWorkflowEditor.
Parametry akcji
Akcje mogą posiadać parametry.
Definicja parametru:
- id - id parametru,
- type - typ parametru,
- name - nazwa parametru (obsługuje tłumaczenia),
- description - opis parametru (obsługuje tłumaczenia),
- array - określa, czy parametr jest tablicą.
Jeżeli przekazana zostanie do parametru wartość innego typu niż w definicji, to zostanie ona skonwertowana do tego typu.
Definiowanie akcji
Akcja musi być zdefiniowana po stronie serwera. W tym celu należy utworzyć klasę i oznaczyć ją adnotacją Javadoc |
---|
displayValue | @ActionWiele źródeł (targetów) akcji Warning |
---|
Funkcjonalność jeszcze niedostępna. |
Możliwe jest określenie więcej niż jednego źródła (targetu) dla akcji np. w celu wywołania dokładnie tej samej akcji, jeżeli została zmieniona wartość jednej z wielu określonych zmiennych. Aby dodać wsparcie do wielu targetów dla akcji, w builderze należy wywołać multitarget(): Code Block |
---|
| @Define
public void action( ActionDefinitionBuilder action )
{
action
.id( "hide-variables" )
.name( "action.hide-variables.name" )
.description( "action.hide-variables.desc" )
.icon( SilkIconPack.EYE )
.category( Categories.TEST )
.multitarget()
.destination( ActionDestination.button() )
.parameter()
.id( "variables" )
.name( "action.hide-variables.variables.name" )
.description( "action.hide-variables.variables.desc" )
.type( Types.VARIABLE_ARRAY )
.create();
} |
Jeżeli akcja została dodana (przeciągnięta) do: - przycisków
- zmiennych nagłówkowych
- tabeli
możliwe jest dodanie kolejnych obiektów tego samego typu jako źródeł wywoływania akcji. Jeżeli źródłem jest tabela, kolejno dodawane obiekty muszą być zmiennymi tabelarycznymi. Akcja pozostaje jednym i tym samym obiektem JavaScriptowym, lecz więcej niż jeden obiekt może wywołać zdarzenia defaultActions: - dla przycisków - każdy z dodanych przycisków wywołuje po kliknięciu zdarzenie button przekazując do funkcji zdarzenia samego siebie
- dla zmiennych nagłówkowych - każda z dodanych zmiennych po zmianie wartości wywołuje zdarzenie variable przekazując do funkcji zdarzenia samą siebie
- dla tabeli - jeżeli nie określono dodatkowych zmiennych tabelarycznych, każda zmiana w tabeli dynamicznej wywołuje zdarzenie variableSet. Jeżeli określono dodatkowe zmienne - zmiana w tabeli dynamicznej wywołuje zdarzenie variableSet tylko wtedy, gdy zmiana zaszła w którejś ze zdefiniowanych zmiennych tabelarycznych (przy dodaniu lub usunięciu wiersza zdarzenie variableSet jest zawsze wywoływane).
Również inicjalizacja akcji dla określonych zmiennych zmienia nieznacznie swoje zachowanie: - buttonInit - przekazuje tablicę przycisków (nawet, gdy określony został tylko jeden przycisk)
- variableInit - przekazuje tablicę zmiennych nagłówkowych (nawet, gdy została określona tylko jedna zmienna)
Symbol błyskawicy zostaje wyświetlony przy każdym z dodanych targetów, lecz edycja takiej akcji jest globalna. Rejestracja akcji we wtyczceJeżeli akcja jest definiowana we wtyczce to należy dodatkowo zaznaczyć, że wtyczka ta udostępnia akcje. W tym celu należy w pliku suncode-plugin.xml dodać wpis: Code Block |
---|
| <!-- Udostępnianie akcji -->
<workflow-components key="components" /> |
|
English |
---|
ActionForm actions are user components that allow you to perform any action on the task form in response to user actions, data changes or other form events. Examples of actions can, for example. - perform mathematical calculations, e.g. convert net amounts, sum values, calculate rates
- add comments
- display messages
- communicate with the server in order to download data
- freely change the values of task variables (via FormAPI)
The created actions are available in the process editor and can be easily used in the business process enabling the execution of business logic. Their behavior can be further configured using parameters. Info |
---|
The ECMAScript 6 standard is supported in the browser-side actions created. |
Defining actionsActions are created based on their definition created by the user. Such a definition must contain the following elements: - An annotation
Javadoc |
---|
displayValue | @Actions |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation. |
---|
|
|
Action. Adnotacja ta sprawia, że system będzie szukał definicji akcji w tej klasie. Dodatkowo należy dodać adnotację - (if the action is not defined in the plug-in, it must come from the com.suncode package)
- An annotation
|
@ActionScript@ActionsScript | property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.annotation. |
---|
|
|
ActionScript i jako jej wartość podać relatywną ścieżkę do skryptu z implementacją akcji. W tak przygotowanej klasie należy teraz dodać definicję akcji. W tym celu trzeba dodać metodę i oznaczyć ją adnotacją - An annotation transferring the path to the script (from classpath) containing the JavaScript implementation, or the path along with the fragments in which the script will be placed (for example, if the action is placed in the process history). In the first case, we specify only the path, while in the second case the path lands in the value parameter, and the fragments in the fragments object. The available values for fragments can be found in the class
|
@DefineActionActionUIFragment | property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action. |
---|
|
|
annotationDefineAction. Metoda musi przyjmować jeden parametr typu - Public method annotated
Javadoc |
---|
displayValue | @Define |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.component.annotation.Define |
---|
| with a single parameter Javadoc |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.action.ActionDefinitionBuilder |
---|
|
|
. W implementacji metody należy za pomocą przekazanego builder'a zdefiniować wszystkie własności akcji.- (many different actions can be defined in a single @Actions class)
An action can also provide a script that builds the appearance of parameters when it is defined in the PWE. To do this, add another annotation for the class Javadoc |
---|
displayValue | @ComponentsFormScript |
---|
property | javadoc.plusworkflow |
---|
className | com.suncode.pwfl.workflow.form.component.annotation.ComponentsFormScript |
---|
| with the path to the script transferred (from classpath).An example definition is shown below: |
...
...
...
...
...
actions/example.js" )
@ComponentsFormScript( "actions/example-form.js" )
public class |
|
...
...
...
public void action( ActionDefinitionBuilder action )
{
|
|
...
...
...
...
hide-variables.name" )
.description( "action. |
|
...
hide-variables.desc" )
.icon( SilkIconPack. |
|
...
EYE )
.category( Categories.TEST )
.destination( ActionDestination. |
|
...
button() )
.parameter()
.id( "variables" )
.name( "action. |
|
...
hide-variables.variables. |
|
...
...
...
hide-variables.variables. |
|
...
...
...
Sample definition for an action placed both on the form and in the history: Code Block |
---|
@Actions
@ActionsScript( value |
|
...
Implementacja akcji
Zdefiniowana na serwerze akcja formularza musi zostać zarejestrowana i zaimplementowana po stronie przeglądarki. Rejestrację umożliwia klasa
= "actions/example.js", fragments = { ActionUIFragment.FORM, ActionUIFragment.HISTORY } )
public class ExampleActions |
Destination elements (destination) Destination elements are indicated at the action definition stage in the destination() method. They specify to which form elements the action can be added: Element | Description | Examples of actions | Selection in PWE |
---|
ActionDestination.form() | Form The action added to the form is initiated with the formInit method. | Actions in which the main element cannot be indicated, e.g. - hiding multiple variables at the same time
| Image Added | ActionDestination.variable() | Variable The action added to the form variable is initialized with the variableInit method in the parameter receiving an object of this variable ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.variable.Variable |
---|
| ). | Actions in which it is possible to clearly indicate the variable to which the action applies (to the greatest extent), e.g. - hiding a variable
- live validation of a variable (e.g. showing a message without acceptance)
| Image Added | ActionDestination.variableSet() | Dynamic table The action added to the form variable is initialized with the variableSetInit method in the parameter receiving a dynamic table object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.VariableSet |
---|
| ). | Actions |
|
za pomocą metody Jsdoc |
---|
displayValue | create |
---|
that apply to a dynamic table and need its identifier, for example. - add a title to the table based on calculations
- import data into the table (action adds a button to the table)
| Image Added | ActionDestination.button() | Button The action added to the form button is initialized with the buttonInit method in the parameter receiving the button object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.Button |
---|
| ). | Actions whose source is a button, e.g. - adding a comment before acceptance
- displaying messages after clicking the button
| Image Added | ActionDestination.dtButton() | Table button The action added to the form's table button is initialized with the dtButtonInit method in the parameter receiving the button object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.DtButton |
---|
| ). | | The action |
|
.Actions.html#method_create. Pierwszym parametrem metody jest id akcji (id musi odpowiadać tej akcji, która została zdefiniowana na serwerze), drugim parametrem jest obiekt konfiguracyjny akcji....
...
is added at the add/edit level of the form table button: Image Added
| ActionDestination.label() | Label The action added to the label on the form is initialized with the labelInit method in the parameter receiving the label object ( Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.Label |
---|
| ). | | Image Added
|
Action initialization Warning |
---|
Functionality not yet available. |
The creator of the process in action can specify its initialization type. Available types: The selected parameter is readable by the action in the getInitializationType function. Setting this parameter DOES NOT affect the operation of the action unless the action creator has implemented it. Assigning a target element to a parameter (bindTo)The selected target element of the action can be transferred to the action parameter by specifying the target parameter ID in the bindTo parameter. E.g.
Code Block |
---|
| ActionDestination.variable( "text" ); // 'text' to identyfikator parametru akcji |
With the action configured in this way, if we add it to any variable, the variable will automatically be set as the value of the parameter. Depending on the target element in the parameter will be entered: Target element | Assigned value |
---|
Variable | Variable | Dynamic table | Dynamic table identifier | Button | Button ID (action name) |
Implementation of actionsThe form action defined on the server must be registered and implemented on the browser side. Registration is enabled by the class Jsdoc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Actions |
---|
| using the method Jsdoc |
---|
displayValue | create |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Actions.html#method_create |
---|
| . The first parameter of the method is the action id (the id must correspond to the action that has been defined on the server), the second parameter is the action implementation object: Code Block |
---|
language | js |
---|
linenumbers | true |
---|
| PW.FormActions.create(' |
|
...
...
...
...
...
...
...
...
...
},
enable: function(){
this.hideVariables();
|
|
...
...
disable: function(){
this. |
|
...
...
...
hideVariables: function() {
this. |
|
...
setVariablesVisibility(false);
},
|
|
...
showVariables: function() {
this.setVariablesVisibility( |
|
...
...
setVariablesVisibility: function(visible) {
|
|
...
PW.each(this.variables, function(variable){
|
|
...
if(visible){
variable.show();
} |
|
...
...
...
...
Default actionsIn order to simplify the creation of actions that react to default events of target elements, it is possible to define so-called default actions. The creator of the action can declare functions that will execute automatically if an event associated with the target element of the action occurs, e.g. if the action is added to a button, clicking on this button will trigger the defined default action. Info |
---|
Default actions are called only if the action execution condition is fulfilled. The parameters of the default action call are the same as the parameters of the events that are the source of the default action call. |
Default events depending on the action target element: Target element | Function name | Default event | Description |
---|
ActionDestination.button() | button | click ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.Button |
---|
| ) | The function is called when you click on the button to which the action is added. Tip |
---|
You can abort acceptance of the form by returning false: Code Block |
---|
| defaultActions: {
button: function(button){
// do some job
return false;
|
|
|
|
...
| ActionDestination.variable() | variable | change ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.variable.Variable |
---|
| ) | The function is called when the value of the variable to which the action is added changes. | ActionDestination.variableSet() | variableSet | change ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.field.VariableSet |
---|
| ) | The function is called if the value of any variable belonging to the dynamic table to which the action is added changes. | ActionDestination.form() | form | enable ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.action.Action |
---|
| ) | The function is called if the condition for the action is fulfilled. | ActionDestination.dtButton() | dtButton | click ( Jsdoc |
---|
displayValue | doc |
---|
property | jsdoc.plusworkflow |
---|
className | PW.form.button.DtButton |
---|
| ) | The function is called when you click on the button in the table to which the action is added. |
Below is an example implementation of an action showing a configured message. Depending on the target element, the message will show when you press a button, change the value of a variable or change the data in a table. Code Block |
---|
PW.FormActions.create('message', {
// domyślne akcje
defaultActions: {
button: function(button){
|
|
...
...
showMsg();
},
variable: function(variable, newValue, oldValue){
this.showMsg();
},
|
|
...
variableSet: function(variableSet, added, updated, removed){
|
|
...
...
...
Jeżeli akcja jest definiowana we wtyczce to należy dodatkowo zaznaczyć, że wtyczka ta udostępnia akcje. W tym celu należy w pliku suncode-plugin.xml dodać wpis
);
},
dtButton: function(button){
this.showMsg();
},
},
showMsg: function(){
ServiceFactory.getMessageService().showSuccess(this.get('msg'));
}
}); |
|
W przykładzie akcji wykorzystany jest mechanizm tłumaczeń:
Code Block |
---|
Action = {
t: PW.I18N.createT('com.suncode-actions-plugin')
}; |
Rejestracja we wtyczce
Multiple sources (targets) of action Warning |
---|
Functionality not yet available. |
It is possible to specify more than one source (target) for an action, for example, to call exactly the same action if the value of one of the many specified variables has been changed. To add support for multiple targets for an action, call multitarget() in the builder: Code Block |
---|
| @Define
public void action( ActionDefinitionBuilder action )
{
action
.id( "hide-variables" )
.name( "action.hide-variables.name" )
.description( "action.hide-variables.desc" )
.icon( SilkIconPack.EYE )
.category( Categories.TEST )
.multitarget()
.destination( ActionDestination.button() )
.parameter()
.id( "variables" )
.name( "action.hide-variables.variables.name" )
.description( "action.hide-variables.variables.desc" )
.type( Types.VARIABLE_ARRAY )
.create();
} |
If the action has been added (dragged) to: - buttons
- header variables
- tables
it is possible to add more objects of the same type as sources for calling the action. If the source is a table, the successively added objects must be table variables. The action remains one and the same JavaScript object, but more than one object can trigger defaultActions events: - for buttons - each of the added buttons triggers the button event when clicked, passing itself to the event function
- for header variables - each of the added variables, after changing the value, triggers the variable event passing itself to the event function
- for table - if no additional table variables are specified, any change in the dynamic table triggers the variableSet. If additional variables are specified - a change in the dynamic table triggers the variableSet event only if the change occurred in any of the defined tabular variables (when adding or deleting a row, the variableSet event is always triggered).
Also, initialization of actions for specified variables changes its behavior slightly: - buttonInit - transfers an array of buttons (even when only one button is specified)
- variableInit - transfers an array of header variables (even when only one variable has been specified)
The lightning symbol is displayed with each added target, but editing such an action is global. Registration of actions in the pluginIf the action is defined in the plugin then you should additionally indicate that the plugin provides the action. To do this, add an entry in the suncode-plugin.xml file: |
...
...
...
...
...
Jest to wymagane, aby nie trzeba było przeszukiwać wszystkich uruchomionych wtyczek, tylko te, które faktycznie posiadają akcje.