diff --git a/app/assets/javascripts/locomotive/views/shared/list_view.js.coffee b/app/assets/javascripts/locomotive/views/shared/list_view.js.coffee index 195de6ed..db27788d 100644 --- a/app/assets/javascripts/locomotive/views/shared/list_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/shared/list_view.js.coffee @@ -37,6 +37,7 @@ class Locomotive.Views.Shared.ListView extends Backbone.View (@_item_views ||= []).push(view) + @$('.no-items').hide() @$('ul').append(view.render().el) remove_item: (item) -> diff --git a/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee b/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee index 5122fa78..aca117db 100644 --- a/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee @@ -25,23 +25,21 @@ class Locomotive.Views.ThemeAssets.IndexView extends Backbone.View return @ build_uploader: -> - el = @$('.quick-upload input[type=file]') - link = @$('.quick-upload a.new') - window.Locomotive.Uploadify.build el, - url: link.attr('href') - data_name: el.attr('name') - file_ext: '*.jpg;*.png;*.jpeg;*.gif;*.flv;*.swf;*.ttf;*.js;*.css;*.mp3' - height: link.outerHeight() - width: link.outerWidth() - success: (model) => @add_asset(model) - error: (msg) => - console.log(msg) - $.growl('alert', msg) + form = @$('#theme-assets-quick-upload') + input = form.find('input[type=file]') + link = form.find('a.new') + + link.bind 'click', (event) -> + event.stopPropagation() & event.preventDefault() + input.click() + + input.bind 'change', (event) => + _.each event.target.files, (file) => + asset = new Locomotive.Models.ThemeAsset(source: file) + asset.save {}, success: @add_asset, headers: { 'X-Flash': true } add_asset: (model) -> - console.log(model) - list_view = @pick_list_view(model.content_type) - console.log(list_view) + list_view = @pick_list_view(model.get('content_type')) list_view.collection.add(model) render_snippets: -> diff --git a/app/assets/stylesheets/locomotive/application.scss b/app/assets/stylesheets/locomotive/application.scss index dd5dc511..f3765b47 100644 --- a/app/assets/stylesheets/locomotive/application.scss +++ b/app/assets/stylesheets/locomotive/application.scss @@ -359,6 +359,16 @@ p span.code { @include single-text-shadow(#fff, 0px, 0px, 1px); } +/* ___ quick upload ___ */ + +form.quick-upload { + display: inline; + + input[type=file] { + visibility: hidden; + } + +} diff --git a/app/views/locomotive/import/show.html.haml b/app/views/locomotive/import/show.html.haml index bad529b7..d0f76644 100644 --- a/app/views/locomotive/import/show.html.haml +++ b/app/views/locomotive/import/show.html.haml @@ -11,9 +11,7 @@ %ul{ :id => 'import-steps', :class => 'list', :'data-url' => import_url(:json), :'data-success-message' => t('.messages.success'), :'data-failure-message' => t('.messages.failure') } - %w(site content_types assets snippets pages).each do |step| %li{ :id => "#{step}-step" } - %em - %strong - = link_to t(".steps.#{step}"), '#' + %strong= t(".steps.#{step}") .more .states   \ No newline at end of file diff --git a/app/views/locomotive/theme_assets/index.html.haml b/app/views/locomotive/theme_assets/index.html.haml index 49f1d4cc..242baf4e 100644 --- a/app/views/locomotive/theme_assets/index.html.haml +++ b/app/views/locomotive/theme_assets/index.html.haml @@ -29,9 +29,10 @@ - content_for :buttons do - if can?(:manage, Locomotive::ThemeAsset) - .button-wrapper.quick-upload - = file_field_tag 'theme_asset[source]' - = local_action_button :quick_upload, theme_assets_url(:json), :class => 'new' + = form_tag theme_assets_url(:json), :id => 'theme-assets-quick-upload', :class => 'quick-upload' do + = file_field_tag 'theme_asset[source]', :multiple => 'multiple' + = local_action_button :quick_upload, '#', :class => 'new' + = local_action_button t('locomotive.snippets.index.new'), new_snippet_url, :class => 'new' if can?(:manage, Locomotive::Snippet) = local_action_button :new, new_theme_asset_url, :class => 'new' if can?(:manage, Locomotive::ThemeAsset) diff --git a/doc/TODO b/doc/TODO index 1ecd5ac1..4b12584e 100644 --- a/doc/TODO +++ b/doc/TODO @@ -24,16 +24,25 @@ x edit my site x edit my account x create a new site x create a new accounts - - theme assets + x theme assets x polish the page x snippets x delete in ajax - - upload many files at once - - site picker + x upload many files at once - import/export - QU + - site picker - content types + - change in main menu + - manage custom_fields + - list + - crud + - move content instances into their own collection + - manage contents + - list + - crud +- message to notify people if their browser is too old - install a site by default at the first installation (without asking) diff --git a/lib/locomotive/responder.rb b/lib/locomotive/responder.rb index c34b7aea..e5ff427d 100644 --- a/lib/locomotive/responder.rb +++ b/lib/locomotive/responder.rb @@ -12,13 +12,14 @@ module Locomotive if get? display resource elsif has_errors? - Rails.logger.debug "--> ERRORS #{resource.errors.inspect}" # FIXME: debug purpose - with_flash_message(:alert) do |message| + with_flash_message(:alert) do display resource.errors, :status => :unprocessable_entity end elsif post? - set_flash_message! - display resource, :location => api_location + in_header = controller.request.headers['X-Flash'] == 'true' + with_flash_message(:notice, in_header) do + display resource, :location => api_location + end elsif put? with_flash_message do |message| display resource, :status => :ok, :location => api_location @@ -38,16 +39,22 @@ module Locomotive protected - def with_flash_message(type = :notice) - set_flash_message! - message = controller.flash[type] + def with_flash_message(type = :notice, in_header = true) + if in_header + set_flash_message! + message = controller.flash[type] - controller.headers['X-Message'] = message - controller.headers['X-Message-Type'] = type + controller.headers['X-Message'] = message + controller.headers['X-Message-Type'] = type - yield(message) if block_given? + yield if block_given? - controller.flash.discard # reset flash messages ! + controller.flash.discard # reset flash messages ! + else + set_flash_message! + + yield if block_given? + end end end