voluntary 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/app/assets/javascripts/voluntary/application.js +1 -1
  2. data/app/assets/javascripts/voluntary/base.js.coffee +30 -1
  3. data/app/assets/stylesheets/voluntary/application.css +1 -0
  4. data/app/assets/stylesheets/voluntary/base.css.sass +1 -1
  5. data/app/controllers/areas_controller.rb +6 -5
  6. data/app/controllers/candidatures_controller.rb +15 -10
  7. data/app/controllers/concerns/voluntary/v1/base_controller.rb +95 -0
  8. data/app/controllers/devise_extensions/registrations_controller.rb +2 -2
  9. data/app/controllers/organizations_controller.rb +7 -6
  10. data/app/controllers/professions_controller.rb +6 -5
  11. data/app/controllers/projects_controller.rb +11 -6
  12. data/app/controllers/users_controller.rb +2 -2
  13. data/app/controllers/vacancies_controller.rb +14 -5
  14. data/app/controllers/voluntary/api/v1/api_controller.rb +9 -0
  15. data/app/controllers/voluntary/application_controller.rb +2 -66
  16. data/app/controllers/workflow/candidatures_controller.rb +1 -1
  17. data/app/controllers/workflow/products_controller.rb +7 -7
  18. data/app/controllers/workflow/stories_controller.rb +1 -1
  19. data/app/controllers/workflow/tasks_controller.rb +2 -2
  20. data/app/controllers/workflow/user/product/areas_controller.rb +2 -2
  21. data/app/controllers/workflow/user/projects_controller.rb +10 -2
  22. data/app/helpers/voluntary/application_helper.rb +79 -0
  23. data/app/helpers/voluntary/collection_helper.rb +45 -0
  24. data/app/helpers/voluntary/comments_helper.rb +13 -0
  25. data/app/helpers/voluntary/form_helper.rb +46 -0
  26. data/app/helpers/voluntary/language_helper.rb +17 -0
  27. data/app/helpers/voluntary/layout_helper.rb +42 -0
  28. data/app/helpers/voluntary/product_helper.rb +36 -0
  29. data/app/helpers/voluntary/show_helper.rb +67 -0
  30. data/app/helpers/voluntary/wizard_helper.rb +29 -0
  31. data/app/models/ability.rb +20 -4
  32. data/app/models/candidature.rb +10 -7
  33. data/app/models/column.rb +1 -0
  34. data/app/models/concerns/user/extensions.rb +5 -0
  35. data/app/models/concerns/user/listable.rb +10 -0
  36. data/app/models/list.rb +30 -0
  37. data/app/models/list_item.rb +22 -0
  38. data/app/models/organization.rb +1 -0
  39. data/app/models/page.rb +2 -1
  40. data/app/models/product.rb +3 -2
  41. data/app/models/project.rb +2 -2
  42. data/app/models/result.rb +1 -0
  43. data/app/models/role.rb +1 -1
  44. data/app/models/state_machines/candidature.rb +17 -1
  45. data/app/models/state_machines/story.rb +15 -2
  46. data/app/models/state_machines/task.rb +33 -0
  47. data/app/models/story.rb +3 -2
  48. data/app/models/task.rb +44 -6
  49. data/app/models/thing.rb +3 -0
  50. data/app/models/user.rb +15 -4
  51. data/app/models/vacancy.rb +7 -5
  52. data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +1 -1
  53. data/app/presenters/shared/collection/table_presenter.rb +1 -1
  54. data/app/views/candidatures/index.html.erb +1 -1
  55. data/app/views/candidatures/show.html.erb +1 -1
  56. data/app/views/columns/_collection.html.erb +0 -0
  57. data/app/views/comments/_resource.html.erb +1 -1
  58. data/app/views/layouts/application.html.erb +12 -0
  59. data/app/views/layouts/shared/_navigation.html.erb +3 -3
  60. data/app/views/organizations/show.html.erb +0 -1
  61. data/app/views/products/index.html.erb +53 -4
  62. data/app/views/projects/_form.html.erb +1 -0
  63. data/app/views/projects/show.html.erb +2 -1
  64. data/app/views/shared/collection/_list.html.erb +1 -1
  65. data/app/views/shared/resource/_actions.html.erb +2 -2
  66. data/app/views/stories/_column_fields.html.erb +0 -0
  67. data/app/views/stories/_form.html.erb +1 -1
  68. data/app/views/stories/steps/_activate.html.erb +1 -1
  69. data/app/views/workflow/products/show.html.erb +1 -1
  70. data/app/views/workflow/project_owner/_candidatures.html.erb +2 -1
  71. data/app/views/workflow/tasks/_work_head.html.erb +1 -1
  72. data/app/views/workflow/tasks/steps/_complete.html.erb +6 -2
  73. data/app/views/workflow/tasks/steps/_review.html.erb +6 -2
  74. data/app/views/workflow/tasks/steps/_work.html.erb +4 -2
  75. data/app/views/workflow/user/product/areas/show.html.erb +0 -0
  76. data/app/views/workflow/user/projects/show.html.erb +0 -0
  77. data/config/initializers/devise.rb +2 -5
  78. data/config/initializers/filter_parameters_logging.rb +1 -0
  79. data/config/initializers/friendly_id.rb +88 -0
  80. data/config/initializers/wrap_parameters.rb +15 -0
  81. data/config/locales/general/en.yml +15 -9
  82. data/config/locales/resources/story/en.yml +1 -0
  83. data/config/routes.rb +9 -0
  84. data/config/routes/workflow.rb +15 -15
  85. data/db/migrate/20120907144853_create_schema.rb +1 -1
  86. data/db/migrate/20120922201955_create_mongo_db_documents.rb +1 -1
  87. data/db/migrate/20121004132105_create_professions.rb +1 -1
  88. data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +20 -1
  89. data/db/migrate/20130817090734_create_lists.rb +33 -0
  90. data/db/migrate/20131018143613_replace_user_by_polymorphic_resource_in_candidatures.rb +46 -0
  91. data/db/migrate/20140307113214_add_user_id_to_organizations.rb +5 -0
  92. data/lib/api_constraints.rb +10 -0
  93. data/lib/applicat/mvc/model/tree.rb +1 -1
  94. data/lib/concerns/model/base_list_item.rb +30 -0
  95. data/lib/concerns/model/base_thing.rb +50 -0
  96. data/lib/db_seed.rb +15 -4
  97. data/lib/generators/voluntary/install/install_generator.rb +17 -16
  98. data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +17 -1
  99. data/lib/generators/voluntary/install/templates/config/main_navigation.rb +1 -260
  100. data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +1 -2
  101. data/lib/generators/voluntary/install/templates/spec/factories.rb +19 -0
  102. data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +14 -4
  103. data/lib/generators/voluntary/product_dummy/product_dummy_generator.rb +23 -17
  104. data/lib/generators/voluntary/product_dummy/templates/config/database.example.yml +1 -1
  105. data/lib/generators/voluntary/product_dummy/templates/dummy/spec/factories.rb +19 -0
  106. data/lib/generators/voluntary/product_dummy/templates/dummy/spec/spec_helper.rb +75 -0
  107. data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb +1 -2
  108. data/lib/generators/voluntary/product_dummy/templates/spec/factories.rb +19 -0
  109. data/lib/voluntary.rb +10 -22
  110. data/lib/voluntary/engine.rb +27 -3
  111. data/lib/voluntary/navigation.rb +358 -0
  112. data/lib/voluntary/test/rspec_helpers/factories.rb +123 -0
  113. data/lib/voluntary/version.rb +1 -1
  114. data/vendor_extensions/active_model/naming.rb +1 -1
  115. metadata +526 -308
  116. data/app/helpers/application_helper.rb +0 -65
  117. data/app/helpers/collection_helper.rb +0 -35
  118. data/app/helpers/comments_helper.rb +0 -11
  119. data/app/helpers/form_helper.rb +0 -43
  120. data/app/helpers/language_helper.rb +0 -15
  121. data/app/helpers/layout_helper.rb +0 -39
  122. data/app/helpers/product_helper.rb +0 -34
  123. data/app/helpers/show_helper.rb +0 -65
  124. data/app/helpers/wizard_helper.rb +0 -27
  125. data/app/observers/candidature_observer.rb +0 -29
  126. data/app/observers/story_observer.rb +0 -6
  127. data/app/observers/task_observer.rb +0 -34
  128. data/lib/voluntary/helpers/application.rb +0 -69
  129. data/lib/voluntary/helpers/collection.rb +0 -35
  130. data/lib/voluntary/helpers/comments.rb +0 -15
  131. data/lib/voluntary/helpers/form.rb +0 -43
  132. data/lib/voluntary/helpers/language.rb +0 -19
  133. data/lib/voluntary/helpers/layout.rb +0 -28
  134. data/lib/voluntary/helpers/product.rb +0 -36
  135. data/lib/voluntary/helpers/show.rb +0 -69
  136. data/lib/voluntary/helpers/wizard.rb +0 -31
