Skip to content

Commit

Permalink
Refactor date input components to use is-editing
Browse files Browse the repository at this point in the history
prop
  • Loading branch information
ChaituVR committed Nov 9, 2023
1 parent ac8c90b commit 632a0b7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/SpaceCreateVoting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ defineEmits<{
<SpaceCreateVotingDateStart
:delay="space.voting?.delay"
:date="dateStart"
:disabled="isEditing || !!space.voting?.delay"
:is-editing="isEditing"
@select="value => setDateStart(value)"
/>

<SpaceCreateVotingDateEnd
:period="space.voting?.period"
:date="dateEnd"
:disabled="isEditing || !!space.voting?.period"
:is-editing="isEditing"
@select="value => setDateEnd(value)"
/>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/SpaceCreateVotingDateEnd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { d } = useI18n();
const props = withDefaults(
defineProps<{
period?: number | null;
isEditing?: boolean;
date: number;
}>(),
{
Expand All @@ -12,6 +13,7 @@ const props = withDefaults(
);
const dateString = computed(() => d(props.date * 1e3, 'short', 'en-US'));
const isDisabled = computed(() => !!props.period || props.isEditing);
const emit = defineEmits(['select']);
</script>
Expand All @@ -20,9 +22,10 @@ const emit = defineEmits(['select']);
<InputDate
type="end"
:title="$t(`create.end`)"
:disabled="isDisabled"
:date="date"
:date-string="dateString"
:tooltip="!!period ? $t('create.periodEnforced') : null"
:tooltip="(!!period && !isEditing) ? $t('create.periodEnforced') : null"
@update:date="emit('select', $event)"
/>
</template>
5 changes: 4 additions & 1 deletion src/components/SpaceCreateVotingDateStart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { t, d } = useI18n();
const props = withDefaults(
defineProps<{
delay?: number | null;
isEditing?: boolean;
date: number;
}>(),
{
Expand All @@ -17,6 +18,7 @@ const dateString = computed(() =>
? t('create.now')
: d(props.date * 1e3, 'short', 'en-US')
);
const isDisabled = computed(() => !!props.delay || props.isEditing);
const emit = defineEmits(['select']);
</script>
Expand All @@ -25,9 +27,10 @@ const emit = defineEmits(['select']);
<InputDate
type="start"
:title="$t(`create.start`)"
:disabled="isDisabled"
:date="date"
:date-string="dateString"
:tooltip="!!delay ? $t('create.delayEnforced') : null"
:tooltip="(!!delay && !isEditing) ? $t('create.delayEnforced') : null"
@update:date="emit('select', $event)"
/>
</template>

0 comments on commit 632a0b7

Please sign in to comment.