Merge branch 'rails_3_1' of github.com:locomotivecms/engine into rails_3_1

This commit is contained in:
did 2011-12-02 16:00:42 +01:00
commit c171e49093
12 changed files with 104 additions and 45 deletions

View File

@ -27,12 +27,12 @@ class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.Form
@enable_liquid_editing() @enable_liquid_editing()
render_domains: -> render_domains: ->
@domains_view = new Locomotive.Views.Site.DomainsView model: @model, errors: @options.errors @domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
@$('#site_domains_input label').after(@domains_view.render().el) @$('#site_domains_input label').after(@domains_view.render().el)
render_memberships: -> render_memberships: ->
@memberships_view = new Locomotive.Views.Site.MembershipsView model: @model @memberships_view = new Locomotive.Views.Sites.MembershipsView model: @model
@$('#site_memberships_input').append(@memberships_view.render().el) @$('#site_memberships_input').append(@memberships_view.render().el)

View File

@ -29,6 +29,9 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
@model.save {}, @model.save {},
success: (model, response, xhr) => success: (model, response, xhr) =>
console.log(response)
console.log(xhr)
$.growl('success', xhr.getResponseHeader('X-Message')) $.growl('success', xhr.getResponseHeader('X-Message'))
model.attributes = previous_attributes model.attributes = previous_attributes
@ -38,6 +41,8 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
error: (model, xhr) => error: (model, xhr) =>
$.growl('error', xhr.getResponseHeader('X-Message')) $.growl('error', xhr.getResponseHeader('X-Message'))
console.log(xhr)
errors = JSON.parse(xhr.responseText) errors = JSON.parse(xhr.responseText)
@show_errors errors @show_errors errors

View File

@ -1,6 +1,6 @@
Locomotive.Views.Site ||= {} Locomotive.Views.Sites ||= {}
class Locomotive.Views.Site.DomainEntryView extends Backbone.View class Locomotive.Views.Sites.DomainEntryView extends Backbone.View
tagName: 'li' tagName: 'li'

View File

@ -1,6 +1,6 @@
Locomotive.Views.Site ||= {} Locomotive.Views.Sites ||= {}
class Locomotive.Views.Site.DomainsView extends Backbone.View class Locomotive.Views.Sites.DomainsView extends Backbone.View
tagName: 'div' tagName: 'div'
@ -72,7 +72,7 @@ class Locomotive.Views.Site.DomainsView extends Backbone.View
@$('.domain input[type=text]').editableField() @$('.domain input[type=text]').editableField()
_insert_entry: (domain) -> _insert_entry: (domain) ->
view = new Locomotive.Views.Site.DomainEntryView model: domain, parent_view: @ view = new Locomotive.Views.Sites.DomainEntryView model: domain, parent_view: @
(@_entry_views ||= []).push(view) (@_entry_views ||= []).push(view)

View File

@ -1,6 +1,6 @@
Locomotive.Views.Site ||= {} Locomotive.Views.Sites ||= {}
class Locomotive.Views.Site.MembershipEntryView extends Backbone.View class Locomotive.Views.Sites.MembershipEntryView extends Backbone.View
className: 'entry' className: 'entry'

View File

@ -1,6 +1,6 @@
Locomotive.Views.Site ||= {} Locomotive.Views.Sites ||= {}
class Locomotive.Views.Site.MembershipsView extends Backbone.View class Locomotive.Views.Sites.MembershipsView extends Backbone.View
tagName: 'div' tagName: 'div'
@ -29,7 +29,7 @@ class Locomotive.Views.Site.MembershipsView extends Backbone.View
@$('.entry select').editableField() @$('.entry select').editableField()
_insert_entry: (membership, index) -> _insert_entry: (membership, index) ->
view = new Locomotive.Views.Site.MembershipEntryView model: membership, parent_view: @, index: index view = new Locomotive.Views.Sites.MembershipEntryView model: membership, parent_view: @, index: index
(@_entry_views ||= []).push(view) (@_entry_views ||= []).push(view)

View File

