Fix directories and images

This commit is contained in:
2015-03-06 11:28:11 +01:00
parent 35296aa653
commit 8ba2fa731e
15 changed files with 37 additions and 34 deletions
+1
View File
@@ -25,6 +25,7 @@ gem 'slim-rails'
gem 'paperclip'
gem 'email_validator'
gem 'actionpack-page_caching'
gem 'font-awesome-rails'
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
+4 -1
View File
@@ -118,12 +118,14 @@ GEM
activemodel
erubis (2.7.0)
eventmachine (1.0.7)
execjs (2.3.0)
execjs (2.4.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
font-awesome-rails (4.3.0.0)
railties (>= 3.2, < 5.0)
foundation-rails (5.5.1.0)
railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5)
@@ -271,6 +273,7 @@ DEPENDENCIES
devise_simply_stored!
email_validator
factory_girl_rails
font-awesome-rails
foundation-rails
jquery-rails
orm_adapter!
@@ -1,5 +1,6 @@
// require 'bootstrap-devise-rails'
// require_directory .
@import font-awesome
@import ./foundation_and_overrides
@import ./structure
@import ./components/*
+2 -1
View File
@@ -75,10 +75,11 @@ module Cmtool
# DELETE /images/1.xml
def destroy
@image = Cmtool::Image.find(params[:id])
directory = @image.directory
@image.destroy
respond_to do |format|
format.html { redirect_to(cmtool.images_url) }
format.html { redirect_to([cmtool, directory || :images]) }
format.xml { head :ok }
end
end
+2 -2
View File
@@ -120,14 +120,14 @@ module Cmtool
def edit_td(obj)
content_tag(
:td,
link_to((content_tag(:span, t('cmtool.table.index.edit'), class: [:edit, 'icon-pencil'])), cmtool.url_for([:edit, obj]), class: [:edit, :btn, 'btn-warning', 'btn-mini']),
link_to((content_tag(:span, '', class: [:edit, 'fa fa-lg fa-pencil'])), cmtool.url_for([:edit, obj]), class: 'tiny warning button'),
class: [:action, :edit]
)
end
def destroy_td(obj)
content_tag(
:td,
link_to(content_tag(:span, t('cmtool.table.index.destroy'), class: [:destroy, 'icon-trash']), cmtool.url_for(obj), method: :delete, confirm: are_you_sure(obj), class: [:destroy, :btn, 'btn-danger', 'btn-mini']),
link_to(content_tag(:span, '', class: [:destroy, 'fa fa-lg fa-trash']), cmtool.url_for(obj), method: :delete, class: 'tiny alert button', data: {confirm: are_you_sure(obj) }),
class: [:action, :destroy]
)
end
+2 -2
View File
@@ -7,10 +7,10 @@ module Cmtool
property :file_content_type
property :file_file_size, type: Fixnum
property :file_updated_at, type: Time
has_attached_file :file, styles: { page: '675x10000>', medium: "354x1000>", thumb: "150x1250>" },
has_attached_file :file, styles: { page: '728x10000>', medium: "354x1000>", thumb: "160x1250>" },
path: ":rails_root/public/system/:attachment/:id/:style.:extension",
url: "/system/:attachment/:id/:style.:extension"
do_not_validate_attachment_file_type :file
validates_attachment :file, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
belongs_to :directory
@@ -1,6 +1,6 @@
-if target.errors.any?
#errorExplanation
h2= t('cmtool.errors.form.title', :count => target.errors.count)
.alert-box.alert
h2= t('cmtool.errors.form.title', count: target.errors.count)
ul
- target.errors.full_messages.each do |msg|
li= msg
@@ -2,4 +2,4 @@ tr
td.image.thumb= link_to(image_tag(image.file.url(:thumb)), cmtool.image_path(image))
td= link_to image.clean_name, cmtool.image_path(image)
td
td.action.destroy.directory= link_to link_to_destroy_content(image), cmtool.image_path(image), :method => :delete, :confirm => are_you_sure(image)
= destroy_td(image)
+8 -9
View File
@@ -1,16 +1,15 @@
- title :show, Cmtool::Directory
- content_for :onload_javascript do
| $('.add-image-container').dialog({modal: true, autoOpen: false, width: 400})
#add-image-container.modal.hide.fade
#add-image-container.reveal-modal data-reveal=true
.modal-header= t('cmtool.directory.add_file')
= form_for [cmtool, Cmtool::Image.new(directory_id: @directory.id)], :html => { :multipart => true, :id => 'add_image_form' } do |f|
= form_for [cmtool, Cmtool::Image.new(directory_id: @directory.id)], html: { multipart: true, id: 'add_image_form' } do |f|
.modal-body
= f.hidden_field :directory_id
= f.file_field :file
.modal-footer
a.secondary.button href: '#', role: :button, data: {dismiss: :modal}, 'aria-hidden' => true x
= f.submit t('cmtool.directory.add_image.label', image: Cmtool::Image.model_name.human), class: 'record-new-button'
.directory.caption= "/# @directory.tree_path.map{|d| link_to(d.name, cmtool.directory_path(d))}.join('/') ".html_safe
.modal-footer= f.submit t('cmtool.directory.add_image.label', image: Cmtool::Image.model_name.human), class: 'record-new-button'
a.close-reveal-modal &#215;
.directory.caption= "/#{@directory.tree_path.map{|d| link_to(d.name, cmtool.directory_path(d))}.join('/')}".html_safe
table#directory-view.table.table-striped.table-hover
thead
tbody
@@ -24,13 +23,13 @@ table#directory-view.table.table-striped.table-hover
td.directory.child= link_to child.name, cmtool.directory_path(child)
td
td
td.action.destroy.directory= link_to link_to_destroy_content(child), cmtool.directory_path(child), :method => :delete, :confirm => are_you_sure(child)
td.action.destroy.directory= link_to link_to_destroy_content(child), cmtool.directory_path(child), method: :delete, confirm: are_you_sure(child)
- for image in @directory.images
= render 'image', :image => image
= render 'image', image: image
- content_for :page_links do
ul
- if @directory.parent
li= link_to '..', cmtool.directory_path(@directory.parent)
li= link_to link_to_edit_content(@directory), cmtool.edit_directory_path(@directory), class: 'record-edit-button'
li= link_to link_to_index_content(Cmtool::Directory), cmtool.directories_path, class: 'to-index-button'
li= link_to t('cmtool.directory.add_file'), '#add-image-container', class: 'record-new-button', role: :button, data: toggle: :modal
li= link_to t('cmtool.directory.add_file'), '#', class: 'record-new-button', data: {'reveal-id' => 'add-image-container'}
+3 -3
View File
@@ -1,12 +1,12 @@
= form_for [cmtool, @image], :html => {:multipart => true} do |f|
= render 'error_messages', :target => @image
= form_for [cmtool, @image], html: {multipart: true} do |f|
= render 'error_messages', target: @image
.field
= f.label :file, Cmtool::Image.model_name.human
= f.file_field :file
.field
= f.label :directory_id, Cmtool::Directory.model_name.human
= f.select :directory_id, Cmtool::Directory.all.map{|d| ["-"*d.depth + ' ' + d.name.to_s, d.id]}
= f.select :directory_id, Cmtool::Directory.all.map{|d| ["-"*d.tree_depth + ' ' + d.name.to_s, d.id]}
.actions
= f.submit @submit || update_button_text(@image)
+3 -3
View File
@@ -1,8 +1,8 @@
<%=raw Cmtool::Image.active.map{|i|
[
{title: "#{i.clean_name} (Origineel)", value: i.file.url(:original)},
{title: "#{i.clean_name} (Pagina)", value: i.file.url(:page)},
{title: "#{i.clean_name} (Medium)", value: i.file.url(:medium)},
{title: "#{i.clean_name} (Thumb)", value: i.file.url(:thumb)}
{title: "#{i.clean_name} (728)", value: i.file.url(:page)},
{title: "#{i.clean_name} (354)", value: i.file.url(:medium)},
{title: "#{i.clean_name} (160)", value: i.file.url(:thumb)}
]
}.flatten.to_json %>
+2 -3
View File
@@ -3,6 +3,5 @@
- content_for :page_links do
ul
li= link_to link_to_show_content(@user), cmtool.user_path(@user)
li= link_to link_to_index_content(User), cmtool.users_path
li= link_to link_to_show_content(@user), cmtool.user_path(@user), class: 'record-show-button'
li= link_to link_to_index_content(User), cmtool.users_path, class: 'to-index-button'
+1 -1
View File
@@ -17,4 +17,4 @@
- content_for :page_links do
ul
li= link_to link_to_new_content(User), cmtool.new_user_path
li= link_to link_to_new_content(User), cmtool.new_user_path, class: 'record-new-button'
+1 -1
View File
@@ -3,4 +3,4 @@
- content_for :page_links do
ul
li= link_to link_to_index_content(User), cmtool.users_path
li= link_to link_to_index_content(User), cmtool.users_path, class: 'to-index-button'
+2 -3
View File
@@ -33,6 +33,5 @@
span.show_value.boolean= boolean_text(@user.active?)
- content_for :page_links do
ul
li= link_to link_to_edit_content(@user), cmtool.edit_user_path(@user)
li= link_to link_to_index_content(User), cmtool.users_path
li= link_to link_to_edit_content(@user), cmtool.edit_user_path(@user), class: 'record-edit-button'
li= link_to link_to_index_content(User), cmtool.users_path, class: 'to-index-button'