Skip to content

Commit 28f57a8

Browse files
Ap 587 update dependencies (#25)
* Updated CHANGES.md * fixes issue with vue rendering icons in production environment
1 parent 5509f25 commit 28f57a8

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

app/javascript/items/components/ItemRow.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<tr class="item">
33
<td class="control">
4-
<a :href="item.edit_url" class="icon-link" target="_blank" :title="`Edit “${item.title}”`"><img src="/assets/icons/edit.svg" :alt="`Edit “${item.title}”`" class="action"></a>
4+
<a :href="item.edit_url" class="icon-link" target="_blank" :title="`Edit “${item.title}”`"><img :src="icons.edit" :alt="`Edit “${item.title}”`" class="action"></a>
55
</td>
66
<td>
77
<p class="title">
@@ -16,10 +16,10 @@
1616
</p>
1717
</td>
1818
<td class="control">
19-
<a :href="item.show_url" class="icon-link" target="_blank" :title="`Admin view of “${item.title}”`"><img src="/assets/icons/eye.svg" :alt="`Admin view of “${item.title}”`" class="action"></a>
19+
<a :href="item.show_url" class="icon-link" target="_blank" :title="`Admin view of “${item.title}”`"><img :src="icons.eye" :alt="`Admin view of “${item.title}”`" class="action"></a>
2020
</td>
2121
<td class="control">
22-
<a :href="item.view_url" class="icon-link" target="_blank" :title="`Permalink to “${item.title}” patron view`"><img src="/assets/icons/link.svg" :alt="`Permalink to “${item.title}” patron view`" class="action"></a>
22+
<a :href="item.view_url" class="icon-link" target="_blank" :title="`Permalink to “${item.title}” patron view`"><img :src="icons.link" :alt="`Permalink to “${item.title}” patron view`" class="action"></a>
2323
</td>
2424
<td class="date">{{ formatDateTime(item.updated_at) }}</td>
2525
<td v-if="item.complete" class="control">Yes</td>
@@ -56,7 +56,7 @@
5656
</td>
5757
<td class="control">
5858
<button class="delete" :disabled="item.complete" :title="item.complete ? 'Only incomplete items can be deleted.' : `Delete “${item.title}”`" @click="deleteItem">
59-
<img class="action" :alt="`Delete “${item.title}”`" src="/assets/icons/trash-alt.svg">
59+
<img class="action" :alt="`Delete “${item.title}”`" :src="icons.trash_alt">
6060
</button>
6161
</td>
6262
</tr>
@@ -65,8 +65,23 @@
6565
<script>
6666
import i18n from '../../shared/mixins/i18n.js'
6767
68+
const iconPath = function (name) {
69+
const icons = window.UCBEARS_ASSETS?.icons
70+
return icons?.[name] || `/assets/icons/${name}.svg`
71+
}
72+
6873
export default {
6974
mixins: [i18n],
75+
data: function () {
76+
return {
77+
icons: {
78+
edit: iconPath('edit'),
79+
eye: iconPath('eye'),
80+
link: iconPath('link'),
81+
trash_alt: iconPath('trash_alt')
82+
}
83+
}
84+
},
7085
props: {
7186
item: { type: Object, default: () => {} },
7287
allTerms: { type: Array, default: () => [] }

app/javascript/shared/components/FlashAlerts.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
>
1212
<div :class="`flash ${message.level}`">
1313
<label :for="`flash-dismiss-${index}`" class="flash-dismiss-label">
14-
<img src="/assets/icons/times-circle.svg" class="flash-dismiss-icon" alt="Hide alert">
14+
<img :src="timesCircleIcon" class="flash-dismiss-icon" alt="Hide alert">
1515
</label>
1616
<p class="flash" role="alert">{{ message.text }}</p>
1717
</div>
@@ -21,7 +21,17 @@
2121

2222
<script>
2323
24+
const iconPath = function (name) {
25+
const icons = window.UCBEARS_ASSETS?.icons
26+
return icons?.[name] || `/assets/icons/${name}.svg`
27+
}
28+
2429
export default {
30+
data: function () {
31+
return {
32+
timesCircleIcon: iconPath('times_circle')
33+
}
34+
},
2535
props: {
2636
messages: { type: Array, default: () => [] }
2737
},

app/javascript/terms/components/TermRow.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<td class="control">{{ term.item_count }}</td>
5858
<td class="control">
5959
<button :id="`term-${term.id}-delete`" :disabled="term.default_term" class="delete" :title="term.default_term ? 'The current default term cannot be deleted.' : `Delete term “${term.name}”`" @click="deleteTerm">
60-
<img class="action" :alt="`Delete “${term.name}”`" src="/assets/icons/trash-alt.svg">
60+
<img class="action" :alt="`Delete “${term.name}”`" :src="trashIcon">
6161
</button>
6262
</td>
6363
</tr>
@@ -66,13 +66,19 @@
6666
<script>
6767
import i18n from '../../shared/mixins/i18n.js'
6868
69+
const iconPath = function (name) {
70+
const icons = window.UCBEARS_ASSETS?.icons
71+
return icons?.[name] || `/assets/icons/${name}.svg`
72+
}
73+
6974
export default {
7075
mixins: [i18n],
7176
props: {
7277
term: { type: Object, default: () => ({}) }
7378
},
7479
data: function () {
7580
return ({
81+
trashIcon: iconPath('trash_alt'),
7682
shadowStartDate: this.term.start_date,
7783
shadowEndDate: this.term.end_date
7884
})

app/views/layouts/application.html.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
<%= csp_meta_tag %>
1010

1111
<link rel="stylesheet" href="https://use.typekit.net/rxa5jay.css">
12+
<% icon_assets = {
13+
edit: asset_path('icons/edit.svg'),
14+
eye: asset_path('icons/eye.svg'),
15+
link: asset_path('icons/link.svg'),
16+
times_circle: asset_path('icons/times-circle.svg'),
17+
trash_alt: asset_path('icons/trash-alt.svg')
18+
} %>
19+
<%= javascript_tag nonce: true do %>
20+
window.UCBEARS_ASSETS = <%= raw json_escape({ icons: icon_assets }.to_json) %>;
21+
<% end %>
1222
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true, type: "module" %>
1323
<%= javascript_include_tag "items", "data-turbo-track": "reload", defer: true %>
1424
<%= javascript_include_tag "terms", "data-turbo-track": "reload", defer: true %>

0 commit comments

Comments
 (0)