|
| 1 | +<script> |
| 2 | + import { useProfileStore } from '@/stores/profile' |
| 3 | + import { usePreferenceStore } from '@/stores/preference' |
| 4 | +
|
| 5 | + import { mapStores, mapState, mapWritableState } from 'pinia' |
| 6 | +
|
| 7 | + export default { |
| 8 | + components: { |
| 9 | +
|
| 10 | + }, |
| 11 | +
|
| 12 | + data() { |
| 13 | + return { |
| 14 | + previewData : {default:null,versions:[]}, |
| 15 | + timeout: null, |
| 16 | + firstLoad: true, |
| 17 | + selected: null |
| 18 | + } |
| 19 | + }, |
| 20 | + computed: { |
| 21 | + // other computed properties |
| 22 | + // ... |
| 23 | + // gives access to this.counterStore and this.userStore |
| 24 | + ...mapStores(useProfileStore,usePreferenceStore), |
| 25 | + // // gives read access to this.count and this.double |
| 26 | + ...mapState(useProfileStore, ['activeProfile']), |
| 27 | + ...mapState(usePreferenceStore, ['styleDefault']), |
| 28 | +
|
| 29 | + ...mapWritableState(useProfileStore, ['activeComponent']), |
| 30 | +
|
| 31 | +
|
| 32 | + }, |
| 33 | + watch: { |
| 34 | +
|
| 35 | + |
| 36 | + }, |
| 37 | +
|
| 38 | + methods: { |
| 39 | +
|
| 40 | + async refreshMarc() { |
| 41 | +
|
| 42 | + this.previewData = await this.profileStore.marcPreview() |
| 43 | + |
| 44 | +
|
| 45 | + } |
| 46 | + |
| 47 | +
|
| 48 | +
|
| 49 | +
|
| 50 | +
|
| 51 | + }, |
| 52 | +
|
| 53 | + created() { |
| 54 | +
|
| 55 | + this.profileStore.$subscribe(async (mutation, state)=>{ |
| 56 | +
|
| 57 | + if (mutation && mutation.events && mutation.events.target && mutation.events.target['@guid'] ){ |
| 58 | + |
| 59 | + window.clearTimeout(this.timeout) |
| 60 | + this.timeout = window.setTimeout(()=>{ |
| 61 | +
|
| 62 | + this.refreshMarc() |
| 63 | +
|
| 64 | + },500) |
| 65 | +
|
| 66 | +
|
| 67 | + |
| 68 | + } |
| 69 | +
|
| 70 | +
|
| 71 | + }, { detached: false }) |
| 72 | +
|
| 73 | + // build the XML on first load |
| 74 | + this.$nextTick(()=>{ |
| 75 | + window.setTimeout(()=>{ |
| 76 | +
|
| 77 | + this.refreshMarc() |
| 78 | +
|
| 79 | + },1000) |
| 80 | + }) |
| 81 | + }, |
| 82 | +
|
| 83 | + mounted() { |
| 84 | + |
| 85 | +
|
| 86 | + |
| 87 | + } |
| 88 | + } |
| 89 | +
|
| 90 | +
|
| 91 | +
|
| 92 | +</script> |
| 93 | + |
| 94 | +<template> |
| 95 | + |
| 96 | + <div class="marc-preview-content"> |
| 97 | + |
| 98 | + <ul> |
| 99 | + <li v-for="ver in previewData.versions"> |
| 100 | + <button @click="selected = ver.version">{{ ver.version }} <span v-if="ver.error">(err)</span></button> |
| 101 | + </li> |
| 102 | + </ul> |
| 103 | + |
| 104 | + |
| 105 | + <template v-if="!selected"> |
| 106 | + <template v-for="ver in previewData.versions"> |
| 107 | + <div v-if="ver.default"> |
| 108 | + <div class="version-number">{{ ver.version }}</div> |
| 109 | + <pre> |
| 110 | + <code> |
| 111 | +{{ ver.marcRecord }} |
| 112 | + </code> |
| 113 | + </pre> |
| 114 | + <hr> |
| 115 | + <pre> |
| 116 | + <code> |
| 117 | +{{ ver.results.stdout.trim() }} |
| 118 | + </code> |
| 119 | + </pre> |
| 120 | + </div> |
| 121 | + </template> |
| 122 | + |
| 123 | + </template> |
| 124 | + <template v-else> |
| 125 | + <template v-for="ver in previewData.versions"> |
| 126 | + <div v-if="selected == ver.version"> |
| 127 | + <div class="version-number">{{ ver.version }}</div> |
| 128 | + <template v-if="ver.error"> |
| 129 | + |
| 130 | + <pre> |
| 131 | + <code> |
| 132 | +{{ ver.results }} |
| 133 | + </code> |
| 134 | + </pre> |
| 135 | + </template> |
| 136 | + <template v-else> |
| 137 | + <pre> |
| 138 | + <code> |
| 139 | +{{ ver.marcRecord }} |
| 140 | + </code> |
| 141 | + </pre> |
| 142 | + <hr> |
| 143 | + <pre> |
| 144 | + <code> |
| 145 | +{{ ver.results.stdout.trim() }} |
| 146 | + </code> |
| 147 | + </pre> |
| 148 | + </template> |
| 149 | + </div> |
| 150 | + </template> |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | + </template> |
| 155 | + |
| 156 | + </div> |
| 157 | +</template> |
| 158 | + |
| 159 | +<style scoped> |
| 160 | +
|
| 161 | +ul{ |
| 162 | + padding: 0; |
| 163 | +} |
| 164 | +li{ |
| 165 | + display: inline-block; |
| 166 | +} |
| 167 | +
|
| 168 | +.marc-preview-content{ |
| 169 | + padding: 0.25em; |
| 170 | +} |
| 171 | +.version-number{ |
| 172 | + font-size: 1.25em; |
| 173 | + font-weight: bold; |
| 174 | +} |
| 175 | +
|
| 176 | +
|
| 177 | +.sidebar-header-text{ |
| 178 | + font-size: v-bind("preferenceStore.returnValue('--n-edit-main-splitpane-opac-font-size', true) + 0.25 + 'em'"); |
| 179 | + font-family: v-bind("preferenceStore.returnValue('--c-edit-main-splitpane-opac-font-family')"); |
| 180 | + color: v-bind("preferenceStore.returnValue('--c-edit-main-splitpane-opac-font-color')") !important; |
| 181 | +
|
| 182 | +} |
| 183 | +
|
| 184 | +
|
| 185 | +.sidebar-spacer{ |
| 186 | + padding-top: 1em; |
| 187 | + margin-top: 1em; |
| 188 | + padding-bottom: 1em; |
| 189 | + border-top: solid 1px v-bind("preferenceStore.returnValue('--c-edit-main-splitpane-opac-font-color')"); |
| 190 | +
|
| 191 | +} |
| 192 | +
|
| 193 | +
|
| 194 | +.item-icon{ |
| 195 | + fill:v-bind("preferenceStore.returnValue('--c-general-icon-item-color')"); |
| 196 | + stroke-width:0.5; |
| 197 | + stroke:rgb(0,0,0) |
| 198 | +} |
| 199 | +
|
| 200 | +
|
| 201 | +
|
| 202 | +
|
| 203 | +</style> |
0 commit comments