adva-core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,7 @@
1
1
  class Admin::PagesController < Admin::SectionsController
2
2
  purges :create, :update
3
-
3
+
4
4
  def update
5
- update! do |success, failure|
6
- failure.html { render :show }
7
- end
5
+ update! { |success, failure| failure.html { render :show } }
8
6
  end
9
7
  end
@@ -1,4 +1,7 @@
1
1
  class Admin::SectionsController < Admin::BaseController
2
+ respond_to :html
3
+ respond_to :json, :only => :update
4
+
2
5
  belongs_to :site
3
6
 
4
7
  before_filter :set_params_for_nested_resources, :only => [:new, :create, :edit, :update]
@@ -29,7 +32,7 @@ class Admin::SectionsController < Admin::BaseController
29
32
 
30
33
  def protect_last_section
31
34
  if site.sections.count == 1
32
- flash[:error] = t(:'flash.actions.destroy.alert', :resource_name => resource.class.model_name)
35
+ resource.errors[:error] = [:last_section_cant_be_destroyed]
33
36
  respond_with(resources)
34
37
  end
35
38
  end
@@ -1,4 +1,7 @@
1
1
  class Admin::SitesController < Admin::BaseController
2
+ respond_to :html
3
+ respond_to :json, :only => :update
4
+
2
5
  purges :update, :destroy
3
6
 
4
7
  before_filter :set_params_for_nested_resources, :only => [:new, :edit]
@@ -0,0 +1,17 @@
1
+ class Admin::Contents::Menu < Adva::View::Menu::Admin::Actions
2
+ include do
3
+ def main
4
+ resource_section_label
5
+ index
6
+ edit_parent
7
+ end
8
+
9
+ def right
10
+ new
11
+ if persisted?
12
+ edit
13
+ destroy
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,30 +1,10 @@
1
- class Admin::Pages::Menu < Adva::View::Menu::Admin::Actions
2
- include do
3
- def main
4
- if resource.try(:persisted?)
5
- label(resource.name)
6
- item(:'.show', show_path)
7
- else
8
- item(:'.sections', index_path)
9
- end
10
- end
1
+ require_dependency 'admin/sections/_menu.html'
11
2
 
3
+ class Admin::Pages::Menu < Admin::Sections::Menu
4
+ include do
12
5
  def right
13
- if resource.try(:persisted?)
14
- item(:'.view', public_url)
15
- item(:'.destroy', resource_path, :method => :delete, :confirm => t(:'.confirm_destroy', :model_name => resource.class.model_name.human))
16
- else
17
- item(:'.new', new_path)
18
- end
6
+ super
7
+ destroy if show?
19
8
  end
