voluntary 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/voluntary/application.js +6 -0
- data/app/assets/javascripts/voluntary/base.js.coffee +34 -0
- data/app/assets/javascripts/voluntary/bootstrap.js.coffee +4 -0
- data/app/assets/javascripts/voluntary/functions.js +24 -0
- data/app/assets/javascripts/voluntary/users.js.coffee +12 -0
- data/app/assets/stylesheets/voluntary/application.css +15 -0
- data/app/assets/stylesheets/voluntary/base.css.scss +40 -0
- data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.less +67 -0
- data/app/controllers/areas_controller.rb +66 -0
- data/app/controllers/candidatures_controller.rb +79 -0
- data/app/controllers/comments_controller.rb +70 -0
- data/app/controllers/devise_extensions/registrations_controller.rb +37 -0
- data/app/controllers/home_controller.rb +7 -0
- data/app/controllers/organizations_controller.rb +67 -0
- data/app/controllers/pages_controller.rb +54 -0
- data/app/controllers/products_controller.rb +62 -0
- data/app/controllers/professions_controller.rb +66 -0
- data/app/controllers/projects_controller.rb +56 -0
- data/app/controllers/results_controller.rb +93 -0
- data/app/controllers/stories_controller.rb +96 -0
- data/app/controllers/tasks_controller.rb +88 -0
- data/app/controllers/users_controller.rb +52 -0
- data/app/controllers/vacancies_controller.rb +79 -0
- data/app/controllers/voluntary/application_controller.rb +92 -0
- data/app/controllers/workflow/candidatures_controller.rb +20 -0
- data/app/controllers/workflow/products_controller.rb +6 -0
- data/app/controllers/workflow/project_owner_controller.rb +33 -0
- data/app/controllers/workflow/stories_controller.rb +6 -0
- data/app/controllers/workflow/tasks_controller.rb +147 -0
- data/app/controllers/workflow/user_controller.rb +6 -0
- data/app/controllers/workflow/vacancies_controller.rb +17 -0
- data/app/controllers/workflow_controller.rb +7 -0
- data/app/helpers/application_helper.rb +65 -0
- data/app/helpers/collection_helper.rb +31 -0
- data/app/helpers/comments_helper.rb +11 -0
- data/app/helpers/form_helper.rb +39 -0
- data/app/helpers/language_helper.rb +15 -0
- data/app/helpers/layout_helper.rb +24 -0
- data/app/helpers/product_helper.rb +32 -0
- data/app/helpers/show_helper.rb +65 -0
- data/app/helpers/wizard_helper.rb +27 -0
- data/app/models/area.rb +19 -0
- data/app/models/area_user.rb +19 -0
- data/app/models/candidature.rb +35 -0
- data/app/models/comment.rb +16 -0
- data/app/models/history_tracker.rb +3 -0
- data/app/models/mongo_db_document.rb +11 -0
- data/app/models/organization.rb +19 -0
- data/app/models/page.rb +30 -0
- data/app/models/product.rb +99 -0
- data/app/models/product/new_product.rb +3 -0
- data/app/models/product/project_management.rb +29 -0
- data/app/models/profession.rb +13 -0
- data/app/models/project.rb +66 -0
- data/app/models/project_user.rb +13 -0
- data/app/models/result.rb +55 -0
- data/app/models/role.rb +8 -0
- data/app/models/role/admin.rb +2 -0
- data/app/models/role/master.rb +2 -0
- data/app/models/role/project_owner.rb +2 -0
- data/app/models/role/user.rb +2 -0
- data/app/models/state_machines/candidature.rb +42 -0
- data/app/models/state_machines/page.rb +18 -0
- data/app/models/state_machines/story.rb +51 -0
- data/app/models/state_machines/task.rb +46 -0
- data/app/models/state_machines/vacancy.rb +41 -0
- data/app/models/story.rb +82 -0
- data/app/models/task.rb +85 -0
- data/app/models/user.rb +95 -0
- data/app/models/user_role.rb +6 -0
- data/app/models/vacancy.rb +41 -0
- data/app/observers/candidature_observer.rb +29 -0
- data/app/observers/story_observer.rb +6 -0
- data/app/observers/task_observer.rb +34 -0
- data/app/presenters/layout/application_presenter.rb +3 -0
- data/app/presenters/layout_presenter.rb +9 -0
- data/app/presenters/presenter.rb +46 -0
- data/app/presenters/resource_presenter.rb +30 -0
- data/app/presenters/resources/general/wizard_presenter.rb +17 -0
- data/app/presenters/resources/general/wizards/story/steps/activate_presenter.rb +3 -0
- data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +5 -0
- data/app/presenters/resources/general/wizards/story_presenter.rb +3 -0
- data/app/presenters/resources/user/form_presenter.rb +16 -0
- data/app/presenters/shared/collection/table_presenter.rb +33 -0
- data/app/views/areas/_form.html.erb +11 -0
- data/app/views/areas/edit.html.erb +3 -0
- data/app/views/areas/index.html.erb +5 -0
- data/app/views/areas/new.html.erb +3 -0
- data/app/views/areas/show.html.erb +6 -0
- data/app/views/candidatures/_form.html.erb +13 -0
- data/app/views/candidatures/edit.html.erb +3 -0
- data/app/views/candidatures/index.html.erb +11 -0
- data/app/views/candidatures/new.html.erb +3 -0
- data/app/views/candidatures/show.html.erb +18 -0
- data/app/views/comments/_form.html.erb +16 -0
- data/app/views/comments/_resource.html.erb +16 -0
- data/app/views/comments/edit.html.erb +3 -0
- data/app/views/comments/new.html.erb +3 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +10 -0
- data/app/views/devise/registrations/new.html.erb +5 -0
- data/app/views/general/wizard.html.erb +16 -0
- data/app/views/kaminari/_first_page.html.erb +13 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +13 -0
- data/app/views/kaminari/_next_page.html.erb +13 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +25 -0
- data/app/views/kaminari/_prev_page.html.erb +13 -0
- data/app/views/layouts/application.html.erb +48 -0
- data/app/views/layouts/shared/_flash_messages.html.erb +7 -0
- data/app/views/layouts/shared/_navigation.html.erb +7 -0
- data/app/views/organizations/_form.html.erb +11 -0
- data/app/views/organizations/edit.html.erb +3 -0
- data/app/views/organizations/index.html.erb +5 -0
- data/app/views/organizations/new.html.erb +3 -0
- data/app/views/organizations/show.html.erb +6 -0
- data/app/views/pages/_form.html.erb +12 -0
- data/app/views/pages/edit.html.erb +3 -0
- data/app/views/pages/index.html.erb +5 -0
- data/app/views/pages/new.html.erb +3 -0
- data/app/views/pages/show.html.erb +10 -0
- data/app/views/products/_form.html.erb +28 -0
- data/app/views/products/edit.html.erb +3 -0
- data/app/views/products/index.html.erb +5 -0
- data/app/views/products/mixins/_keywords.html.erb +4 -0
- data/app/views/products/new.html.erb +3 -0
- data/app/views/products/show.html.erb +11 -0
- data/app/views/products/types/text_creation/stories/_form.html.erb +19 -0
- data/app/views/products/types/text_creation/stories/_task_fields.html.erb +7 -0
- data/app/views/projects/_form.html.erb +16 -0
- data/app/views/projects/edit.html.erb +3 -0
- data/app/views/projects/index.html.erb +5 -0
- data/app/views/projects/new.html.erb +3 -0
- data/app/views/projects/show.html.erb +13 -0
- data/app/views/shared/_comments.html.erb +7 -0
- data/app/views/shared/collection/_list.html.erb +37 -0
- data/app/views/shared/collection/_table.html.erb +36 -0
- data/app/views/shared/form/_error_messages.html.erb +10 -0
- data/app/views/shared/resource/_actions.html.erb +26 -0
- data/app/views/shared/resource/_event_elements.html.erb +7 -0
- data/app/views/stories/_collection.html.erb +8 -0
- data/app/views/stories/_form.html.erb +19 -0
- data/app/views/stories/_task_fields.html.erb +11 -0
- data/app/views/stories/index.html.erb +1 -0
- data/app/views/stories/show.html.erb +13 -0
- data/app/views/stories/steps/_activate.html.erb +17 -0
- data/app/views/stories/steps/_setup_tasks.html.erb +35 -0
- data/app/views/stories/tasks.html.erb +0 -0
- data/app/views/tasks/_collection.html.erb +12 -0
- data/app/views/users/_form.html.erb +43 -0
- data/app/views/users/edit.html.erb +3 -0
- data/app/views/users/index.html.erb +6 -0
- data/app/views/users/new.html.erb +3 -0
- data/app/views/users/preferences.html.erb +11 -0
- data/app/views/users/show.html.erb +6 -0
- data/app/views/vacancies/_form.html.erb +15 -0
- data/app/views/vacancies/edit.html.erb +3 -0
- data/app/views/vacancies/index.html.erb +7 -0
- data/app/views/vacancies/new.html.erb +3 -0
- data/app/views/vacancies/show.html.erb +17 -0
- data/app/views/workflow/index.html.erb +0 -0
- data/app/views/workflow/products/show.html.erb +34 -0
- data/app/views/workflow/project_owner/_candidatures.html.erb +31 -0
- data/app/views/workflow/project_owner/_stories.html.erb +29 -0
- data/app/views/workflow/project_owner/_tasks.html.erb +34 -0
- data/app/views/workflow/project_owner/_vacancies.html.erb +27 -0
- data/app/views/workflow/project_owner/index.html.erb +24 -0
- data/app/views/workflow/tasks/_work_form.html.erb +8 -0
- data/app/views/workflow/tasks/_work_head.html.erb +15 -0
- data/app/views/workflow/tasks/edit.html.erb +3 -0
- data/app/views/workflow/tasks/index.html.erb +31 -0
- data/app/views/workflow/tasks/next.html.erb +0 -0
- data/app/views/workflow/tasks/steps/_complete.html.erb +11 -0
- data/app/views/workflow/tasks/steps/_review.html.erb +13 -0
- data/app/views/workflow/tasks/steps/_work.html.erb +17 -0
- data/app/views/workflow/user/_tasks.html.erb +30 -0
- data/app/views/workflow/user/index.html.erb +14 -0
- data/config/initializers/1_initialize_app_config.rb +5 -0
- data/config/initializers/devise.rb +193 -0
- data/config/initializers/locale_settings.rb +42 -0
- data/config/initializers/mongoid-history.rb +2 -0
- data/config/initializers/recaptcha.rb +7 -0
- data/config/initializers/simple_form.rb +178 -0
- data/config/initializers/simple_navigation.rb +2 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/en.yml +26 -0
- data/config/locales/general/en.yml +71 -0
- data/config/locales/resources/area/en.yml +12 -0
- data/config/locales/resources/candidature/en.yml +19 -0
- data/config/locales/resources/comment/en.yml +11 -0
- data/config/locales/resources/organization/en.yml +11 -0
- data/config/locales/resources/page/en.yml +11 -0
- data/config/locales/resources/product/en.yml +23 -0
- data/config/locales/resources/project/en.yml +9 -0
- data/config/locales/resources/result/en.yml +9 -0
- data/config/locales/resources/story/en.yml +34 -0
- data/config/locales/resources/task/en.yml +36 -0
- data/config/locales/resources/user/en.yml +14 -0
- data/config/locales/resources/vacancy/en.yml +29 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/workflow/en.yml +37 -0
- data/config/routes.rb +188 -0
- data/db/migrate/20120907144853_create_schema.rb +217 -0
- data/db/migrate/20120911093743_remove_timestamps_from_habtm_tables.rb +21 -0
- data/db/migrate/20120919161831_add_unique_index_for_one_user_candidature_per_vacancy.rb +9 -0
- data/db/migrate/20120922201955_create_mongo_db_documents.rb +13 -0
- data/db/migrate/20120923140109_add_product_to_project.rb +6 -0
- data/db/migrate/20121004061413_add_extra_user_attributes.rb +9 -0
- data/db/migrate/20121004132105_create_professions.rb +13 -0
- data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +6 -0
- data/db/migrate/20121006170407_add_type_attribute_to_roles.rb +5 -0
- data/db/migrate/20121007071543_add_foreign_languages_to_user.rb +6 -0
- data/db/migrate/20121028073712_create_organizations.rb +13 -0
- data/db/seeds.rb +14 -0
- data/lib/applicat/mvc/controller.rb +171 -0
- data/lib/applicat/mvc/controller/error_handling.rb +40 -0
- data/lib/applicat/mvc/controller/resource.rb +19 -0
- data/lib/applicat/mvc/controller/transition_actions.rb +43 -0
- data/lib/applicat/mvc/model/resource/base.rb +56 -0
- data/lib/applicat/mvc/model/tokenable.rb +24 -0
- data/lib/applicat/mvc/model/tree.rb +82 -0
- data/lib/db_seed.rb +150 -0
- data/lib/environment_configuration.rb +54 -0
- data/lib/generators/voluntary/install/install_generator.rb +118 -0
- data/lib/generators/voluntary/install/templates/app/controllers/application_controller.rb +3 -0
- data/lib/generators/voluntary/install/templates/app/models/ability.rb +49 -0
- data/lib/generators/voluntary/install/templates/app/models/app_config.rb +32 -0
- data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +50 -0
- data/lib/generators/voluntary/install/templates/config/application.yml +147 -0
- data/lib/generators/voluntary/install/templates/config/cucumber.yml +8 -0
- data/lib/generators/voluntary/install/templates/config/database.example.yml +28 -0
- data/lib/generators/voluntary/install/templates/config/deploy.rb +59 -0
- data/lib/generators/voluntary/install/templates/config/email.example.yml +9 -0
- data/lib/generators/voluntary/install/templates/config/initializers/recaptcha_example +4 -0
- data/lib/generators/voluntary/install/templates/config/locale_settings.yml +121 -0
- data/lib/generators/voluntary/install/templates/config/main_navigation.rb +262 -0
- data/lib/generators/voluntary/install/templates/config/mongoid.yml +78 -0
- data/lib/generators/voluntary/install/templates/config/nginx.conf +27 -0
- data/lib/generators/voluntary/install/templates/config/unicorn.rb +9 -0
- data/lib/generators/voluntary/install/templates/config/unicorn_init.sh +84 -0
- data/lib/generators/voluntary/install/templates/db/seeds.rb +14 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/email_steps.rb +89 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/factory_steps.rb +120 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/javascript_steps.rb +15 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/navigation_steps.rb +3 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/resources_steps.rb +8 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/session_steps.rb +35 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/web_steps.rb +271 -0
- data/lib/generators/voluntary/install/templates/features/support/database_cleaner_patches.rb +24 -0
- data/lib/generators/voluntary/install/templates/features/support/env.rb +83 -0
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +32 -0
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_form.html.erb +1 -0
- data/lib/generators/voluntary/install/templates/features/support/paths.rb +98 -0
- data/lib/generators/voluntary/install/templates/features/support/selectors.rb +44 -0
- data/lib/generators/voluntary/install/templates/features/support/spork_env +72 -0
- data/lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb +78 -0
- data/lib/generators/voluntary/install/templates/lib/volontariat_seed.rb +36 -0
- data/lib/generators/voluntary/install/templates/spec/spec_helper.rb +72 -0
- data/lib/generators/voluntary/install/templates/spec/support/deferred_garbage_collector.rb +45 -0
- data/lib/generators/voluntary/install/templates/spec/support/devise.rb +3 -0
- data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +19 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/javascripts/jquery.tokeninput.js +915 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-facebook.css +122 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-mac.css +204 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input.css +127 -0
- data/lib/i18n_interpolation_fallbacks.rb +21 -0
- data/lib/model/mongo_db/commentable.rb +17 -0
- data/lib/model/mongo_db/core_extensions.rb +10 -0
- data/lib/model/mongo_db/customizable.rb +23 -0
- data/lib/model/mongo_db/product/keywords.rb +31 -0
- data/lib/model/mongo_db/state_version_attributes.rb +15 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/voluntary_tasks.rake +4 -0
- data/lib/vendors/active_model/naming.rb +14 -0
- data/lib/vendors/simple_navigation/renderer/breadcrumbs_without_method_links.rb +30 -0
- data/lib/vendors/simple_navigation/renderer/twitter_sidenav.rb +34 -0
- data/lib/voluntary.rb +87 -0
- data/lib/voluntary/engine.rb +11 -0
- data/lib/voluntary/helpers/application.rb +69 -0
- data/lib/voluntary/helpers/collection.rb +35 -0
- data/lib/voluntary/helpers/comments.rb +15 -0
- data/lib/voluntary/helpers/form.rb +43 -0
- data/lib/voluntary/helpers/language.rb +19 -0
- data/lib/voluntary/helpers/layout.rb +28 -0
- data/lib/voluntary/helpers/product.rb +36 -0
- data/lib/voluntary/helpers/show.rb +69 -0
- data/lib/voluntary/helpers/wizard.rb +31 -0
- data/lib/voluntary/version.rb +3 -0
- data/lib/wizard.rb +58 -0
- data/lib/wizard/controller/concerns/paths.rb +31 -0
- data/lib/wizard/controller/concerns/steps.rb +142 -0
- metadata +1217 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Collection
|
4
|
+
def table_cell column, resource, alternative_value = nil
|
5
|
+
value = '-'
|
6
|
+
|
7
|
+
if column == 'name'
|
8
|
+
value = resource.send(column)
|
9
|
+
|
10
|
+
if alternative_value.is_a?(Proc)
|
11
|
+
return alternative_value.call(resource)
|
12
|
+
elsif value.blank? && alternative_value.present?
|
13
|
+
value = eval("resource.#{alternative_value}")
|
14
|
+
elsif value.blank?
|
15
|
+
value = '-'
|
16
|
+
end
|
17
|
+
|
18
|
+
link_to value, eval("#{root_model_class_name(resource).tableize.singularize}_path(resource)")
|
19
|
+
elsif column.match('_id')
|
20
|
+
association = nil
|
21
|
+
|
22
|
+
begin
|
23
|
+
association = resource.send(column.gsub('_id', ''))
|
24
|
+
rescue
|
25
|
+
association = eval("resource.#{alternative_value}") if alternative_value.present?
|
26
|
+
end
|
27
|
+
|
28
|
+
association ? link_to(association.name, association) : value
|
29
|
+
else
|
30
|
+
resource.send(column)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Comments
|
4
|
+
def nested_comments(comments)
|
5
|
+
comments.map do |comment, sub_comments|
|
6
|
+
next if comment.id.blank?
|
7
|
+
|
8
|
+
content = render(partial: 'comments/resource', locals: { resource: comment })
|
9
|
+
content += content_tag(:div, nested_comments(sub_comments), class: 'nested_comments')
|
10
|
+
content
|
11
|
+
end.join.html_safe
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Form
|
4
|
+
def link_to_add_fields(name, f, association, options = {})
|
5
|
+
attributes = {
|
6
|
+
"#{root_model_class_name(f.object).tableize.singularize}_id".to_sym => f.object.id
|
7
|
+
}
|
8
|
+
|
9
|
+
new_object = if f.object.respond_to? "#{association.to_s.singularize}_class"
|
10
|
+
f.object.tasks.new(attributes)
|
11
|
+
else
|
12
|
+
f.object.send(association).new(attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
id = new_object.object_id
|
16
|
+
|
17
|
+
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
18
|
+
render_product_specific_partial_if_available(
|
19
|
+
new_object, "#{controller_name}/#{association.to_s.singularize}_fields",
|
20
|
+
f: builder
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
data = {id: id, fields: fields.gsub("\n", '')}
|
25
|
+
data[:target] = options[:target] if options.has_key?(:target)
|
26
|
+
|
27
|
+
link_to(name, '#', class: 'add_fields', data: data)
|
28
|
+
end
|
29
|
+
|
30
|
+
def remove_fields(f)
|
31
|
+
if f.object.try(:new_record?)
|
32
|
+
link_to t('general.remove'), '#', class: 'remove_fields'
|
33
|
+
else
|
34
|
+
f.check_box(:_destroy) + f.label(:_destroy, t('general.destroy'))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def autocomplete_input(f, field)
|
39
|
+
f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{field.to_s.tableize}_path")} }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Language
|
4
|
+
def available_language_options
|
5
|
+
options = []
|
6
|
+
|
7
|
+
AVAILABLE_LANGUAGES.each do |locale, language|
|
8
|
+
options << [language, locale]
|
9
|
+
end
|
10
|
+
|
11
|
+
options.sort_by { |o| o[0] }
|
12
|
+
end
|
13
|
+
|
14
|
+
def all_language_options
|
15
|
+
User.languages.sort_by { |o| o[0] }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Layout
|
4
|
+
def breadcrumbs
|
5
|
+
result = render_navigation context: :main, renderer: :breadcrumbs_without_method_links, join_with: ' > '
|
6
|
+
result && result.split('<a').length > 2 ? result : ''
|
7
|
+
end
|
8
|
+
|
9
|
+
def sidenav
|
10
|
+
result = render_navigation context: :main, renderer: :twitter_sidenav, level: @twitter_sidenav_level
|
11
|
+
result && result.split('<a').length > 2 ? result : ''
|
12
|
+
end
|
13
|
+
|
14
|
+
def footer_navigation
|
15
|
+
links = []
|
16
|
+
|
17
|
+
['privacy-policy', 'terms-of-use', 'about-us'].each do |page_name|
|
18
|
+
text = t("pages.#{page_name.gsub('-', '_')}.title")
|
19
|
+
path = "#{controller_name}/#{params[:id]}"
|
20
|
+
active = path == "#{controller_name}/#{page_name}"
|
21
|
+
links << (active ? text : link_to(text, page_path(page_name)))
|
22
|
+
end
|
23
|
+
|
24
|
+
raw links.join(' | ')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Product
|
4
|
+
def render_product_specific_presenter_if_available(resource, partial_path, method, options = {})
|
5
|
+
if @presenter.respond_to?(method)
|
6
|
+
@step_presenter = @presenter.send(method)
|
7
|
+
else
|
8
|
+
@step_presenter = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
render_product_specific_partial_if_available(resource, "#{partial_path}/#{method}", options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def render_product_specific_partial_if_available(resource, partial_path, options = {})
|
15
|
+
path = nil
|
16
|
+
partial_path = partial_path.split('/')
|
17
|
+
file_name = partial_path.pop
|
18
|
+
partial_path = partial_path.join('/')
|
19
|
+
|
20
|
+
if resource && resource.respond_to?(:product) && resource.product
|
21
|
+
path = "products/types/#{directory_for_resource(resource.product)}/#{partial_path}"
|
22
|
+
|
23
|
+
if File.exist?("#{Rails.root.to_s}/app/views/#{path}/_#{file_name}.html.erb")
|
24
|
+
path = [path, file_name].join('/')
|
25
|
+
else
|
26
|
+
path = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
path = [partial_path, file_name].join('/') if path.blank?
|
31
|
+
|
32
|
+
render path, options
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Show
|
4
|
+
def show_attributes(*attributes)
|
5
|
+
result = ''
|
6
|
+
|
7
|
+
attributes.each {|attribute| result += show_attribute attribute}
|
8
|
+
|
9
|
+
raw result
|
10
|
+
end
|
11
|
+
|
12
|
+
def show_attribute(attribute, options = {})
|
13
|
+
title = options[:title] || attribute_translation(attribute)
|
14
|
+
value = options[:value] || resource.send(attribute)
|
15
|
+
|
16
|
+
value.blank? ? '' : content_tag(:dt, title) + content_tag(:dd, value)
|
17
|
+
end
|
18
|
+
|
19
|
+
def show_associations(*associations)
|
20
|
+
result = ''
|
21
|
+
|
22
|
+
associations.each {|association| result += show_association association}
|
23
|
+
|
24
|
+
raw result
|
25
|
+
end
|
26
|
+
|
27
|
+
def show_association(association)
|
28
|
+
if association.to_s == association.to_s.pluralize
|
29
|
+
return show_attribute(
|
30
|
+
association,
|
31
|
+
title: t("#{association}.index.title"),
|
32
|
+
value: raw(resource.send(association).map{|a| link_to a.name, a}.join(', '))
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
title = if general_attribute?(:parent)
|
37
|
+
t("activerecord.attributes.general.#{association}")
|
38
|
+
else
|
39
|
+
if resource.send(association)
|
40
|
+
t("activerecord.models.#{root_model_class_name(resource.send(association)).underscore}")
|
41
|
+
else
|
42
|
+
t("activerecord.models.#{association}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if resource.send(association)
|
47
|
+
show_attribute(
|
48
|
+
association,
|
49
|
+
title: title,
|
50
|
+
value: link_to(resource.send(association).try(:name), resource.send(association))
|
51
|
+
)
|
52
|
+
else
|
53
|
+
''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def show_actions
|
58
|
+
result = content_tag :dt, raw(' ')
|
59
|
+
result += content_tag :dd, render(
|
60
|
+
partial: 'shared/resource/actions', locals: {
|
61
|
+
type: root_model_class_name(resource).tableize, resource: resource
|
62
|
+
}
|
63
|
+
)
|
64
|
+
|
65
|
+
raw result
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Voluntary
|
2
|
+
module Helpers
|
3
|
+
module Wizard
|
4
|
+
def section_header(wizard_step)
|
5
|
+
wizard_step_index = wizard_steps.index(wizard_step) + 1
|
6
|
+
|
7
|
+
content = ["#{wizard_step_index} / #{wizard_steps.length}"]
|
8
|
+
content << t("stories.steps.#{wizard_step}.title")
|
9
|
+
content << (future_step?(wizard_step) ? t('general.not_available') : '')
|
10
|
+
|
11
|
+
content.join(' ')
|
12
|
+
end
|
13
|
+
|
14
|
+
def step_pane(wizard_step)
|
15
|
+
return if future_step?(wizard_step)
|
16
|
+
|
17
|
+
partial_path = wizard_step == :initialization ? 'form' : "steps/#{wizard_step}"
|
18
|
+
|
19
|
+
if @presenter.respond_to?(wizard_step)
|
20
|
+
@step_presenter = @presenter.send(wizard_step)
|
21
|
+
else
|
22
|
+
@step_presenter = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
render_product_specific_partial_if_available(
|
26
|
+
resource, "#{controller_name}/#{partial_path}"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/wizard.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Wizard
|
2
|
+
module Controller
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
include Concerns::Steps
|
6
|
+
include Concerns::Paths
|
7
|
+
|
8
|
+
included do
|
9
|
+
# Set step variables
|
10
|
+
before_filter :setup_wizard, only: [:new, :create, :edit, :update]
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def setup_wizard
|
16
|
+
@step = action_name.try(:to_sym)
|
17
|
+
|
18
|
+
unless wizard_steps.include? @step
|
19
|
+
@step = nil
|
20
|
+
|
21
|
+
step_from_event unless step_from_state
|
22
|
+
|
23
|
+
@step = wizard_steps.first unless @step
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
@previous_step = previous_step(@step)
|
29
|
+
@next_step = action_name.try(:to_sym) == @step ? @step : next_step(@step)
|
30
|
+
end
|
31
|
+
|
32
|
+
def step_from_state
|
33
|
+
return false unless wizard_step_per_state.is_a?(Hash)
|
34
|
+
|
35
|
+
state = resource.try(:state).try(:to_sym)
|
36
|
+
|
37
|
+
return false unless state
|
38
|
+
|
39
|
+
wizard_step_per_state.each do |step,states|
|
40
|
+
if states.include?(state)
|
41
|
+
@step = step
|
42
|
+
break
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
return @step ? true : false
|
47
|
+
end
|
48
|
+
|
49
|
+
# TODO: just for backward compatibility purposes
|
50
|
+
def step_from_event
|
51
|
+
@step = resource.try(:event).try(:to_sym)
|
52
|
+
|
53
|
+
if @step && (!self.respond_to?(:current_step_is_next_step_after_event) || current_step_is_next_step_after_event)
|
54
|
+
@step = next_step(@step)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Wizard
|
2
|
+
module Controller
|
3
|
+
module Concerns
|
4
|
+
module Paths
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
# Give our Views helper methods!
|
9
|
+
helper_method :wizard_path, :next_wizard_path, :previous_wizard_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def next_wizard_path(options = {})
|
13
|
+
wizard_path(@next_step, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def previous_wizard_path(options = {})
|
17
|
+
wizard_path(@previous_step, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def wizard_path(goto_step = nil, options = {})
|
21
|
+
url_for(
|
22
|
+
{
|
23
|
+
controller: controller_name, action: goto_step,
|
24
|
+
id: params[:id], only_path: true
|
25
|
+
}.merge options
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module Wizard
|
2
|
+
module Controller
|
3
|
+
module Concerns
|
4
|
+
module Steps
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
# Give our Views helper methods!
|
9
|
+
helper_method :step, :next_step, :wizard_steps, :current_step?,
|
10
|
+
:past_step?, :future_step?, :previous_step?,
|
11
|
+
:next_step?, :last_step?
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
private
|
16
|
+
|
17
|
+
def wizard_steps(*wizard_steps)
|
18
|
+
const_set 'WIZARD_STEPS', wizard_steps
|
19
|
+
|
20
|
+
# TODO: clarify if we still need to generate actions when we have an update action and next_step trigger
|
21
|
+
"::#{self.to_s}::WIZARD_STEPS".constantize.each do |wizard_step|
|
22
|
+
next if wizard_step == :initialization
|
23
|
+
|
24
|
+
define_method wizard_step do
|
25
|
+
setup_wizard
|
26
|
+
|
27
|
+
send("before_#{wizard_step}") if self.respond_to?("before_#{wizard_step}")
|
28
|
+
|
29
|
+
wizard_resource = wizard_resource_class_name.constantize.find(params[:id])
|
30
|
+
resource_name = wizard_resource_class_name.underscore
|
31
|
+
resource.attributes = params[resource_name.to_sym] if params[resource_name.to_sym]
|
32
|
+
|
33
|
+
if @story.send(next_step)
|
34
|
+
redirect_to eval("#{next_step}_#{resource_name}_path(resource)")
|
35
|
+
else
|
36
|
+
send("after_#{wizard_step}") if self.respond_to?("after_#{wizard_step}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def wizard_step_per_state(hash)
|
43
|
+
const_set 'WIZARD_STEP_PER_STATE', hash
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def wizard_steps
|
48
|
+
"#{controller_class_name}::WIZARD_STEPS".constantize
|
49
|
+
end
|
50
|
+
|
51
|
+
def wizard_step_per_state
|
52
|
+
"#{controller_class_name}::WIZARD_STEP_PER_STATE".constantize rescue {}
|
53
|
+
end
|
54
|
+
|
55
|
+
def wizard_resource_class_name
|
56
|
+
controller_name.classify
|
57
|
+
end
|
58
|
+
|
59
|
+
def jump_to(goto_step)
|
60
|
+
@skip_to = goto_step
|
61
|
+
end
|
62
|
+
|
63
|
+
def skip_step
|
64
|
+
@skip_to = @next_step
|
65
|
+
end
|
66
|
+
|
67
|
+
def step
|
68
|
+
@step
|
69
|
+
end
|
70
|
+
|
71
|
+
# will return true if step passed in is the currently rendered step
|
72
|
+
def current_step?(step_name)
|
73
|
+
return false if step_name.nil? || step.nil?
|
74
|
+
|
75
|
+
step == step_name
|
76
|
+
end
|
77
|
+
|
78
|
+
# will return true if the step passed in has already been executed by the wizard
|
79
|
+
def past_step?(step_name)
|
80
|
+
return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil?
|
81
|
+
|
82
|
+
wizard_steps.index(step) > wizard_steps.index(step_name)
|
83
|
+
end
|
84
|
+
|
85
|
+
# will return true if the step passed in has already been executed by the wizard
|
86
|
+
def future_step?(step_name)
|
87
|
+
return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil?
|
88
|
+
|
89
|
+
wizard_steps.index(step) < wizard_steps.index(step_name)
|
90
|
+
end
|
91
|
+
|
92
|
+
# will return true if the last step is the step passed in
|
93
|
+
def previous_step?(step_name)
|
94
|
+
return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil?
|
95
|
+
|
96
|
+
wizard_steps.index(step) - 1 == wizard_steps.index(step_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
# will return true if the next step is the step passed in
|
100
|
+
def next_step?(step_name)
|
101
|
+
return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil?
|
102
|
+
|
103
|
+
wizard_steps.index(step) + 1 == wizard_steps.index(step_name)
|
104
|
+
end
|
105
|
+
|
106
|
+
def previous_step(current_step = nil)
|
107
|
+
return @previous_step if current_step == nil
|
108
|
+
|
109
|
+
index = wizard_steps.index(current_step)
|
110
|
+
step = wizard_steps.at(index - 1) if index.present? && index != 0
|
111
|
+
step ||= wizard_steps.first
|
112
|
+
|
113
|
+
step
|
114
|
+
end
|
115
|
+
|
116
|
+
def next_step(current_step = nil)
|
117
|
+
return @next_step if current_step == nil
|
118
|
+
|
119
|
+
index = wizard_steps.index(current_step)
|
120
|
+
step = wizard_steps.at(index + 1) if index.present?
|
121
|
+
step ||= :finish
|
122
|
+
|
123
|
+
step
|
124
|
+
end
|
125
|
+
|
126
|
+
def last_step?(current_step = nil)
|
127
|
+
current_step = current_step || step
|
128
|
+
|
129
|
+
current_step == wizard_steps.last
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def controller_class_name
|
135
|
+
name = self.to_s.gsub(/#|<|>|#/, '').split(':').select{|e| !e.blank? }
|
136
|
+
name.pop
|
137
|
+
name.join('::')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|