diff --git a/src/app/presentation/design/path/path.component.ts b/src/app/presentation/design/path/path.component.ts index 907aad5d..ed801205 100644 --- a/src/app/presentation/design/path/path.component.ts +++ b/src/app/presentation/design/path/path.component.ts @@ -122,24 +122,20 @@ export class PathComponent implements OnInit { if (this.pipeData.length <= 0) { return; } + this.maxLength--; + this.pipeData = this.removeLastItem(this.pipeData); + } - const that = this; - - function removeLastItem(items) { - // tslint:disable-next-line:prefer-for-of - for (let i = 0; i < items.length; i++) { - for (let j = 0; j <= that.maxLength; j++) { - if (j > that.maxLength - 1) { - items[i].items.splice(-1, 1); - } + removeLastItem(items) { + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < items.length; i++) { + for (let j = 0; j <= this.maxLength; j++) { + if (j > this.maxLength - 1) { + items[i].items.splice(-1, 1); } } - - return items; } - - this.maxLength--; - this.pipeData = removeLastItem(this.pipeData); + return items; } getContainerStyle(pipe: Item) { diff --git a/src/app/presentation/job/job.component.ts b/src/app/presentation/job/job.component.ts index dfedb14e..1f2d9532 100644 --- a/src/app/presentation/job/job.component.ts +++ b/src/app/presentation/job/job.component.ts @@ -47,20 +47,7 @@ export class JobComponent implements OnInit { .subscribe( (res: any[]) => { const result: any[] = res || []; - const jobList = []; - for (const job of result.reverse()) { - const arr = job.body.replace(/:/g, ':').split('\r\n'); - const info = {}; - for (const str of arr) { - const [key, value] = this.splitOnFirstColon(str); - info[key] = value; - } - const jobInfo = issueToForm(info); - jobInfo.htmlUrl = job.html_url; - jobInfo.date = format(new Date(job.updated_at), 'yyyy/MM/dd'); - jobList.push(jobInfo); - } - this.jobList = jobList; + this.buildJobList(result); }, () => {}, () => { @@ -69,6 +56,23 @@ export class JobComponent implements OnInit { ); } + private buildJobList(result: any[]) { + const jobList = []; + for (const job of result.reverse()) { + const arr = job.body.replace(/:/g, ':').split('\r\n'); + const info = {}; + for (const str of arr) { + const [key, value] = this.splitOnFirstColon(str); + info[key] = value; + } + const jobInfo = issueToForm(info); + jobInfo.htmlUrl = job.html_url; + jobInfo.date = format(new Date(job.updated_at), 'yyyy/MM/dd'); + jobList.push(jobInfo); + } + this.jobList = jobList; + } + splitOnFirstColon(str) { const idx = str.indexOf(':'); return [str.substr(0, idx), str.substr(idx + 1)];