|
@@ -1,14 +1,18 @@
|
|
|
<template>
|
|
|
- <section class="forms content">
|
|
|
+ <section class="forms content relative">
|
|
|
<h1 class="title is-4">Forms</h1>
|
|
|
<hr />
|
|
|
- <div class="columns">
|
|
|
+ <b-loading v-if="loading.lists" :active="loading.lists" :is-full-page="false" />
|
|
|
+ <div class="columns" v-else-if="publicLists.length > 0">
|
|
|
<div class="column is-4">
|
|
|
<h4>Public lists</h4>
|
|
|
<p>Select lists to add to the form.</p>
|
|
|
+
|
|
|
+ <b-loading :active="loading.lists" :is-full-page="false" />
|
|
|
<ul class="no">
|
|
|
- <li v-for="l in lists" :key="l.id">
|
|
|
- <b-checkbox v-model="checked" :native-value="l.uuid">{{ l.name }}</b-checkbox>
|
|
|
+ <li v-for="l in publicLists" :key="l.id">
|
|
|
+ <b-checkbox v-model="checked"
|
|
|
+ :native-value="l.uuid">{{ l.name }}</b-checkbox>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
@@ -27,7 +31,7 @@
|
|
|
<h3>Subscribe</h3>
|
|
|
<p><input type="text" name="email" placeholder="E-mail" /></p>
|
|
|
<p><input type="text" name="name" placeholder="Name (optional)" /></p>
|
|
|
- <template v-for="l in lists"><span v-if="l.uuid in selected" :key="l.id" :set="id = l.uuid.substr(0, 5)">
|
|
|
+ <template v-for="l in publicLists"><span v-if="l.uuid in selected" :key="l.id" :set="id = l.uuid.substr(0, 5)">
|
|
|
<p>
|
|
|
<input id="{{ id }}" type="checkbox" name="l" value="{{ uuid }}" />
|
|
|
<label for="{{ id }}">{{ l.name }}</label>
|
|
@@ -36,12 +40,15 @@
|
|
|
</div>
|
|
|
</form></pre>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div><!-- columns -->
|
|
|
+
|
|
|
+ <p v-else>There are no public lists to create forms.</p>
|
|
|
</section>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import Vue from 'vue';
|
|
|
+import { mapState } from 'vuex';
|
|
|
|
|
|
export default Vue.extend({
|
|
|
name: 'ListForm',
|
|
@@ -52,13 +59,23 @@ export default Vue.extend({
|
|
|
};
|
|
|
},
|
|
|
|
|
|
+ methods: {
|
|
|
+ getPublicLists(lists) {
|
|
|
+ console.log(lists.filter((l) => l.type === 'public'));
|
|
|
+ return lists.filter((l) => l.type === 'public');
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
computed: {
|
|
|
- lists() {
|
|
|
- if (!this.$store.state.lists.results) {
|
|
|
+ ...mapState(['lists', 'loading']),
|
|
|
+
|
|
|
+ publicLists() {
|
|
|
+ if (!this.lists.results) {
|
|
|
return [];
|
|
|
}
|
|
|
- return this.$store.state.lists.results.filter((l) => l.type === 'public');
|
|
|
+ return this.lists.results.filter((l) => l.type === 'public');
|
|
|
},
|
|
|
+
|
|
|
selected() {
|
|
|
const sel = [];
|
|
|
this.checked.forEach((uuid) => {
|
|
@@ -67,9 +84,5 @@ export default Vue.extend({
|
|
|
return sel;
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
- mounted() {
|
|
|
- this.$api.getLists();
|
|
|
- },
|
|
|
});
|
|
|
</script>
|