Skip to end of metadata
Go to start of metadata

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.
    • Function parameters

Name

Type

Default value

Description

doNotFocus

Boolean

false

Informs whether to startediting values in the field (no focus)

 

  • Function result: null

 

  • 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.
    • Function parameters:

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)
    • Function result: null

 

  • get - gets all comments for the task.
    • Function parameters:

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)

    • Function result: null

 

  • remove - removes a comment for the task by checking if the comment provided was added by the person currently performing the task.
    • Function parameters:

 

Name

Type

Default value

Description

commentId

Number

null

Comment id

    • Function result: null

 

  • 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

      NameType

      Default value

      DescriptionExample
      hookObjectnullHooks 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
      //example of hook after adding comment
      CommentService.registerHook({
          afterAdd: function( comment ) {
             PW.ui.Message.success( 'Comment was added.' );
          }
      });


  • No labels