Commit 210a6cd6d42bd2dd71190066ccaed4dcb647beca
1 parent
e86ca3da
check repeat function, pages views
Showing
12 changed files
with
100 additions
and
55 deletions
| ... | ... | @@ -2180,6 +2180,18 @@ jQuery(document).ready(function(){ |
| 2180 | 2180 | $('.nestable-page-list').nestable({ |
| 2181 | 2181 | group: 1 |
| 2182 | 2182 | }).on('change', function(){ |
| 2183 | + var url = $(this).data('sort-url'); | |
| 2184 | + | |
| 2185 | + jQuery.ajax({ | |
| 2186 | + type: 'POST', | |
| 2187 | + url: url, | |
| 2188 | + dataType: 'json', | |
| 2189 | + data: {sort: $('.nestable-page-list').nestable('serialize')}, | |
| 2190 | + success: function(data){ | |
| 2191 | + | |
| 2192 | + } | |
| 2193 | + }); | |
| 2194 | + | |
| 2183 | 2195 | console.log($('.nestable-page-list').nestable('serialize')); |
| 2184 | 2196 | }); // activate Nestable for list 2 |
| 2185 | 2197 | ... | ... |
| ... | ... | @@ -99,7 +99,7 @@ module Kanjai |
| 99 | 99 | def clone |
| 100 | 100 | @page = Page.find(params[:id]) |
| 101 | 101 | @page.clone |
| 102 | - redirect_to action: :index | |
| 102 | + redirect_to action: :index, domain_id: @page.domain.id | |
| 103 | 103 | end |
| 104 | 104 | |
| 105 | 105 | def show_editor |
| ... | ... | @@ -201,6 +201,9 @@ module Kanjai |
| 201 | 201 | |
| 202 | 202 | |
| 203 | 203 | def sort |
| 204 | + | |
| 205 | + sort_order(params[:sort], nil) | |
| 206 | + | |
| 204 | 207 | @page = Page.find(params[:id]) |
| 205 | 208 | |
| 206 | 209 | case params[:direction] |
| ... | ... | @@ -210,7 +213,7 @@ module Kanjai |
| 210 | 213 | @page.move_lower |
| 211 | 214 | end |
| 212 | 215 | |
| 213 | - redirect_to :action => :index | |
| 216 | + render json: {status: 'ok'} | |
| 214 | 217 | |
| 215 | 218 | end |
| 216 | 219 | |
| ... | ... | @@ -359,6 +362,19 @@ module Kanjai |
| 359 | 362 | @obj.build_markers(@obj.type_content) |
| 360 | 363 | end |
| 361 | 364 | |
| 365 | + def sort_order(collection, parent) | |
| 366 | + collection.each do |order, data| | |
| 367 | + p order | |
| 368 | + page = Kanjai::Page.where(id: data[:id]).first | |
| 369 | + if page | |
| 370 | + page.update_columns(position: order.to_i + 1, parent_id: parent) | |
| 371 | + if data[:children] | |
| 372 | + sort_order(data[:children], page.id) | |
| 373 | + end | |
| 374 | + end | |
| 375 | + end | |
| 376 | + end | |
| 377 | + | |
| 362 | 378 | |
| 363 | 379 | end |
| 364 | 380 | end |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <div class="container"> |
| 3 | 3 | |
| 4 | 4 | <div class="drop-down-upload"> |
| 5 | - <div style="padding:10px;"> | |
| 5 | + <div style="padding:30px;"> | |
| 6 | 6 | <div class="drop" data-url="<%= @s3_direct_post.url %>" data-form-data="<%= @s3_direct_post.fields.to_json %>" data-host="<%= URI.parse(@s3_direct_post.url).host %>" > |
| 7 | 7 | <%= t('drop_your_file') %> |
| 8 | 8 | <div class="dropped-file-list row"></div> | ... | ... |
| ... | ... | @@ -42,11 +42,24 @@ |
| 42 | 42 | <%= form2.text_area :text_value, :class => "form-control" %> |
| 43 | 43 | <% end %> |
| 44 | 44 | <% if form2.object.get_marker_type(@obj.type_content) == 'file' %> |
| 45 | - <% s3_direct_post = S3_BUCKET.presigned_post(key: "#{form2.object.get_file_path}${filename}", success_action_status: '201', acl: 'public-read') %> | |
| 46 | - <%= form2.file_field :text_value, :class => "", 'data-url' => s3_direct_post.url, 'data-form-data' => s3_direct_post.fields.to_json, 'data-host' => URI.parse(s3_direct_post.url).host , 'data-type' => 'zip' %> | |
| 47 | - <% if form2.object.text_value.present? %> | |
| 48 | - <%= link_to 'file', form2.object.text_value %> | |
| 49 | - <% end %> | |
| 45 | + <%= form2.hidden_field :text_value %> | |
| 46 | + <div class="preview"> | |
| 47 | + <% if form2.object.text_value.present? %> | |
| 48 | + <% if Kanjai::PageContentMarker.image?(form2.object.text_value) %> | |
| 49 | + <div class="image-preview-block without-border"> | |
| 50 | + <div class="image-preview"> | |
| 51 | + <img src="<%= form2.object.text_value %>" alt="preview" /> | |
| 52 | + </div> | |
| 53 | + </div> | |
| 54 | + <% else %> | |
| 55 | + <%= link_to 'file', form2.object.text_value %> | |
| 56 | + <% end %> | |
| 57 | + <% end %> | |
| 58 | + </div> | |
| 59 | + <div class="btn-group"> | |
| 60 | + <%= link_to t('actions.choose_file'), get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %> | |
| 61 | + <%= link_to t('actions.remove_file'), get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %> | |
| 62 | + </div> | |
| 50 | 63 | <% end %> |
| 51 | 64 | |
| 52 | 65 | </div> | ... | ... |
| 1 | +<div class="row"> | |
| 2 | + <div class="col-xl-12"> | |
| 3 | + <!-- START card--> | |
| 4 | + <div class="card card-default"> | |
| 5 | + <div class="card-header"> | |
| 6 | + <div class="row"> | |
| 7 | + <div class="col-md-8"> | |
| 8 | + <%= t('admin.pages.page_title') %> | |
| 9 | + </div> | |
| 10 | + <div class="col-md-4 text-right"> | |
| 11 | + <%= link_to t('admin.pages.add_new'), new_admin_page_url(domain_id: domain.id), class: 'btn btn-primary' %> | |
| 12 | + </div> | |
| 13 | + </div> | |
| 14 | + </div> | |
| 15 | + <div class="card-body"> | |
| 16 | + <div class=""> | |
| 17 | + <div class="nestable-page-list dd dd-full-width page-list" data-sort-url="<%= sort_admin_pages_path %>"> | |
| 18 | + <ol class="dd-list"> | |
| 19 | + <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: domain.pages.where(parent: nil).order(:position)} %> | |
| 20 | + </ol> | |
| 21 | + </div> | |
| 22 | + </div> | |
| 23 | + </div> | |
| 24 | + </div><!-- END card--> | |
| 25 | + </div> | |
| 26 | +</div> | |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | |
| 6 | 6 | <div class="card card-default"> |
| 7 | 7 | <div class="card-header"> |
| 8 | + <%= link_to t('back_to_page_list'), admin_pages_path(domain_id: @page.domain.id) %> | |
| 8 | 9 | <div class="card-title"><%= t('admin.pages.edit', title: @page.lang_attributes(Kanjai::PageLang.default(@page.domain), :title)) %></div> |
| 9 | 10 | </div> |
| 10 | 11 | <%= render partial: 'form' %> | ... | ... |
| 1 | 1 | <div class="content-wrapper"> |
| 2 | 2 | |
| 3 | - | |
| 4 | - <div id="accordion"> | |
| 5 | - <% Kanjai::Domain.order(:title).each do |domain| %> | |
| 6 | - <div class="card card-default mb-1"> | |
| 7 | - <div class="card-header" id="domain-headline-<%= domain.id %>"> | |
| 8 | - <h4 class="mb-0"><a class="text-inherit" data-toggle="collapse" data-target="#domain-<%= domain.id %>" aria-expanded="true" aria-controls="domain-<%= domain.id %>" href=""><%= domain.title %></a></h4> | |
| 9 | - </div> | |
| 10 | - <div class="collapse <%= params[:domain_id].to_i == domain.id ? 'show' : '' %>" id="domain-<%= domain.id %>" aria-labelledby="domain-headline-<%= domain.id %>" data-parent="#accordion" style=""> | |
| 11 | - <div class="card-body border-top"> | |
| 12 | - | |
| 13 | - | |
| 14 | - <div class="row"> | |
| 15 | - <div class="col-xl-12"> | |
| 16 | - <!-- START card--> | |
| 17 | - <div class="card card-default"> | |
| 18 | - <div class="card-header"> | |
| 19 | - <div class="row"> | |
| 20 | - <div class="col-md-8"> | |
| 21 | - <%= t('admin.pages.page_title') %> | |
| 22 | - </div> | |
| 23 | - <div class="col-md-4 text-right"> | |
| 24 | - <%= link_to t('admin.pages.add_new'), new_admin_page_url(domain_id: domain.id), class: 'btn btn-primary' %> | |
| 25 | - </div> | |
| 26 | - </div> | |
| 27 | - </div> | |
| 28 | - <div class="card-body"> | |
| 29 | - <div class=""> | |
| 30 | - <div class="nestable-page-list dd dd-full-width page-list"> | |
| 31 | - <ol class="dd-list"> | |
| 32 | - <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: domain.pages.where(parent: nil).order(:position)} %> | |
| 33 | - </ol> | |
| 34 | - </div> | |
| 35 | - </div> | |
| 36 | - </div> | |
| 37 | - </div><!-- END card--> | |
| 38 | - </div> | |
| 39 | - </div> | |
| 40 | - | |
| 41 | - | |
| 42 | - </div> | |
| 43 | - </div> | |
| 44 | - </div> | |
| 45 | - <% end %> | |
| 46 | - </div> | |
| 3 | + <% if Kanjai::Domain.count == 1 %> | |
| 4 | + <%= render partial: 'kanjai/admin/pages/pages_one_domain', locals: {domain: Kanjai::Domain.first} %> | |
| 5 | + <% else %> | |
| 6 | + <div id="accordion"> | |
| 7 | + <% Kanjai::Domain.order(:title).each do |domain| %> | |
| 8 | + <div class="card card-default mb-1"> | |
| 9 | + <div class="card-header" id="domain-headline-<%= domain.id %>"> | |
| 10 | + <h4 class="mb-0"><a class="text-inherit" data-toggle="collapse" data-target="#domain-<%= domain.id %>" aria-expanded="true" aria-controls="domain-<%= domain.id %>" href=""><%= domain.title %></a></h4> | |
| 11 | + </div> | |
| 12 | + <div class="collapse <%= params[:domain_id].to_i == domain.id ? 'show' : '' %>" id="domain-<%= domain.id %>" aria-labelledby="domain-headline-<%= domain.id %>" data-parent="#accordion" style=""> | |
| 13 | + <div class="card-body border-top"> | |
| 14 | + <%= render partial: 'kanjai/admin/pages/pages_one_domain', locals: {domain: domain} %> | |
| 15 | + </div> | |
| 16 | + </div> | |
| 17 | + </div> | |
| 18 | + <% end %> | |
| 19 | + </div> | |
| 20 | + <% end %> | |
| 47 | 21 | |
| 48 | 22 | |
| 49 | 23 | </div> | ... | ... |
| ... | ... | @@ -91,6 +91,8 @@ |
| 91 | 91 | </div> |
| 92 | 92 | <div class="col-md-6"> |
| 93 | 93 | <div class="float-right"> |
| 94 | + <%= link_to t('back_to_page_list'), admin_pages_path(domain_id: @page.domain.id), class: 'btn btn-secondary' %> | |
| 95 | + | |
| 94 | 96 | <%= link_to t('actions.reset'), 'javascript:void(0)', class: 'btn btn-secondary btn-form-reset' %> |
| 95 | 97 | <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> |
| 96 | 98 | </div> | ... | ... |
| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | <div class="card-footer mt-20"> |
| 29 | 29 | <div class="clearfix"> |
| 30 | 30 | <div class="float-right"> |
| 31 | + <%= link_to t('back_to_page_list'), admin_pages_path(domain_id: @page.domain.id), class: 'btn btn-secondary' %> | |
| 31 | 32 | <%= link_to t('actions.reset'), 'javascript:void(0)', class: 'btn btn-secondary btn-form-reset' %> |
| 32 | 33 | <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> |
| 33 | 34 | </div> | ... | ... |
| ... | ... | @@ -46,7 +46,7 @@ en: |
| 46 | 46 | rte_choose_image: "Choose Image" |
| 47 | 47 | add_alternative_domain: "Add Alternative Domain" |
| 48 | 48 | tag_input_help_text: "Type the name of the tag and finish the input with enter" |
| 49 | - | |
| 49 | + back_to_page_list: "Back to page overview" | |
| 50 | 50 | |
| 51 | 51 | date: |
| 52 | 52 | formats: | ... | ... |
| ... | ... | @@ -34,7 +34,7 @@ Kanjai::Engine.routes.draw do |
| 34 | 34 | get :clone, on: :member |
| 35 | 35 | post :meta_update, on: :member |
| 36 | 36 | |
| 37 | - get :sort, on: :member | |
| 37 | + post :sort, on: :collection | |
| 38 | 38 | get :structure, on: :member |
| 39 | 39 | get :save_structure, on: :member |
| 40 | 40 | post :delete_content, on: :member | ... | ... |