20
-
21
- protected
22
-
23
- def active?(url, options)
24
- # hmmm ...
25
- types = Section.types.map { |type| type.underscore.pluralize }.join('|')
26
- return false if url =~ %r(/admin/sites/\d+/#{types}/\d+$) && request.path != url
27
- super
28
- end
29
9
  end
30
10
  end
@@ -1,12 +1,45 @@
1
+ # Base menu for sections. Also used on admin/sections/new.
1
2
  class Admin::Sections::Menu < Adva::View::Menu::Admin::Actions
2
3
  include do
3
4
  def main
4
- item(:'.sections', index_path)
5
+ if collection?
6
+ index
7
+ else
8
+ resource_label
9
+ show
10
+ edit unless page?
11
+ end
5
12
  end
6
-
13
+
7
14
  def right
8
- item(:'.new', new_path)
9
- item(:'.reorder', index_path, :activate => false)
15
+ new if collection?
16
+ destroy if edit?
17
+ reorder if index? # TODO should only happen if we actually have more than 1 category
10
18
  end
19
+
20
+ protected
21
+
22
+ def index
23
+ item(:".sections", index_parent_path(:sections))
24
+ end
25
+
26
+ def reorder
27
+ super( :'data-resource_type' => 'site', :'data-sortable_type' => 'sections')
28
+ end
29
+
30
+ def page?
31
+ resource.is_a?(Page)
32
+ end
33
+
34
+ def edit
35
+ item(:'.edit_section', edit_path)
36
+ end
37
+
38
+ def active?(url, options)
39
+ # hmmm ...
40
+ types = Section.types.map { |type| type.underscore.pluralize }.join('|')
41
+ return false if url =~ %r(/admin/sites/\d+/#{types}/\d+$) && request.path != url
42
+ super
43
+ end
11
44
  end
12
- end
45
+ end
@@ -18,11 +18,11 @@ class Admin::Sections::Index < Minimal::Template
18
18
  end
19
19
 
20
20
  def link_to_view(section)
21
- capture { link_to(:'.view', public_url_for([section]), :class => :view) }
21
+ capture { link_to(:'.actions.view', public_url_for([section]), :class => :view) }
22
22
  end
23
23
 
24
24
  def status(section)
25
25
  capture { span(t(:'.published'), :title => t(:'.published'), :class => 'status published') }
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -1,6 +1,2 @@
1
1
  class Admin::Sites::Menu < Adva::View::Menu::Admin::Actions
2
- include do
3
- def right
4
- end
5
- end
6
- end
2
+ end
@@ -27,6 +27,7 @@ class Layouts::Admin::Top < Adva::View::Menu::Admin
27
27
  item(site.name, url_for([:admin, site])) unless site.new_record?
28
28
  end
29
29
  item(:'.new_site', url_for([:new, :admin, :site]))
30
+ render_items
30
31
  end
31
32
  end
32
33
  end
@@ -38,6 +39,7 @@ class Layouts::Admin::Top < Adva::View::Menu::Admin
38
39
  item(section.name, url_for([:admin, site, section]), :class => :section)
39
40
  end
40
41
  item(:'.new_section', url_for([:new, :admin, site, :section]))
42
+ render_items
41
43
  end
42
44
  end
43
45
  end
@@ -5,27 +5,41 @@ class Layouts::Default < Layouts::Base
5
5
  end
6
6
 
7
7
  def body
8
+ page
9
+ footer
10
+ end
11
+
12
+ def page
8
13
  div :id => :page do
9
- div :id => :header do
10
- h1 site.title
11
- h4 site.subtitle unless site.subtitle.blank?
12
- render :partial => 'layouts/default/menu'
13
- end
14
+ header
14
15
  div :id => :main do
15
16
  content
16
17
  end
18
+ sidebar
17
19
  end
18
- div :id => :footer do
19
- footer
20
+ end
21
+
22
+ def header
23
+ div :id => :header do
24
+ h1 site.title
25
+ h4 site.subtitle unless site.subtitle.blank?
26
+ render :partial => 'layouts/default/menu'
20
27
  end
21
28
  end
22
29
 
23
30
  def footer
24
- ul :class => :left do
25
- li :'.made_with'
26
- end
27
- ul :class => :right do
31
+ div :id => :footer do
32
+ ul :class => :left do
33
+ li :'.made_with'
34
+ end
35
+ ul :class => :right do
36
+ end
28
37
  end
29
38
  end
39
+
40
+ def sidebar
41
+ sidebar = capture { block.call(:sidebar) }
42
+ div sidebar, :id => 'sidebar', :class => 'left' unless sidebar.blank?
43
+ end
30
44
  end
31
- end
45
+ end
@@ -1,24 +1,19 @@
1
1
  class Layouts::Default::Menu < Adva::View::Menu
2
2
  include do
3
- def to_html
3
+ def build
4
4
  ul(:id => :menu) do
5
5
  site.sections.each do |section|
6
6
  item(section.name, url_for(section))
7
7
  end
8
+ render_items
8
9
  end
9
10
  end
10
-
11
+
11
12
  protected
12
13
 
13
14
  def active?(url, options)
14
15
  return false if url =~ %r(/admin/sites(/\d+)?$) && request.fullpath != url
15
16
  super
16
17
  end
17
-
18
- # def path_and_parents(path)
19
- # paths = super
20
- # paths.detect { |path| path.gsub!(/(#{Section.types.map(&:tableize).join('|')})$/) { 'sections' } }
21
- # paths
22
- # end
23
18
  end
24
- end
19
+ end
@@ -1,20 +1,49 @@
1
1
  en:
2
2
  a_or_b: '%{a} or %{b}'
3
+
3
4
  flash:
4
- actions:
5
- create:
6
- notice: '%{resource_name} successfully created.'
7
- alert: '%{resource_name} could not be created.'
8
- update:
9
- notice: '%{resource_name} successfully updated.'
10
- alert: '%{resource_name} could not be updated.'
11
- destroy:
12
- notice: '%{resource_name} successfully deleted.'
13
- alert: '%{resource_name} could not be deleted.'
5
+ create:
6
+ notice: '%{resource_name} successfully created.'
7
+ alert: '%{resource_name} could not be created.'
8
+ update:
9
+ notice: '%{resource_name} successfully updated.'
10
+ alert: '%{resource_name} could not be updated.'
11
+ destroy:
12
+ notice: '%{resource_name} successfully deleted.'
13
+ alert: '%{resource_name} could not be deleted.'
14
14
  installation:
15
15
  protected: "Installation for %{host} is already complete. Please log in with your admin account."
16
- confirm:
17
- delete: 'Do you really want to delete this %{model_name}?'
16
+
17
+ confirmations:
18
+ destroy: 'Do you really want to delete this %{model_name}?'
19
+
20
+ menu:
21
+ sections: Sections
22
+ page: Page
23
+ view: View
24
+ new: New
25
+ edit: Edit
26
+ edit_section: Settings
27
+ destroy: Delete
28
+ reorder: Reorder
29
+ confirm_destroy: "Do you really want to delete this %{model_name}?"
30
+
31
+ columns:
32
+ published: Published
33
+ author: Author
34
+
35
+ status:
36
+ published: Published
37
+
38
+ actions:
39
+ view: View
40
+ edit: Edit
41
+ destroy: Delete
42
+
43
+ section:
44
+ types:
45
+ page: Page
46
+ default_name: Home
18
47
 
19
48
  installations:
20
49
  new:
@@ -29,11 +58,6 @@ en:
29
58
  confirm: You have successfully created your site. Enjoy!
30
59
  link_to_admin: "Manage your new site &raquo;"
31
60
 
32
- sections:
33
- columns:
34
- section: Section
35
- actions: ""
36
-
37
61
  admin:
38
62
  sites:
39
63
  index:
@@ -48,48 +72,21 @@ en:
48
72
  new: New Section
49
73
  site:
50
74
  new: New Site
51
- sections: All Sections
52
- menu:
53
- new: New Site
54
- edit: Edit
55
- destroy: Delete
56
- new_item: New Section
57
- confirm_destroy: "Do you really want to delete this %{model_name}?"
58
75
  sections:
59
76
  index:
60
77
  title: Sections
61
- view: View
62
- edit: Edit
63
- destroy: Delete
64
78
  published: Published
65
- confirm_destroy: "Do you really want to delete this %{model_name}?"
66
79
  new:
67
80
  title: Create a New Section
68
- show:
69
- title: Settings
70
- menu:
71
- sections: Sections
72
- new: New
73
- reorder: Reorder
74
81
  pages:
75
82
  show:
76
83
  title: Edit Page
77
84
  new:
78
85
  title: Create a New Section
79
- menu:
80
- sections: Sections
81
- new: New
82
- show: Page
83
- view: View
84
- destroy: Delete
85
- confirm_destroy: "Do you really want to delete this %{model_name}?"
86
- posts:
87
- edit:
88
- title: Settings
89
-
90
86
  tabs:
91
87
  options: Options
92
88
  assets: Assets
89
+
93
90
  layouts:
94
91
  default:
95
92
  made_with: "Made with <a href=\"http://github.com/svenfuchs/adva-cms2\">adva cms 2</a>"
@@ -108,11 +105,6 @@ en:
108
105
  change_language: "Change language:"
109
106
  website: "Website »"
110
107
 
111
- section:
112
- types:
113
- page: Page
114
- default_name: Home
115
-
116
108
  simple_form:
117
109
  "yes": 'Yes'
118
110
  "no": 'No'
@@ -10,14 +10,15 @@ require 'has_many_polymorphs'
10
10
  require 'minimal'
11
11
  require 'silence_log_tailer'
12
12
 
13
- require 'routing_filter'
13
+ require 'adva/i18n'
14
14
  require 'adva/routing_filters/section_path'
15
15
  require 'adva/routing_filters/section_root'
16
16
  require 'adva/controller/abstract_actions'
17
17
  require 'adva/controller/references'
18
18
  require 'adva/active_record/has_options'
19
- require 'adva/view/tabs'
20
19
  require 'adva/view/form'
20
+ require 'adva/view/helper/i18n'
21
+ require 'adva/view/tabs'
21
22
 
22
23
  require 'core_ext/ruby/module/include_anonymous'
23
24
  require 'core_ext/rails/action_view/has_many_through_collection_helpers'
@@ -0,0 +1,73 @@
1
+ require 'i18n/exceptions'
2
+
3
+ I18n.module_eval do
4
+ self.exception_handler = :log_missing_translations
5
+
6
+ class << self
7
+ attr_writer :missing_translations
8
+
9
+ def missing_translations
10
+ @missing_translations ||= MemoryLogger.new
11
+ end
12
+
13
+ def log_missing_translations(exception, locale, key, options)
14
+ missing_translations.log(exception.keys) if I18n::MissingTranslationData === exception
15
+ default_exception_handler(exception, locale, key, options)
16
+ end
17
+ end
18
+
19
+ class MemoryLogger < Hash
20
+ def initialize
21
+ at_exit { dump } if Rails.env.test?
22
+ end
23
+
24
+ def log(keys)
25
+ log = self
26
+ keys.each_with_index do |key, ix|
27
+ key = key.to_s
28
+ if ix < keys.size - 1
29
+ log = log.key?(key) ? log[key] : (log[key] = {})
30
+ else
31
+ log[key] = key.to_s.titleize
32
+ end
33
+ end
34
+ end
35
+
36
+ def dump
37
+ require 'yaml'
38
+ puts YAML.dump(Hash[*to_a.flatten]) unless empty?
39
+ end
40
+ end
41
+ end
42
+
43
+ # TODO move to I18n
44
+ I18n.module_eval do
45
+ class << self
46
+ def handle_exception(exception, locale, key, options)
47
+ case handler = options[:exception_handler] || config.exception_handler
48
+ when Symbol
49
+ send(handler, exception, locale, key, options)
50
+ else
51
+ handler.call(exception, locale, key, options)
52
+ end
53
+ end
54
+
55
+ def wrap_exception(exception, locale, key, options)
56
+ case exception
57
+ when MissingTranslationData
58
+ %(<span class="translation_missing">#{exception.keys.join('.')}</span>)
59
+ else
60
+ raise exception
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ I18n::MissingTranslationData.class_eval do
67
+ def keys
68
+ options.each { |k, v| options[k] = v.inspect if v.is_a?(Proc) }
69
+ keys = I18n.normalize_keys(locale, key, options[:scope])
70
+ keys << 'no key' if keys.size < 2
71
+ keys
72
+ end
73
+ end
@@ -28,4 +28,4 @@ module Adva
28
28
  end
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -1,4 +1,4 @@
1
- require 'routing_filter/filter'
1
+ require 'routing_filter'
2
2
 
3
3
  # If the path is, aside from a slash and an optional locale, the leftmost part
4
4
  # of the path, replace it by "sections/:id" segments.
@@ -1,4 +1,4 @@
1
- require 'routing_filter/filter'
1
+ require 'routing_filter'
2
2
 
3
3
  module RoutingFilter
4
4
  class SectionRoot < Filter
@@ -0,0 +1,26 @@
1
+ I18n::Backend::Simple.send(:include, I18n::Backend::Cascade)
2
+
3
+ # TODO no idea how to use a module here :/
4
+ ActionView::Base.class_eval do
5
+ def translate(key, options = {})
6
+ # TODO must be fixed in I18n::Backend::Cascade
7
+ options.merge!(:cascade => { :step => 1, :offset => 2, :skip_root => false }) if key.to_s.include?('.')
8
+ super(key, options)
9
+ end
10
+ alias t translate
11
+ end
12
+
13
+ # TODO submit a Rails patch
14
+ ActionView::Helpers::TranslationHelper.module_eval do
15
+ def translate(key, options = {})
16
+ options.merge!(:wrap_exception => true) unless options.key?(:wrap_exception)
17
+ translation = I18n.translate(scope_key_by_partial(key), options)
18
+ if html_safe_translation_key?(key) && translation.respond_to?(:html_safe)
19
+ translation.html_safe
20
+ else
21
+ translation
22
+ end
23
+ end
24
+ alias :t :translate
25
+ end
26
+
@@ -2,25 +2,47 @@ module Adva
2
2
  module View
3
3
  class Menu < Minimal::Template
4
4
  autoload :Admin, 'adva/view/menu/admin'
5
+ autoload :Items, 'adva/view/menu/items'
6
+
7
+ def to_html
8
+ build
9
+ render_items
10
+ end
5
11
 
6
12
  def item(text, url = nil, options = {}, &block)
7
- options.merge!(:class => text.to_s.gsub('.', '')) if text.is_a?(Symbol)
8
- url = url_for(url) unless url.is_a?(String)
9
- li(:class => active?(url, options) ? 'active' : nil) do
10
- options[:type] == :label ? h4(text, options) : link_to(text, url, options)
11
- self << capture { instance_eval(&block) } if block_given?
12
- end
13
+ items.insert(text, url, options, block)
13
14
  end
14
15
 
15
16
  def label(text, url = nil, options = {}, &block)
16
17
  item(text, url, options.merge(:type => :label), &block)
17
18
  end
18
19
 
19
- def link(text, url = '#', options = {}, &block)
20
- item(text, url, options.merge(:type => :link), &block)
21
- end
22
-
23
20
  protected
21
+ def items
22
+ @items ||= Items.new
23
+ end
24
+
25
+ def render_items
26
+ items, @items = self.items, Items.new
27
+ items.each { |args| render_item(*args) }
28
+ end
29
+
30
+ def render_item(text, url, options, block)
31
+ options.merge!(:class => text.to_s.split('.').last) if text.is_a?(Symbol)
32
+ url = url_for(url) unless url.is_a?(String) || options[:type] == :label
33
+
34
+ li(:class => active?(url, options) ? 'active' : nil) do
35
+ options[:type] == :label ? h4(text, options) : link_to(text, url, options)
36
+ render_block(block) if block
37
+ end
38
+ end
39
+
40
+ def render_block(block)
41
+ self << capture do
42
+ instance_eval(&block)
43
+ render_items
44
+ end
45
+ end
24
46
 
25
47
  def name
26
48
  @name ||= self.class.name.demodulize.underscore
@@ -12,18 +12,16 @@ module Adva
12
12
  id :actions
13
13
  end
14
14
 
15
- def to_html
15
+ def build
16
16
  div :id => id, :class => 'menus' do
17
- menus
18
- end
19
- end
20
-
21
- def menus
22
- ul :class => 'menu main' do
23
- main
24
- end
25
- ul :class => 'menu right' do
26
- right
17
+ ul :class => 'menu main' do
18
+ main
19
+ render_items
20
+ end
21
+ ul :class => 'menu right' do
22
+ right
23
+ render_items
24
+ end
27
25
  end
28
26
  end
29
27
 
@@ -39,9 +37,63 @@ module Adva
39
37
  self.class.read_inheritable_attribute(:id)
40
38
  end
41
39
 
40
+ def resource_label
41
+ label("#{resource.name}:")
42
+ end
43
+
44
+ def resource_section_label
45
+ label("#{resource.section.name}:")
46
+ end
47
+
48
+ def parent_resource_label
49
+ label("#{parent_resource.name}:")
50
+ end
51
+
52
+ def index
53
+ item(:".#{resource.class.name.pluralize.underscore}", index_path)
54
+ end
55
+
56
+ def show
57
+ item(:".#{resource.class.name.underscore}", show_path)
58
+ end
59
+
60
+ def edit
61
+ item(:'.edit', edit_path)
62
+ end
63
+
64
+ def edit_parent
65
+ item(:".edit_#{parent_resource.class.base_class.name.underscore}", edit_parent_path)
66
+ end
67
+
68
+ def categories(url = nil, options = { :before => :'.edit_section' })
69
+ item(:'.categories', url || index_path(:categories), options)
70
+ end
71
+
72
+ def new
73
+ item(:'.new', new_path)
74
+ end
75
+
76
+ def reorder(options = {})
77
+ item(:'.reorder', index_path, options.merge(:activate => false))
78
+ end
79
+
80
+ def destroy
81
+ item(:'.destroy', resource_path, :method => :delete, :confirm => t(:'.confirm_destroy', :model_name => resource.class.model_name.human))
82
+ end
83
+
42
84
  def persisted?
43
85
  resource.try(:persisted?)
44
86
  end
87
+
88
+ def collection?
89
+ index? || new? || create?
90
+ end
91
+
92
+ %w(index show new create edit update).each do |action|
93
+ define_method(:"#{action}?") do
94
+ params[:action] == action
95
+ end
96
+ end
45
97
  end
46
98
  end
47
99
  end
@@ -0,0 +1,26 @@
1
+ module Adva
2
+ module View
3
+ class Menu
4
+ class Items < Array
5
+ def insert(text, url, options, block)
6
+ item = [text, url, options, block]
7
+ if ix = options.delete(:at)
8
+ super(ix, item)
9
+ elsif ix = index(options.delete(:before))
10
+ super(ix, item)
11
+ elsif ix = index(options.delete(:after))
12
+ super(ix + 1, item)
13
+ elsif ix = index(options.delete(:replace))
14
+ self[ix] = item
15
+ else
16
+ push(item)
17
+ end
18
+ end
19
+
20
+ def index(text)
21
+ each_with_index { |item, ix| return ix if item[0] == text } and nil
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module AdvaCore
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'responders/flash_responder'
2
+
3
+ Responders::FlashResponder.class_eval do
4
+ def flash_defaults_by_namespace(status)
5
+ defaults = []
6
+ slices = controller.controller_path.split('/')
7
+
8
+ while slices.size > 0
9
+ defaults << :"flash.#{slices.fill(controller.controller_name, -1).join('.')}.#{controller.action_name}.#{status}"
10
+ defaults << :"flash.#{slices.join('.')}.#{controller.action_name}.#{status}"
11
+ slices.shift
12
+ end
13
+
14
+ defaults << :"flash.#{controller.action_name}.#{status}"
15
+ defaults.uniq << ""
16
+ end
17
+ end
@@ -14,11 +14,18 @@ objectify = lambda do |table|
14
14
  table.transpose
15
15
  end
16
16
 
17
+ TRANSFORM_FOREIGN_KEY_TYPES = Section.types.map(&:underscore) << 'section' << 'site'
18
+ TRANSFORM_FOREIGN_KEY_MAP = {}
19
+
17
20
  foreign_keyify = lambda do |table|
18
- types = Section.types.map(&:underscore) << 'section' << 'site'
19
- keys = types.map { |type| "#{type}_id" }
21
+ keys = TRANSFORM_FOREIGN_KEY_TYPES.map { |type| "#{type}_id" }
20
22
  keys = table.headers.select { |header| keys.include?(header) }
21
- keys.each { |key| table.map_column!(key) { |value| key.gsub('_id', '').classify.constantize.find_by_name(value).try(:id).to_s } }
23
+ keys.each do |key|
24
+ table.map_column!(key) do |value|
25
+ klass = TRANSFORM_FOREIGN_KEY_MAP[key] || key.gsub('_id', '').classify.constantize
26
+ Array(klass.find_by_name(value)).first.try(:id).to_s
27
+ end
28
+ end
22
29
  table.transpose
23
30
  end
24
31
 
@@ -5,7 +5,8 @@ $(document).ready(function() {
5
5
 
6
6
  $('a.reorder').click(function(event) {
7
7
  $(this).parent().toggleClass('active');
8
- TableTree.toggle($('table.list'), $(this).attr('data-resource_type'), $(this).attr('data-sortable_type'), this.href);
8
+ var url = this.href.split('/').slice(0, -1).join('/');
9
+ TableTree.toggle($('table.list'), $(this).attr('data-resource_type'), $(this).attr('data-sortable_type'), url);
9
10
  event.preventDefault();
10
11
  return false;
11
12
  })
@@ -23,12 +23,12 @@ TableTree = {
23
23
  return $(row).ttnode() ? true : false;
24
24
  }
25
25
  },
26
- toggle: function(table, resource_type, sortable_type, collection_url) {
27
- TableTree.current_table ? TableTree.teardown(table) : TableTree.setup(table, resource_type, sortable_type, collection_url);
26
+ toggle: function(table, resource_type, sortable_type, remote_url) {
27
+ TableTree.current_table ? TableTree.teardown(table) : TableTree.setup(table, resource_type, sortable_type, remote_url);
28
28
  },
29
- setup: function(table, resource_type, sortable_type, collection_url) {
29
+ setup: function(table, resource_type, sortable_type, remote_url) {
30
30
  $('tbody', table).tableDnD(TableTree.tableDnDOptions);
31
- TableTree.current_table = new TableTree.Table($(table).get(0), resource_type, sortable_type, collection_url);
31
+ TableTree.current_table = new TableTree.Table($(table).get(0), resource_type, sortable_type, remote_url);
32
32
  TableTree.current_table.setSortable();
33
33
  },
34
34
  teardown: function(table) {
@@ -54,13 +54,13 @@ TableTree = {
54
54
  }
55
55
  },
56
56
  Base: function() {},
57
- Table: function(table, resource_type, sortable_type, collection_url) {
57
+ Table: function(table, resource_type, sortable_type, remote_url) {
58
58
  this.is_tree = $(table).hasClass('tree')
59
59
  this.table = table; //$('tbody', table)
60
60
  this.resource_type = resource_type;
61
61
  this.sortable_type = sortable_type;
62
62
  this.level = -1;
63
- this.collection_url = collection_url;
63
+ this.remote_url = remote_url;
64
64
  this.rebuild();
65
65
  },
66
66
  Node: function(parent, element, level) {
@@ -156,7 +156,8 @@ TableTree.Table.prototype = jQuery.extend(new TableTree.Base(), {
156
156
  this.show_spinner(row);
157
157
  $.ajax({
158
158
  type: "POST",
159
- url: this.collection_url,
159
+ url: this.remote_url,
160
+ dataType: 'json',
160
161
  data: jQuery.extend(this.serialize(row), { authenticity_token: window._auth_token, '_method': 'put' }),
161
162
  success: function(msg) { _this.hide_spinner(row); },
162
163
  error: function(msg) { _this.hide_spinner(row); }
@@ -167,13 +168,13 @@ TableTree.Table.prototype = jQuery.extend(new TableTree.Base(), {
167
168
  var data = {};
168
169
  var key = this.resource_type + '[' + this.sortable_type + '_attributes][0]'
169
170
  data[key + '[id]'] = row.id() || '';
170
- data[key + '[parent_id]'] = row.parent_id() || '';
171
- data[key + '[left_id]'] = row.left_id() || '';
171
+ data[key + '[parent_id]'] = row.parent_id() || 'null';
172
+ data[key + '[left_id]'] = row.left_id() || 'null';
172
173
  return data;
173
174
  },
174
175
  show_spinner: function(row) {
175
176
  img = document.createElement('img');
176
- img.src = '/images/adva_cms/indicator.gif';
177
+ img.src = '/images/adva-core/indicator.gif';
177
178
  img.className = 'spinner';
178
179
  $('td', row)[0].appendChild(img);
179
180
  },
@@ -257,12 +258,15 @@ TableTree.Node.prototype = jQuery.extend(new TableTree.Base(), {
257
258
 
258
259
  this.level = level;
259
260
  this.children.each(function() { this.update_level(event, level + 1); });
261
+
262
+ TableTree.current_table.dirty = true;
260
263
  },
261
264
  adjust_level: function() {
262
265
  var prev = $(this.element).prev().ttnode();
263
266
  if(!prev) {
264
267
  this.update_level(null, 0);
265
268
  } else if(prev.level + 1 < this.level) {
269
+ // } else {
266
270
  this.update_level(null, prev.level + 1);
267
271
  }
268
272
  },
@@ -191,7 +191,7 @@
191
191
  font-weight: normal;
192
192
  }
193
193
  #actions h4:after {
194
- content: ':';
194
+ /* content: ':'; */
195
195
  }
196
196
  #actions .main li a {
197
197
  -webkit-border-top-left-radius: 5px;
@@ -121,6 +121,14 @@ p.active a {
121
121
  -moz-border-radius:4px 4px 4px 4px;
122
122
  }
123
123
 
124
+ .tree .drag {
125
+ background-color: lightyellow;
126
+ }
127
+ .tree .spinner {
128
+ float: right;
129
+ padding-top: 2px;
130
+ }
131
+
124
132
  /* TODO move to adva-assets */
125
133
 
126
134
  ul#uploaded_images {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adva-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ingo Weiss
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-29 00:00:00 +02:00
19
+ date: 2010-11-08 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -91,12 +91,12 @@ dependencies:
91
91
  requirements:
92
92
  - - "="
93
93
  - !ruby/object:Gem::Version
94
- hash: 5
94
+ hash: 3
95
95
  segments:
96
96
  - 0
97
97
  - 0
98
- - 13
99
- version: 0.0.13
98
+ - 14
99
+ version: 0.0.14
100
100
  type: :runtime
101
101
  version_requirements: *id005
102
102
  - !ruby/object:Gem::Dependency
@@ -155,12 +155,12 @@ dependencies:
155
155
  requirements:
156
156
  - - "="
157
157
  - !ruby/object:Gem::Version
158
- hash: 17
158
+ hash: 11
159
159
  segments:
160
160
  - 0
161
161
  - 0
162
- - 7
163
- version: 0.0.7
162
+ - 10
163
+ version: 0.0.10
164
164
  type: :runtime
165
165
  version_requirements: *id009
166
166
  - !ruby/object:Gem::Dependency
@@ -171,12 +171,12 @@ dependencies:
171
171
  requirements:
172
172
  - - "="
173
173
  - !ruby/object:Gem::Version
174
- hash: 1
174
+ hash: 57
175
175
  segments:
176
176
  - 0
177
177
  - 0
178
- - 15
179
- version: 0.0.15
178
+ - 19
179
+ version: 0.0.19
180
180
  type: :runtime
181
181
  version_requirements: *id010
182
182
  - !ruby/object:Gem::Dependency
@@ -211,7 +211,7 @@ dependencies:
211
211
  version: 0.0.1
212
212
  type: :runtime
213
213
  version_requirements: *id012
214
- description: "[description]"
214
+ description: Core engine for adva-cms2
215
215
  email: nobody@adva-cms.org
216
216
  executables: []
217
217
 
@@ -244,6 +244,7 @@ files:
244
244
  - app/views/pages/show.html.rb
245
245
  - app/views/installations/show.html.rb
246
246
  - app/views/installations/new.html.rb
247
+ - app/views/admin/contents/_menu.html.rb
247
248
  - app/views/admin/pages/show.html.rb
248
249
  - app/views/admin/pages/new.html.rb
249
250
  - app/views/admin/pages/_menu.html.rb
@@ -285,6 +286,7 @@ files:
285
286
  - lib/patches/rails/url_for.rb
286
287
  - lib/patches/rails/sti_associations.rb
287
288
  - lib/patches/inherited_resources.rb
289
+ - lib/patches/responders/flash_responder.rb
288
290
  - lib/patches/simple_form.rb
289
291
  - lib/patches/thor/group/symbolized_options.rb
290
292
  - lib/patches/thor/core_ext/hash.rb
@@ -318,6 +320,7 @@ files:
318
320
  - lib/adva/active_record/has_options.rb
319
321
  - lib/adva/rack/static.rb
320
322
  - lib/adva/rack.rb
323
+ - lib/adva/i18n.rb
321
324
  - lib/adva/view.rb
322
325
  - lib/adva/testing/engine.rb
323
326
  - lib/adva/responder.rb
@@ -325,8 +328,10 @@ files:
325
328
  - lib/adva/routing_filters/section_path.rb
326
329
  - lib/adva/view/tabs.rb
327
330
  - lib/adva/view/menu/admin.rb
331
+ - lib/adva/view/menu/items.rb
328
332
  - lib/adva/view/form.rb
329
333
  - lib/adva/view/menu.rb
334
+ - lib/adva/view/helper/i18n.rb
330
335
  - lib/adva/view/form/tabs.rb
331
336
  - lib/adva/controller.rb
332
337
  - lib/adva/engine.rb
@@ -341,6 +346,7 @@ files:
341
346
  - lib/testing/factories.rb
342
347
  - lib/testing/assertions.rb
343
348
  - lib/testing/paths.rb
349
+ - lib/adva_core/version.rb
344
350
  - public/stylesheets/adva-core/common/styles.css
345
351
  - public/stylesheets/adva-core/common/layout.css
346
352
  - public/stylesheets/adva-core/common/reset.css
@@ -481,13 +487,11 @@ files:
481
487
  - public/images/adva-core/icons/bullet_yellow.png
482
488
  - public/images/adva-core/icons/bullet_white.png
483
489
  - public/images/adva-core/asset_selected.png
484
- - public/images/adva-core/sortable_tree/drag.png
485
490
  - public/images/adva-core/avatar.gif
486
491
  - public/images/adva-core/lines.png
487
492
  - public/images/adva-core/feed.mini.png
488
493
  - public/images/adva-core/indicator.gif
489
494
  - public/images/adva-core/preview.png
490
- - public/images/adva-core/rails.png
491
495
  - public/images/adva-core/admin/section_menu_bg.png
492
496
  - public/images/adva-core/admin/tab_action_active.png
493
497
  - public/images/adva-core/admin/tab_sidebar_active.png
@@ -531,6 +535,6 @@ rubyforge_project: "[none]"
531
535
  rubygems_version: 1.3.7
532
536
  signing_key:
533
537
  specification_version: 3
534
- summary: "[summary]"
538
+ summary: Core engine for adva-cms2
535
539
  test_files: []
536
540