yumechi-no-kuni/packages/client/src/pages/my-clips/index.vue

104 lines
2 KiB
Vue
Raw Normal View History

2020-11-14 21:04:54 -06:00
<template>
2021-12-02 05:09:12 -06:00
<MkSpacer :content-max="700">
<div class="qtcaoidl">
<MkButton primary class="add" @click="create"><i class="fas fa-plus"></i> {{ $ts.add }}</MkButton>
2020-11-14 21:04:54 -06:00
2021-12-02 05:09:12 -06:00
<MkPagination v-slot="{items}" ref="list" :pagination="pagination" class="list">
2021-04-10 04:17:42 -05:00
<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
2020-11-14 21:34:47 -06:00
<b>{{ item.name }}</b>
<div v-if="item.description" class="description">{{ item.description }}</div>
</MkA>
2020-11-14 21:04:54 -06:00
</MkPagination>
</div>
2021-12-02 05:09:12 -06:00
</MkSpacer>
2020-11-14 21:04:54 -06:00
</template>
<script lang="ts">
import { defineComponent } from 'vue';
2021-11-11 11:02:25 -06:00
import MkPagination from '@/components/ui/pagination.vue';
import MkButton from '@/components/ui/button.vue';
import * as os from '@/os';
import * as symbols from '@/symbols';
2020-11-14 21:04:54 -06:00
export default defineComponent({
components: {
MkPagination,
MkButton,
},
data() {
return {
2021-04-09 22:54:12 -05:00
[symbols.PAGE_INFO]: {
2020-12-25 19:47:36 -06:00
title: this.$ts.clip,
icon: 'fas fa-paperclip',
2021-12-02 05:09:12 -06:00
bg: 'var(--bg)',
2020-11-14 21:04:54 -06:00
action: {
icon: 'fas fa-plus',
2020-11-14 21:04:54 -06:00
handler: this.create
}
},
pagination: {
endpoint: 'clips/list',
limit: 10,
},
draft: null,
};
},
methods: {
async create() {
2020-12-25 19:47:36 -06:00
const { canceled, result } = await os.form(this.$ts.createNewClip, {
2020-11-14 21:04:54 -06:00
name: {
type: 'string',
2020-12-25 19:47:36 -06:00
label: this.$ts.name
2020-11-14 21:04:54 -06:00
},
description: {
type: 'string',
required: false,
multiline: true,
2020-12-25 19:47:36 -06:00
label: this.$ts.description
2020-11-14 21:04:54 -06:00
},
isPublic: {
type: 'boolean',
2020-12-25 19:47:36 -06:00
label: this.$ts.public,
default: false
2020-11-14 21:04:54 -06:00
}
});
if (canceled) return;
os.apiWithDialog('clips/create', result);
},
onClipCreated() {
this.$refs.list.reload();
this.draft = null;
},
onClipDeleted() {
this.$refs.list.reload();
},
}
});
</script>
2020-11-14 21:34:47 -06:00
<style lang="scss" scoped>
.qtcaoidl {
> .add {
margin: 0 auto 16px auto;
}
2021-12-02 05:09:12 -06:00
> .list {
> .item {
display: block;
padding: 16px;
2020-11-14 21:34:47 -06:00
2021-12-02 05:09:12 -06:00
> .description {
margin-top: 8px;
padding-top: 8px;
border-top: solid 0.5px var(--divider);
2020-11-14 21:34:47 -06:00
}
}
}
}
</style>