2022-07-20 06:24:26 -07:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2022-06-20 01:38:49 -07:00
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-07-20 06:24:26 -07:00
|
|
|
<MkSpacer :content-max="700">
|
|
|
|
<div class="qtcaoidl">
|
2022-12-18 20:53:41 -08:00
|
|
|
<MkButton primary class="add" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
2020-11-14 19:04:54 -08:00
|
|
|
|
2022-07-20 06:24:26 -07:00
|
|
|
<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="list">
|
|
|
|
<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
|
|
|
|
<b>{{ item.name }}</b>
|
|
|
|
<div v-if="item.description" class="description">{{ item.description }}</div>
|
|
|
|
</MkA>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-11-14 19:04:54 -08:00
|
|
|
</template>
|
|
|
|
|
2022-01-14 23:40:15 -08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2022-09-06 02:21:49 -07:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-11 09:02:25 -08:00
|
|
|
import * as os from '@/os';
|
2022-01-27 08:09:46 -08:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 01:38:49 -07:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2020-11-14 19:04:54 -08:00
|
|
|
|
2022-01-14 23:40:15 -08:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'clips/list' as const,
|
|
|
|
limit: 10,
|
|
|
|
};
|
2020-11-14 19:04:54 -08:00
|
|
|
|
2022-01-14 23:40:15 -08:00
|
|
|
const pagingComponent = $ref<InstanceType<typeof MkPagination>>();
|
2020-11-14 19:04:54 -08:00
|
|
|
|
2022-01-14 23:40:15 -08:00
|
|
|
async function create() {
|
2022-01-27 18:39:49 -08:00
|
|
|
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
|
2022-01-14 23:40:15 -08:00
|
|
|
name: {
|
|
|
|
type: 'string',
|
2022-01-27 18:39:49 -08:00
|
|
|
label: i18n.ts.name,
|
2020-11-14 19:04:54 -08:00
|
|
|
},
|
2022-01-14 23:40:15 -08:00
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
2022-01-27 18:39:49 -08:00
|
|
|
label: i18n.ts.description,
|
2020-11-14 19:04:54 -08:00
|
|
|
},
|
2022-01-14 23:40:15 -08:00
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
2022-01-27 18:39:49 -08:00
|
|
|
label: i18n.ts.public,
|
2022-01-14 23:40:15 -08:00
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/create', result);
|
|
|
|
|
|
|
|
pagingComponent.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onClipCreated() {
|
|
|
|
pagingComponent.reload();
|
|
|
|
}
|
2020-11-14 19:04:54 -08:00
|
|
|
|
2022-01-14 23:40:15 -08:00
|
|
|
function onClipDeleted() {
|
|
|
|
pagingComponent.reload();
|
|
|
|
}
|
|
|
|
|
2022-06-20 01:38:49 -07:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.clip,
|
2022-12-18 20:53:41 -08:00
|
|
|
icon: 'ti ti-paperclip',
|
2022-06-20 01:38:49 -07:00
|
|
|
action: {
|
2022-12-18 20:53:41 -08:00
|
|
|
icon: 'ti ti-plus',
|
2022-06-20 01:38:49 -07:00
|
|
|
handler: create,
|
2022-01-14 23:40:15 -08:00
|
|
|
},
|
2020-11-14 19:04:54 -08:00
|
|
|
});
|
|
|
|
</script>
|
2020-11-14 19:34:47 -08:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.qtcaoidl {
|
|
|
|
> .add {
|
|
|
|
margin: 0 auto 16px auto;
|
|
|
|
}
|
|
|
|
|
2021-12-02 03:09:12 -08:00
|
|
|
> .list {
|
|
|
|
> .item {
|
|
|
|
display: block;
|
|
|
|
padding: 16px;
|
2020-11-14 19:34:47 -08:00
|
|
|
|
2021-12-02 03:09:12 -08:00
|
|
|
> .description {
|
|
|
|
margin-top: 8px;
|
|
|
|
padding-top: 8px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-11-14 19:34:47 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|