Commit a66442e8 by Mykhailo Makohin

some progerss in sortable

parent 9d7f634f
...@@ -34,7 +34,7 @@ gem 'globalize-accessors' ...@@ -34,7 +34,7 @@ gem 'globalize-accessors'
gem 'ckeditor', '~> 4.3' gem 'ckeditor', '~> 4.3'
gem 'mini_magick' gem 'mini_magick'
gem 'video_info', '~> 2.7' gem 'video_info', '~> 2.7'
gem 'tooltipster-rails' gem 'acts_as_list'
group :development, :test do group :development, :test do
gem 'byebug', platform: :mri gem 'byebug', platform: :mri
......
...@@ -50,6 +50,8 @@ GEM ...@@ -50,6 +50,8 @@ GEM
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
acts_as_list (0.9.19)
activerecord (>= 3.0)
addressable (2.7.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
ansi (1.5.0) ansi (1.5.0)
...@@ -290,7 +292,6 @@ GEM ...@@ -290,7 +292,6 @@ GEM
thor (0.20.3) thor (0.20.3)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.9) tilt (2.0.9)
tooltipster-rails (4.2.6)
turbolinks (5.2.0) turbolinks (5.2.0)
turbolinks-source (~> 5.2) turbolinks-source (~> 5.2)
turbolinks-source (5.2.0) turbolinks-source (5.2.0)
...@@ -318,6 +319,7 @@ PLATFORMS ...@@ -318,6 +319,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
activeadmin activeadmin
acts_as_list
awesome_print awesome_print
bootstrap-sass bootstrap-sass
byebug byebug
...@@ -348,7 +350,6 @@ DEPENDENCIES ...@@ -348,7 +350,6 @@ DEPENDENCIES
simple_form simple_form
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
tooltipster-rails
turbolinks (~> 5) turbolinks (~> 5)
tzinfo-data tzinfo-data
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
......
...@@ -22,6 +22,7 @@ ActiveAdmin.register Project do ...@@ -22,6 +22,7 @@ ActiveAdmin.register Project do
def create def create
@project = Project.new(project_params) @project = Project.new(project_params)
if @project.save if @project.save
create_project_partials
redirect_to admin_project_path(@project) redirect_to admin_project_path(@project)
else else
render :new render :new
...@@ -32,6 +33,11 @@ ActiveAdmin.register Project do ...@@ -32,6 +33,11 @@ ActiveAdmin.register Project do
scoped_collection.friendly.find(params[:id]) scoped_collection.friendly.find(params[:id])
end end
def create_project_partials
[@project.short_description, @project.description].each_with_index {|val, index|
ProjectPartial.create(title: val, position: index, project_id: @project.id)}
end
def project_params def project_params
params.require(:project).permit(:photo, :photo_preview, :photo_before, :remove_photo_before, params.require(:project).permit(:photo, :photo_preview, :photo_before, :remove_photo_before,
:photo_after, :remove_photo_after, :types, :status, :individual_type_uk, :individual_type_en, :photo_after, :remove_photo_after, :types, :status, :individual_type_uk, :individual_type_en,
......
...@@ -14,7 +14,8 @@ class Project < ApplicationRecord ...@@ -14,7 +14,8 @@ class Project < ApplicationRecord
enum types: [:program, :project] enum types: [:program, :project]
enum status: [:in_progress, :implemented] enum status: [:in_progress, :implemented]
has_many :project_partials
has_many :project_galeries, inverse_of: :project, dependent: :destroy has_many :project_galeries, inverse_of: :project, dependent: :destroy
has_many :project_qoutes, inverse_of: :project, dependent: :destroy has_many :project_qoutes, inverse_of: :project, dependent: :destroy
has_many :project_photos, inverse_of: :project, dependent: :destroy has_many :project_photos, inverse_of: :project, dependent: :destroy
......
class ProjectPartial < ApplicationRecord
belongs_to :project
end
module ProjectPartialService
class << self
def create(params)
ProjectPartial.new()
end
end
end
= raw @project.short_description
\ No newline at end of file
= raw @project.description
\ No newline at end of file
...@@ -5,6 +5,11 @@ Rails.application.routes.draw do ...@@ -5,6 +5,11 @@ Rails.application.routes.draw do
ActiveAdmin.routes(self) ActiveAdmin.routes(self)
resources :users resources :users
resources :projects, only: [:show] resources :projects, only: [:show]
resources :project_partials do
collection do
patch :sort
end
end
end end
devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks", devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks",
registrations: "users"} registrations: "users"}
......
class ProjectPartials < ActiveRecord::Migration[5.0]
def change
create_table :project_partials do |t|
t.text :title
t.integer :position
t.references :project
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20191008073420) do ActiveRecord::Schema.define(version: 20191016070020) do
create_table "active_admin_comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "active_admin_comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "namespace" t.string "namespace"
...@@ -104,6 +104,13 @@ ActiveRecord::Schema.define(version: 20191008073420) do ...@@ -104,6 +104,13 @@ ActiveRecord::Schema.define(version: 20191008073420) do
t.index ["project_id"], name: "index_project_links_on_project_id", using: :btree t.index ["project_id"], name: "index_project_links_on_project_id", using: :btree
end end
create_table "project_partials", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.text "title", limit: 65535
t.integer "position"
t.integer "project_id"
t.index ["project_id"], name: "index_project_partials_on_project_id", using: :btree
end
create_table "project_photo_translations", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "project_photo_translations", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "project_photo_id", null: false t.integer "project_photo_id", null: false
t.string "locale", null: false t.string "locale", null: false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment