2018-02-02 22:20:31 +00:00
|
|
|
- unless @post.errors.empty?
|
|
|
|
.alert.alert-danger
|
|
|
|
%ul
|
2018-02-03 22:37:09 +00:00
|
|
|
- @post.errors.each do |_,error|
|
2018-02-02 22:20:31 +00:00
|
|
|
%li= error
|
|
|
|
|
2018-02-03 22:37:09 +00:00
|
|
|
-# TODO habilitar form_for
|
|
|
|
- if @post.new?
|
|
|
|
- url = site_posts_path(@site)
|
|
|
|
- method = :post
|
|
|
|
- else
|
|
|
|
- url = site_post_path(@site, @post)
|
|
|
|
- method = :patch
|
|
|
|
= form_tag url, method: method, class: 'form' do
|
2018-01-31 20:29:27 +00:00
|
|
|
.form-group
|
|
|
|
= submit_tag t('posts.save'), class: 'btn btn-success'
|
|
|
|
.form-group
|
|
|
|
= text_field 'post', 'title', value: @post.title, class: 'form-control',
|
|
|
|
placeholder: t('posts.title')
|
|
|
|
.form-group
|
|
|
|
= text_area_tag 'post[content]', @post.content, autofocus: true,
|
2018-02-03 22:37:09 +00:00
|
|
|
class: 'form-control post-content', data: { provide: 'markdown' },
|
|
|
|
cols: 72, wrap: 'hard'
|
2018-01-31 20:29:27 +00:00
|
|
|
.form-group
|
|
|
|
= label_tag 'post_date', t('posts.date')
|
2018-02-03 22:37:09 +00:00
|
|
|
= date_field 'post', 'date', value: @post.date.try(:strftime, '%F'),
|
2018-01-31 20:29:27 +00:00
|
|
|
class: 'form-control'
|
|
|
|
%small.text-muted.form-text= t('posts.date_help')
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_categories', t('posts.categories')
|
2018-02-03 23:41:02 +00:00
|
|
|
= select_tag 'post[categories][]',
|
|
|
|
options_for_select(@site.categories, @post.categories),
|
|
|
|
{ class: 'form-control select2', multiple: 'multiple' }
|
2018-01-31 20:29:27 +00:00
|
|
|
%small.text-muted.form-text= t('posts.tags_help')
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_tags', t('posts.tags')
|
2018-02-03 23:41:02 +00:00
|
|
|
= select_tag 'post[tags][]',
|
|
|
|
options_for_select(@site.tags, @post.tags),
|
|
|
|
{ class: 'form-control select2', multiple: 'multiple' }
|
2018-01-31 20:29:27 +00:00
|
|
|
%small.text-muted.form-text= t('posts.tags_help')
|
2018-02-02 22:20:31 +00:00
|
|
|
.form-group
|
|
|
|
= label_tag 'post_slug', t('posts.slug')
|
|
|
|
= text_field 'post', 'slug', value: @post.slug,
|
|
|
|
class: 'form-control'
|
|
|
|
%small.text-muted.form-text= t('posts.slug_help')
|
2018-02-03 23:41:02 +00:00
|
|
|
|
|
|
|
:javascript
|
|
|
|
$(document).on('turbolinks:load', function() {
|
|
|
|
$('.select2').select2({ tags: true, tokenSeparators: [',']});
|
|
|
|
});
|