@@ -18,12 +18,28 @@ module StateMachines::Candidature
18
18
  end
19
19
 
20
20
  event :deny do
21
- transition :new => :denied
21
+ transition [:new, :accepted] => :denied
22
22
  end
23
23
 
24
24
  event :quit do
25
25
  transition :accepted => :denied
26
26
  end
27
+
28
+ after_transition do |object, transition|
29
+ case transition.to
30
+ when 'accepted'
31
+ ProjectUser.find_or_create_by_project_id_and_vacancy_id_and_user_id!(
32
+ project_id: object.vacancy.project_id, vacancy_id: object.vacancy_id,
33
+ user_id: object.resource_id
34
+ )
35
+
36
+ if object.vacancy.limit == object.vacancy.candidatures.accepted.count
37
+ object.vacancy.close! unless object.vacancy.closed?
38
+ end
39
+ when 'denied'
40
+ # if comming from :accepted then the vacancy offerer has to reopen the vacancy manually
41
+ end
42
+ end
27
43
  end
28
44
 
29
45
  private
@@ -20,7 +20,7 @@ module StateMachines::Story
20
20
  end
21
21
 
22
22
  state :tasks_defined do
23
- validates_associated :tasks
23
+ #validates_associated :tasks
24
24
  validate :presence_of_tasks
