Skip to content

Commit 8d732c0

Browse files
authored
Merge pull request #1052 from dddjava/codex/package-glossary-link
パッケージ概要から用語集にリンクで飛べるようにする
2 parents 3292308 + b6bcc20 commit 8d732c0

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

jig-core/src/main/resources/templates/assets/package.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,19 @@ function buildPackageTableRowElement(spec, applyFilter, applyRelatedFilterForRow
450450
nameTd.textContent = spec.name;
451451
tr.appendChild(nameTd);
452452

453+
const glossaryTd = document.createElement('td');
454+
glossaryTd.className = 'glossary-cell';
455+
const glossaryLink = document.createElement('a');
456+
glossaryLink.className = 'glossary-link-icon';
457+
glossaryLink.href = `glossary.html#${encodeURIComponent(spec.fqn)}`;
458+
glossaryLink.setAttribute('aria-label', '用語集');
459+
const glossaryText = document.createElement('span');
460+
glossaryText.className = 'screen-reader-only';
461+
glossaryText.textContent = '用語集';
462+
glossaryLink.appendChild(glossaryText);
463+
glossaryTd.appendChild(glossaryLink);
464+
tr.appendChild(glossaryTd);
465+
453466
const classCountTd = document.createElement('td');
454467
classCountTd.textContent = String(spec.classCount);
455468
classCountTd.className = 'number';

jig-core/src/main/resources/templates/assets/style.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,21 @@ label {
351351
.package-list button.related-icon:hover {
352352
background-color: #f5f5f5;
353353
}
354+
.package-list a.glossary-link-icon {
355+
display: inline-block;
356+
width: 1.8em;
357+
height: 1.8em;
358+
box-sizing: border-box;
359+
border-radius: 999px;
360+
border: 1px solid #999;
361+
background: #fff no-repeat center;
362+
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/><path d='M4 4v15.5A2.5 2.5 0 0 0 6.5 22H20'/><path d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5V4A2.5 2.5 0 0 1 6.5 2z'/></svg>");
363+
text-decoration: none;
364+
vertical-align: middle;
365+
}
366+
.package-list a.glossary-link-icon:hover {
367+
background-color: #f5f5f5;
368+
}
354369
.package-list .mutual-dependencies {
355370
margin: 12px 0 16px 0;
356371
padding: 8px 12px;
@@ -378,6 +393,12 @@ label {
378393
.package-list table .col-action {
379394
width: 2.5em;
380395
}
396+
.package-list table .col-glossary {
397+
width: 2.5em;
398+
}
399+
.package-list td.glossary-cell {
400+
text-align: center;
401+
}
381402
.package-list table th.no-sort {
382403
cursor: default;
383404
}

jig-core/src/main/resources/templates/package.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ <h1>パッケージ概要</h1>
8282
<col class="col-action">
8383
<col class="col-fqn">
8484
<col class="col-name">
85+
<col class="col-glossary">
8586
<col class="col-number">
8687
<col class="col-number">
8788
<col class="col-number">
@@ -92,6 +93,7 @@ <h1>パッケージ概要</h1>
9293
<th class="no-sort"><span class="screen-reader-only">関連のみ表示</span></th>
9394
<th>完全修飾名</th>
9495
<th>名称</th>
96+
<th class="no-sort"><span class="screen-reader-only">用語集</span></th>
9597
<th>クラス数</th>
9698
<th>関連数(依存元)</th>
9799
<th>関連数(依存先)</th>

jig-core/src/test/js/package.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ function setupDiagramEnvironment(doc, context) {
234234
const mutual = doc.createElement('div');
235235
mutual.id = 'mutual-dependency-list';
236236
doc.elementsById.set('mutual-dependency-list', mutual);
237+
const transitiveReductionToggle = doc.createElement('input');
238+
transitiveReductionToggle.id = 'transitive-reduction-toggle';
239+
transitiveReductionToggle.type = 'checkbox';
240+
doc.elementsById.set('transitive-reduction-toggle', transitiveReductionToggle);
237241
global.window = {
238242
mermaid: {
239243
initialize() {
@@ -652,9 +656,9 @@ test.describe('package.js', () => {
652656

653657
assert.equal(tbody.children.length, 2);
654658
assert.equal(tbody.children[0].children[3].textContent, 'A');
655-
assert.equal(tbody.children[0].children[4].textContent, '2');
656-
assert.equal(tbody.children[0].children[5].textContent, '0');
657-
assert.equal(tbody.children[0].children[6].textContent, '2');
659+
assert.equal(tbody.children[0].children[5].textContent, '2');
660+
assert.equal(tbody.children[0].children[6].textContent, '0');
661+
assert.equal(tbody.children[0].children[7].textContent, '2');
658662
});
659663
});
660664
});

0 commit comments

Comments
 (0)