Skip to content

Commit f46d5d6

Browse files
committed
feat: collection Edit - Limit Name and Image Update
1 parent eaad18c commit f46d5d6

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

components/collection/EditModal.vue

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@
1717
required
1818
:error="!name"
1919
>
20-
<NeoInput
21-
v-model="name"
22-
required
23-
:placeholder="$t('mint.collection.name.placeholder')"
24-
/>
20+
<NonRecommendFieldNotification
21+
:show="name && nameChanged"
22+
@undo="name = props.collection.name"
23+
>
24+
<NeoInput
25+
v-model="name"
26+
required
27+
:placeholder="$t('mint.collection.name.placeholder')"
28+
/>
29+
</NonRecommendFieldNotification>
2530
</NeoField>
2631

2732
<!-- collection description -->
@@ -36,11 +41,16 @@
3641
/>
3742
</NeoField>
3843
<CollectionEditSection :title="$t('edit.collection.image.label')">
39-
<FormLogoField
40-
v-model:file="image"
41-
v-model:url="imageUrl"
42-
:title="$t('edit.collection.image.message')"
43-
/>
44+
<NonRecommendFieldNotification
45+
:show="hasImageChanged"
46+
@undo="initLogoImage"
47+
>
48+
<FormLogoField
49+
v-model:file="image"
50+
v-model:url="imageUrl"
51+
:title="$t('edit.collection.image.message')"
52+
/>
53+
</NonRecommendFieldNotification>
4454
</CollectionEditSection>
4555

4656
<CollectionEditSection :title="$t('edit.collection.banner.label')">
@@ -165,19 +175,26 @@ const unlimited = ref(true)
165175
const min = computed(() => props.min || 1)
166176
const max = ref<number | null>(null)
167177
178+
const nameChanged = computed(() => props.collection.name !== name.value)
179+
const hasImageChanged = computed(() => (!imageUrl.value && Boolean(props.collection.image)) || Boolean(image.value))
180+
const originalLogoImageUrl = computed(() => sanitizeIpfsUrl(props.collection.image))
181+
168182
const disabled = computed(() => {
169183
const hasImage = imageUrl.value
170184
const isNameFilled = Boolean(name.value)
171185
172-
const nameChanged = props.collection.name !== name.value
173186
const descriptionChanged = props.collection.description !== description.value
174-
const hasImageChanged = (!imageUrl.value && Boolean(props.collection.image)) || Boolean(image.value)
175187
const hasBannerChanged = (!bannerUrl.value && Boolean(props.collection.banner)) || Boolean(banner.value)
176188
const hasMaxChanged = max.value !== props.collection.max
177189
178-
return !hasImage || !isNameFilled || (!nameChanged && !descriptionChanged && !hasImageChanged && !hasBannerChanged && !hasMaxChanged)
190+
return !hasImage || !isNameFilled || (!nameChanged.value && !descriptionChanged && !hasImageChanged.value && !hasBannerChanged && !hasMaxChanged)
179191
})
180192
193+
const initLogoImage = () => {
194+
imageUrl.value = originalLogoImageUrl.value
195+
image.value = undefined
196+
}
197+
181198
const editCollection = async () => {
182199
emit('submit', {
183200
name: name.value,
@@ -193,10 +210,9 @@ watch(isModalActive, (value) => {
193210
if (value && props.collection) {
194211
name.value = props.collection.name
195212
description.value = props.collection.description
196-
imageUrl.value = sanitizeIpfsUrl(props.collection.image)
197213
bannerUrl.value = props.collection.banner && sanitizeIpfsUrl(props.collection.banner)
198-
image.value = undefined
199214
banner.value = undefined
215+
initLogoImage()
200216
unlimited.value = !props.collection.max
201217
max.value = props.collection.max
202218
}

0 commit comments

Comments
 (0)