Showing
28 changed files
with
382 additions
and
97 deletions
| 1 | PATH | 1 | PATH |
| 2 | remote: . | 2 | remote: . |
| 3 | specs: | 3 | specs: |
| 4 | - kanjai (0.0.155) | 4 | + kanjai (0.0.198) |
| 5 | acts-as-taggable-on (~> 6.5) | 5 | acts-as-taggable-on (~> 6.5) |
| 6 | acts_as_list | 6 | acts_as_list |
| 7 | acts_as_tree | 7 | acts_as_tree |
| @@ -970,11 +970,11 @@ GEM | @@ -970,11 +970,11 @@ GEM | ||
| 970 | aws-sigv2 (1.0.1) | 970 | aws-sigv2 (1.0.1) |
| 971 | aws-sigv4 (1.1.4) | 971 | aws-sigv4 (1.1.4) |
| 972 | aws-eventstream (~> 1.0, >= 1.0.2) | 972 | aws-eventstream (~> 1.0, >= 1.0.2) |
| 973 | - bcrypt (3.1.13) | 973 | + bcrypt (3.1.15) |
| 974 | builder (3.2.4) | 974 | builder (3.2.4) |
| 975 | concurrent-ruby (1.1.6) | 975 | concurrent-ruby (1.1.6) |
| 976 | crass (1.0.6) | 976 | crass (1.0.6) |
| 977 | - devise (4.7.1) | 977 | + devise (4.7.2) |
| 978 | bcrypt (~> 3.0) | 978 | bcrypt (~> 3.0) |
| 979 | orm_adapter (~> 0.1) | 979 | orm_adapter (~> 0.1) |
| 980 | railties (>= 4.1.0) | 980 | railties (>= 4.1.0) |
| 1 | +module Kanjai | ||
| 2 | + class Admin::DomainsController < AdminController | ||
| 3 | + | ||
| 4 | + def index | ||
| 5 | + @collection = Domain.order(:title) | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + def new | ||
| 9 | + @domain = Domain.new | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + def create | ||
| 13 | + @domain = Domain.new(permitted_params[:domain]) | ||
| 14 | + | ||
| 15 | + if @domain.save | ||
| 16 | + redirect_to admin_domains_url | ||
| 17 | + else | ||
| 18 | + render :action => :new | ||
| 19 | + end | ||
| 20 | + end | ||
| 21 | + | ||
| 22 | + def edit | ||
| 23 | + @domain = Domain.find(params[:id]) | ||
| 24 | + end | ||
| 25 | + | ||
| 26 | + def update | ||
| 27 | + @domain = Domain.find(params[:id]) | ||
| 28 | + if @domain.update(permitted_params[:domain]) | ||
| 29 | + redirect_to admin_domains_url | ||
| 30 | + else | ||
| 31 | + render action: :edit | ||
| 32 | + end | ||
| 33 | + | ||
| 34 | + end | ||
| 35 | + | ||
| 36 | + def destroy | ||
| 37 | + @domain = Domain.find(params[:id]) | ||
| 38 | + @domain.destroy | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + render :json => {:status => 'ok'}.to_json | ||
| 42 | + | ||
| 43 | + end | ||
| 44 | + | ||
| 45 | + private | ||
| 46 | + | ||
| 47 | + def permitted_params | ||
| 48 | + params.permit(:domain => [:title]) | ||
| 49 | + end | ||
| 50 | + | ||
| 51 | + end | ||
| 52 | +end |
| @@ -6,16 +6,18 @@ module Kanjai | @@ -6,16 +6,18 @@ module Kanjai | ||
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | def new | 8 | def new |
| 9 | + @domain = Domain.find(params[:domain_id]) | ||
| 9 | @page_lang = PageLang.new | 10 | @page_lang = PageLang.new |
| 11 | + @page_lang.domain = @domain | ||
| 10 | end | 12 | end |
| 11 | 13 | ||
| 12 | def create | 14 | def create |
| 15 | + @page_lang = PageLang.new(permitted_params[:page_lang]) | ||
| 16 | + | ||
| 13 | if params[:page_lang][:default_use].to_i == 1 | 17 | if params[:page_lang][:default_use].to_i == 1 |
| 14 | - PageLang.all.each {|item| item.update_column(:default_use, false) } | 18 | + @page_lang.domain.page_langs.all.each {|item| item.update_column(:default_use, false) } |
| 15 | end | 19 | end |
| 16 | 20 | ||
| 17 | - @page_lang = PageLang.new(permitted_params[:page_lang]) | ||
| 18 | - | ||
| 19 | if @page_lang.save | 21 | if @page_lang.save |
| 20 | redirect_to admin_page_langs_url | 22 | redirect_to admin_page_langs_url |
| 21 | else | 23 | else |
| @@ -28,11 +30,11 @@ module Kanjai | @@ -28,11 +30,11 @@ module Kanjai | ||
| 28 | end | 30 | end |
| 29 | 31 | ||
| 30 | def update | 32 | def update |
| 33 | + @page_lang = PageLang.find(params[:id]) | ||
| 31 | if params[:page_lang][:default_use].to_i == 1 | 34 | if params[:page_lang][:default_use].to_i == 1 |
| 32 | - PageLang.all.each {|item| item.update_column(:default_use, false) } | 35 | + @page_lang.domain.page_langs.all.each {|item| item.update_column(:default_use, false) } |
| 33 | end | 36 | end |
| 34 | 37 | ||
| 35 | - @page_lang = PageLang.find(params[:id]) | ||
| 36 | if @page_lang.update(permitted_params[:page_lang]) | 38 | if @page_lang.update(permitted_params[:page_lang]) |
| 37 | redirect_to admin_page_langs_url | 39 | redirect_to admin_page_langs_url |
| 38 | else | 40 | else |
| @@ -53,7 +55,7 @@ module Kanjai | @@ -53,7 +55,7 @@ module Kanjai | ||
| 53 | private | 55 | private |
| 54 | 56 | ||
| 55 | def permitted_params | 57 | def permitted_params |
| 56 | - params.permit(:page_lang => [:code, :title, :default_use]) | 58 | + params.permit(:page_lang => [:code, :title, :default_use, :domain_id]) |
| 57 | end | 59 | end |
| 58 | 60 | ||
| 59 | end | 61 | end |
| 1 | module Kanjai | 1 | module Kanjai |
| 2 | class Admin::PagesController < AdminController | 2 | class Admin::PagesController < AdminController |
| 3 | 3 | ||
| 4 | - before_action :get_page_list, :only => [:new, :create] | ||
| 5 | - before_action :get_page_list_without_current, :only => [:edit, :update] | ||
| 6 | - | ||
| 7 | def new | 4 | def new |
| 8 | @page = Page.new | 5 | @page = Page.new |
| 6 | + @domain = Domain.find(params[:domain_id]) | ||
| 7 | + @page.domain = @domain | ||
| 8 | + | ||
| 9 | + get_page_list(@domain) | ||
| 10 | + | ||
| 9 | end | 11 | end |
| 10 | 12 | ||
| 11 | def create | 13 | def create |
| 12 | 14 | ||
| 13 | @page = Page.new(permitted_params[:page]) | 15 | @page = Page.new(permitted_params[:page]) |
| 14 | 16 | ||
| 17 | + get_page_list(@page.domain) | ||
| 18 | + | ||
| 15 | if @page.save | 19 | if @page.save |
| 16 | 20 | ||
| 17 | if @page.default_private_page | 21 | if @page.default_private_page |
| @@ -44,6 +48,9 @@ module Kanjai | @@ -44,6 +48,9 @@ module Kanjai | ||
| 44 | @page = Page.find(params[:id]) | 48 | @page = Page.find(params[:id]) |
| 45 | @page_data = @page.page_data.find_by_lang(params[:lang]) | 49 | @page_data = @page.page_data.find_by_lang(params[:lang]) |
| 46 | 50 | ||
| 51 | + get_page_list_without_current(@page.domain) | ||
| 52 | + | ||
| 53 | + | ||
| 47 | @step = 'general' | 54 | @step = 'general' |
| 48 | 55 | ||
| 49 | if @page_data.nil? | 56 | if @page_data.nil? |
| @@ -58,6 +65,9 @@ module Kanjai | @@ -58,6 +65,9 @@ module Kanjai | ||
| 58 | @page = Page.find(params[:id]) | 65 | @page = Page.find(params[:id]) |
| 59 | @page_data = @page.page_data.find_by_lang(params[:lang]) | 66 | @page_data = @page.page_data.find_by_lang(params[:lang]) |
| 60 | @step = 'general' | 67 | @step = 'general' |
| 68 | + | ||
| 69 | + get_page_list_without_current(@page.domain) | ||
| 70 | + | ||
| 61 | if @page.update(permitted_params[:page]) | 71 | if @page.update(permitted_params[:page]) |
| 62 | 72 | ||
| 63 | if @page.default_private_page | 73 | if @page.default_private_page |
| @@ -73,7 +83,7 @@ module Kanjai | @@ -73,7 +83,7 @@ module Kanjai | ||
| 73 | end | 83 | end |
| 74 | end | 84 | end |
| 75 | 85 | ||
| 76 | - redirect_to :action => :index | 86 | + redirect_to admin_pages_path(domain_id: @page.domain.id) |
| 77 | else | 87 | else |
| 78 | render :action => :edit, lang: params[:lang] | 88 | render :action => :edit, lang: params[:lang] |
| 79 | end | 89 | end |
| @@ -293,7 +303,7 @@ module Kanjai | @@ -293,7 +303,7 @@ module Kanjai | ||
| 293 | private | 303 | private |
| 294 | 304 | ||
| 295 | def permitted_params | 305 | def permitted_params |
| 296 | - params.permit(:page => [:parent_id, :page_template_id, :title, :private_flag, :default_private_page, :root_page, :show_public_only, | 306 | + params.permit(:page => [:parent_id, :domain_id, :page_template_id, :title, :private_flag, :default_private_page, :root_page, :show_public_only, |
| 297 | :page_data_attributes => [:id, :title, :url, :meta_title, :meta_description, :meta_keywords]], | 307 | :page_data_attributes => [:id, :title, :url, :meta_title, :meta_description, :meta_keywords]], |
| 298 | :page_content => [:type_content, :text_html, :controller_name, :action_name, | 308 | :page_content => [:type_content, :text_html, :controller_name, :action_name, |
| 299 | page_content_markers_attributes: [:id, :page_content_id, :marker, :text_value, :attachment_file_name, :form_subject, :form_body, :from_mail, :to_mail, :form_answer_text, :_destroy] | 309 | page_content_markers_attributes: [:id, :page_content_id, :marker, :text_value, :attachment_file_name, :form_subject, :form_body, :from_mail, :to_mail, :form_answer_text, :_destroy] |
| @@ -302,17 +312,17 @@ module Kanjai | @@ -302,17 +312,17 @@ module Kanjai | ||
| 302 | ) | 312 | ) |
| 303 | end | 313 | end |
| 304 | 314 | ||
| 305 | - def get_page_list | 315 | + def get_page_list(domain) |
| 306 | @pages = [] | 316 | @pages = [] |
| 307 | - Page.walk_tree do |page, level| | 317 | + domain.pages.walk_tree do |page, level| |
| 308 | @pages << {title: page.lang_attributes(PageLang.default, :title), level: level, id: page.id} | 318 | @pages << {title: page.lang_attributes(PageLang.default, :title), level: level, id: page.id} |
| 309 | end | 319 | end |
| 310 | end | 320 | end |
| 311 | 321 | ||
| 312 | - def get_page_list_without_current | 322 | + def get_page_list_without_current(domain) |
| 313 | @pages = [] | 323 | @pages = [] |
| 314 | object = Page.find(params[:id]) | 324 | object = Page.find(params[:id]) |
| 315 | - Page.where('id <> ?', object.id).walk_tree do |page, level| | 325 | + domain.pages.where('id <> ?', object.id).walk_tree do |page, level| |
| 316 | @pages << {title: page.lang_attributes(PageLang.default, :title), level: level, id: page.id} | 326 | @pages << {title: page.lang_attributes(PageLang.default, :title), level: level, id: page.id} |
| 317 | end | 327 | end |
| 318 | end | 328 | end |
| @@ -37,15 +37,21 @@ module Kanjai | @@ -37,15 +37,21 @@ module Kanjai | ||
| 37 | $original_fullpath = request.original_fullpath | 37 | $original_fullpath = request.original_fullpath |
| 38 | $original_format = request.format | 38 | $original_format = request.format |
| 39 | 39 | ||
| 40 | + $domain = Domain.where(title: request.domain).first | ||
| 41 | + | ||
| 42 | + if $domain.nil? | ||
| 43 | + render plain: 'Domain Not Exist' and return | ||
| 44 | + end | ||
| 45 | + | ||
| 40 | #@page_data = PageDatum.where(:url => @url).first | 46 | #@page_data = PageDatum.where(:url => @url).first |
| 41 | #$current_locale = PageLang.where(default_use: true).first.code | 47 | #$current_locale = PageLang.where(default_use: true).first.code |
| 42 | - @page_data = PageDatum.where(:url => @url, lang: I18n.locale).first | 48 | + @page_data = PageDatum.joins(page: :domain).where(kanjai_domains: {id: $domain.id}).where(:url => @url, lang: I18n.locale).first |
| 43 | $current_locale = I18n.locale | 49 | $current_locale = I18n.locale |
| 44 | if @page_data.nil? | 50 | if @page_data.nil? |
| 45 | mas = @url.split('/') | 51 | mas = @url.split('/') |
| 46 | if mas.length > 1 | 52 | if mas.length > 1 |
| 47 | @url = '/' + mas[1] + '/:path' | 53 | @url = '/' + mas[1] + '/:path' |
| 48 | - @page_data = PageDatum.where(:url => @url, lang: I18n.locale).first | 54 | + @page_data = PageDatum.joins(page: :domain).where(kanjai_domains: {id: $domain.id}).where(:url => @url, lang: I18n.locale).first |
| 49 | end | 55 | end |
| 50 | end | 56 | end |
| 51 | 57 | ||
| @@ -54,7 +60,7 @@ module Kanjai | @@ -54,7 +60,7 @@ module Kanjai | ||
| 54 | #$current_locale = @page_data.lang | 60 | #$current_locale = @page_data.lang |
| 55 | else | 61 | else |
| 56 | if @url == '/' | 62 | if @url == '/' |
| 57 | - root_page = Page.where(root_page: true).first | 63 | + root_page = Page.joins(:domain).where(kanjai_domains: {id: $domain.id}).where(root_page: true).first |
| 58 | if root_page | 64 | if root_page |
| 59 | redirect_to root_page.menu_url($scheme) | 65 | redirect_to root_page.menu_url($scheme) |
| 60 | end | 66 | end |
app/models/kanjai/domain.rb
0 → 100644
| @@ -9,7 +9,9 @@ module Kanjai | @@ -9,7 +9,9 @@ module Kanjai | ||
| 9 | include ActiveRecord::Acts::Tree | 9 | include ActiveRecord::Acts::Tree |
| 10 | include ActiveRecord::Acts::List | 10 | include ActiveRecord::Acts::List |
| 11 | 11 | ||
| 12 | - acts_as_tree order: 'position' | 12 | + belongs_to :domain |
| 13 | + | ||
| 14 | + acts_as_tree order: 'position', scope: :domain_id | ||
| 13 | acts_as_list :scope => :parent_id | 15 | acts_as_list :scope => :parent_id |
| 14 | 16 | ||
| 15 | belongs_to :page_template | 17 | belongs_to :page_template |
| 1 | module Kanjai | 1 | module Kanjai |
| 2 | class PageLang < ActiveRecord::Base | 2 | class PageLang < ActiveRecord::Base |
| 3 | 3 | ||
| 4 | + belongs_to :domain | ||
| 5 | + | ||
| 4 | validates :code, :title, presence: true | 6 | validates :code, :title, presence: true |
| 5 | 7 | ||
| 6 | default_scope { order('code') } | 8 | default_scope { order('code') } |
| 7 | 9 | ||
| 8 | def self.default | 10 | def self.default |
| 9 | - obj = PageLang.where(:default_use => true).first | 11 | + obj = domain.page_langs.where(:default_use => true).first |
| 10 | if obj.nil? | 12 | if obj.nil? |
| 11 | return 'en' | 13 | return 'en' |
| 12 | else | 14 | else |
| 1 | +<div class="card-body"> | ||
| 2 | + | ||
| 3 | + <div class="form-group"> | ||
| 4 | + <%= f.label :title, Kanjai::Domain.human_attribute_name(:title) + ' *', class: 'col-form-label' %> | ||
| 5 | + <%= f.text_field :title, class: "form-control #{@domain.errors.include?(:title) ? 'parsley-error' : ''} " %> | ||
| 6 | + <%= error_messages(@domain, :title) %> | ||
| 7 | + </div> | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + <div class="card-footer mt-20"> | ||
| 11 | + <div class="clearfix"> | ||
| 12 | + <div class="row"> | ||
| 13 | + <div class="col-md-6"> | ||
| 14 | + <p class="mt-1"><%= t('mandatory_fields') %></p> | ||
| 15 | + </div> | ||
| 16 | + <div class="col-md-6 text-right"> | ||
| 17 | + <%= link_to t('actions.cancel'), admin_domains_url, class: 'btn btn-secondary' %> | ||
| 18 | + <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | ||
| 19 | + </div> | ||
| 20 | + </div> | ||
| 21 | + </div> | ||
| 22 | + </div> | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +</div> | ||
| 26 | + |
app/views/kanjai/admin/domains/edit.html.erb
0 → 100644
| 1 | +<div class="content-wrapper"> | ||
| 2 | + <div class="row"> | ||
| 3 | + <div class="col-xl-12"> | ||
| 4 | + | ||
| 5 | + <%= form_for @domain, url: admin_domain_url(@domain), class: 'form-horizontal', method: 'PUT', novalidate: '', data: {parsley_validate: ''} do |f| %> | ||
| 6 | + <div class="card card-default"> | ||
| 7 | + <div class="card-header"> | ||
| 8 | + <div class="card-title"><%= t('admin.domains.edit') %></div> | ||
| 9 | + </div> | ||
| 10 | + <%= render partial: 'form', locals: {f: f} %> | ||
| 11 | + </div> | ||
| 12 | + <% end %> | ||
| 13 | + | ||
| 14 | + </div> | ||
| 15 | + </div> | ||
| 16 | +</div> |
| 1 | +<div class="content-wrapper"> | ||
| 2 | + <div class="row"> | ||
| 3 | + <div class="col-xl-12"> | ||
| 4 | + <!-- START card--> | ||
| 5 | + <div class="card card-default"> | ||
| 6 | + <div class="card-header"> | ||
| 7 | + <div class="row"> | ||
| 8 | + <div class="col-md-8"> | ||
| 9 | + <%= t('admin.domains.title') %> | ||
| 10 | + </div> | ||
| 11 | + <div class="col-md-4 text-right"> | ||
| 12 | + <%= link_to I18n.t('admin.domains.create'), new_admin_domain_url, class: 'btn btn-primary' %> | ||
| 13 | + </div> | ||
| 14 | + </div> | ||
| 15 | + </div> | ||
| 16 | + <div class="card-body"> | ||
| 17 | + <!-- START table-responsive--> | ||
| 18 | + <div class="table-responsive"> | ||
| 19 | + <table class="table"> | ||
| 20 | + <thead> | ||
| 21 | + <tr> | ||
| 22 | + <th><%= Kanjai::Domain.human_attribute_name(:title) %></th> | ||
| 23 | + <th width="50px"></th> | ||
| 24 | + </tr> | ||
| 25 | + </thead> | ||
| 26 | + <tbody> | ||
| 27 | + <% @collection.each do |item| %> | ||
| 28 | + <tr id='<%= dom_id(item) %>'> | ||
| 29 | + <td><%= item.title %></td> | ||
| 30 | + <td> | ||
| 31 | + <div class="dropdown"> | ||
| 32 | + <button class="btn btn-secondary dropdown-toggle dropdown-toggle-nocaret" type="button" data-toggle="dropdown" aria-expanded="false"> | ||
| 33 | + <span class="dropdown-text"><span class="icon icon-options-vertical"></span></span> | ||
| 34 | + </button> | ||
| 35 | + <ul class="dropdown-menu"> | ||
| 36 | + <li class="dropdown-item"><%= link_to t('actions.edit'), edit_admin_domain_url(item), class: 'dropdown-item' %></li> | ||
| 37 | + <li class="dropdown-item"><%= link_to t('actions.delete'), admin_domain_url(item), :class => 'delete-row-item dropdown-item' %></li> | ||
| 38 | + </ul> | ||
| 39 | + </div> | ||
| 40 | + </td> | ||
| 41 | + </tr> | ||
| 42 | + <% end %> | ||
| 43 | + | ||
| 44 | + </tbody> | ||
| 45 | + </table> | ||
| 46 | + </div><!-- END table-responsive--> | ||
| 47 | + </div> | ||
| 48 | + </div><!-- END card--> | ||
| 49 | + </div> | ||
| 50 | + </div> | ||
| 51 | +</div> |
app/views/kanjai/admin/domains/new.html.erb
0 → 100644
| 1 | +<div class="content-wrapper"> | ||
| 2 | + <div class="row"> | ||
| 3 | + <div class="col-xl-12"> | ||
| 4 | + | ||
| 5 | + <%= form_for @domain, url: admin_domains_url, class: 'form-horizontal', novalidate: '', data: {parsley_validate: ''} do |f| %> | ||
| 6 | + <div class="card card-default"> | ||
| 7 | + <div class="card-header"> | ||
| 8 | + <div class="card-title"><%= t('admin.domains.create') %></div> | ||
| 9 | + </div> | ||
| 10 | + <%= render partial: 'form', locals: {f: f} %> | ||
| 11 | + </div> | ||
| 12 | + <% end %> | ||
| 13 | + | ||
| 14 | + </div> | ||
| 15 | + </div> | ||
| 16 | +</div> |
| 1 | +<%= f.hidden_field :domain_id, :class => "form-control" %> | ||
| 2 | + | ||
| 1 | <div class="card-body"> | 3 | <div class="card-body"> |
| 2 | <div class="form-group"> | 4 | <div class="form-group"> |
| 3 | <%= f.label :code, Kanjai::PageLang.human_attribute_name(:code) + ' *', class: 'col-form-label' %> | 5 | <%= f.label :code, Kanjai::PageLang.human_attribute_name(:code) + ' *', class: 'col-form-label' %> |
| @@ -2,52 +2,70 @@ | @@ -2,52 +2,70 @@ | ||
| 2 | <div class="row"> | 2 | <div class="row"> |
| 3 | <div class="col-xl-12"> | 3 | <div class="col-xl-12"> |
| 4 | <!-- START card--> | 4 | <!-- START card--> |
| 5 | - <div class="card card-default"> | ||
| 6 | - <div class="card-header"> | ||
| 7 | - <div class="row"> | ||
| 8 | - <div class="col-md-8"> | ||
| 9 | - <%= t('admin.page_langs.title') %> | ||
| 10 | - </div> | ||
| 11 | - <div class="col-md-4 text-right"> | ||
| 12 | - <%= link_to I18n.t('admin.page_langs.create'), new_admin_page_lang_url, class: 'btn btn-primary' %> | ||
| 13 | - </div> | ||
| 14 | - </div> | 5 | + |
| 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> | ||
| 15 | </div> | 11 | </div> |
| 16 | - <div class="card-body"> | ||
| 17 | - <!-- START table-responsive--> | ||
| 18 | - <div class="table-responsive"> | ||
| 19 | - <table class="table"> | ||
| 20 | - <thead> | ||
| 21 | - <tr> | ||
| 22 | - <th><%= Kanjai::PageLang.human_attribute_name(:code) %></th> | ||
| 23 | - <th><%= Kanjai::PageLang.human_attribute_name(:title) %></th> | ||
| 24 | - <th width="50px"></th> | ||
| 25 | - </tr> | ||
| 26 | - </thead> | ||
| 27 | - <tbody> | ||
| 28 | - <% @collection.each do |item| %> | ||
| 29 | - <tr id='<%= dom_id(item) %>'> | ||
| 30 | - <td><%= item.code %></td> | ||
| 31 | - <td><%= item.title %></td> | ||
| 32 | - <td> | ||
| 33 | - <div class="dropdown"> | ||
| 34 | - <button class="btn btn-secondary dropdown-toggle dropdown-toggle-nocaret" type="button" data-toggle="dropdown" aria-expanded="false"> | ||
| 35 | - <span class="dropdown-text"><span class="icon icon-options-vertical"></span></span> | ||
| 36 | - </button> | ||
| 37 | - <ul class="dropdown-menu"> | ||
| 38 | - <li class="dropdown-item"><%= link_to t('actions.edit'), edit_admin_page_lang_url(item), class: 'dropdown-item' %></li> | ||
| 39 | - <li class="dropdown-item"><%= link_to t('actions.delete'), admin_page_lang_url(item), :class => 'delete-row-item dropdown-item' %></li> | ||
| 40 | - </ul> | ||
| 41 | - </div> | ||
| 42 | - </td> | ||
| 43 | - </tr> | ||
| 44 | - <% end %> | 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 | + <div class="card card-default"> | ||
| 15 | + <div class="card-header"> | ||
| 16 | + <div class="row"> | ||
| 17 | + <div class="col-md-8"> | ||
| 18 | + <%= t('admin.page_langs.title') %> | ||
| 19 | + </div> | ||
| 20 | + <div class="col-md-4 text-right"> | ||
| 21 | + <%= link_to I18n.t('admin.page_langs.create'), new_admin_page_lang_url(domain_id: domain.id), class: 'btn btn-primary' %> | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 24 | + </div> | ||
| 25 | + <div class="card-body"> | ||
| 26 | + <!-- START table-responsive--> | ||
| 27 | + <div class="table-responsive"> | ||
| 28 | + <table class="table"> | ||
| 29 | + <thead> | ||
| 30 | + <tr> | ||
| 31 | + <th><%= Kanjai::PageLang.human_attribute_name(:code) %></th> | ||
| 32 | + <th><%= Kanjai::PageLang.human_attribute_name(:title) %></th> | ||
| 33 | + <th width="50px"></th> | ||
| 34 | + </tr> | ||
| 35 | + </thead> | ||
| 36 | + <tbody> | ||
| 37 | + <% domain.page_langs.order(:code).each do |item| %> | ||
| 38 | + <tr id='<%= dom_id(item) %>'> | ||
| 39 | + <td><%= item.code %></td> | ||
| 40 | + <td><%= item.title %></td> | ||
| 41 | + <td> | ||
| 42 | + <div class="dropdown"> | ||
| 43 | + <button class="btn btn-secondary dropdown-toggle dropdown-toggle-nocaret" type="button" data-toggle="dropdown" aria-expanded="false"> | ||
| 44 | + <span class="dropdown-text"><span class="icon icon-options-vertical"></span></span> | ||
| 45 | + </button> | ||
| 46 | + <ul class="dropdown-menu"> | ||
| 47 | + <li class="dropdown-item"><%= link_to t('actions.edit'), edit_admin_page_lang_url(item), class: 'dropdown-item' %></li> | ||
| 48 | + <li class="dropdown-item"><%= link_to t('actions.delete'), admin_page_lang_url(item), :class => 'delete-row-item dropdown-item' %></li> | ||
| 49 | + </ul> | ||
| 50 | + </div> | ||
| 51 | + </td> | ||
| 52 | + </tr> | ||
| 53 | + <% end %> | ||
| 54 | + | ||
| 55 | + </tbody> | ||
| 56 | + </table> | ||
| 57 | + </div><!-- END table-responsive--> | ||
| 58 | + </div> | ||
| 59 | + </div><!-- END card--> | ||
| 60 | + | ||
| 45 | 61 | ||
| 46 | - </tbody> | ||
| 47 | - </table> | ||
| 48 | - </div><!-- END table-responsive--> | 62 | + </div> |
| 49 | </div> | 63 | </div> |
| 50 | - </div><!-- END card--> | 64 | + </div> |
| 65 | + <% end %> | ||
| 66 | + </div> | ||
| 67 | + | ||
| 68 | + | ||
| 51 | </div> | 69 | </div> |
| 52 | </div> | 70 | </div> |
| 53 | </div> | 71 | </div> |
| 1 | <div class="content-wrapper"> | 1 | <div class="content-wrapper"> |
| 2 | - <div class="row"> | ||
| 3 | - <div class="col-xl-12"> | ||
| 4 | - <!-- START card--> | ||
| 5 | - <div class="card card-default"> | ||
| 6 | - <div class="card-header"> | ||
| 7 | - <div class="row"> | ||
| 8 | - <div class="col-md-8"> | ||
| 9 | - <%= t('admin.pages.page_title') %> | ||
| 10 | - </div> | ||
| 11 | - <div class="col-md-4 text-right"> | ||
| 12 | - <%= link_to t('admin.pages.add_new'), new_admin_page_url, class: 'btn btn-primary' %> | ||
| 13 | - </div> | ||
| 14 | - </div> | 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> | ||
| 15 | </div> | 9 | </div> |
| 16 | - <div class="card-body"> | ||
| 17 | - <div class="table-responsive"> | ||
| 18 | - <div class="nestable-page-list dd dd-full-width page-list"> | ||
| 19 | - <ol class="dd-list"> | ||
| 20 | - <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: Kanjai::Page.where(parent: nil).order(:position)} %> | ||
| 21 | - </ol> | ||
| 22 | - </div> | ||
| 23 | - </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="table-responsive"> | ||
| 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> | ||
| 24 | </div> | 43 | </div> |
| 25 | - </div><!-- END card--> | ||
| 26 | - </div> | 44 | + </div> |
| 45 | + <% end %> | ||
| 27 | </div> | 46 | </div> |
| 47 | + | ||
| 48 | + | ||
| 28 | </div> | 49 | </div> |
| 29 | 50 | ||
| 30 | 51 |
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | <div class="card-footer mt-20"> | 19 | <div class="card-footer mt-20"> |
| 20 | <div class="clearfix"> | 20 | <div class="clearfix"> |
| 21 | <div class="float-right"> | 21 | <div class="float-right"> |
| 22 | - <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | 22 | + <%= link_to t('actions.cancel'), admin_pages_url(domain_id: @page.domain.id), class: 'btn btn-secondary' %> |
| 23 | <button class="btn btn-primary save" type="submit"><%= t('actions.save') %></button> | 23 | <button class="btn btn-primary save" type="submit"><%= t('actions.save') %></button> |
| 24 | </div> | 24 | </div> |
| 25 | </div> | 25 | </div> |
| 1 | <%= form_for(@page, :url => (@page.new_record? ? admin_pages_url : admin_page_url(@page, :lang => params[:lang])), :html => {:class => "form-horizontal ajax-file-upload-form simple_submit"}) do |form| %> | 1 | <%= form_for(@page, :url => (@page.new_record? ? admin_pages_url : admin_page_url(@page, :lang => params[:lang])), :html => {:class => "form-horizontal ajax-file-upload-form simple_submit"}) do |form| %> |
| 2 | 2 | ||
| 3 | + <%= form.hidden_field :domain_id, :class => "form-control" %> | ||
| 4 | + | ||
| 3 | <fieldset> | 5 | <fieldset> |
| 4 | <legend><%= t('admin.pages.edit_general_content') %></legend> | 6 | <legend><%= t('admin.pages.edit_general_content') %></legend> |
| 5 | 7 | ||
| @@ -89,7 +91,7 @@ | @@ -89,7 +91,7 @@ | ||
| 89 | </div> | 91 | </div> |
| 90 | <div class="col-md-6"> | 92 | <div class="col-md-6"> |
| 91 | <div class="float-right"> | 93 | <div class="float-right"> |
| 92 | - <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | 94 | + <%= link_to t('actions.cancel'), admin_pages_url(domain_id: @page.domain.id), class: 'btn btn-secondary' %> |
| 93 | <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | 95 | <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> |
| 94 | </div> | 96 | </div> |
| 95 | </div> | 97 | </div> |
| @@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
| 28 | <div class="card-footer mt-20"> | 28 | <div class="card-footer mt-20"> |
| 29 | <div class="clearfix"> | 29 | <div class="clearfix"> |
| 30 | <div class="float-right"> | 30 | <div class="float-right"> |
| 31 | - <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | 31 | + <%= link_to t('actions.cancel'), admin_pages_url(domain_id: @page.domain.id), class: 'btn btn-secondary' %> |
| 32 | <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | 32 | <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> |
| 33 | </div> | 33 | </div> |
| 34 | </div> | 34 | </div> |
| @@ -42,6 +42,9 @@ | @@ -42,6 +42,9 @@ | ||
| 42 | </div> | 42 | </div> |
| 43 | </li> | 43 | </li> |
| 44 | 44 | ||
| 45 | + <li class="nav-item <%= controller_name == 'domains' ? 'active' : '' %>"> | ||
| 46 | + <%= link_to t('domains_menu_title'), kanjai.admin_domains_url, :class => 'nav-link' %> | ||
| 47 | + </li> | ||
| 45 | <li class="nav-item <%= controller_name == 'pages' ? 'active' : '' %>"> | 48 | <li class="nav-item <%= controller_name == 'pages' ? 'active' : '' %>"> |
| 46 | <%= link_to t('pages_menu_title'), kanjai.admin_pages_url, :class => 'nav-link' %> | 49 | <%= link_to t('pages_menu_title'), kanjai.admin_pages_url, :class => 'nav-link' %> |
| 47 | </li> | 50 | </li> |
| @@ -25,6 +25,7 @@ en: | @@ -25,6 +25,7 @@ en: | ||
| 25 | templates_menu_title: "Templates" | 25 | templates_menu_title: "Templates" |
| 26 | images_menu_title: "Files" | 26 | images_menu_title: "Files" |
| 27 | user_menu_title: "Users" | 27 | user_menu_title: "Users" |
| 28 | + domains_menu_title: "Domains" | ||
| 28 | page_langs_menu_title: "Page Languages" | 29 | page_langs_menu_title: "Page Languages" |
| 29 | drop_your_file: "Drop your file here ..." | 30 | drop_your_file: "Drop your file here ..." |
| 30 | are_you_sure: "Are you sure?" | 31 | are_you_sure: "Are you sure?" |
| @@ -157,8 +158,15 @@ en: | @@ -157,8 +158,15 @@ en: | ||
| 157 | empty_text: "You don't have template" | 158 | empty_text: "You don't have template" |
| 158 | edit: "Edit template" | 159 | edit: "Edit template" |
| 159 | create: "Add new template" | 160 | create: "Add new template" |
| 161 | + domains: | ||
| 162 | + title: "Domains" | ||
| 163 | + add_new: "Add domain" | ||
| 164 | + empty_text: "Empty domain list" | ||
| 165 | + create: "Add new domain" | ||
| 166 | + edit: "Edit domain" | ||
| 160 | template_status: | 167 | template_status: |
| 161 | not_file: "" | 168 | not_file: "" |
| 162 | unzip: "Ready" | 169 | unzip: "Ready" |
| 163 | zip: "In Progress" | 170 | zip: "In Progress" |
| 164 | 171 | ||
| 172 | + |
| @@ -25,6 +25,8 @@ Kanjai::Engine.routes.draw do | @@ -25,6 +25,8 @@ Kanjai::Engine.routes.draw do | ||
| 25 | 25 | ||
| 26 | resources :admin_users | 26 | resources :admin_users |
| 27 | 27 | ||
| 28 | + resources :domains | ||
| 29 | + | ||
| 28 | resources :pages do | 30 | resources :pages do |
| 29 | get :markdown, on: :member | 31 | get :markdown, on: :member |
| 30 | get :html, on: :member | 32 | get :html, on: :member |
| @@ -31,7 +31,7 @@ module Kanjai | @@ -31,7 +31,7 @@ module Kanjai | ||
| 31 | content = item[:source] | 31 | content = item[:source] |
| 32 | if current_page | 32 | if current_page |
| 33 | content = content.gsub('###link###', current_page.menu_url('http://', lang = nil)) | 33 | content = content.gsub('###link###', current_page.menu_url('http://', lang = nil)) |
| 34 | - .gsub('###title###', current_page.lang_attributes(PageLang.default, :title)) | 34 | + .gsub('###title###', current_page.lang_attributes($domain.page_langs.default, :title)) |
| 35 | end | 35 | end |
| 36 | subparts << content | 36 | subparts << content |
| 37 | when 'repeat' | 37 | when 'repeat' |
| @@ -68,7 +68,7 @@ module Kanjai | @@ -68,7 +68,7 @@ module Kanjai | ||
| 68 | end | 68 | end |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | - page_collection = Page.order(:position) | 71 | + page_collection = Page.joins(:domain).where(kanjai_domains: {id: $domain.id}).order(:position) |
| 72 | 72 | ||
| 73 | if item[:attributes]["ids"].present? | 73 | if item[:attributes]["ids"].present? |
| 74 | page_collection = page_collection.where('id in (?)', item[:attributes]["ids"]) | 74 | page_collection = page_collection.where('id in (?)', item[:attributes]["ids"]) |
| @@ -147,7 +147,7 @@ module Kanjai | @@ -147,7 +147,7 @@ module Kanjai | ||
| 147 | elements.each do |item| | 147 | elements.each do |item| |
| 148 | case item[:name] | 148 | case item[:name] |
| 149 | when 'text' | 149 | when 'text' |
| 150 | - lang = PageLang.find_by_code($current_locale) | 150 | + lang = $domain.page_langs.find_by_code($current_locale) |
| 151 | content = item[:source] | 151 | content = item[:source] |
| 152 | content = content.gsub('###CURRENT_LANG_TITLE###', lang.title) | 152 | content = content.gsub('###CURRENT_LANG_TITLE###', lang.title) |
| 153 | .gsub('###CURRENT_LANG_CODE###', lang.code) | 153 | .gsub('###CURRENT_LANG_CODE###', lang.code) |
| @@ -178,7 +178,7 @@ module Kanjai | @@ -178,7 +178,7 @@ module Kanjai | ||
| 178 | if page_data | 178 | if page_data |
| 179 | page = page_data.page | 179 | page = page_data.page |
| 180 | end | 180 | end |
| 181 | - PageLang.all.each do |lang| | 181 | + $domain.page_langs.all.each do |lang| |
| 182 | if lang.code.to_s == $current_locale.to_s && active_state_template | 182 | if lang.code.to_s == $current_locale.to_s && active_state_template |
| 183 | content = active_state_template.gsub('###LANG_CODE###', lang.code) | 183 | content = active_state_template.gsub('###LANG_CODE###', lang.code) |
| 184 | .gsub('###LANG_TITLE###', lang.title) | 184 | .gsub('###LANG_TITLE###', lang.title) |
test/fixtures/kanjai/domains.yml
0 → 100644
| 1 | +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
| 2 | + | ||
| 3 | +# This model initially had no columns defined. If you add columns to the | ||
| 4 | +# model remove the '{}' from the fixture names and add the columns immediately | ||
| 5 | +# below each fixture, per the syntax in the comments below | ||
| 6 | +# | ||
| 7 | +one: {} | ||
| 8 | +# column: value | ||
| 9 | +# | ||
| 10 | +two: {} | ||
| 11 | +# column: value |