Serwis CommentsService pozwala
Polish |
---|
Serwis CommentService pozwala zarządzać komentarzami zadania, które aktualnie jest wykonywane. Posiada następujące funkcje: - showArea - otwiera pole komentarza wraz z przyciskami dodawania komentarza i ukrywania pola. Działa, gdy komentarze są włączone dla zadania.
Parametry funkcji:
Nazwa | Typ | Wartość domyślna | Opis |
---|
doNotFocus | Boolean | false | Informuje, czy nie rozpoczynać edycji wartości w polu (brak focus'a) |
- Rezultat funkcji: brak
- hideArea - ukrywa pole komentarza wraz z przyciskami dodawania komentarza i ukrywania pola. Działa, gdy komentarze są włączone dla zadania.
- Parametry funkcji: brak
- Rezultat funkcji: brak
- showCommentsForm (od 3.1.24) - pokazuje tabelkę komentarzy wraz z przyciskiem dodania komentarza.
|
...
- Działa, gdy komentarze są włączone dla zadania.
- Parametry funkcji: brak
- Rezultat funkcji: brak
|
...
- hideCommentsForm (od 3.1.24) -
|
...
- ukrywa tabelkę komentarzy
|
...
...
- i przyciskiem dodania komentarza.
|
...
- Działa, gdy komentarze są włączone dla zadania.
- Parametry funkcji: brak
- Rezultat funkcji: brak
- add - dodaje komentarz do procesu. Odświeża także tabelę komentarzy, jeżeli są one włączone dla zadania. Komentarz jest widziany jako dodany przez osobę aktualnie wykonującą zadanie.
Nazwa | Typ | Wartość domyślna | Opis |
---|
comment | String | null | Treść komentarza (maksymalnie 4000 znaków, dłuższe komentarze są ignorowane) | config | Object | null | Konfiguracja dodawania komentarza. Obiekt posiada następujące właściwości: - success (Typ Function) - Opcjonalna funkcja wykonywana po zapisie zakończonym sukcesem (domyślnie: null)
- failure (Typ Function) - Opcjonalna funkcja wykonywana po zapisie zakończonym niepowodzeniem (domyślnie: null)
- scope (Typ Object) - Scope dla opcjonalnych funkcji po dodaniu komentarza (success i failure)
|
Rezultat funkcji: brak |
...
...
- isEdited (od 3.1.8) - informuje, czy pole komentarza jest otwarte, a jego wartość niepusta.
Parametry funkcji: brak
Rezultat funkcji:
Typ | Opis |
---|
Boolean | Zwraca wartość true, jeżeli pole komentarza jest otwarte, a jego wartość niepusta |
- registerHook (od 3.2.94) - pozwala wpiąć się w moment dodawania komentarza przez użytkownika i wykonać jakąś akcję.
Parametry funkcji Nazwa | Typ | Wartość domyślna | Opis | Przykład |
---|
hook | Object | null | Zdefiniowane hooki, które mają się wywołać: - beforeAdd (Typ Function) Funkcja, która zostanie wywołana zanim komentarz zostanie dodany przez użytkownika. Jeżeli funkcja zwróci wartość false, to komentarz nie zostanie dodany. Funkcja przyjmuje jako parametr oboiekt komentarza. - afterAdd (Typ Function) Funkcja, która zostanie dodana po pomyślnym dodaniu komentarza przez użytkownika. - scope (Typ Object) Scope dla wywołania funkcji | Code Block |
---|
//przykład dodanie tylko hooka po dodaniu komentarza
CommentService.registerHook({
afterAdd: function( comment ) {
PW.ui.Message.success( 'Komentarz został dodany' );
}
}); |
|
|
English |
---|
CommentServiceallows to manage the comments of the task that is currently being performed. It has the following functions: - showArea- opens the comment field with the buttons for adding a comment and hiding the field. Works when comments are enabled for a task.
Name | Type | Default value | Description |
---|
doNotFocus | Boolean | false | Informs whether to startediting values in the field (no focus) |
- hideArea - hides the comment field together with the buttons for adding a comment and hiding the field. Works when comments are enabled for task.
- Function parameters:null
- Function result: null
- showCommentsForm (from 3.1.24) - shows the table of comments together with the button for adding a comment. Works when comments are enabled for task.
- Function parameters:null
- Function result: null
- hideCommentsForm (from 3.1.24) - hides a table of comments with a field and a comment button. Works when comments are enabled for task.
- Function parameters:null
- Function result: null
- add - adds a comment to the process. It also refreshes the comments table if they are included for the task. The comment is seen as added by the person currently performing the task.
Name | Type | Default value | Description |
---|
comment | String | null | Contents of the comment (maximum 4000 characters, longer comments are ignored) | config | Object | null | Configuration of adding a comment. The object has the following properties: - success (Function Type) - Optional function performed after successful writing (default: null)
- failure (Function Type) - Optional function performed after unsuccessful writing (default: null)
- scope (Object Type) - Scope for optional functions after adding a comment (success and failure)
|
- get - gets all comments for the task.
Name | Type | Default value | Description |
---|
config | Object | { } | Configuration of downloading comments. The object has the following properties: - handler(Function Type) Function that will be called after downloading comments for the task (default: null) - scope(Object Type) Scope for optional functions performed after writing specified in the success and failure properties (default: window) - success(Function Type) Optional function performed after successful writing (default: null) - params(Object Type[]) An array specifying parameters passed to the function specified in the handler property is additionally supplemented with downloaded comments for the task (default: [comments] - downloaded comments for the task) |
- remove - removes a comment for the task by checking if the comment provided was added by the person currently performing the task.
Name | Type | Default value | Description |
---|
commentId | Number | null | Comment id |
- isEdited(from 3.1.8)- informs whether the comment field is open and its value is not empty.
- Function parameters: null
- Function result:
Type | Description |
---|
Boolean | Returns true value if the comment field is open and its value is not empty. |
- registerHook (od 3.2.94) - allow to execute some actions while user is adding comment
Function parameters Name | Type | Default value | Description | Example |
---|
hook | Object | null | Hooks to be executed: - beforeAdd (Type Function) Function which will be executed before adding a comment. If function returns false the comment won't be aded. Function has one parameter - object of a comment. - afterAdd (Type Function) Function which will be executed after adding a comment. - scope (Type Object) Scope for functions | Code Block |
---|
//example of hook after adding comment
CommentService.registerHook({
afterAdd: function( comment ) {
PW.ui.Message.success( 'Comment was added.' );
}
}); |
|
|