25
25
  end
26
26
 
@@ -35,12 +35,25 @@ module StateMachines::Story
35
35
  event :close do
36
36
  transition :completed => :closed
37
37
  end
38
+
39
+ before_transition do |object, transition|
40
+ object.event = transition.event.to_s
41
+ object.state_before = transition.from
42
+ end
38
43
  end
39
44
 
40
45
  private
41
46
 
42
47
  def presence_of_tasks
43
- unless tasks.any?
48
+ self.tasks.delete_if{|t| t.name.blank? && t.text.blank? }
49
+
50
+ if tasks.select{|t| !t.valid?}.any?
51
+ errors[:base] << I18n.t(
52
+ 'activerecord.errors.models.story.attributes.base.invalid_tasks'
53
+ )
54
+ end
55
+
56
+ if tasks.none?
44
57
  errors[:base] << I18n.t(
45
58
  'activerecord.errors.models.story.attributes.base.missing_tasks'
46
59
  )
@@ -40,6 +40,39 @@ module StateMachines::Task
40
40
  # TODO: complete the story through observer
41
41
  transition :under_supervision => :completed
42
42
  end
43
+
44
+ before_transition do |object, transition|
45
+ object.event = transition.event.to_s
46
+ object.state_before = transition.from
47
+
48
+ case transition.event
49
+ when :assign
50
+ object.author_id = object.user_id
51
+ when :cancel
52
+ object.unassigned_user_ids ||= []
53
+ object.unassigned_user_ids << object.user_id
54
+ object.user_id = nil
55
+ object.author_id = nil
56
+ object.result.text = nil if object.result
57
+ when :review
58
+ object.user_id = object.offeror_id
59
+ when :follow_up
60
+ object.user_id = object.author_id
61
+ end
62
+ end
63
+
64
+ after_transition do |object, transition|
65
+ case transition.event
66
+ when :follow_up
67
+ if object.story.completed?
68
+ object.story.activate
69
+ end
70
+ when :complete
71
+ if object.story.tasks.complete.count == object.story.tasks.count
72
+ object.story.complete
73
+ end
74
+ end
75
+ end
43
76
  end
