diff --git a/components/ISCNTypeIcon.vue b/components/ISCNTypeIcon.vue index 5b79d74d..225edb15 100644 --- a/components/ISCNTypeIcon.vue +++ b/components/ISCNTypeIcon.vue @@ -20,7 +20,7 @@ export enum RecordType { @Component export default class ISCNTypeIcon extends Vue { - @Prop(String) readonly type!: String | undefined + @Prop({ default: 'CreativeWork' }) readonly type!: String | undefined get recordType() { switch (this.type) { diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index e7502ddd..83352992 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -188,7 +188,7 @@ @@ -223,8 +223,38 @@ :placeholder="$t('IscnRegisterForm.placeholder.description')" /> + + + + + @@ -240,7 +270,7 @@ text-preset="h6" type="button" :text="author.name" - @click="editAuthor(index)" + @click="editAuthor({ type: 'stakeholder', index })" /> - + - + + + + + + + - - + @@ -379,7 +446,7 @@ {{ $t('IscnRegisterForm.error.buy') }} - + + + + + + + + Promise + typeOptions = [ + 'Book', + 'Photo', + 'Image', + 'CreativeWork', + ] + + fileTypeOptions = [ + 'epub', + 'pdf', + 'mp3', + 'jpg', + '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: [], + wallet: [], + likerId: '', + authorDescription: '', + } authors: Author[] = [] name: string = '' @@ -644,7 +778,8 @@ export default class IscnRegisterForm extends Vue { tags: string[] = [] sameAs: string[] = [] url: string = '' - license: string = '' + license: string = this.licenseOptions[0] + customLicense: string = '' authorName: string = '' authorUrl: string[] = [] authorWalletAddress: string[] = [] @@ -657,6 +792,7 @@ export default class IscnRegisterForm extends Vue { authorDescription: string = '' contentFingerprintInput: string = '' customContentFingerprints: string[] = [] + type: string = this.defaultType arweaveFeeTargetAddress: string = '' arweaveFee = new BigNumber(0) @@ -669,6 +805,7 @@ export default class IscnRegisterForm extends Vue { isOpenFileInfoDialog = false isOpenAuthorDialog = false + isOpenSameAsDialog = false isOpenWarningSnackbar = false isOpenKeplr = true activeEditingAuthorIndex = -1 @@ -686,6 +823,9 @@ export default class IscnRegisterForm extends Vue { showUploadOnly = this.isUploadOnly + currentAuthorDialogType: AuthorDialogType = AuthorDialogType.stakeholder + sameAsList: any = [] + get tagsString(): string { return this.tags.join(',') } @@ -716,12 +856,19 @@ export default class IscnRegisterForm extends Vue { return this.exifInfo && this.exifInfo.ExifImageWidth } - get type() { + 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' } + get authorDialogTitle() { + return this.currentAuthorDialogType === AuthorDialogType.author + ? this.$t('IscnRegisterForm.title.editAuthor') + : this.$t('IscnRegisterForm.title.editStakeholder') + } + get formattedIpfs() { return this.$t('IscnRegisterForm.ipfs.link', { hash: this.ipfsHash }) } @@ -730,6 +877,37 @@ export default class IscnRegisterForm extends Vue { return this.$t('IscnRegisterForm.arweave.link', { arweaveId: this.uploadArweaveId }) } + get contentFingerprintLinks() { + const array=[] + if (this.uploadArweaveId) { + array.push(this.formattedArweave) + } + if (this.ipfsHash){ + array.push(this.formattedIpfs) + } + if (this.customContentFingerprints.length){ + array.push(...this.customContentFingerprints) + } + return array + } + + 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 ''; + }); + } + + get licenseOptions() { + return Object.keys(this.licenseMap) + } + + get formattedLicense() { + return this.licenseMap[this.license] || this.customLicense; + } + get errorMsg() { switch (this.error) { case 'INSUFFICIENT_BALANCE': @@ -799,14 +977,15 @@ export default class IscnRegisterForm extends Vue { name: this.name, description: this.description, tagsString: this.tagsString, - sameAs: this.sameAs, + 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, fileSHA256: this.fileSHA256, + author: this.author.name, authorNames: this.authorNames, authorUrls: this.authorUrls, authorWallets: this.authorWalletAddresses, @@ -874,8 +1053,7 @@ export default class IscnRegisterForm extends Vue { this.name && this.description && this.name.length <= CharactersLimit.name && - this.description.length <= CharactersLimit.description && - this.license.length <= CharactersLimit.license + this.description.length <= CharactersLimit.description ) } @@ -899,26 +1077,50 @@ export default class IscnRegisterForm extends Vue { addContentFingerprint() { this.customContentFingerprints.push(this.contentFingerprintInput) + this.contentFingerprintInput = '' } - handleOpenAuthorDialog() { - logTrackerEvent(this, 'ISCNCreate', 'OpenAuthorDialog', '', 1); + handleOpenAuthorDialog({ type }: { type: AuthorDialogType }) { this.checkedAuthorInfo = false this.isOpenAuthorDialog = true this.initAuthorInfo() + switch (type) { + case AuthorDialogType.author: + logTrackerEvent(this, 'ISCNCreate', 'OpenAuthorDialog', '', 1) + this.currentAuthorDialogType = AuthorDialogType.author + break + + case AuthorDialogType.stakeholder: + default: + logTrackerEvent(this, 'ISCNCreate', 'OpenStakeholderDialog', '', 1) + this.currentAuthorDialogType = AuthorDialogType.stakeholder + break + } } - editAuthor(index: number) { - logTrackerEvent(this, 'ISCNCreate', 'EditAuthor', index.toString(), 1); - const { name, wallet, url, likerId, authorDescription } = - this.authors[index] - this.authorName = name - this.authorWalletAddress = wallet - this.authorUrl = url - this.likerId = likerId - this.authorDescription = authorDescription - this.activeEditingAuthorIndex = index + editAuthor({ type = AuthorDialogType.stakeholder, index }: { type: AuthorDialogType; index: any }) { this.isOpenAuthorDialog = true + + if (type === AuthorDialogType.author) { + logTrackerEvent(this, 'ISCNCreate', 'EditAuthor', '', 1) + const { name, wallet, url, likerId, authorDescription } = this.author + this.authorName = name + this.authorWalletAddress = wallet + this.authorUrl = url + this.likerId = likerId + this.authorDescription = authorDescription + this.activeEditingAuthorIndex = this.authors.findIndex(author => author.name === name); + } else { + logTrackerEvent(this, 'ISCNCreate', 'EditStakeholder', index.toString(), 1) + const { name, wallet, url, likerId, authorDescription } = + this.authors[index] + this.authorName = name + this.authorWalletAddress = wallet + this.authorUrl = url + this.likerId = likerId + this.authorDescription = authorDescription + this.activeEditingAuthorIndex = index + } } dismissAuthorDialog() { @@ -959,6 +1161,9 @@ export default class IscnRegisterForm extends Vue { likerId: this.likerId, authorDescription: this.authorDescription, } + if (this.currentAuthorDialogType === AuthorDialogType.author) { + this.author = newAuthor + } if (this.activeEditingAuthorIndex >= 0) { this.authors.splice(this.activeEditingAuthorIndex, 1, newAuthor) } else { @@ -980,6 +1185,24 @@ export default class IscnRegisterForm extends Vue { this.authorName = value } + setType(value: string) { + this.type = value + } + + setLicense(value: string) { + this.license = value + } + + handleOpenSameAsDialog() { + this.isOpenSameAsDialog = true + } + + confirmSameAsChange(value: any) { + logTrackerEvent(this, 'ISCNCreate', 'ConfirmSameAsChange', '', 1); + this.sameAsList = value + this.isOpenSameAsDialog = false + } + async getLikerIdsAddresses(): Promise { try { this.likerIdsAddresses = await Promise.all( diff --git a/components/IscnUploadedInfo.vue b/components/IscnUploadedInfo.vue index f092888c..ff315363 100644 --- a/components/IscnUploadedInfo.vue +++ b/components/IscnUploadedInfo.vue @@ -10,10 +10,19 @@ -