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

71 lines
1.2 KiB
Vue
Raw Normal View History

2018-05-29 22:45:27 +03: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 22:45:27 +03: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 22:45:27 +03:00
import Progress from '../../../common/scripts/loading';
export default Vue.extend({
i18n: i18n('mobile/views/pages/user-lists.vue'),
2018-05-29 22:45:27 +03:00
data() {
return {
fetching: true,
lists: []
};
},
mounted() {
document.title = this.$t('title');
2018-05-29 22:45:27 +03:00
Progress.start();
2018-11-09 01:13:34 +02:00
this.$root.api('users/lists/list').then(lists => {
2018-05-29 22:45:27 +03:00
this.fetching = false;
this.lists = lists;
Progress.done();
});
},
methods: {
fn() {
2018-11-09 01:26:32 +02:00
this.$root.apis.input({
title: this.$t('enter-list-name'),
2018-05-29 22:45:27 +03:00
}).then(async title => {
2018-11-09 01:13:34 +02:00
const list = await this.$root.api('users/lists/create', {
2018-05-29 22:45:27 +03:00
title
});
2018-09-01 17:12:51 +03:00
this.$router.push(`/i/lists/${list.id}`);
2018-05-29 22:45:27 +03:00
});
}
}
});
</script>
<style lang="stylus" scoped>
2018-09-26 14:19:35 +03:00
2018-05-29 22:45:27 +03: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>