Skip to content

Commit

Permalink
✨ Support sameAs in edit ISCN page
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Apr 18, 2023
1 parent 15e6e53 commit 5a18252
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions pages/edit/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@
</button>
</div>

<p>sameAs URLs</p>
<div>
<div v-for="(sameAs, i) in contentMetadata.sameAs" :key="i" class="sameAs">
<p>
<input v-model="contentMetadata.sameAs[i]" type="text" size="50">
<button class="button" @click="deleteSameAs(i)">
Delete
</button>
</p>
</div>
<button class="button" @click="newSameAs">
New sameAs URL
</button>
</div>

<p
v-for="[key] in Object.entries(contentMetadata).filter(
([k]) => !(defaultFields.includes(k) || excludeFields.includes(k)))"
Expand Down Expand Up @@ -187,6 +202,7 @@

<script>
import { mapState } from 'vuex'
import Vue from 'vue'
import { INDEXER } from '@/config'
import { getIscnPrefix } from '@/utils/utils'
Expand All @@ -203,7 +219,7 @@ export default {
stakeholders: {},
contentFingerprints: {},
recordNotes: '',
defaultFields: ['@type', 'description', 'url', 'name', 'keywords', 'version', 'usageInfo'],
defaultFields: ['@type', 'description', 'url', 'name', 'keywords', 'sameAs', 'version', 'usageInfo'],
excludeFields: ['@context'],
newField: '',
jsonMode: false,
Expand All @@ -226,7 +242,8 @@ export default {
const record = res.records[0].data
this.iscnId = record['@id']
Object.assign(this, record)
this.contentMetadata.keywords = record.contentMetadata.keywords.split(',').filter(k => !!k)
Vue.set(this.contentMetadata, 'keywords', record.contentMetadata.keywords.split(',').filter(k => !!k))
Vue.set(this.contentMetadata, 'sameAs', record.contentMetadata.sameAs || [])
},
computed: {
Expand All @@ -247,6 +264,7 @@ export default {
contentMetadata: {
...contentMetadata,
keywords: contentMetadata.keywords.join(','),
sameAs: contentMetadata.sameAs.filter(s => !!s),
},
stakeholders,
contentFingerprints,
Expand Down Expand Up @@ -278,6 +296,12 @@ export default {
newKeyword () {
this.contentMetadata.keywords.push('')
},
deleteSameAs (i) {
this.contentMetadata.sameAs = this.contentMetadata.sameAs.filter((_, j) => j !== i)
},
newSameAs () {
this.contentMetadata.sameAs.push('')
},
addField () {
this.contentMetadata[this.newField] = ''
this.newField = ''
Expand Down Expand Up @@ -312,6 +336,7 @@ export default {
this.contentMetadata = {
...contentMetadata,
keywords: contentMetadata.keywords.split(',').filter(k => !!k),
sameAs: contentMetadata.sameAs.filter(s => !!s),
}
this.contentFingerprints = contentFingerprints
this.stakeholders = stakeholders
Expand Down

0 comments on commit 5a18252

Please sign in to comment.