【问题标题】:Ways to integrate the Jira issue collector with an Angular app?将 Jira 问题收集器与 Angular 应用程序集成的方法?
【发布时间】:2019-11-16 00:38:27
【问题描述】:

我希望创建一个 Angular 7 应用程序,该应用程序利用 Jira 问题收集器将问题直接提交到各自的项目。

当我按照现在的方式构建应用程序时,什么也没有发生。当我将代码从方法“submitIssue”直接移动到“ngOnInIt”下时,问题收集器对话框出现了。代码sn-p应该加在哪里?

任何帮助将不胜感激。谢谢!

Jira 代码片段示例

// Requires jQuery!
jQuery.ajax({
    url: "https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com",
    type: "get",
    cache: true,
    dataType: "script"
});

 window.ATL_JQ_PAGE_PROPS =  {
    "triggerFunction": function(showCollectorDialog) {
        //Requires that jQuery is available! 
        jQuery("#myCustomTrigger").click(function(e) {
            e.preventDefault();
            showCollectorDialog();
        });
    }};

这是我的数组,用我的问题收集器组件上的不同项目和按钮填充卡片。

db-data.ts

export const PROJECTS: any = [

    {
        id: 1,
        title: 'Project Title',
        /** The url is taken directly from the issue collector section within the Jira project. Link below is modified
         * for security purposes. */
        url: 'https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com'
    },
    {
        id: 2,
        title: 'Project Title',
        /** The url is taken directly from the issue collector section within the Jira project. Link below is modified
         * for security purposes. */
        url: 'https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com'
    },

];


export function findCourseById(projectId:number) {
    return PROJECTS.find(project => project.id === projectId);


}

jira-card.component.ts

import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { Project } from 'src/app/model/project';
import { PROJECTS } from 'src/db-data';
import { projection } from '@angular/core/src/render3';
import * as $ from 'jquery';

declare global {
  interface Window { ATL_JQ_PAGE_PROPS: any; }
}

window.ATL_JQ_PAGE_PROPS = window.ATL_JQ_PAGE_PROPS || {};

@Component({
  selector: 'app-jira-card',
  templateUrl: './jira-card.component.html',
  styleUrls: ['./jira-card.component.scss']
})

export class JiraCardComponent implements OnInit {

  @Input()
  project: Project;

  constructor() { }

   ngOnInit() {}

   submitIssue() {

            // Requires jQuery!
            jQuery.ajax({
              url: this.project.url,
              type: 'get',
              cache: true,
              dataType: 'script'
            });
    
        window.ATL_JQ_PAGE_PROPS =  {
        "triggerFunction": function(showCollectorDialog) {
          jQuery("#submit").on('click', function(e) {
            e.preventDefault();
            showCollectorDialog();
          });
        }};
       }
   }


jira-card.component.html

<div class="main-div">
  <mat-card class="jira-card">
      <mat-card-header>
        <mat-card-title>{{ project.title }}</mat-card-title>
        <mat-card-subtitle></mat-card-subtitle>
      </mat-card-header>
      <mat-card-actions>
        <button mat-raised-button id (click)="submitIssue()" id="#submit">Submit Issue</button>
      </mat-card-actions>
    </mat-card>
</div>    

【问题讨论】:

    标签: jquery typescript angular6 jira angular7


    【解决方案1】:

    index.html 中将showCollectorDialog 函数设为全局

    <script type="text/javascript" src="<jira-issue-collector-URL>"></script>
    <script>
      window.ATL_JQ_PAGE_PROPS = {
        triggerFunction: function(showCollectorDialog) {
          window.showCollectorDialog = showCollectorDialog
        }
      };
    </script>
    

    然后在some.component.ts中调用它:

    submitIssue() {
      (window as any).showCollectorDialog()
    }
    

    【讨论】:

      猜你喜欢
      • 2022-07-28
      • 2014-08-06
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 2012-09-06
      • 2022-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多