mirror of
https://github.com/knadh/listmonk.git
synced 2025-10-17 18:57:02 +08:00
Instead of using a response transformer, move the global response JSON transformation (snake case to camel case) to the pre-existing response interceptor. Also, fix the `data.data` and `data` discrepancy in responses.
88 lines
2.8 KiB
Vue
88 lines
2.8 KiB
Vue
<template>
|
|
<section class="forms content relative">
|
|
<h1 class="title is-4">Forms</h1>
|
|
<hr />
|
|
<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 publicLists" :key="l.id">
|
|
<b-checkbox v-model="checked"
|
|
:native-value="l.uuid">{{ l.name }}</b-checkbox>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="column">
|
|
<h4>Form HTML</h4>
|
|
<p>
|
|
Use the following HTML to show a subscription form on an external webpage.
|
|
</p>
|
|
<p>
|
|
The form should have the <code>email</code> field and one or more <code>l</code>
|
|
(list UUID) fields. The <code>name</code> field is optional.
|
|
</p>
|
|
|
|
<pre><!-- eslint-disable max-len --><form method="post" action="http://localhost:9000/subscription/form" class="listmonk-form">
|
|
<div>
|
|
<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 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="{{ l.uuid }}" />
|
|
<label for="{{ id }}">{{ l.name }}</label>
|
|
</p></span></template>
|
|
<p><input type="submit" value="Subscribe" /></p>
|
|
</div>
|
|
</form></pre>
|
|
</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',
|
|
|
|
data() {
|
|
return {
|
|
checked: [],
|
|
};
|
|
},
|
|
|
|
methods: {
|
|
getPublicLists(lists) {
|
|
console.log(lists.filter((l) => l.type === 'public'));
|
|
return lists.filter((l) => l.type === 'public');
|
|
},
|
|
},
|
|
|
|
computed: {
|
|
...mapState(['lists', 'loading']),
|
|
|
|
publicLists() {
|
|
if (!this.lists.results) {
|
|
return [];
|
|
}
|
|
return this.lists.results.filter((l) => l.type === 'public');
|
|
},
|
|
|
|
selected() {
|
|
const sel = [];
|
|
this.checked.forEach((uuid) => {
|
|
sel[uuid] = true;
|
|
});
|
|
return sel;
|
|
},
|
|
},
|
|
});
|
|
</script>
|