Showing
5 changed files
with
33 additions
and
8 deletions
| ... | ... | @@ -2111,6 +2111,32 @@ jQuery(document).ready(function(){ |
| 2111 | 2111 | document.location.href = url; |
| 2112 | 2112 | }); |
| 2113 | 2113 | |
| 2114 | + $(document).on('ajax:before', '.template-form', function(){ | |
| 2115 | + var dialog = bootbox.dialog({ | |
| 2116 | + message: '<p class="text-center">Please wait ...</p>', | |
| 2117 | + closeButton: false, | |
| 2118 | + className: 'template-wait-layer', | |
| 2119 | + buttons: { | |
| 2120 | + 'close': { | |
| 2121 | + label: 'Close', | |
| 2122 | + className: 'btn-primary template-form-close-button', | |
| 2123 | + callback: function(){ | |
| 2124 | + document.location.href = $('.template-form .card-footer .btn-secondary').attr('href'); | |
| 2125 | + } | |
| 2126 | + } | |
| 2127 | + } | |
| 2128 | + }); | |
| 2129 | + }); | |
| 2130 | + | |
| 2131 | + $(document).on('ajax:success', '.template-form', function(e, data){ | |
| 2132 | + if($('.template-wait-layer').length > 0){ | |
| 2133 | + $('.template-wait-layer .modal-body .text-center').text('The template is successfully processed'); | |
| 2134 | + $('.template-wait-layer .modal-footer').css('display', 'flex'); | |
| 2135 | + } | |
| 2136 | + }); | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2114 | 2140 | }); |
| 2115 | 2141 | |
| 2116 | 2142 | ... | ... |
| ... | ... | @@ -17,9 +17,7 @@ module Kanjai |
| 17 | 17 | @page_template = PageTemplate.new(permitted_params[:page_template]) |
| 18 | 18 | |
| 19 | 19 | if @page_template.save |
| 20 | - redirect_to admin_page_templates_url | |
| 21 | - else | |
| 22 | - render action: :new | |
| 20 | + render json: {status: 'ok'} | |
| 23 | 21 | end |
| 24 | 22 | end |
| 25 | 23 | |
| ... | ... | @@ -54,9 +52,7 @@ module Kanjai |
| 54 | 52 | @page_template.unzip = false |
| 55 | 53 | |
| 56 | 54 | if @page_template.update(permitted_params[:page_template]) |
| 57 | - redirect_to admin_page_templates_url | |
| 58 | - else | |
| 59 | - render :action => :edit | |
| 55 | + render json: {status: 'ok'} | |
| 60 | 56 | end |
| 61 | 57 | |
| 62 | 58 | end | ... | ... |
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | </ul><!-- Tab panes--> |
| 20 | 20 | <div class="tab-content"> |
| 21 | 21 | <div class="tab-pane <%= controller_name == 'page_templates' ? 'active' : '' %>" id="general" role="tabpanel"> |
| 22 | - <%= form_for @page_template, url: admin_page_template_url(@page_template), html: {class: 'form-horizontal ajax-file-upload-form simple_submit'} do |f| %> | |
| 22 | + <%= form_for @page_template, url: admin_page_template_url(@page_template), remote: true, html: {class: 'form-horizontal ajax-file-upload-form simple_submit template-form'} do |f| %> | |
| 23 | 23 | <%= render partial: 'form', locals: {f: f} %> |
| 24 | 24 | <% end %> |
| 25 | 25 | </div> | ... | ... |
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <div class="row"> |
| 3 | 3 | <div class="col-xl-12"> |
| 4 | 4 | |
| 5 | - <%= form_for @page_template, url: admin_page_templates_path, html: {class: 'form-horizontal ajax-file-upload-form simple_submit'} do |f| %> | |
| 5 | + <%= form_for @page_template, url: admin_page_templates_path, remote: true, html: {class: 'form-horizontal ajax-file-upload-form simple_submit template-form'} do |f| %> | |
| 6 | 6 | <div class="card card-default"> |
| 7 | 7 | <div class="card-header"> |
| 8 | 8 | <div class="card-title"><%= t('admin.templates.create') %></div> | ... | ... |