Skip to content

Commit eaad18c

Browse files
authored
Merge pull request #11200 from Jarsen136/issue-11156
feat: Item Edit: Limit Name and Image Update
2 parents 7193ac9 + 51b7484 commit eaad18c

File tree

3 files changed

+81
-15
lines changed

3 files changed

+81
-15
lines changed

components/common/EditNftModal.vue

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
:label="$t('mint.nft.art.label')"
1717
required
1818
>
19-
<FormLogoField
20-
v-model:file="image"
21-
v-model:url="imageUrl"
22-
/>
19+
<NonRecommendFieldNotification
20+
:show="imageChanged"
21+
@undo="initImage"
22+
>
23+
<FormLogoField
24+
v-model:file="image"
25+
v-model:url="imageUrl"
26+
/>
27+
</NonRecommendFieldNotification>
2328
</NeoField>
2429

2530
<!-- nft name -->
@@ -28,11 +33,16 @@
2833
required
2934
:error="!name"
3035
>
31-
<NeoInput
32-
v-model="name"
33-
required
34-
:placeholder="$t('mint.nft.name.placeholder')"
35-
/>
36+
<NonRecommendFieldNotification
37+
:show="name && nameChanged"
38+
@undo="name = props.metadata?.name"
39+
>
40+
<NeoInput
41+
v-model="name"
42+
required
43+
:placeholder="$t('mint.nft.name.placeholder')"
44+
/>
45+
</NonRecommendFieldNotification>
3646
</NeoField>
3747

3848
<!-- nft description -->
@@ -91,17 +101,24 @@ const image = ref<File>()
91101
const imageUrl = ref<string>()
92102
const attributes = ref<Attribute[]>([])
93103
104+
const originalImageUrl = computed(() => sanitizeIpfsUrl(props.metadata?.image))
105+
106+
const nameChanged = computed(() => props.metadata?.name !== name.value)
107+
const imageChanged = computed(() => originalImageUrl.value !== imageUrl.value)
108+
109+
const initImage = () => {
110+
imageUrl.value = originalImageUrl.value
111+
image.value = undefined
112+
}
113+
94114
const disabled = computed(() => {
95115
const hasImage = Boolean(imageUrl.value)
96116
const isNameFilled = Boolean(name.value)
97-
98-
const nameChanged = props.metadata?.name !== name.value
99117
const descriptionChanged = props.metadata?.description !== description.value
100-
const imageChanged = Boolean(image.value)
101118
const attributesChanged = JSON.stringify(attributes.value) !== JSON.stringify(props.metadata?.attributes || [])
102119
103120
return !hasImage || !isNameFilled
104-
|| (!nameChanged && !descriptionChanged && !imageChanged && !attributesChanged)
121+
|| (!nameChanged.value && !descriptionChanged && !imageChanged.value && !attributesChanged)
105122
})
106123
107124
const editCollection = async () => {
@@ -118,8 +135,7 @@ const editCollection = async () => {
118135
119136
watch(isModalActive, (value) => {
120137
if (value) {
121-
imageUrl.value = sanitizeIpfsUrl(props.metadata?.image)
122-
image.value = undefined
138+
initImage()
123139
name.value = props.metadata?.name
124140
description.value = props.metadata?.description
125141
attributes.value = structuredClone(toRaw(props.metadata?.attributes || []))
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<div class="flex flex-col w-full">
3+
<slot />
4+
<div
5+
v-if="show"
6+
class="flex items-center gap-2 bg-yellow-50 border border-yellow-200 rounded-md p-3 !mt-2"
7+
>
8+
<NeoIcon
9+
icon="warning"
10+
class="text-yellow-500"
11+
size="small"
12+
/>
13+
14+
<div>
15+
<p class="text-sm text-yellow-700">
16+
{{ $t('mint.notRecommendedModify') }}
17+
</p>
18+
<div
19+
v-if="!disabledUndo"
20+
class="w-full flex justify-end"
21+
>
22+
<NeoButton
23+
variant="text"
24+
class="flex items-center gap-1 text-sm !text-yellow-600 hover:!text-yellow-700 capitalize"
25+
@click="emit('undo')"
26+
>
27+
<NeoIcon
28+
icon="undo"
29+
size="small"
30+
/>
31+
{{ $t('general.undo') }}
32+
</NeoButton>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
</template>
38+
39+
<script lang="ts" setup>
40+
import { NeoButton, NeoIcon } from '@kodadot1/brick'
41+
42+
defineProps<{
43+
show: boolean
44+
disabledUndo?: boolean
45+
}>()
46+
47+
const emit = defineEmits(['undo'])
48+
</script>

locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@
941941
"cancelled": "Transaction was cancelled",
942942
"feesPaidIn": "You are paying fees in {0}"
943943
},
944+
"undo": "Undo",
944945
"updateOnWebsiteSoon": "Update on website visible soon",
945946
"usd": "USD",
946947
"using": "using"
@@ -1358,6 +1359,7 @@
13581359
"message": "People will be able to buy your NFT."
13591360
}
13601361
},
1362+
"notRecommendedModify": "Please note that this field is not recommended to be modified as it may lead to misuse and confusion",
13611363
"progress": "In Progress",
13621364
"requiredDeposit": "A deposit of <strong>{0}</strong> is required to create a {1}. Please note, this initial deposit is refundable.",
13631365
"royalty": {

0 commit comments

Comments
 (0)