44
77
  end
45
78
  end
data/app/models/story.rb CHANGED
@@ -2,6 +2,7 @@ class Story
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
4
  include Mongoid::Slug
5
+ include ActiveModel::MassAssignmentSecurity
5
6
 
6
7
  include Model::MongoDb::Customizable
7
8
  include StateMachines::Story
@@ -25,7 +26,7 @@ class Story
25
26
 
26
27
  attr_accessible :project_id, :name, :text, :tasks_attributes
27
28
 
28
- scope :active, where(state: 'active')
29
+ scope :active, -> { where(state: 'active') }
29
30
 
30
31
  validates :project_id, presence: true
31
32
  validates :offeror_id, presence: true
@@ -61,7 +62,7 @@ class Story
61
62
  if task
62
63
  task.user_id = user.id
63
64
 
64
- return task.errors.full_messages.join('<br/>') unless task.assign
65
+ raise task.errors.full_messages.join('<br/>') unless task.assign
65
66
  else
66
67
  self.users_without_tasks_ids ||= []
67
68
  self.users_without_tasks_ids << user.id
data/app/models/task.rb CHANGED
@@ -3,6 +3,7 @@ class Task
3
3
  include Mongoid::Timestamps
4
4
  include Mongoid::Slug
5
5
  #include Mongoid::History::Trackable
6
+ include ActiveModel::MassAssignmentSecurity
6
7
 
7
8
  include Model::MongoDb::Customizable
8
9
  include Model::MongoDb::Commentable
@@ -25,11 +26,11 @@ class Task
25
26
 
26
27
  attr_accessible :story, :story_id, :name, :text, :result_attributes
27
28
 
28
- scope :current, where(state: 'new')
29
- scope :unassigned, where(user_id: nil)
30
- scope :assigned, ne(user_id: nil)
31
- scope :complete, where(state: 'completed')
32
- scope :incomplete, ne(state: 'completed')
29
+ scope :current, -> { where(state: 'new') }
30
+ scope :unassigned, -> { where(user_id: nil) }
31
+ scope :assigned, -> { ne(user_id: nil) }
32
+ scope :complete, -> { where(state: 'completed') }
33
+ scope :incomplete, -> { ne(state: 'completed') }
33
34
 
34
35
  validates :story_id, presence: true
35
36
  validates :offeror_id, presence: true
@@ -61,10 +62,47 @@ class Task
61
62
  end
62
63
  end
63
64
 
65
+ def with_result?
66
+ true
67
+ end
68
+
69
+ def before_transition(transition)
70
+ self.event = transition.event.to_s
71
+ self.state_before = transition.from
72
+
73
+ case transition.event
74
+ when :assign
75
+ self.author_id = self.user_id
76
+ when :cancel
77
+ self.unassigned_user_ids ||= []
78
+ self.unassigned_user_ids << self.user_id
79
+ self.user_id = nil
80
+ self.author_id = nil
81
+ self.result.text = nil if self.result
82
+ when :review
83
+ self.user_id = self.offeror_id
84
+ when :follow_up
85
+ self.user_id = self.author_id
86
+ end
87
+ end
88
+
89
+ def after_transition(transition)
90
+ case transition.event
91
+ when :follow_up
92
+ self.story.activate if self.story.completed?
93
+ when :complete
94
+ if self.story.tasks.complete.count == self.story.tasks.count
95
+ self.story.complete
96
+ end
97
+ end
98
+ end
99
+
64
100
  protected
