Skip to content

Commit

Permalink
Merge 023bdaa into dd5b4aa
Browse files Browse the repository at this point in the history
  • Loading branch information
appirits-ymatsumoto committed Jun 3, 2015
2 parents dd5b4aa + 023bdaa commit f09290e
Show file tree
Hide file tree
Showing 23 changed files with 516 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#= require morris
#= require pace/pace
#= require gritter
#= require moment
#= require moment/ja
#= require bootstrap-datetimepicker
#= require_tree .

$( ->
# ---
# functions
# ---

initialize_beforeunload_event = ->
$form = $('form[method!="get"]')
$form.change(->
Expand Down Expand Up @@ -96,6 +98,9 @@ $( ->
$(document).on('change', '.btn-file :file', ->
$(this).closest('form').submit()
)

# datetimepicker setting
$('.datetimepicker').datetimepicker(format: 'YYYY-MM-DD HH:mm')
)
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
Expand Down
28 changes: 28 additions & 0 deletions backend/app/assets/stylesheets/comable/admin/_pages.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.slug {
-webkit-box-flex: 0;
display: flex;
}

.slug .url {
width: 60%;
overflow: scroll;
border: 1px solid #ccc;
background: #fafafa;
border-right: 0;
border-radius: 4px 0 0 4px;
}

.slug .url span {
color: #666;
display: inline-block;
font-size: 13px;
padding: 6px 4px 0 4px;
}

.slug .slug-body {
width: 40%;
}

.slug .slug-body input{
border-radius: 0 4px 4px 0;
}
2 changes: 2 additions & 0 deletions backend/app/assets/stylesheets/comable/admin/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import 'morris';
@import 'pace/white/pace-theme-minimal';
@import 'gritter';
@import 'bootstrap-datetimepicker';

@import 'comable/admin/mixins';
@import 'comable/admin/overrides';
Expand All @@ -18,4 +19,5 @@
@import 'comable/admin/dashboard';
@import 'comable/admin/orders';
@import 'comable/admin/products';
@import 'comable/admin/pages';
@import 'comable/admin/user_sessions';
61 changes: 61 additions & 0 deletions backend/app/controllers/comable/admin/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require_dependency 'comable/admin/application_controller'

module Comable
module Admin
class PagesController < Comable::Admin::ApplicationController
load_and_authorize_resource class: Comable::Page.name, except: :index

def index
@q = Comable::Page.ransack(params[:q])
@pages = @q.result(distinct: true).page(params[:page]).accessible_by(current_ability)
end

def show
render :edit
end

def new
end

def edit
end

def create
@page = Comable::Page.new(page_params)

if @page.save
redirect_to comable.admin_page_path(@page), notice: Comable.t('successful')
else
render :new
end
end

def update
if @page.update_attributes(page_params)
redirect_to comable.admin_page_path(@page), notice: Comable.t('successful')
else
render :edit
end
end

def destroy
@page.destroy
redirect_to admin_pages_url, notice: Comable.t('successful')
end

private

def page_params
params.require(:page).permit(
:title, # コンテンツのタイトル
:content, # コンテンツ
:page_title, # ページのタイトル
:meta_description, # ディスクリプション
:meta_keywords, # キーワード
:slug, # スラグ
:published_at # 公開日時
)
end
end
end
end
6 changes: 6 additions & 0 deletions backend/app/helpers/comable/admin/pages_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Comable
module Admin
module PagesHelper
end
end
end
61 changes: 61 additions & 0 deletions backend/app/views/comable/admin/pages/_form.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
= error_messages_for @page

- url = @page.new_record? ? comable.admin_pages_path : comable.admin_page_path(@page)

= form_for @page, url: url, html: { multipart: true } do |f|
.hidden
= f.submit

fieldset
.col-md-3
legend
= Comable.t('admin.nav.pages.general')

.col-md-9
.form-group
= f.label :title
= f.text_field :title

.form-group
= f.label :content
= f.text_area :content

hr

fieldset
.col-md-3
legend
= Comable.t('admin.nav.pages.seo')

.col-md-9
.form-group
= f.label :page_title
= f.text_field :page_title

.form-group
= f.label :meta_description
= f.text_field :meta_description

.form-group
= f.label :meta_keywords
= f.text_field :meta_keywords

.form-group
= f.label :slug
.slug
.url
span= comable.admin_pages_url + '/'
.slug-body
= f.text_field :slug

hr

fieldset
.col-md-3
legend
= Comable.t('admin.nav.pages.visibility')

.col-md-9
.form-group
= f.label :published_at
= f.text_field :published_at, value: @page.published_at.try(:strftime,'%Y-%m-%d %H:%m'), class: 'datetimepicker'
36 changes: 36 additions & 0 deletions backend/app/views/comable/admin/pages/edit.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.comable-page
.comable-main-fixed-top
.comable-page-heading
ul.pull-right.list-inline
li.dropdown
= link_to '#', class: 'btn btn-default', 'data-toggle' => 'dropdown' do
i.fa.fa-bars
ul.dropdown-menu.dropdown-menu-right
li
= link_to comable.admin_page_path(@page) do
span.fa.fa-external-link>
= Comable.t('admin.preview')

li
= link_to_save

h1.page-header
ol.breadcrumb
li>
= link_to Comable.t('admin.nav.page'), comable.admin_pages_path
li.active
= @page.title

.comable-page-body
= render 'form'
hr
.panel.panel-danger
.panel-heading type="button" data-toggle="collapse" data-target="#comable-danger"
strong
span.fa.fa-angle-down>
= Comable.t('admin.actions.destroy')
#comable-danger.collapse
.panel-body
p
= Comable.t('admin.confirmation_to_remove_page')
= link_to Comable.t('admin.actions.destroy'), comable.admin_page_path(@page), method: :delete, class: 'btn btn-danger'
47 changes: 47 additions & 0 deletions backend/app/views/comable/admin/pages/index.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.comable-page
.comable-page-heading
ul.pull-right.list-inline
li
= link_to comable.root_path do
= link_to Comable.t('admin.actions.new'), comable.new_admin_page_path, class: 'btn btn-default'
h1.page-header
= Comable.t('admin.nav.page')
small<
| #{@pages.total_count} #{Comable.t('admin.results')}

.comable-page-body
.comable-search
= search_form_for @q, url: comable.admin_pages_path do |f|
.input-group
span.input-group-btn
button.btn.btn-default.dropdown-toggle type="button" data-toggle="dropdown"
i.fa.fa-search
span.caret<
ul.dropdown-menu role="menu"
li
= link_to Comable.t('admin.advanced_search'), 'javascript:void(0)', 'data-toggle' => 'collapse', 'data-target' => '#comable-advanced-search'
li
= link_to Comable.t('admin.clear_search_conditions'), comable.admin_pages_path
= f.text_field :title_cont, class: 'form-control'
span.input-group-btn
= f.submit Comable.t('admin.search'), class: 'btn btn-default'

= render 'comable/admin/shared/advanced_search', f: f

section
- if @pages.empty?
= Comable.t('admin.not_found')
- else
table.table.table-striped
thead
th
= sort_link [:comable, @q], :id
th
= sort_link [:comable, @q], :title
tbody
- @pages.each do |page|
tr
td
= page.id
td
= link_to page.title, comable.admin_page_path(page)
16 changes: 16 additions & 0 deletions backend/app/views/comable/admin/pages/new.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.comable-page
.comable-main-fixed-top
.comable-page-heading
ul.pull-right.list-inline
li
= link_to_save

h1.page-header
ol.breadcrumb
li>
= link_to Comable.t('admin.nav.page'), comable.admin_products_path
li.active
= Comable.t('admin.actions.new')

.comable-page-body
= render 'form'
4 changes: 4 additions & 0 deletions backend/app/views/comable/admin/shared/_sidebar.slim
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
= link_to comable.admin_users_path do
i.fa.fa-user
= Comable.t('admin.nav.user')
li class="#{'active' if controller_name == 'pages'}"
= link_to comable.admin_pages_path do
i.fa.fa-file-text-o
= Comable.t('admin.nav.page')
li class="#{'active' if controller_name.in? %w( store shipment_methods payment_methods )}"
= link_to '#' do
i.fa.fa-cog
Expand Down
3 changes: 3 additions & 0 deletions backend/comable_backend.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ Gem::Specification.new do |s|
s.add_dependency 'morrisjs-rails', '~> 0.5.1'
s.add_dependency 'pace-rails', '~> 0.1.3'
s.add_dependency 'gritter', '~> 1.1.0'

s.add_dependency 'momentjs-rails', '~> 2.10.2'
s.add_dependency 'bootstrap3-datetimepicker-rails', '~> 4.7.14'
end
1 change: 1 addition & 0 deletions backend/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
end

resources :categories
resources :pages
resources :users
resources :shipment_methods
resources :payment_methods
Expand Down
2 changes: 2 additions & 0 deletions backend/lib/comable/backend/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
require 'morrisjs-rails'
require 'pace/rails'
require 'gritter'
require 'bootstrap3-datetimepicker-rails'
require 'momentjs-rails'

module Comable
module Backend
Expand Down
Loading

0 comments on commit f09290e

Please sign in to comment.