egirlskey/src/client/app/mobile/views/pages/user-lists.vue

73 lines
1.3 KiB
Vue
Raw Normal View History

2018-05-29 19:45:27 +00:00
<template>
<mk-ui>
<span slot="header"><fa icon="list"/>{{ $t('title') }}</span>
<template slot="func"><button @click="fn"><fa icon="plus"/></button></template>
2018-05-29 19:45:27 +00:00
<main>
<ul>
<li v-for="list in lists" :key="list.id"><router-link :to="`/i/lists/${list.id}`">{{ list.title }}</router-link></li>
</ul>
</main>
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
2018-05-29 19:45:27 +00:00
import Progress from '../../../common/scripts/loading';
export default Vue.extend({
i18n: i18n('mobile/views/pages/user-lists.vue'),
2018-05-29 19:45:27 +00:00
data() {
return {
fetching: true,
lists: []
};
},
mounted() {
document.title = this.$t('title');
2018-05-29 19:45:27 +00:00
Progress.start();
2018-11-08 23:13:34 +00:00
this.$root.api('users/lists/list').then(lists => {
2018-05-29 19:45:27 +00:00
this.fetching = false;
this.lists = lists;
Progress.done();
});
},
methods: {
fn() {
2018-12-02 11:10:53 +00:00
this.$root.dialog({
title: this.$t('enter-list-name'),
2018-12-02 11:10:53 +00:00
input: true
}).then(async ({ canceled, result: title }) => {
if (canceled) return;
2018-11-08 23:13:34 +00:00
const list = await this.$root.api('users/lists/create', {
2018-05-29 19:45:27 +00:00
title
});
2018-09-01 14:12:51 +00:00
this.$router.push(`/i/lists/${list.id}`);
2018-05-29 19:45:27 +00:00
});
}
}
});
</script>
<style lang="stylus" scoped>
2018-09-26 11:19:35 +00:00
2018-05-29 19:45:27 +00:00
main
width 100%
max-width 680px
margin 0 auto
padding 8px
@media (min-width 500px)
padding 16px
@media (min-width 600px)
padding 32px
</style>