setup syntax

This commit is contained in:
ThatOneCalculator 2022-09-13 17:14:56 -07:00
parent 031b3661e2
commit 399f0115be

View File

@ -35,45 +35,24 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, defineComponent } from 'vue'; import { computed, watch } from 'vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { definePageMetadata } from '@/scripts/page-metadata';\ import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ const props = defineProps<{
components: {
MkButton,
},
props: {
groupId: { groupId: {
type: String, type: String,
required: true, required: true,
}, },
}, }>();
data() { watch(() => props.groupId, () => {
return { fetch();
[Symbol('Page info')]: computed(() => this.group ? { });
title: this.group.name,
icon: 'fas fa-users',
} : null),
group: null,
users: [],
};
},
watch: { function fetch() {
groupId: 'fetch',
},
created() {
this.fetch();
},
methods: {
fetch() {
os.api('users/groups/show', { os.api('users/groups/show', {
groupId: this.groupId groupId: this.groupId
}).then(group => { }).then(group => {
@ -84,9 +63,9 @@ export default defineComponent({
this.users = users; this.users = users;
}); });
}); });
}, }
invite() { function invite() {
os.selectUser().then(user => { os.selectUser().then(user => {
os.apiWithDialog('users/groups/invite', { os.apiWithDialog('users/groups/invite', {
groupId: this.group.id, groupId: this.group.id,
@ -95,7 +74,7 @@ export default defineComponent({
}); });
}, },
removeUser(user) { function removeUser(user) {
os.api('users/groups/pull', { os.api('users/groups/pull', {
groupId: this.group.id, groupId: this.group.id,
userId: user.id userId: user.id
@ -104,7 +83,7 @@ export default defineComponent({
}); });
}, },
async renameGroup() { async function renameGroup() {
const { canceled, result: name } = await os.inputText({ const { canceled, result: name } = await os.inputText({
title: this.$ts.groupName, title: this.$ts.groupName,
default: this.group.name default: this.group.name
@ -119,7 +98,7 @@ export default defineComponent({
this.group.name = name; this.group.name = name;
}, },
transfer() { function transfer() {
os.selectUser().then(user => { os.selectUser().then(user => {
os.apiWithDialog('users/groups/transfer', { os.apiWithDialog('users/groups/transfer', {
groupId: this.group.id, groupId: this.group.id,
@ -128,7 +107,7 @@ export default defineComponent({
}); });
}, },
async deleteGroup() { async function deleteGroup() {
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$t('removeAreYouSure', { x: this.group.name }), text: this.$t('removeAreYouSure', { x: this.group.name }),
@ -140,8 +119,6 @@ export default defineComponent({
}); });
this.$router.push('/my/groups'); this.$router.push('/my/groups');
} }
}
});
definePageMetadata(computed(() => ({ definePageMetadata(computed(() => ({
title: i18n.ts.members, title: i18n.ts.members,