Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Support update activity
Browse files Browse the repository at this point in the history
  • Loading branch information
kikakkz committed Dec 6, 2023
1 parent 1a59f2c commit baeceaa
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 9 deletions.
1 change: 1 addition & 0 deletions activity/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl Activity {
if let Some(vote_end_at) = params.vote_end_at {
activity.vote_end_at = vote_end_at
}
self.activities.insert(&activity.clone().id, activity)?;
Ok(())
}

Expand Down
24 changes: 24 additions & 0 deletions webui/src/components/ActivityCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
<div :style='{margin:"4px 8px 4px 4px"}'>
Progress
</div>
<q-separator />
<div :style='{margin:"4px 8px 4px 4px"}'>
Join Type
</div>
<q-separator />
<div :style='{margin:"4px 8px 4px 4px"}'>
Object Type
</div>
<q-separator />
<div :style='{margin:"4px 8px 4px 4px"}'>
Vote Type
</div>
</template>
<template #after>
<div class='row'>
Expand Down Expand Up @@ -97,6 +109,18 @@
<div :style='{margin:"4px 8px 4px 4px"}' class='text-bold text-grey-6'>
{{ activity.finalized ? 'Finalized' : 'In Progress' }}
</div>
<q-separator />
<div :style='{margin:"4px 8px 4px 4px"}' class='text-bold text-blue-6'>
{{ activity.joinType }}
</div>
<q-separator />
<div :style='{margin:"4px 8px 4px 4px"}' class='text-bold text-blue-6'>
{{ activity.objectType }}
</div>
<q-separator />
<div :style='{margin:"4px 8px 4px 4px"}' class='text-bold text-blue-6'>
{{ activity.voteType }}
</div>
</template>
</q-splitter>
<q-separator :style='{margin:"0 0 32px 0"}' />
Expand Down
24 changes: 16 additions & 8 deletions webui/src/components/CreateActivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</template>

<script lang='ts' setup>
import { computed, ref, watch } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import {
ActivityTypes,
ActivityType,
Expand Down Expand Up @@ -180,34 +180,37 @@ const activityId = ref((route.query as unknown as Query).activityId)
const activity = useActivityStore()
const _activity = computed(() => activity.activity(Number(activityId.value)))
watch(_activity, () => {
const activity2Params = () => {
if (!_activity.value) {
return
}
params.value = {
id: activityId.value,
title: _activity.value.title,
slogan: _activity.value.slogan,
banner: _activity.value.banner,
hostResume: _activity.value.hostResume,
posters: _activity.value.posters,
introduction: _activity.value.introduction,
activityType: _activity.value.activityType,
activityType: activity.activityType(_activity.value.id),
votable: _activity.value.votable,
voteType: _activity.value.voteType,
objectType: _activity.value.objectType,
voteType: activity.voteType(_activity.value.id),
objectType: activity.objectType(_activity.value.id),
condition: _activity.value.condition,
sponsors: _activity.value.sponsors,
prizeConfigs: _activity.value.prizeConfigs,
voterRewardPercent: _activity.value.voterRewardPercent,
budgetAmount: _activity.value.budgetAmount,
joinType: _activity.value.joinType,
joinType: activity.joinType(_activity.value.id),
location: _activity.value.location,
registerStartAt: date.formatDate(_activity.value.registerStartAt, 'YYYY/MM/DD').toString(),
registerEndAt: date.formatDate(_activity.value.registerEndAt, 'YYYY/MM/DD').toString(),
voteStartAt: date.formatDate(_activity.value.voteStartAt, 'YYYY/MM/DD').toString(),
voteEndAt: date.formatDate(_activity.value.voteEndAt, 'YYYY/MM/DD').toString()
} as CreateParams
}
watch(_activity, () => {
activity2Params()
})
const params = ref({
Expand Down Expand Up @@ -300,7 +303,7 @@ const params2Gql = () => {
} else {
s += ` updateActivity {
update (params: {
id: ${_activity.value.id},
activity_id: ${_activity.value.id},
`
}
s += `
Expand Down Expand Up @@ -368,6 +371,7 @@ const params2Gql = () => {
const onSubmitClick = async () => {
const gqlStr = params2Gql()
console.log(gqlStr)
const { mutate, onDone, onError } = provideApolloClient(apolloClient)(() => useMutation(gql(
gqlStr
)))
Expand All @@ -394,4 +398,8 @@ const onDeletePrizeConfig = (place: number) => {
params.value.prizeConfigs.splice(index >= 0 ? index : 0, index >= 0 ? 1 : 0)
}
onMounted(() => {
activity2Params()
})
</script>
72 changes: 71 additions & 1 deletion webui/src/stores/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface Winner {
}

export interface CreateParams {
id?: number
title: string
slogan?: string
banner: string
Expand Down Expand Up @@ -141,6 +140,77 @@ export const useActivityStore = defineStore('activity', {
return (id: number) => {
return this.activities.get(id)
}
},
activityType (): (id: number) => ActivityType {
return (id: number) => {
let activityType = this.activities.get(id)?.activityType || ActivityType.Campaign
switch (activityType) {
case ActivityType.Campaign.toUpperCase():
activityType = ActivityType.Campaign
break
case ActivityType.MeetUp.toUpperCase():
activityType = ActivityType.MeetUp
break
}
return activityType
}
},
voteType (): (id: number) => VoteType {
return (id: number) => {
let voteType = this.activities.get(id)?.voteType || VoteType.Power
switch (voteType) {
case VoteType.Account.toUpperCase():
voteType = VoteType.Account
break
case VoteType.Power.toUpperCase():
voteType = VoteType.Power
break
}
return voteType
}
},
objectType (): (id: number) => ObjectType {
return (id: number) => {
let objectType = this.activities.get(id)?.objectType || ObjectType.Content
switch (objectType) {
case ObjectType.ArtCollection.toUpperCase():
objectType = ObjectType.ArtCollection
break
case ObjectType.ArtWork.toUpperCase():
objectType = ObjectType.ArtWork
break
case ObjectType.Author.toUpperCase():
objectType = ObjectType.Author
break
case ObjectType.Comment.toUpperCase():
objectType = ObjectType.Comment
break
case ObjectType.Content.toUpperCase():
objectType = ObjectType.Content
break
case ObjectType.Creator.toUpperCase():
objectType = ObjectType.Creator
break
case ObjectType.Reviewer.toUpperCase():
objectType = ObjectType.Reviewer
break
}
return objectType
}
},
joinType (): (id: number) => JoinType {
return (id: number) => {
let joinType = this.activities.get(id)?.joinType || JoinType.Online
switch (joinType) {
case JoinType.Online.toUpperCase():
joinType = JoinType.Online
break
case JoinType.InPerson.toUpperCase():
joinType = JoinType.InPerson
break
}
return joinType
}
}
},
actions: {}
Expand Down

0 comments on commit baeceaa

Please sign in to comment.