rename namespace for the sites backbone views + create backbone view for the creation of a new site
This commit is contained in:
parent
fb0e87c64d
commit
87a04aafe9
@ -27,12 +27,12 @@ class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.Form
|
||||
@enable_liquid_editing()
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
|
@ -29,6 +29,9 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
|
||||
|
||||
@model.save {},
|
||||
success: (model, response, xhr) =>
|
||||
console.log(response)
|
||||
console.log(xhr)
|
||||
|
||||
$.growl('success', xhr.getResponseHeader('X-Message'))
|
||||
|
||||
model.attributes = previous_attributes
|
||||
@ -38,6 +41,8 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
|
||||
error: (model, xhr) =>
|
||||
$.growl('error', xhr.getResponseHeader('X-Message'))
|
||||
|
||||
console.log(xhr)
|
||||
|
||||
errors = JSON.parse(xhr.responseText)
|
||||
|
||||
@show_errors errors
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
@ -72,7 +72,7 @@ class Locomotive.Views.Site.DomainsView extends Backbone.View
|
||||
@$('.domain input[type=text]').editableField()
|
||||
|
||||
_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)
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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'
|
||||
|
||||
@ -29,7 +29,7 @@ class Locomotive.Views.Site.MembershipsView extends Backbone.View
|
||||
@$('.entry select').editableField()
|
||||
|
||||
_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)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -3,6 +3,8 @@ module Locomotive
|
||||
|
||||
sections 'settings'
|
||||
|
||||
respond_to :json, :only => [:create]
|
||||
|
||||
def new
|
||||
@site = Site.new
|
||||
respond_with @site
|
||||
|
@ -6,8 +6,8 @@
|
||||
:plain
|
||||
{ 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.input :name, :required => false
|
||||
= f.inputs :name => :information, :style => 'display: none' do
|
||||
= f.input :name
|
||||
|
||||
= f.inputs :name => :seo, :class => "inputs foldable #{'folded' if inputs_folded?(@site)}" do
|
||||
= f.input :seo_title
|
||||
|
@ -1,37 +1,45 @@
|
||||
- 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.input :name, :required => false
|
||||
= f.inputs :name => :information do
|
||||
= f.input :name
|
||||
|
||||
- if manage_subdomain_or_domains?
|
||||
= f.foldable_inputs :name => :access_points, :class => 'editable-list off' do
|
||||
|
||||
= f.custom_input :subdomain, :css => 'path' do
|
||||
%em
|
||||
http://
|
||||
= f.text_field :subdomain
|
||||
\.
|
||||
%em
|
||||
= application_domain
|
||||
= f.inputs :name => :access_points do
|
||||
= f.input :subdomain, :as => :'Locomotive::Subdomain', :domain => application_domain, :input_html => { :readonly => !manage_subdomain? }
|
||||
|
||||
- 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')
|
||||
= f.input :domains, :as => :'Locomotive::Empty'
|
||||
|
||||
%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')
|
||||
|
||||
/ - if manage_subdomain_or_domains?
|
||||
/ = f.foldable_inputs :name => :access_points, :class => 'editable-list off' do
|
||||
/
|
||||
/ = f.custom_input :subdomain, :css => 'path' do
|
||||
/ %em
|
||||
/ http://
|
||||
/ = f.text_field :subdomain
|
||||
/ \.
|
||||
/ %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')
|
3
doc/TODO
3
doc/TODO
@ -21,8 +21,9 @@ x edit my site
|
||||
x roles
|
||||
x save
|
||||
- fix other sections
|
||||
- edit my account
|
||||
x edit my account
|
||||
- create a new site
|
||||
- create a new account
|
||||
- theme assets
|
||||
- content types
|
||||
|
||||
|
@ -9,6 +9,7 @@ module Locomotive
|
||||
end
|
||||
|
||||
def to_json
|
||||
Rails.logger.debug "TO JSON !!!!"
|
||||
if get?
|
||||
display resource
|
||||
elsif has_errors?
|
||||
|
Loading…
Reference in New Issue
Block a user