app/views/storytime/dashboard/posts/_form.html.erb in storytime-0.0.4 vs app/views/storytime/dashboard/posts/_form.html.erb in storytime-1.0.0

- old
+ new

@@ -1,28 +1,149 @@ <%= simple_form_for [:dashboard, @post] do |f| %> <%= f.error_notification %> - <%= f.input :title, autofocus: true %> + <%= hidden_field_tag :type, @post.type_name %> + <%= hidden_field_tag 'post[published]', @post.published_at.nil? ? 0 : 1 if Pundit.policy(current_user, @post).publish? %> + + <div class="post_field post_title"> + <small> + <div class="pull-right" id="title_character_limit" data-limit="<%= Storytime.post_title_character_limit %>"></div> + </small> + <%= f.input :title, autofocus: true %> + </div> - <% if lookup_context.template_exists?("storytime/dashboard/posts/_#{@post.type_name}_fields") %> - <%= render("storytime/dashboard/posts/#{@post.type_name}_fields", f: f) %> - <% end %> + + <div class="post_field post_excerpt"> + <small> + <div class="pull-right" id="excerpt_character_limit" data-limit="<%= Storytime.post_excerpt_character_limit %>"></div> + </small> + <%= f.input :excerpt, required: false %> + </div> - <%= f.input :excerpt %> - <%= f.input :draft_content, as: :text, input_html: { rows: 20, class: "wysiwyg" }, label: "Content" %> - - <%= f.input :featured_media_id, as: :hidden, input_html: { id: "featured_media_id" } %> - <%= link_to "Select Featured Image", "#", class: "btn btn-default", id: "featured_media_button" %> - <div id="featured_media_container"> - <%= image_tag @post.featured_media.file_url(:thumb), id: "featured_media_image" if @post.featured_media %> + + <div class="post_field post_content"> + <%= f.input :draft_content, as: :text, input_html: { rows: 20, class: "summernote" }, label: "Content" %> </div> - <%= f.input :tag_list %> + + <div class="post_field post_tags"> + <%= f.association :tags, input_html: { :name => 'post[tag_list][]', class: 'chosen-select', multiple: true } %> + </div> + + + <div class="panel-group" id="accordion"> + <% if Storytime.enable_file_upload %> + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <span class="glyphicon glyphicon-picture"></span> + <a data-toggle="collapse" href="#post_featured_images"> + <%= t('dashboard.posts.featured_images') %> + </a> + </h4> + </div> + <div id="post_featured_images" class="panel-collapse collapse"> + <div class="panel-body"> + + <div class="col-md-6"> + <%= f.input :featured_media_id, as: :hidden, input_html: { id: "featured_media_id" } %> + + <div class="featured_image_block center-block"> + <span class="glyphicon glyphicon-picture select_featured_image" style="<% if @post.featured_media %>display: none<% end %>"></span> + + <div id="featured_media_container" class="image_container"> + <%= image_tag @post.featured_media.file_url(:thumb), id: "featured_media_image" if @post.featured_media %> + </div> + + <div class="select_featured_image" <% if @post.featured_media %>style="display: none"<% end %>> + <%= link_to "Select Featured Image", "#", class: "btn btn-primary", id: "featured_media_button" %> + </div> + </div> + + <button type="button" class="btn btn-danger remove_featured_image center-block" <% unless @post.featured_media %>style="display: none"<% end %>> + <%= t('dashboard.posts.remove_image') %> + </button> + </div> + + <div class="col-md-6"> + <%= f.input :secondary_media_id, as: :hidden, input_html: { id: "secondary_media_id" } %> + + <div class="featured_image_block center-block"> + <span class="glyphicon glyphicon-picture select_featured_image" style="<% if @post.secondary_media %>display: none<% end %>"></span> + + <div id="secondary_media_container" class="image_container"> + <%= image_tag @post.secondary_media.file_url(:thumb), id: "secondary_media_image" if @post.secondary_media %> + </div> + + <div class="select_featured_image" <% if @post.secondary_media %>style="display: none"<% end %>> + <%= link_to "Select Secondary Image", "#", class: "btn btn-primary", id: "secondary_media_button" %> + </div> + </div> + + <button type="button" class="btn btn-danger remove_featured_image center-block" <% unless @post.secondary_media %>style="display: none"<% end %>> + <%= t('dashboard.posts.remove_image') %> + </button> + </div> + + </div> + </div> + </div> + <% end %> + + <% if lookup_context.template_exists?("storytime/dashboard/posts/_#{@post.type_name}_fields") %> + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <span class="glyphicon glyphicon-th-list"></span> + <a data-toggle="collapse" href="#post_additional_fields"> + <%= t('dashboard.posts.additional_fields') %> + </a> + </div> + <div id="post_additional_fields" class="panel-collapse collapse in"> + <div class="panel-body"> + <%= render("storytime/dashboard/posts/#{@post.type_name}_fields", f: f) %> + </div> + </div> + </div> + <% end %> + + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <span class="glyphicon glyphicon-cog"></span> + <a data-toggle="collapse" href="#post_advanced_settings"> + <%= t('dashboard.posts.advanced_settings') %> + </a> + </h4> + </div> + <div id="post_advanced_settings" class="panel-collapse collapse"> + <div class="panel-body"> + + <%= f.input :slug %> + + <%= f.input :published_at, as: :date_time_picker, input_html: { style: "display: inline" } if @post.published? %> + + </div> + </div> + </div> + </div> - <%= f.input :published, as: :boolean, label: false, inline_label: true if Pundit.policy(current_user, @post).publish? %> - - <div class="actions"> - <%= f.submit (@post.new_record? ? "Create #{@post.human_name}" : "Update #{@post.human_name}"), class: "btn btn-primary" %> + <hr> + + <div class="post_actions"> + <% if @post.persisted? %> + <%= link_to 'Delete', url_for([:dashboard, @post]), method: :delete, data: { confirm: t('common.are_you_sure_you_want_to_delete', resource_name: @post.human_name) }, class: "btn btn-danger" %> + <%= link_to "Preview", post_path(@post, preview: true), class: "btn btn-info", id: "preview_post", target: "_blank" %> + <% else %> + <button id="preview_post" class="btn btn-info">Preview</button> + <% end %> + + <%= f.submit "Save Draft", class: "btn btn-default save" unless @post.published? %> + + <div class="pull-right"> + <%= f.submit "Publish", class: "btn btn-primary publish", publish: true unless @post.published? %> + <%= f.submit "Update", class: "btn btn-default save" if @post.published? %> + </div> </div> <% end %> -<%= render "storytime/dashboard/media/modal" %> \ No newline at end of file +<%= render "storytime/dashboard/media/modal" if Storytime.enable_file_upload %>