123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <section class="forms content relative">
- <h1 class="title is-4">{{ $t('forms.title') }}</h1>
- <hr />
- <b-loading v-if="loading.lists" :active="loading.lists" :is-full-page="false" />
- <p v-else-if="publicLists.length === 0">
- {{ $t('forms.noPublicLists') }}
- </p>
- <div class="columns" v-else-if="publicLists.length > 0">
- <div class="column is-4">
- <h4>{{ $t('forms.publicLists') }}</h4>
- <p>{{ $t('forms.selectHelp') }}</p>
- <b-loading :active="loading.lists" :is-full-page="false" />
- <ul class="no" data-cy="lists">
- <li v-for="l in publicLists" :key="l.id">
- <b-checkbox v-model="checked"
- :native-value="l.uuid">{{ l.name }}</b-checkbox>
- </li>
- </ul>
- <template v-if="settings['app.enable_public_subscription_page']">
- <hr />
- <h4>{{ $t('forms.publicSubPage') }}</h4>
- <p>
- <a :href="`${settings['app.root_url']}/subscription/form`"
- target="_blank" data-cy="url">{{ settings['app.root_url'] }}/subscription/form</a>
- </p>
- </template>
- </div>
- <div class="column" data-cy="form">
- <h4>{{ $t('forms.formHTML') }}</h4>
- <p>
- {{ $t('forms.formHTMLHelp') }}
- </p>
- <!-- eslint-disable max-len -->
- <pre v-if="checked.length > 0"><form method="post" action="{{ settings['app.root_url'] }}/subscription/form" class="listmonk-form">
- <div>
- <h3>Subscribe</h3>
- <p><input type="email" name="email" required placeholder="{{ $t('subscribers.email') }}" /></p>
- <p><input type="text" name="name" placeholder="{{ $t('public.subName') }}" /></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" checked value="{{ l.uuid }}" />
- <label for="{{ id }}">{{ l.name }}</label>
- </p></span></template>
- <p><input type="submit" value="{{ $t('public.sub') }}" /></p>
- </div>
- </form></pre>
- </div>
- </div><!-- columns -->
- </section>
- </template>
- <script>
- import Vue from 'vue';
- import { mapState } from 'vuex';
- export default Vue.extend({
- name: 'ListForm',
- data() {
- return {
- checked: [],
- };
- },
- methods: {
- getPublicLists(lists) {
- return lists.filter((l) => l.type === 'public');
- },
- },
- computed: {
- ...mapState(['loading', 'lists', 'settings']),
- 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>
|