From b8dd3e772e0f1652af50b4b7b3b0b9775bbd2382 Mon Sep 17 00:00:00 2001 From: dinedine Date: Thu, 24 Jun 2010 11:14:08 +0200 Subject: [PATCH] bug fixes --- app/controllers/admin/layouts_controller.rb | 1 + app/models/asset_collection.rb | 2 +- app/views/admin/content_types/_form.html.haml | 2 +- app/views/admin/content_types/edit.html.haml | 4 ++-- app/views/admin/layouts/_form.html.haml | 2 +- app/views/admin/shared/menu/_contents.html.haml | 2 +- doc/TODO | 6 +++++- lib/locomotive/liquid/drops/contents.rb | 1 + lib/locomotive/liquid/drops/page.rb | 6 +++++- public/javascripts/admin/application.js | 8 ++++---- public/stylesheets/admin/formtastic_changes.css | 15 +++++++++++++++ 11 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/controllers/admin/layouts_controller.rb b/app/controllers/admin/layouts_controller.rb index 00c38b28..fb138316 100644 --- a/app/controllers/admin/layouts_controller.rb +++ b/app/controllers/admin/layouts_controller.rb @@ -22,6 +22,7 @@ module Admin flash_success! redirect_to edit_admin_layout_url(@layout) else + logger.debug "===> #{@layout.errors.inspect}" flash_error! render :action => 'new' end diff --git a/app/models/asset_collection.rb b/app/models/asset_collection.rb index 09098aaf..0d744bcc 100644 --- a/app/models/asset_collection.rb +++ b/app/models/asset_collection.rb @@ -50,7 +50,7 @@ class AssetCollection self.assets.find(asset_id).position = index end - self.assets.each do |asset| + self.assets.clone.each do |asset| if !@assets_order.split(',').include?(asset._id) self.assets.delete(asset) asset.send(:delete) diff --git a/app/views/admin/content_types/_form.html.haml b/app/views/admin/content_types/_form.html.haml index 5830662b..852558db 100644 --- a/app/views/admin/content_types/_form.html.haml +++ b/app/views/admin/content_types/_form.html.haml @@ -7,7 +7,7 @@ = f.input :slug = f.input :description -= render 'admin/custom_fields/index', :f => f, :collection_name => 'contents' += render 'admin/custom_fields/index', :form => f, :collection_name => 'contents' - unless f.object.new_record? = f.foldable_inputs :name => :presentation, :class => 'switchable' do diff --git a/app/views/admin/content_types/edit.html.haml b/app/views/admin/content_types/edit.html.haml index 873d6105..77fd7188 100644 --- a/app/views/admin/content_types/edit.html.haml +++ b/app/views/admin/content_types/edit.html.haml @@ -9,9 +9,9 @@ %p= t('.help') -= semantic_form_for @content_type, :url => admin_content_type_url(@content_type) do |form| += semantic_form_for @content_type, :url => admin_content_type_url(@content_type) do |f| - = render 'form', :f => form + = render 'form', :f => f = render 'admin/shared/form_actions', :back_url => admin_contents_url(@content_type.slug), :button_label => :update diff --git a/app/views/admin/layouts/_form.html.haml b/app/views/admin/layouts/_form.html.haml index f0efebf2..78fed3c5 100644 --- a/app/views/admin/layouts/_form.html.haml +++ b/app/views/admin/layouts/_form.html.haml @@ -2,7 +2,7 @@ = f.input :name = f.inputs :name => :code do - = f.custom_input :value, :css => 'full', :with_label => false do + = f.custom_input :value, :css => 'code full', :with_label => false do %code{ :class => 'html' } = f.text_area :value diff --git a/app/views/admin/shared/menu/_contents.html.haml b/app/views/admin/shared/menu/_contents.html.haml index 3fe2ee7f..36a2c4b0 100644 --- a/app/views/admin/shared/menu/_contents.html.haml +++ b/app/views/admin/shared/menu/_contents.html.haml @@ -7,7 +7,7 @@ %ul - current_site.pages.latest_updated.each do |page| %li - = link_to truncate(page.title, :length => 30), edit_admin_page_url(page) + = link_to truncate(page.title, :length => 25), edit_admin_page_url(page) %span= time_ago_in_words(page.updated_at) - current_site.content_types.each do |content_type| diff --git a/doc/TODO b/doc/TODO index e7aeab1f..5ce59740 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,5 +1,8 @@ BOARD: +- asset picker (content instance) +- theme asset picker when editing layout + - refactoring admin crud (pages + layouts + snippets) - refactor slugify method (use parameterize + create a module) @@ -40,4 +43,5 @@ x refactor custom field types x new custom field types x boolean x enable/disable text formatting -x custom fields for asset collections \ No newline at end of file +x custom fields for asset collections +x [BUG] impossible to remove many assets in an asset collection \ No newline at end of file diff --git a/lib/locomotive/liquid/drops/contents.rb b/lib/locomotive/liquid/drops/contents.rb index 2b5966ff..01abdfe0 100644 --- a/lib/locomotive/liquid/drops/contents.rb +++ b/lib/locomotive/liquid/drops/contents.rb @@ -32,6 +32,7 @@ module Locomotive def each(&block) @collection ||= @content_type.ordered_contents(@context['with_scope']) + @collection.each(&block) end def paginate(options = {}) diff --git a/lib/locomotive/liquid/drops/page.rb b/lib/locomotive/liquid/drops/page.rb index f46ce464..2d737dad 100644 --- a/lib/locomotive/liquid/drops/page.rb +++ b/lib/locomotive/liquid/drops/page.rb @@ -3,12 +3,16 @@ module Locomotive module Drops class Page < Base - liquid_attributes << :title << :fullpath + liquid_attributes << :title def children @children ||= liquify(*@source.children) end + def fullpath + @fullpath ||= @source.fullpath + end + end end end diff --git a/public/javascripts/admin/application.js b/public/javascripts/admin/application.js index 77248398..7c4192d1 100644 --- a/public/javascripts/admin/application.js +++ b/public/javascripts/admin/application.js @@ -49,8 +49,8 @@ var TinyMceDefaultSettings = { script_url : '/javascripts/admin/plugins/tiny_mce/tiny_mce.js', theme : 'advanced', skin : 'locomotive', - theme_advanced_buttons1 : 'code,|,bold,italic,|,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink', - theme_advanced_buttons2 : 'formatselect,fontselect,fontsizeselect,|,undo,redo', + theme_advanced_buttons1 : 'code,|,bold,italic,|,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,|,formatselect,fontselect,fontsizeselect', + theme_advanced_buttons2 : '', theme_advanced_buttons3 : '' }; @@ -72,8 +72,8 @@ $(document).ready(function() { $('#submenu > ul > li.' + css).addClass('on'); // form - $('.formtastic li input, .formtastic li textarea').focus(function() { - $('.formtastic li.error p.inline-errors').fadeOut(200); + $('.formtastic li input, .formtastic li textarea, .formtastic li code').focus(function() { + $('.formtastic li.error:not(.code) p.inline-errors').fadeOut(200); if ($(this).parent().hasClass('error')) { $(this).nextAll('p.inline-errors').show(); } diff --git a/public/stylesheets/admin/formtastic_changes.css b/public/stylesheets/admin/formtastic_changes.css index b829f04d..b6dbf8b9 100644 --- a/public/stylesheets/admin/formtastic_changes.css +++ b/public/stylesheets/admin/formtastic_changes.css @@ -137,6 +137,15 @@ form.formtastic fieldset ol li p.inline-errors { font-size: 0.7em !important; } +form.formtastic fieldset ol li.code p.inline-errors { + display: block; + float: right; + margin: 4px 16px 0 0; + position: relative; + left: 0px; + background-image: none; +} + form.formtastic fieldset ol li.more { text-align: right; width: auto; margin-right: 20px; line-height: 0.6em; } form.formtastic fieldset ol li.more a { text-decoration: none; color: #787A89; font-size: 0.7em; } form.formtastic fieldset ol li.more a:hover { text-decoration: underline; } @@ -370,6 +379,12 @@ form.formtastic fieldset.validations ol li.added em.key { width: 180px; } +/* ___ content instance ___ */ + +form.content_instance fieldset ol li.text textarea { + width: 75%; +} + /* ___ my account ___ */ form.formtastic fieldset.language li.full span {