65
101
 
66
102
  # validates :name, presence: true, uniqueness: { scope: :story_id }
67
103
  def name_valid?
104
+ return unless name_changed?
105
+
68
106
  if name.present?
69
107
  if Task.where(name: name, story_id: story_id).any?
70
108
  errors.add(:name, I18n.t('errors.messages.taken'))
@@ -83,4 +121,4 @@ class Task
83
121
  def cache_product_association
84
122
  self.product_id = story.product_id if story_id.present? && (story rescue nil)
85
123
  end
86
- end
124
+ end
@@ -0,0 +1,3 @@
1
+ class Thing < ActiveRecord::Base
2
+ include Concerns::Model::BaseThing
3
+ end
data/app/models/user.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  class User < ActiveRecord::Base
2
2
  include ::Applicat::Mvc::Model::Resource::Base
3
+ include User::Listable
4
+ include User::Extensions
3
5
 
4
6
  belongs_to :main_role, class_name: 'Role'
5
7
  belongs_to :profession
@@ -8,9 +10,10 @@ class User < ActiveRecord::Base
8
10
  has_and_belongs_to_many :areas
9
11
  has_and_belongs_to_many :projects
10
12
 
13
+ has_many :organizations, dependent: :destroy
11
14
  has_many :offeror_vacancies, source: :offeror, class_name: 'Vacancy'
12
15
  has_many :offeror_candidatures, source: :offeror, class_name: 'Candidature'
13
- has_many :candidatures
16
+ has_many :candidatures, as: :resource
14
17
 
15
18
  accepts_nested_attributes_for :areas, allow_destroy: true
16
19
 
@@ -23,10 +26,10 @@ class User < ActiveRecord::Base
23
26
  validates :country, presence: true
24
27
  validates :interface_language, presence: true
25
28
 
26
- attr_accessible :name, :password, :password_confirmation, :text, :language, :first_name, :last_name,
29
+ attr_accessible :name, :password, :password_confirmation, :remember_me, :text, :language, :first_name, :last_name,
27
30
  :salutation, :marital_status, :family_status, :date_of_birth, :place_of_birth, :citizenship,
28
31
  :email, :country, :language, :interface_language, :foreign_language_tokens, :profession_id,
29
- :employment_relationship, :area_tokens,
32
+ :employment_relationship, :area_tokens, :remember_me
30
33
  # preferences
31
34
  :main_role_id
32
35
 
@@ -59,6 +62,10 @@ class User < ActiveRecord::Base
59
62
  options
60
63
  end
61
64
 
65
+ def is_master?
66
+ roles.where(name: 'Master').any?
67
+ end
68
+
62
69
  def languages
63
70
  (foreign_languages || []) + [language]
64
71
  end
@@ -87,9 +94,13 @@ class User < ActiveRecord::Base
87
94
  areas
88
95
  end
89
96
 
97
+ def full_name
98
+ [first_name, last_name].join(' ')
99
+ end
100
+
90
101
  private
91
102
 
92
103
  def set_main_role
93
- self.update_attribute :main_role_id, Role.find_or_create_by_name('User').id
104
+ self.update_attribute :main_role_id, Role.find_or_create_by(name: 'User').id if self.respond_to? :main_role_id
94
105
  end
95
106
  end
@@ -4,13 +4,15 @@ class Vacancy < ActiveRecord::Base
4
4
  belongs_to :project
5
5
  belongs_to :offeror, class_name: 'User'
6
6
  belongs_to :author, class_name: 'User'
7
- belongs_to :user
7
+ belongs_to :resource, polymorphic: true
8
8
  belongs_to :project_user
9
9
 
10
10
  has_many :candidatures, dependent: :destroy
11
11
  has_many :comments, as: :commentable, dependent: :destroy
12
12
 
13
- scope :open, where(state: 'open')
13
+ accepts_nested_attributes_for :candidatures, allow_destroy: true, reject_if: ->(t) { t['name'].blank? }
14
+ scope :open, -> { where(state: 'open') }
15
+
14
16
 