@ -0,0 +1,43 @@
#= require ../shared/form_view
#= require ../sites/domains_view
Locomotive.Views.Sites ||= {}
class Locomotive.Views.Sites.NewView extends Locomotive.Views.Shared.FormView
el: '#content'
events:
'submit': 'save'
initialize: ->
@model = new Locomotive.Models.Site()
Backbone.ModelBinding.bind @
window.foo = @model
render: ->
super()
@render_domains()
render_domains: ->
@domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
@$('#site_domains_input label').after(@domains_view.render().el)
save: (event) ->
@save_in_ajax(event)
show_error: (attribute, message, html) ->
if attribute == 'domains'
@domains_view.show_error(message)
else
super
remove: ->
@domains_view.remove()
super

View File

@ -3,6 +3,8 @@ module Locomotive
sections 'settings' sections 'settings'
respond_to :json, :only => [:create]
def new def new
@site = Site.new @site = Site.new
respond_with @site respond_with @site

View File

@ -6,8 +6,8 @@
:plain :plain
{ site: #{@site.to_json(:current_account => current_locomotive_account, :current_site => current_site)}, errors: #{@site.errors.to_json} } { site: #{@site.to_json(:current_account => current_locomotive_account, :current_site => current_site)}, errors: #{@site.errors.to_json} }
= f.inputs :name => :information, :style => "#{'display: none' unless @site.new_record?}" do = f.inputs :name => :information, :style => 'display: none' do
= f.input :name, :required => false = f.input :name
= f.inputs :name => :seo, :class => "inputs foldable #{'folded' if inputs_folded?(@site)}" do = f.inputs :name => :seo, :class => "inputs foldable #{'folded' if inputs_folded?(@site)}" do
= f.input :seo_title = f.input :seo_title

View File

@ -1,37 +1,45 @@
- content_for :head do - content_for :head do
= include_javascripts :site = render 'locomotive/sites/domains'
= f.foldable_inputs :name => :information, :style => "#{'display: none' unless @site.new_record?}" do = f.inputs :name => :information do
= f.input :name, :required => false = f.input :name
- if manage_subdomain_or_domains? - if manage_subdomain_or_domains?
= f.foldable_inputs :name => :access_points, :class => 'editable-list off' do = f.inputs :name => :access_points do
= f.input :subdomain, :as => :'Locomotive::Subdomain', :domain => application_domain, :input_html => { :readonly => !manage_subdomain? }
= f.custom_input :subdomain, :css => 'path' do
%em
http://
= f.text_field :subdomain
\.
%em
= application_domain
- if manage_domains? - if manage_domains?
- @site.domains_without_subdomain.each_with_index do |name, index| = f.input :domains, :as => :'Locomotive::Empty'
%li{ :class => "item added #{'last' if index == @site.domains.size - 1}" }
%em
http://
= text_field_tag 'site[domains][]', name, :class => 'string label void domain'
 
= error_on_domain(@site, name)
%span.actions
= link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm')
%li.item.template
%em / - if manage_subdomain_or_domains?
http:// / = f.foldable_inputs :name => :access_points, :class => 'editable-list off' do
= text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain' /
  / = f.custom_input :subdomain, :css => 'path' do
%span.actions / %em
= link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm') / http://
%button{ :class => 'button light add', :type => 'button' } / = f.text_field :subdomain
%span!= t('locomotive.buttons.new_item') / \.
/ %em
/ = application_domain
/
/ - if manage_domains?
/ - @site.domains_without_subdomain.each_with_index do |name, index|
/ %li{ :class => "item added #{'last' if index == @site.domains.size - 1}" }
/ %em
/ http://
/ = text_field_tag 'site[domains][]', name, :class => 'string label void domain'
/  
/ = error_on_domain(@site, name)
/ %span.actions
/ = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm')
/
/ %li.item.template
/ %em
/ http://
/ = text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain'
/  
/ %span.actions
/ = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm')
/ %button{ :class => 'button light add', :type => 'button' }
/ %span!= t('locomotive.buttons.new_item')

View File

@ -21,7 +21,7 @@ x edit my site
x roles x roles
x save x save
- fix other sections - fix other sections
- edit my account x edit my account
- create a new site - create a new site
- create a new account - create a new account
- theme assets - theme assets

View File

@ -9,6 +9,7 @@ module Locomotive
end end
def to_json def to_json
Rails.logger.debug "TO JSON !!!!"
if get? if get?
display resource display resource
elsif has_errors? elsif has_errors?