GlideTimelineItem - グローバル

  • リリースバージョン: Xanadu
  • 更新日 2024年08月01日
  • 所要時間:18分
  • GlideTimelineItem API は、抽象 ScheduleItem クラスを拡張して、タイムラインに固有の追加のプロパティを定義します。

    タイムラインアイテムは、基本的にタイムライン全体で単一の行に表示されるアイテムです。GlideTimelineItem には、0 個以上のスパン (TimelineSpan オブジェクト) が関連付けられています。

    GlideTimelineItem - GlideTimelineItem(文字列 tableName)

    「ダミー」の GlideTimelineItem オブジェクトを作成します。

    これは、YMoving を許可しない行を作成する場合に便利ですが、ネストされた子が含まれます (グループリソースタイムラインの最上位の「ユーザー」行など)。sys_id は、DOM レベル関数を正しく解析するために一意である必要があります。デフォルトでは、テーブル名が指定されていないためこのオブジェクトは「ドロップ可能」ではありません。

    表 : 1. パラメーター
    名前 タイプ 説明
    tableName 文字列 現在のオブジェクトに関連付けられているテーブルの名前。
    表 : 2. 返される内容
    タイプ 説明
    なし

    GlideTimelineItem - GlideTimelineItem(文字列 tableName, 文字列 sys_id)

    必要なテーブルと sys_id プロパティを設定するコンストラクター。

    このオブジェクトの残りのプロパティは、問い合わせユーザーが設定する必要があります。デフォルトでは、テーブル名が指定されているためこのオブジェクトインスタンスは「ドロップ可能」です。

    表 : 3. パラメーター
    名前 タイプ 説明
    tableName 文字列 現在のオブジェクトに関連付けられているテーブルの名前。
    sys_id 文字列 オブジェクトの sys ID。
    表 : 4. 返される内容
    タイプ 説明
    なし

    GlideTimelineItem - createTimelineSpan(文字列 tableName)

    現在のインスタンスオブジェクトに関連付けられた新しい TimelineSpan オブジェクトを作成します。

    他の TimelineSpan オブジェクトが存在しない場合、新しく作成されたオブジェクトは現在のインスタンスオブジェクトと同じ sys_id を共有します。それ以外の場合は、ランダムに生成された GUID が使用されます。

    表 : 5. パラメーター
    名前 タイプ 説明
    tableName 文字列 現在のオブジェクトに関連付けられているテーブルの名前。
    表 : 6. 返される内容
    タイプ 説明
    オブジェクト 新しく作成されたスパンオブジェクトインスタンス。

    GlideTimelineItem - createTimelineSpan(文字列 tableName, 文字列 sys_id)

    指定されたテーブルと sys_id を使用して現在のインスタンスオブジェクトに関連付けられた新しい TimelineSpan オブジェクトを作成します。

    表 : 7. パラメーター
    名前 タイプ 説明
    tableName 文字列 現在のオブジェクトに関連付けられているテーブルの名前。
    sys_id 文字列 オブジェクトの sys_id。
    表 : 8. 返される内容
    タイプ 説明
    オブジェクト 新しく作成されたスパンオブジェクトインスタンス。

    次の例は、createTimelineSpan() を使用して新しい 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( )

    現在の GlideTimelineItem に関連付けられている画像ファイルの名前を指定する文字列を返します。

    表 : 9. パラメーター
    名前 タイプ 説明
    none
    表 : 10. 返される内容
    タイプ 説明
    文字列 現在の GlideTimelineItem に関連付けられている画像ファイルの名前。現在のアイテムに画像が関連付けられていない場合は、空の文字列 ("") が返されます。

    GlideTimelineItem - getIsDroppable( )

    タイムライン要素を垂直に移動するときに、現在のインスタンスオブジェクトを「ドロップゾーン」として許可するかどうかを示します。

    表 : 11. パラメーター
    名前 タイプ 説明
    none
    表 : 12. 返される内容
    タイプ 説明
    ブーリアン ドロップ可能な場合は true。可能でない場合は false。

    GlideTimelineItem - getLeftLabelText( )

    左ペインに表示されるテキストを返します (有効な場合)。

    表 : 13. パラメーター
    名前 タイプ 説明
    none
    表 : 14. 返される内容
    タイプ 説明
    文字列 左ペインに表示されるテキストの値。

    GlideTimelineItem - getParent( )

    現在の GlideTimelineItem の親オブジェクトの一意の sysId を返します。

    表 : 15. パラメーター
    名前 タイプ 説明
    none
    表 : 16. 返される内容
    タイプ 説明
    文字列 現在の GlideTimelineItem の親オブジェクトの一意の sysId。親が存在しない場合は、空の文字列 ("") が返されます。

    GlideTimelineItem - getTimelineSpans( )

    ArrayList の現在のインスタンスに関連付けられているすべての TimelineSpan オブジェクトを返します。

    表 : 17. パラメーター
    名前 タイプ 説明
    none
    表 : 18. 返される内容
    タイプ 説明
    オブジェクトアレイ 現在のインスタンスに関連付けられている TimelineSpan オブジェクトのリスト。

    GlideTimelineItem - isTextBold( )

    左ペインのテキストが太字で表示されるように設定されているかどうかを示します。

    表 : 19. パラメーター
    名前 タイプ 説明
    なし
    表 : 20. 返される内容
    タイプ 説明
    ブーリアン テキストを太字にするかどうかを示すフラグ。
    可能な値:
    • true:テキストを太字にする必要があります。
    • false:テキストを太字以外にする必要があります。

    次の例では、インシデントのステータスが「新規」かどうかを確認し、アイテムのテキストを太字に設定します。

    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(文字列 strImageName)

    左ペインのアイテムのアイコンとして使用する画像ファイルの名前 (パスを含む) を設定します。

    表 : 21. パラメーター
    名前 タイプ 説明
    strImageName 文字列 パスを含む画像の名前。
    表 : 22. 返される内容
    タイプ 説明
    なし

    次の例は、setImage() を使用して左ペインのアイコンに表示される画像を定義する方法を示しています。

    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(ブーリアン b)

    現在のインスタンスオブジェクトをクリックして別の GlideTimelineItem にドラッグできるかどうかを設定します。

    表 : 23. パラメーター
    名前 タイプ 説明
    b ブーリアン クリックアンドドラッグでアイテムを移動できるかどうかを示すフラグ。
    有効な値:
    • true:アイテムはクリックアンドドラッグで移動できます。
    • false:アイテムはクリックアンドドラッグで移動できません。
    表 : 24. 返される内容
    タイプ 説明
    なし

    次の例は、setIsDraggable() を使用して、現在のオブジェクトを別の 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(文字列 strText)

    このアイテムの左ペインに表示するテキストを指定します。

    表 : 25. パラメーター
    名前 タイプ 説明
    strText 文字列 このアイテムの左ペインに表示するテキスト。
    表 : 26. 返される内容
    タイプ 説明
    なし

    次の例は、setLeftLabelText() を使用して左ペインのテキストを設定する方法を示しています。

    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(文字列 sysId)

    現在の GlideTimelineItem の親を設定します。

    表 : 27. パラメーター
    名前 タイプ 説明
    sysId 文字列 現在の GlideTimelineItem の親になる必要がある GlideTimelineItem の sysID。
    表 : 28. 返される内容
    タイプ 説明
    なし

    GlideTimelineItem - setTextBold(ブーリアン b)

    左ペインのアイテムのテキストスタイルを太字にするかどうかを指定します。

    表 : 29. パラメーター
    名前 タイプ 説明
    b ブーリアン 左ペインのテキストを太字にするかどうかを示すフラグ。
    有効な値:
    • true:テキストを太字にする必要があります。
    • false:テキストを太字以外にする必要があります。
    表 : 30. 返される内容
    タイプ 説明
    なし

    次の例は、左ペインのテキストを太字に設定する方法を示しています。

    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); 
    }