15
17
  validates :project_id, presence: true
16
18
  validates :offeror_id, presence: true
@@ -18,7 +20,7 @@ class Vacancy < ActiveRecord::Base
18
20
  validates :text, presence: true
19
21
  validates :limit, presence: true
20
22
 
21
- attr_accessible :project_id, :name, :text, :limit
23
+ attr_accessible :project_id, :name, :text, :limit, :candidatures_attributes
22
24
 
23
25
  extend FriendlyId
24
26
 
@@ -30,7 +32,7 @@ class Vacancy < ActiveRecord::Base
30
32
  limit - candidatures.accepted.count
31
33
  end
32
34
 
33
- private
35
+ protected
34
36
 
35
37
  def set_defaults
36
38
  if project
@@ -38,4 +40,4 @@ class Vacancy < ActiveRecord::Base
38
40
  self.author_id = project.user_id unless self.author_id.present?
39
41
  end
40
42
  end
41
- end
43
+ end
@@ -1,5 +1,5 @@
1
1
  class Resources::General::Wizards::Story::Steps::SetupTasksPresenter < Presenter
2
2
  def form_options
3
- { html: {class: 'form-horizontal'} }
3
+ { html: {class: 'form-horizontal'}, url: story_path(resource), as: :story }
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ class Shared::Collection::TablePresenter < Presenter
14
14
  end
15
15
 
16
16
  def actions
17
- return '' unless show_actions
17
+ return content_tag(:td, '') unless show_actions
18
18
 
19
19
  content_tag :td, render('shared/resource/actions', type: type, resource: resource)
20
20
  end
@@ -1,4 +1,4 @@
1
- <% columns = { 'name' => 'user.name', 'user_id' => ''} %>
1
+ <% columns = { 'name' => 'resource.name', 'resource_id' => ''} %>
2
2
  <% columns['vacancy_id'] = '' unless @vacancy %>
3
3
  <% columns['project_id'] = 'vacancy.project' unless @vacancy %>
4
4
 
@@ -8,7 +8,7 @@
8
8
  </h3>
9
9
 
10
10
  <dl class="dl-horizontal">
11
- <%= show_associations :project, :vacancy, :user %>
11
+ <%= show_associations :project, :vacancy, :resource %>
12
12
  <%= show_attribute :state %>
13
13
  <%= show_actions %>
14
14
  </dl>
File without changes
@@ -11,6 +11,6 @@
11
11
  "new_#{resource.commentable_type.tableize.singularize}_comment_path(resource.commentable, comment: { parent_id: resource.id })"
12
12
  ), class: 'new_comment' %> |
13
13
  <%= link_to t('general.edit'), edit_comment_path(resource), class: 'edit_comment' %> |
14
- <%= link_to t('general.destroy'), resource, confirm: t('general.questions.are_you_sure'), method: :delete, class: 'destroy_comment' %>
14
+ <%= link_to t('general.destroy'), resource, data: { confirm: t('general.questions.are_you_sure') }, method: :delete, class: 'destroy_comment' %>
15
15
  </div>
16
16
  </div>
@@ -4,7 +4,9 @@
4
4
  <title><%= t('layout.title') %></title>
5
5
  <meta charset='utf-8'>
6
6
  <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
8
  <%= stylesheet_link_tag 'voluntary/application', media: 'all' %>
9
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
10
  <link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet"/>
9
11
  </head>
10
12
  <body>
@@ -24,6 +26,7 @@
24
26
  </div>
25
27
  <% end %>
26
28
  <div class="row-fluid">
29
+ <% if sidenav(@sidenav_links_count).present? %>
27
30
  <div class="span9">
28
31
  <%= breadcrumbs %>
29
32
 
@@ -32,6 +35,13 @@
32
35
  <div class="span3">
33
36
  <%= sidenav(@sidenav_links_count) %>
34
37
  </div>
