GlideTimelineItem - Global

  • Versão de lançamento: Yokohama
  • Atualizado 30 de jan. de 2025
  • 8 min. de leitura
  • A API GlideTimelineItem estende a classe ScheduleItem abstrata para definir propriedades adicionais que são específicas para a linha do tempo.

    Um item de linha do tempo é essencialmente qualquer item exibido em uma linha única na linha do tempo. Um GlideTimelineItem tem zero ou mais períodos associados (objetos TimelineSpan).

    GlideTimelineItem - GlideTimelineItem(cadeia de caracteres "tableName")

    Crie um objeto GlideTimelineItem "fictício".

    Isso é útil para criar linhas que não permitem YMovimento para; no entanto, contêm secundários aninhados (por exemplo, a linha "Usuários" de nível superior na linha do tempo de recursos do grupo). O sys_id precisa ser exclusivo para que as funções de nível de DOM sejam analisadas corretamente. Por padrão, este objeto não será "solto" porque um nome de tabela não foi especificado.

    Tabela 1. Parâmetros
    Nome Tipo Descrição
    tableName Cadeia de caracteres O nome da tabela associada ao objeto atual.
    Tabela 2. Retornos
    Tipo Descrição
    vazio

    GlideTimelineItem – GlideTimelineItem(cadeia de caracteres "tableName", cadeia de caracteres sys_id)

    Construtor que define a tabela necessária e as propriedades sys_id .

    O restante das propriedades deste objeto deve ser definido pelo solicitante. Por padrão, esta instância de objeto é "soltável", já que um nome de tabela é especificado.

    Tabela 3. Parâmetros
    Nome Tipo Descrição
    tableName Cadeia de caracteres O nome da tabela associada ao objeto atual.
    sys_id Cadeia de caracteres O SYS ID do objeto.
    Tabela 4. Retornos
    Tipo Descrição
    vazio

    GlideTimelineItem – createTimelineSpan(cadeia de caracteres "tableName")

    Cria um novo objeto TimelineSpan associado ao objeto de instância atual.

    Se nenhum outro objeto TimelineSpan existir, o objeto recém-criado compartilhará o mesmo sys_id que o objeto de instância atual. Caso contrário, um GUID gerado aleatoriamente será usado.

    Tabela 5. Parâmetros
    Nome Tipo Descrição
    tableName Cadeia de caracteres O nome da tabela associada ao objeto atual.
    Tabela 6. Retornos
    Tipo Descrição
    Objeto A instância de objeto de período recém-criada.

    GlideTimelineItem – createTimelineSpan(cadeia de caracteres "tableName", cadeia de caracteres sys_id)

    Cria um novo objeto TimelineSpan associado ao objeto de instância atual usando a tabela e o sys_id especificados.

    Tabela 7. Parâmetros
    Nome Tipo Descrição
    tableName Cadeia de caracteres Nome da tabela associada ao objeto atual
    sys_id Cadeia de caracteres Sys_id do objeto.
    Tabela 8. Retornos
    Tipo Descrição
    Objeto Instância de objeto de período recém-criada.

    O exemplo a seguir mostra como usar createTimelineSpan() para criar um novo objeto TimelineSpan.

    var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
    var grUser = new GlideRecord('user_resource');
    grUser.addQuery('planned_task', project_id);
    grUser.setQueryReferences(true);
    grUser.orderBy('user.name', 'DESC');
    grUser.query();
    while (grUser.next()) {
      var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
      /* Specify the text to display in the left pane for this item. */
      item.setLeftLabelText(grUser.user.name); 
      /* Set the name of the image file (including it's path) */
      item.setImage('../images/icons/user.gifx'); 
      /* Specify whether or not to bold the text style of the item in the left pane. */
      item.setTextBold(true); 
      /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
      item.setIsDraggable(true);
      /* Create a new TimelineSpan object associated with the current instance object using the specified table and sys_id. */ 
      item.createTimelineSpan(grUser.getTableName(), grUser.getUniqueValue());
    }

    GlideTimelineItem – getImage()

    Retorna uma cadeia de caracteres que especifica o nome do arquivo de imagem associado ao GlideTimelineItematual.

    Tabela 9. Parâmetros
    Nome Tipo Descrição
    nenhum
    Tabela 10. Retornos
    Tipo Descrição
    Cadeia de caracteres O nome do arquivo de imagem associado ao GlideTimelineItem atual. Se nenhuma imagem estiver associada ao item atual, uma cadeia de caracteres vazia ("") será retornada.

    GlideTimelineItem – getIsDroppable()

    Indica se o objeto de instância atual deve ou não ser permitido como uma "zona de lançamento" ao mover elementos da linha do tempo verticalmente.

    Tabela 11. Parâmetros
    Nome Tipo Descrição
    nenhum
    Tabela 12. Retornos
    Tipo Descrição
    Booliano Verdadeiro se for descartável; caso contrário, falso.

    GlideTimelineItem – getLeftLabelText()

    Retorna o texto a ser exibido no painel esquerdo (se habilitado).

    Tabela 13. Parâmetros
    Nome Tipo Descrição
    nenhum
    Tabela 14. Retornos
    Tipo Descrição
    Cadeia de caracteres O valor do texto a ser exibido no painel esquerdo.

    GlideTimelineItem – getParent()

    Retorna o sysId exclusivo do objeto primário do GlideTimelineItematual.

    Tabela 15. Parâmetros
    Nome Tipo Descrição
    nenhum
    Tabela 16. Retornos
    Tipo Descrição
    Cadeia de caracteres O sysId exclusivo do objeto primário do GlideTimelineItem atual. Se o primário não existir, será retornada uma cadeia de caracteres vazia ("").

    GlideTimelineItem – getTimelineSpans()

    Retorna todos os objetos TimelineSpan associados à instância atual em um ArrayList.

    Tabela 17. Parâmetros
    Nome Tipo Descrição
    nenhum
    Tabela 18. Retornos
    Tipo Descrição
    Matriz de objetos A lista de objetos TimelineSpan associados à instância atual.

    GlideTimelineItem - isTextBold()

    Indica se o texto do painel esquerdo está definido para ser exibido usando um estilo em negrito.

    Tabela 19. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 20. Retorna
    Tipo Descrição
    Booliano Sinalizador que indica se o texto deve estar em negrito.
    Valores possíveis:
    • verdadeiro: o texto deve estar em negrito.
    • falso: o texto não deve estar em negrito.

    O exemplo a seguir verifica se o estado de um incidente é "Novo" e define o texto do item como negrito.

    var NewIncidentTimelineScriptInclude = Class.create();
    NewIncidentTimelineScriptInclude.prototype = Object.extendsObject(AbstractTimelineSchedulePage, {
    
      getItems: function() {
        // Specify the page title 
        this.setPageTitle('New Incident Timeline');
    
        var groupNew = new GlideTimelineItem('new');
        groupNew.setLeftLabelText('New Incidents');
    
        groupNew.setImage('../images/icons/all.gifx');
        this.add(groupNew);
    
        // Get all the new incidents and add them to a new label 
        var grIncident = new GlideRecord('incident');
        grIncident.query();
        while (grIncident.next()) {
          // Loop through all and capture new incidents 
          if (grIncident.incident_state != '1') continue;
    
          // Create the item and the span item. 
          var item = new GlideTimelineItem(grIncident.getTableName(), grIncident.sys_id);
          var span = item.createTimelineSpan(grIncident.getTableName(), grIncident.sys_id);
    
          if (grIncident.incident_state == '1') { // New
            item.setParent(groupNew.getSysId());
            // Check and set bold text
              item.setTextBold(item.isTextBold() ? false : true);
            } 
          item.setImage('../images/icons/open.gifx');
          span.setTimeSpan(grIncident.getElement('opened_at').getGlideObject().getNumericValue(),
          grIncident.getElement('opened_at').getGlideObject().getNumericValue());
    
          // Show different colors based upon the priorities only for new incidents 
          switch (grIncident.getElement('priority').toString()) {
            case '1':
              span.setPointIconClass('red_circle');
              break;
            case '2':
              span.setPointIconClass('red_square');
              break;
            case '3':
              span.setPointIconClass('blue_circle');
              break;
            case '4':
              span.setPointIconClass('blue_square');
              break;
            case '5':
              span.setPointIconClass('sepia_circle');
              break;
    
              default: // Otherwise, the default point icon class will be used (Milestone)
          }
    
          // Common item properties 
          item.setLeftLabelText(grIncident.short_description);
    
          // Common span properties
          span.setSpanText(grIncident.short_description);
          span.setSpanColor('blue');
          span.setTooltip('<strong>' + GlideStringUtil.escapeHTML(grIncident.short_description) +
            '</strong><br>' + grIncident.number);
          this.add(item);
        }
      }
    
    });

    GlideTimelineItem – setImage(String strImageName)

    Define o nome do arquivo de imagem (incluindo seu caminho) a ser usado como o ícone do item no painel esquerdo.

    Tabela 21. Parâmetros
    Nome Tipo Descrição
    strImageName Cadeia de caracteres Nome da imagem, incluindo o caminho.
    Tabela 22. Retornos
    Tipo Descrição
    vazio

    O exemplo a seguir mostra como usar setImage() para definir a imagem que deve aparecer para o ícone no painel esquerdo.

    var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
    var grUser = new GlideRecord('user_resource');
    grUser.addQuery('planned_task', project_id);
    grUser.setQueryReferences(true);
    grUser.orderBy('user.name', 'DESC');
    grUser.query();
    while (grUser.next()) {
      var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
      /* Specify the text to display in the left pane for this item. */
      item.setLeftLabelText(grUser.user.name); 
      /* Set the name of the image file (including it's path) */
      item.setImage('../images/icons/user.gifx'); 
      /* Specify whether or not to bold the text style of the item in the left pane. */
      item.setTextBold(true); 
      /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
      item.setIsDraggable(true); 
    }

    GlideTimelineItem – setIsDraggable(Booliano b)

    Define se o objeto de instância atual pode ou não ser clicado e arrastado para outro GlideTimelineItem.

    Tabela 23. Parâmetros
    Nome Tipo Descrição
    b Booliano Sinalizador que indica se o item pode ser movido clicando e arrastando.
    Valores válidos:
    • verdadeiro: o item pode ser movido clicando e arrastando.
    • falso: o item não pode ser movido clicando e arrastando.
    Tabela 24. Retornos
    Tipo Descrição
    vazio

    O exemplo a seguir mostra como usar setIsDraggable() para permitir que o objeto atual seja arrastado para outro GlideTimelineItem.

    var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
    var grUser = new GlideRecord('user_resource');
    grUser.addQuery('planned_task', project_id);
    grUser.setQueryReferences(true);
    grUser.orderBy('user.name', 'DESC');
    grUser.query();
    while (grUser.next()) {
      var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
      /* Specify the text to display in the left pane for this item. */
      item.setLeftLabelText(grUser.user.name); 
      /* Set the name of the image file (including it's path) */
      item.setImage('../images/icons/user.gifx'); 
      /* Specify whether or not to bold the text style of the item in the left pane. */
      item.setTextBold(true); 
      /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
      item.setIsDraggable(true); 
    }

    GlideTimelineItem – setLeftLabelText(cadeia de caracteres strText)

    Especifica o texto a ser exibido no painel esquerdo deste item.

    Tabela 25. Parâmetros
    Nome Tipo Descrição
    strText Cadeia de caracteres Texto a ser exibido no painel esquerdo deste item.
    Tabela 26. Retornos
    Tipo Descrição
    vazio

    O exemplo a seguir mostra como usar setLeftLabelText() para definir o texto no painel esquerdo.

    var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
    var grUser = new GlideRecord('user_resource');
    grUser.addQuery('planned_task', project_id);
    grUser.setQueryReferences(true);
    grUser.orderBy('user.name', 'DESC');
    grUser.query();
    while (grUser.next()) {
      var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
      /* Specify the text to display in the left pane for this item. */
      item.setLeftLabelText(grUser.user.name); 
      /* Set the name of the image file (including it's path) */
      item.setImage('../images/icons/user.gifx'); 
      /* Specify whether or not to bold the text style of the item in the left pane. */
      item.setTextBold(true); 
      /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
      item.setIsDraggable(true); 
    }

    GlideTimelineItem – setParent(String sysId)

    Define o primário do GlideTimelineItematual.

    Tabela 27. Parâmetros
    Nome Tipo Descrição
    sysId Cadeia de caracteres O sysID do GlideTimelineItem que deve se tornar o primário do GlideTimelineItem atual.
    Tabela 28. Retornos
    Tipo Descrição
    vazio

    GlideTimelineItem – setTextBold(Booliano b)

    Especifica se o estilo de texto do item no painel esquerdo deve ser colocado em negrito ou não.

    Tabela 29. Parâmetros
    Nome Tipo Descrição
    b Booliano Sinalizador que indica se o texto no painel esquerdo deve estar em negrito.
    Valores válidos:
    • verdadeiro: o texto deve estar em negrito.
    • falso: o texto não deve estar em negrito.
    Tabela 30. Retornos
    Tipo Descrição
    vazio

    O exemplo a seguir mostra como definir o texto no painel esquerdo como negrito.

    var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
    var grUser = new GlideRecord('user_resource');
    grUser.addQuery('planned_task', project_id);
    grUser.setQueryReferences(true);
    grUser.orderBy('user.name', 'DESC');
    grUser.query();
    while (grUser.next()) {
      var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
      /* Specify the text to display in the left pane for this item. */
      item.setLeftLabelText(grUser.user.name); 
      /* Set the name of the image file (including it's path) */
      item.setImage('../images/icons/user.gifx'); 
      /* Specify whether or not to bold the text style of the item in the left pane. */
      item.setTextBold(true); 
      /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
      item.setIsDraggable(true); 
    }