2020-11-15 04:04:54 +01:00
|
|
|
<template>
|
2021-12-02 12:09:12 +01: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-15 04:04:54 +01:00
|
|
|
|
2022-01-15 08:40:15 +01:00
|
|
|
<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="list">
|
2021-04-10 11:17:42 +02:00
|
|
|
<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
|
2020-11-15 04:34:47 +01:00
|
|
|
<b>{{ item.name }}</b>
|
|
|
|
<div v-if="item.description" class="description">{{ item.description }}</div>
|
|
|
|
</MkA>
|
2020-11-15 04:04:54 +01:00
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2021-12-02 12:09:12 +01:00
|
|
|
</MkSpacer>
|
2020-11-15 04:04:54 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-15 08:40:15 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2021-11-11 18:02:25 +01: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';
|
2022-01-27 17:09:46 +01:00
|
|
|
import { i18n } from '@/i18n';
|
2020-11-15 04:04:54 +01:00
|
|
|
|
2022-01-15 08:40:15 +01:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'clips/list' as const,
|
|
|
|
limit: 10,
|
|
|
|
};
|
2020-11-15 04:04:54 +01:00
|
|
|
|
2022-01-15 08:40:15 +01:00
|
|
|
const pagingComponent = $ref<InstanceType<typeof MkPagination>>();
|
2020-11-15 04:04:54 +01:00
|
|
|
|
2022-01-15 08:40:15 +01:00
|
|
|
async function create() {
|
|
|
|
const { canceled, result } = await os.form(i18n.locale.createNewClip, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.locale.name,
|
2020-11-15 04:04:54 +01:00
|
|
|
},
|
2022-01-15 08:40:15 +01:00
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
|
|
|
label: i18n.locale.description,
|
2020-11-15 04:04:54 +01:00
|
|
|
},
|
2022-01-15 08:40:15 +01:00
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: i18n.locale.public,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/create', result);
|
|
|
|
|
|
|
|
pagingComponent.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onClipCreated() {
|
|
|
|
pagingComponent.reload();
|
|
|
|
}
|
2020-11-15 04:04:54 +01:00
|
|
|
|
2022-01-15 08:40:15 +01:00
|
|
|
function onClipDeleted() {
|
|
|
|
pagingComponent.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: i18n.locale.clip,
|
|
|
|
icon: 'fas fa-paperclip',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
action: {
|
|
|
|
icon: 'fas fa-plus',
|
|
|
|
handler: create
|
2020-11-15 04:04:54 +01:00
|
|
|
},
|
2022-01-15 08:40:15 +01:00
|
|
|
},
|
2020-11-15 04:04:54 +01:00
|
|
|
});
|
|
|
|
</script>
|
2020-11-15 04:34:47 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.qtcaoidl {
|
|
|
|
> .add {
|
|
|
|
margin: 0 auto 16px auto;
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:09:12 +01:00
|
|
|
> .list {
|
|
|
|
> .item {
|
|
|
|
display: block;
|
|
|
|
padding: 16px;
|
2020-11-15 04:34:47 +01:00
|
|
|
|
2021-12-02 12:09:12 +01:00
|
|
|
> .description {
|
|
|
|
margin-top: 8px;
|
|
|
|
padding-top: 8px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-11-15 04:34:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|