38
+ <% else %>
39
+ <div class="span12">
40
+ <%= breadcrumbs %>
41
+
42
+ <%= yield %>
43
+ </div>
44
+ <% end %>
35
45
  </div>
36
46
  </div>
37
47
  <div class="container-fluid">
@@ -42,6 +52,8 @@
42
52
  </div>
43
53
  </div>
44
54
  <%= javascript_include_tag 'voluntary/application' %>
55
+ <%= javascript_include_tag 'application' %>
56
+ <%= yield :javascript_includes %>
45
57
  <%= csrf_meta_tags %>
46
58
  <%= javascript_tag do %>
47
59
  <%= yield :top_javascript %>
@@ -1,10 +1,10 @@
1
1
  <div class="navbar navbar-inverse navbar-fixed-top">
2
2
  <div class="navbar-inner">
3
3
  <div class="container">
4
- <a id="plattform_brand" class="brand" href="#">Volontari.at /</a>
5
- <a id="product_brand" class="brand" href="#">Core</a>
4
+ <a id="plattform_brand" class="brand" href="/">Volontari.at /</a>
5
+ <a id="product_brand" class="brand" href="<%= navigation_product_path %>"><%= navigation_product_name %></a>
6
6
 
7
- <%= render_navigation context: :main, expand_all: false, renderer: :bootstrap %>
7
+ <%= render_navigation context: application_navigation, expand_all: false, renderer: :bootstrap %>
8
8
  </div>
9
9
  </div>
10
10
  </div>
@@ -1,6 +1,5 @@
1
1
  <h3><%= @organization.name %></h3>
2
2
 
3
3
  <dl class="dl-horizontal">
4
- <%= show_associations :parent %>
5
4
  <%= show_actions %>
6
5
  </dl>
@@ -1,5 +1,54 @@
1
- <%= form_tag update_multiple_products_path, method: :post do %>
2
- <%= render partial: 'shared/collection/table', locals: {
3
- type: 'products', collection: @products, columns: ['name']
4
- } %>
1
+ <h3><%= t("products.index.title") %></h3>
2
+ <% if @products.none? || @products.select{|e| e.id.present? }.none? %>
3
+ <p><%= I18n.t("products.index.empty_collection")%></p>
4
+ <% else %>
5
+ <table class="table table-striped">
6
+ <thead>
7
+ <tr class="<%= cycle('odd', 'even') %>">
8
+ <th><%= t("activerecord.attributes.product.name") %></th>
9
+ <th></th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% @products.select{|e| e.id.present? }.each do |product| %>
14
+ <tr class="<%= cycle('odd', 'even') %>">
15
+ <td>
16
+ <%= link_to product.name, product_path(product) %>
17
+ </td>
18
+ <td>
19
+ <% if !product.is_a?(Column) && (
20
+ can?(:destroy, product) || can?(:edit, product) || (
21
+ product.respond_to?(:state_events) && product.state_events.select{|event| can? event, product }.any?
22
+ )
23
+ ) %>
24
+ <div class="dropdown">
25
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= t('general.actions') %></a>
26
+ <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
27
+ <% if can? :destroy, product %>
28
+ <li>
29
+ <%= link_to(
30
+ t('general.destroy'), product_path(product.id), id: "product_#{product.id}", method: :delete,
31
+ data: { confirm: t('general.questions.are_you_sure') },
32
+ onclick: "delete_link('product_#{product.id}'); return false;"
33
+ )
34
+ %>
35
+ </li>
36
+ <% end %>
37
+ <% if can? :edit, product %>
38
+ <li><%= link_to t('general.edit'), eval("edit_product_path(product)") %></li>
39
+ <% end %>
40
+ <% if product.respond_to? :state_events %>
41
+ <li class="divider"></li>
42
+ <% end %>
43
+ <%= render 'shared/resource/event_elements', resource: product, type: 'products' %>
44
+ </ul>
45
+ </div>
46
+ <% end %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
5
52
  <% end %>
53
+
54
+ <%= link_to t("products.new.title"), products_path %>