Skip to content

Commit b9f8512

Browse files
authored
Merge pull request #1428 from ddbj/fix
Fix Bugs
2 parents 14ea22c + 9406b63 commit b9f8512

File tree

7 files changed

+107
-82
lines changed

7 files changed

+107
-82
lines changed

web/app/components/details-count.gts

Lines changed: 0 additions & 22 deletions
This file was deleted.

web/app/components/validation-detail.gts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { LinkTo } from '@ember/routing';
22

3-
import DetailsCount from 'repository/components/details-count';
43
import ProgressLabel from 'repository/components/progress-label';
54
import Results from 'repository/components/validation-detail/results';
65
import SubmitForm from 'repository/components/validation-detail/submit-form';
76
import ValidityBadge from 'repository/components/validity-badge';
87
import formatDatetime from 'repository/helpers/format-datetime';
8+
import detailsCount from 'repository/helpers/details-count';
99

1010
import type { TOC } from '@ember/component/template-only';
1111
import type { components } from 'schema/openapi';
@@ -79,7 +79,12 @@ export default <template>
7979

8080
<dd>
8181
<ValidityBadge @validity={{@validation.validity}} />
82-
<DetailsCount @results={{@validation.results}} />
82+
83+
{{#let (detailsCount @validation.results) as |count|}}
84+
{{#if count}}
85+
<span class="badge bg-secondary">{{count}}</span>
86+
{{/if}}
87+
{{/let}}
8388
</dd>
8489
</div>
8590

web/app/components/validations-table.gts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { LinkTo } from '@ember/routing';
22

33
import { notEq } from 'ember-truth-helpers';
4-
5-
import DetailsCount from 'repository/components/details-count';
64
import Pagination from 'repository/components/pagination';
75
import ProgressLabel from 'repository/components/progress-label';
86
import Table from 'repository/components/table';
97
import ValidityBadge from 'repository/components/validity-badge';
108
import formatDatetime from 'repository/helpers/format-datetime';
9+
import detailsCount from 'repository/helpers/details-count';
1110

1211
import type { TOC } from '@ember/component/template-only';
1312
import type { components } from 'schema/openapi';
@@ -81,7 +80,12 @@ export default <template>
8180

8281
<td>
8382
<ValidityBadge @validity={{validation.validity}} />
84-
<DetailsCount @results={{validation.results}} />
83+
84+
{{#let (detailsCount validation.results) as |count|}}
85+
{{#if count}}
86+
<span class="badge bg-secondary">{{count}}</span>
87+
{{/if}}
88+
{{/let}}
8589
</td>
8690

8791
<td class="position-relative">

web/app/helpers/details-count.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { components } from 'schema/openapi';
2+
3+
type Results = components['schemas']['Validation']['results'];
4+
5+
export default function detailsCount(results: Results) {
6+
return results.reduce((acc: number, { details }) => acc + details.length, 0);
7+
}

web/app/routes/submission/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import Route from '@ember/routing/route';
2+
import { service } from '@ember/service';
23

4+
import type RouterService from '@ember/routing/router-service';
35
import type { components } from 'schema/openapi';
46

57
type Submission = components['schemas']['Submission'];
68

79
export default class SubmissionIndexRoute extends Route {
10+
@service declare router: RouterService;
11+
812
timer?: number;
913

1014
afterModel({ progress }: Submission) {
1115
if (progress === 'waiting' || progress === 'running') {
1216
this.timer = setTimeout(() => {
13-
this.refresh();
17+
this.router.refresh();
1418
}, 2000);
1519
}
1620
}

web/app/templates/accession-renewal.gts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import AccessionSummary from 'repository/components/accession-summary';
1212
import formatDatetime from 'repository/helpers/format-datetime';
1313

1414
import type RequestService from 'repository/services/request';
15+
import type RouterService from '@ember/routing/router-service';
1516
import type { components } from 'schema/openapi';
1617

1718
type Accession = components['schemas']['Accession'];
@@ -28,15 +29,24 @@ interface Signature {
2829

2930
export default class extends Component<Signature> {
3031
@service declare request: RequestService;
32+
@service declare router: RouterService;
3133

3234
@action
3335
async downloadFile(url: string) {
3436
await this.request.downloadFile(url);
3537
}
3638

39+
@action
40+
backToAccession() {
41+
this.router.refresh();
42+
this.router.transitionTo('accession', this.args.model.accession.number);
43+
}
44+
3745
<template>
3846
<div class="mb-3">
39-
<LinkTo @route="accession" @model={{@model.accession.number}}>&laquo; Back to accession</LinkTo>
47+
<LinkTo @route="accession" @model={{@model.accession.number}} {{on "click" this.backToAccession}}>
48+
&laquo; Back to accession
49+
</LinkTo>
4050
</div>
4151

4252
<AccessionSummary @accession={{@model.accession}} />
@@ -80,10 +90,27 @@ export default class extends Component<Signature> {
8090

8191
<div>
8292
<dt>Validity</dt>
83-
<dd><ValidityBadge @validity={{@model.renewal.validity}} /></dd>
93+
94+
<dd>
95+
<ValidityBadge @validity={{@model.renewal.validity}} />
96+
97+
{{#if @model.renewal.validation_details.length}}
98+
<span class="badge bg-secondary">{{@model.renewal.validation_details.length}}</span>
99+
{{/if}}
100+
</dd>
84101
</div>
85102
</dl>
86103

104+
{{#if @model.renewal.file}}
105+
<h3>File</h3>
106+
107+
<button
108+
type="button"
109+
class="btn btn-link p-0 mb-3"
110+
{{on "click" (fn this.downloadFile @model.renewal.file.url)}}
111+
>{{@model.renewal.file.filename}}</button>
112+
{{/if}}
113+
87114
{{#if @model.renewal.validation_details.length}}
88115
<h3>Validation Results</h3>
89116

@@ -105,14 +132,5 @@ export default class extends Component<Signature> {
105132
</tbody>
106133
</table>
107134
{{/if}}
108-
109-
{{#if @model.renewal.file}}
110-
<h3>File</h3>
111-
<button
112-
type="button"
113-
class="btn btn-link p-0"
114-
{{on "click" (fn this.downloadFile @model.renewal.file.url)}}
115-
>{{@model.renewal.file.filename}}</button>
116-
{{/if}}
117135
</template>
118136
}

web/app/templates/accession/index.gts

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,50 +40,59 @@ export default class extends Component<Signature> {
4040
Renew Accession
4141
</LinkTo>
4242

43-
<table class="table">
44-
<thead>
45-
<tr>
46-
<th>ID</th>
47-
<th>Created</th>
48-
<th>Started</th>
49-
<th>Finished</th>
50-
<th>Progress</th>
51-
<th>Validity</th>
52-
</tr>
53-
</thead>
54-
55-
<tbody>
56-
{{#each this.renewals as |renewal|}}
43+
{{#if this.renewals}}
44+
<table class="table">
45+
<thead>
5746
<tr>
58-
<td>
59-
<LinkTo @route="accession_renewal" @model={{renewal.id}}>
60-
#{{renewal.id}}
61-
</LinkTo>
62-
</td>
63-
64-
<td>{{formatDate renewal.created_at}}</td>
65-
66-
<td>
67-
{{#if renewal.started_at}}
68-
{{formatDate renewal.started_at}}
69-
{{else}}
70-
-
71-
{{/if}}
72-
</td>
73-
74-
<td>
75-
{{#if renewal.finished_at}}
76-
{{formatDate renewal.finished_at}}
77-
{{else}}
78-
-
79-
{{/if}}
80-
</td>
81-
82-
<td><ProgressLabel @progress={{renewal.progress}} /></td>
83-
<td><ValidityBadge @validity={{renewal.validity}} /></td>
47+
<th>ID</th>
48+
<th>Created</th>
49+
<th>Started</th>
50+
<th>Finished</th>
51+
<th>Progress</th>
52+
<th>Validity</th>
8453
</tr>
85-
{{/each}}
86-
</tbody>
87-
</table>
54+
</thead>
55+
56+
<tbody>
57+
{{#each this.renewals as |renewal|}}
58+
<tr>
59+
<td>
60+
<LinkTo @route="accession_renewal" @model={{renewal.id}}>
61+
#{{renewal.id}}
62+
</LinkTo>
63+
</td>
64+
65+
<td>{{formatDate renewal.created_at}}</td>
66+
67+
<td>
68+
{{#if renewal.started_at}}
69+
{{formatDate renewal.started_at}}
70+
{{else}}
71+
-
72+
{{/if}}
73+
</td>
74+
75+
<td>
76+
{{#if renewal.finished_at}}
77+
{{formatDate renewal.finished_at}}
78+
{{else}}
79+
-
80+
{{/if}}
81+
</td>
82+
83+
<td><ProgressLabel @progress={{renewal.progress}} /></td>
84+
85+
<td>
86+
<ValidityBadge @validity={{renewal.validity}} />
87+
88+
{{#if renewal.validation_details.length}}
89+
<span class="badge bg-secondary">{{renewal.validation_details.length}}</span>
90+
{{/if}}
91+
</td>
92+
</tr>
93+
{{/each}}
94+
</tbody>
95+
</table>
96+
{{/if}}
8897
</template>
8998
}

0 commit comments

Comments
 (0)