Skip to content

Commit

Permalink
🔀 Merge #398 updates to deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Oct 19, 2023
2 parents 8b6d4e8 + 6dfd382 commit 6c6bcc6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 51 deletions.
54 changes: 30 additions & 24 deletions components/IscnRegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,16 @@
class="mb-[12px]"
>
<Selector
class="h-[40px] w-[320px]"
class="h-[40px] w-[320px] mb-[8px]"
:options="licenseOptions"
:placeholder="license"
@input="setLicense"
/>
<TextField
v-if="license === 'Other'"
v-model="customLicense"
:placeholder="$t('iscn.meta.license.placeholder')"
/>
</FormField>
<Divider class="my-[12px]" />
<!-- register -->
Expand Down Expand Up @@ -745,11 +750,6 @@ export default class IscnRegisterForm extends Vue {
'CreativeWork',
]
licenseOptions = [
'Copyright. All rights reserved.',
'CC BY 4.0',
]
fileTypeOptions = [
'epub',
'pdf',
Expand All @@ -758,6 +758,12 @@ export default class IscnRegisterForm extends Vue {
'png',
]
licenseMap: { [key: string]: string | null }= {
'Copyright. All rights reserved.': 'All Rights Reserved',
'CC BY 4.0': 'https://creativecommons.org/licenses/by/4.0/',
'Other': null,
}
author: Author = {
name: '',
url: [],
Expand All @@ -773,6 +779,7 @@ export default class IscnRegisterForm extends Vue {
sameAs: string[] = []
url: string = ''
license: string = this.licenseOptions[0]
customLicense: string = ''
authorName: string = ''
authorUrl: string[] = []
authorWalletAddress: string[] = []
Expand Down Expand Up @@ -852,6 +859,7 @@ export default class IscnRegisterForm extends Vue {
get defaultType() {
if (this.isPhoto) return 'Photo'
if (this.isImage) return 'Image'
if (this.fileType === 'application/pdf' || this.fileType === 'application/epub+zip') return 'Book'
return 'CreativeWork'
}
Expand Down Expand Up @@ -884,13 +892,21 @@ export default class IscnRegisterForm extends Vue {
}
get formattedSameAsList() {
return this.sameAsList.map((sameAs: { filename: any; filetype: any; url: any }) => {
if (sameAs.filename && sameAs.filetype) {
return `${sameAs.url}?name=${sameAs.filename}.${sameAs.filetype}`;
}
return '';
});
}
return this.sameAsList.map((sameAs: { filename: any; filetype: any; url: any }) => {
if (sameAs.filename && sameAs.filetype) {
return `${sameAs.url}?name=${sameAs.filename}.${sameAs.filetype}`;
}
return '';
});
}
get licenseOptions() {
return Object.keys(this.licenseMap)
}
get formattedLicense() {
return this.licenseMap[this.license] || this.customLicense;
}
get errorMsg() {
switch (this.error) {
Expand Down Expand Up @@ -964,7 +980,7 @@ export default class IscnRegisterForm extends Vue {
sameAs: this.formattedSameAsList,
url: this.url,
exifInfo: this.exif,
license: this.license,
license: this.formattedLicense,
ipfsHash: this.uploadIpfsHash || this.ipfsHash,
arweaveId: this.uploadArweaveId || this.arweaveId,
numbersProtocolAssetId: this.numbersProtocolAssetId,
Expand Down Expand Up @@ -1051,15 +1067,6 @@ export default class IscnRegisterForm extends Vue {
if (errormsg) this.isOpenWarningSnackbar = true
}
// @Watch('contentFingerprintLinks')
// setSameAsList() {
// this.sameAsList = this.contentFingerprintLinks.map((url) => ({
// url,
// filename: '',
// filetype: this.fileTypeOptions[0],
// }))
// }
async mounted() {
this.uploadStatus = 'loading'
await this.estimateArweaveFee();
Expand Down Expand Up @@ -1192,7 +1199,6 @@ export default class IscnRegisterForm extends Vue {
confirmSameAsChange(value: any) {
logTrackerEvent(this, 'ISCNCreate', 'ConfirmSameAsChange', '', 1);
console.log('value',value)
this.sameAsList = value
this.isOpenSameAsDialog = false
}
Expand Down
11 changes: 1 addition & 10 deletions components/IscnUploadedInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,11 @@ export default class IscnUploadedInfo extends Vue {
}
handleClickDownload() {
const { url, name, keywords, usageInfo, author, description, sameAs } =
this.metadata
const generateData = {
contentMetadata: {
url,
name,
...this.metadata,
'@type': this.type,
version: 1,
'@context': "http://schema.org/",
keywords,
usageInfo,
author,
description,
sameAs,
},
stakeholders: this.recordData?.stakeholders,
contentFingerprints: this.contentFingerprints,
Expand Down
38 changes: 24 additions & 14 deletions components/SameAsFieldList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<FormField :label="$t('IscnRegisterForm.label.fileType')">
<Selector
class="h-[40px] w-[80px]"
:options="filetypeOptions"
:placeholder="item.filetype || filetypeOptions[0]"
:options="sameAsFiletypeOptions"
:placeholder="item.filetype || sameAsFiletypeOptions[0]"
@input="(value) => handleSelectValue({ value, index: i })"
/>
</FormField>
Expand Down Expand Up @@ -68,7 +68,7 @@

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import { FILE_TYPES } from '~/constant'
import { SAME_AS_FILE_TYPES } from '~/constant'
@Component
export default class WalletFieldList extends Vue {
Expand All @@ -84,16 +84,26 @@ export default class WalletFieldList extends Vue {
url: '',
id: 1,
filename: this.formatName,
filetype: FILE_TYPES[0],
filetype: SAME_AS_FILE_TYPES[0],
}]
// eslint-disable-next-line class-methods-use-this
get filetypeOptions() {
return FILE_TYPES
get sameAsFiletypeOptions() {
return SAME_AS_FILE_TYPES
}
get formatName(){
return this.name ? this.name.toUpperCase() : ''
get formatName() {
if (!this.name) {
return '';
}
if (/[\u4E00-\u9FA5]/.test(this.name)) {
return this.name;
}
return this.name.replace(/[.,!?;:'"(){}[\]<>]/g, '').replace(/\s+/g, '_').toUpperCase();
}
get formatUrlOptions() {
return this.urlOptions.filter(url => url.startsWith('ar://'))
}
mounted() {
Expand All @@ -102,21 +112,21 @@ export default class WalletFieldList extends Vue {
url: list.url,
id: `${list.url}-${list.filename}`,
filename: list.filename,
filetype: list.filetype || FILE_TYPES[0],
filetype: list.filetype || SAME_AS_FILE_TYPES[0],
}))
} else if (this.urlOptions.length) {
this.sameAsList = this.urlOptions.map((url, index) => ({
} else if (this.formatUrlOptions.length) {
this.sameAsList = this.formatUrlOptions.map((url, index) => ({
url,
id: `${url}-${index}`,
filename: this.formatName,
filetype: FILE_TYPES[0],
filetype: SAME_AS_FILE_TYPES[0],
}))
} else {
this.sameAsList = [{
url: '',
id: 1,
filename: this.formatName,
filetype: FILE_TYPES[0],
filetype: SAME_AS_FILE_TYPES[0],
}]
}
}
Expand All @@ -130,7 +140,7 @@ export default class WalletFieldList extends Vue {
url: '',
id: Date.now(),
filename: '',
filetype: FILE_TYPES[0],
filetype: SAME_AS_FILE_TYPES[0],
})
}
Expand Down
5 changes: 3 additions & 2 deletions components/Selector.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="flex items-stretch border-[2px] border-medium-gray rounded-[12px] hover:bg-light-gray">
<button :class="selectorWrapper" @blur.prevent="isOpenOptions = false">
<button :class="selectorWrapper" type="button" @blur.prevent="isOpenOptions = false">
<div
class="flex items-center justify-between whitespace-nowrap px-[12px]"
@click.prevent="isOpenOptions = !isOpenOptions"
Expand Down Expand Up @@ -32,7 +32,7 @@
hover:bg-light-gray
active:bg-shade-gray
"
@click.prevent="handleSelectValue(option)"
@click="handleSelectValue(option)"
>
<div class="py-[8px]">{{ option }}</div>
<IconDiver v-if="i !== options.length - 1" />
Expand Down Expand Up @@ -85,6 +85,7 @@ export default class Selector extends Vue {
this.isOpenOptions = false
this.value = value
this.$emit('input', value)
}
}
</script>
2 changes: 1 addition & 1 deletion constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const WALLET_TYPES = [
'eth',
]

export const FILE_TYPES = [
export const SAME_AS_FILE_TYPES = [
'epub',
'pdf',
'mp3',
Expand Down

0 comments on commit 6c6bcc6

Please sign in to comment.