Skip to content

Commit d6995b3

Browse files
committed
Error badge
1 parent 33dacc8 commit d6995b3

File tree

4 files changed

+82
-60
lines changed

4 files changed

+82
-60
lines changed

web/app/components/details-count.gts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import NumberBadge from 'repository/components/number-badge';
2+
13
import type { TOC } from '@ember/component/template-only';
24
import type { components } from 'schema/openapi';
35

@@ -9,13 +11,7 @@ interface Signature {
911
};
1012
}
1113

12-
export default <template>
13-
{{#let (detailsCount @results) as |count|}}
14-
{{#if count}}
15-
<span class="badge bg-secondary">{{count}}</span>
16-
{{/if}}
17-
{{/let}}
18-
</template> satisfies TOC<Signature>;
14+
export default <template><NumberBadge @number={{detailsCount @results}} /></template> satisfies TOC<Signature>;
1915

2016
function detailsCount(results: Results) {
2117
return results.reduce((acc, { details }) => acc + details.length, 0);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { TOC } from '@ember/component/template-only';
2+
3+
interface Signature {
4+
Args: {
5+
number: number;
6+
};
7+
}
8+
9+
export default <template>
10+
{{#if @number}}
11+
<span class="badge bg-secondary">{{@number}}</span>
12+
{{/if}}
13+
</template> satisfies TOC<Signature>;

web/app/templates/accession-renewal.gts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { fn } from '@ember/helper';
55
import { on } from '@ember/modifier';
66
import { service } from '@ember/service';
77

8+
import NumberBadge from 'repository/components/number-badge';
89
import ProgressLabel from 'repository/components/progress-label';
910
import ValidityBadge from 'repository/components/validity-badge';
1011

@@ -80,10 +81,24 @@ export default class extends Component<Signature> {
8081

8182
<div>
8283
<dt>Validity</dt>
83-
<dd><ValidityBadge @validity={{@model.renewal.validity}} /></dd>
84+
85+
<dd>
86+
<ValidityBadge @validity={{@model.renewal.validity}} />
87+
<NumberBadge @number={{@model.renewal.validation_details.length}} />
88+
</dd>
8489
</div>
8590
</dl>
8691

92+
{{#if @model.renewal.file}}
93+
<h3>File</h3>
94+
95+
<button
96+
type="button"
97+
class="btn btn-link p-0 mb-3"
98+
{{on "click" (fn this.downloadFile @model.renewal.file.url)}}
99+
>{{@model.renewal.file.filename}}</button>
100+
{{/if}}
101+
87102
{{#if @model.renewal.validation_details.length}}
88103
<h3>Validation Results</h3>
89104

@@ -105,14 +120,5 @@ export default class extends Component<Signature> {
105120
</tbody>
106121
</table>
107122
{{/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}}
117123
</template>
118124
}

web/app/templates/accession/index.gts

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
22
import { LinkTo } from '@ember/routing';
33

44
import AccessionSummary from 'repository/components/accession-summary';
5+
import NumberBadge from 'repository/components/number-badge';
56
import ProgressLabel from 'repository/components/progress-label';
67
import ValidityBadge from 'repository/components/validity-badge';
78
import formatDate from 'repository/helpers/format-datetime';
@@ -40,50 +41,56 @@ export default class extends Component<Signature> {
4041
Renew Accession
4142
</LinkTo>
4243

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

0 commit comments

Comments
 (0)