<commit_before><template>
<div>
    <form-layout icon="newspaper-o" :title="title" :save="save" :cancel="cancel" footer="true" :model="post">
        <post-form v-ref:form :post="post"></post-form>
    </form-layout>
</div>
</template>

<script>
import PostForm from 'components/post/form.vue';
import Post from 'models/post';
import FormLayout from 'components/form-layout.vue';

export default {
    data() {
        return {
            post: new Post(),
        };
    },
    components: {FormLayout, PostForm},
    computed: {
        title() {
            if (this.post.name) {
                return this._('Edit post "{name}"', {
                    name: this.post.name
                });
            }
        }
    },
    methods: {
        save() {
            const form = this.$refs.form;
            if (form.validate()) {
                this.post.update(form.serialize(), (response) => {
                    this.post.on_fetched(response);
                    this.$go({name: 'post', params: {oid: this.post.id}});
                }, form.on_error);
            }
        },
        cancel() {
            this.$go({name: 'post', params: {oid: this.post.id}});
        }
    },
    route: {
        data() {
            if (this.$route.params.oid !== this.post.id) {
                this.post.fetch(this.$route.params.oid);
                this.$scrollTo(this.$el);
            }
        }
    }
};
</script><commit_msg>Add the save and continue post form action (fix #1750)<commit_after><template>
<div>
    <form-layout icon="newspaper-o" :title="title" :save="save" :cancel="cancel" footer="true" :model="post">
        <post-form v-ref:form :post="post"></post-form>
        <button v-if="save" slot="right-actions"
            class="btn btn-primary"
            @click.prevent="save(true)">
            {{ _('Save and continue') }}
        </button>
    </form-layout>
</div>
</template>

<script>
import PostForm from 'components/post/form.vue';
import Post from 'models/post';
import FormLayout from 'components/form-layout.vue';

export default {
    data() {
        return {
            post: new Post(),
        };
    },
    components: {FormLayout, PostForm},
    computed: {
        title() {
            if (this.post.name) {
                return this._('Edit post "{name}"', {
                    name: this.post.name
                });
            }
        }
    },
    methods: {
        save(continueEditing=false) {
            const form = this.$refs.form;
            if (form.validate()) {
                this.post.update(form.serialize(), (response) => {
                    this.post.on_fetched(response);
                    if (!continueEditing) {
                        this.$go({name: 'post', params: {oid: this.post.id}});
                    }
                }, form.on_error);
            }
        },
        cancel() {
            this.$go({name: 'post', params: {oid: this.post.id}});
        }
    },
    route: {
        data() {
            if (this.$route.params.oid !== this.post.id) {
                this.post.fetch(this.$route.params.oid);
                this.$scrollTo(this.$el);
            }
        }
    }
};
</script>
{'fraction_non_alphanumeric': 0.1656749138740996, 'fraction_numerical': 0.001252740369558409, 'mean_word_length': 1.5695897023330652, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7449513', 'n_tokens_mistral': 961, 'n_tokens_neox': 932, 'n_words': 176}