fix: 条件変更時に有効期限を変更していないのに勝手に更新される問題を修正

This commit is contained in:
Chocolate Pie 2023-06-19 17:01:10 +09:00
parent f1889d3c5b
commit 9b00b3556e
2 changed files with 13 additions and 4 deletions

View File

@ -56,6 +56,7 @@ const props = defineProps<{
expiresAt: string; expiresAt: string;
forward: boolean; forward: boolean;
expirationDate: string; expirationDate: string;
beforeExpiresAt?: string;
} }
editable: boolean; editable: boolean;
data?: { data?: {
@ -77,9 +78,6 @@ const emit = defineEmits(['update:modelValue']);
const value = computed({ const value = computed({
get() { get() {
if (props.modelValue && props.editable) {
emit('update:modelValue', props.data ?? props.modelValue);
}
const data = props.data ?? props.modelValue ?? { const data = props.data ?? props.modelValue ?? {
name: '', name: '',
targetUserPattern: '', targetUserPattern: '',
@ -93,6 +91,9 @@ const value = computed({
data[key] = ''; data[key] = '';
} }
} }
if (props.modelValue && props.editable) {
emit('update:modelValue', data);
}
return data as unknown as Exclude<NonNullType<typeof props.modelValue>, undefined>; return data as unknown as Exclude<NonNullType<typeof props.modelValue>, undefined>;
}, },
set(updateValue) { set(updateValue) {
@ -116,6 +117,11 @@ function renderExpirationDate(empty = false) {
watch(() => value.value.expirationDate, () => renderExpirationDate(), { immediate: true }); watch(() => value.value.expirationDate, () => renderExpirationDate(), { immediate: true });
watch(() => value.value.expiresAt, () => renderExpirationDate(true)); watch(() => value.value.expiresAt, () => renderExpirationDate(true));
watch(() => props.editable, () => {
if (props.editable) {
value.value.beforeExpiresAt = value.value.expiresAt;
}
});
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -123,6 +123,7 @@ let editingResolver = $ref<{
expiresAt: string; expiresAt: string;
expirationDate: string; expirationDate: string;
forward: boolean; forward: boolean;
beforeExpiresAt?: string;
}>(defaultResolver); }>(defaultResolver);
const pagination = { const pagination = {
@ -155,7 +156,9 @@ function save(): void {
targetUserPattern: editingResolver.targetUserPattern || null, targetUserPattern: editingResolver.targetUserPattern || null,
reporterPattern: editingResolver.reporterPattern || null, reporterPattern: editingResolver.reporterPattern || null,
reportContentPattern: editingResolver.reportContentPattern || null, reportContentPattern: editingResolver.reportContentPattern || null,
expiresAt: editingResolver.expiresAt, ...(editingResolver.beforeExpiresAt && editingResolver.beforeExpiresAt === editingResolver.expiresAt ? {} : {
expiresAt: editingResolver.expiresAt,
}),
forward: editingResolver.forward, forward: editingResolver.forward,
}).then(() => { }).then(() => {
editableResolver = null; editableResolver = null;