fat_free_crm 0.13.6 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +8 -5
- data/CHANGELOG +26 -0
- data/Gemfile +26 -26
- data/Gemfile.lock +280 -250
- data/Guardfile +0 -1
- data/README.md +7 -9
- data/Rakefile +1 -1
- data/app/assets/javascripts/application.js.erb +1 -0
- data/app/assets/javascripts/crm.js.coffee +6 -7
- data/app/assets/javascripts/search.js.coffee +7 -1
- data/app/assets/stylesheets/about.css.scss +10 -0
- data/app/assets/stylesheets/application.css.erb +2 -0
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +3 -3
- data/app/controllers/admin/field_groups_controller.rb +12 -7
- data/app/controllers/admin/fields_controller.rb +21 -17
- data/app/controllers/admin/groups_controller.rb +10 -4
- data/app/controllers/admin/plugins_controller.rb +1 -2
- data/app/controllers/admin/settings_controller.rb +1 -2
- data/app/controllers/admin/tags_controller.rb +10 -4
- data/app/controllers/admin/users_controller.rb +32 -12
- data/app/controllers/application_controller.rb +58 -38
- data/app/controllers/authentications_controller.rb +5 -8
- data/app/controllers/comments_controller.rb +15 -11
- data/app/controllers/emails_controller.rb +1 -2
- data/app/controllers/entities/accounts_controller.rb +20 -20
- data/app/controllers/entities/campaigns_controller.rb +25 -22
- data/app/controllers/entities/contacts_controller.rb +25 -24
- data/app/controllers/entities/leads_controller.rb +33 -31
- data/app/controllers/entities/opportunities_controller.rb +31 -28
- data/app/controllers/entities_controller.rb +26 -22
- data/app/controllers/home_controller.rb +18 -18
- data/app/controllers/lists_controller.rb +11 -7
- data/app/controllers/passwords_controller.rb +5 -6
- data/app/controllers/tasks_controller.rb +23 -18
- data/app/controllers/users_controller.rb +31 -7
- data/app/helpers/accounts_helper.rb +40 -42
- data/app/helpers/addresses_helper.rb +1 -3
- data/app/helpers/admin/application_helper.rb +4 -4
- data/app/helpers/admin/field_groups_helper.rb +5 -7
- data/app/helpers/admin/fields_helper.rb +2 -3
- data/app/helpers/admin/plugins_helper.rb +0 -1
- data/app/helpers/admin/settings_helper.rb +0 -1
- data/app/helpers/admin/tags_helper.rb +1 -1
- data/app/helpers/admin/users_helper.rb +16 -18
- data/app/helpers/application_helper.rb +127 -119
- data/app/helpers/authentications_helper.rb +0 -1
- data/app/helpers/campaigns_helper.rb +5 -7
- data/app/helpers/comments_helper.rb +0 -1
- data/app/helpers/contacts_helper.rb +0 -1
- data/app/helpers/home_helper.rb +14 -14
- data/app/helpers/javascript_helper.rb +30 -0
- data/app/helpers/leads_helper.rb +7 -7
- data/app/helpers/opportunities_helper.rb +8 -10
- data/app/helpers/passwords_helper.rb +0 -1
- data/app/helpers/tags_helper.rb +1 -3
- data/app/helpers/tasks_helper.rb +24 -26
- data/app/helpers/users_helper.rb +6 -7
- data/app/helpers/versions_helper.rb +3 -5
- data/app/inputs/date_pair_input.rb +6 -7
- data/app/inputs/date_time_input.rb +3 -4
- data/app/inputs/datetime_pair_input.rb +0 -1
- data/app/inputs/text_input.rb +2 -2
- data/app/mailers/dropbox_mailer.rb +4 -7
- data/app/mailers/subscription_mailer.rb +4 -5
- data/app/mailers/user_mailer.rb +7 -9
- data/app/models/entities/account.rb +31 -28
- data/app/models/entities/account_contact.rb +2 -1
- data/app/models/entities/account_opportunity.rb +1 -1
- data/app/models/entities/campaign.rb +22 -19
- data/app/models/entities/contact.rb +55 -53
- data/app/models/entities/contact_opportunity.rb +1 -1
- data/app/models/entities/lead.rb +49 -41
- data/app/models/entities/opportunity.rb +38 -38
- data/app/models/fields/custom_field.rb +21 -27
- data/app/models/fields/custom_field_date_pair.rb +7 -8
- data/app/models/fields/custom_field_datetime_pair.rb +0 -2
- data/app/models/fields/custom_field_pair.rb +8 -10
- data/app/models/fields/field.rb +29 -30
- data/app/models/fields/field_group.rb +4 -4
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +1 -1
- data/app/models/observers/lead_observer.rb +1 -1
- data/app/models/observers/opportunity_observer.rb +1 -1
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/address.rb +7 -7
- data/app/models/polymorphic/avatar.rb +8 -9
- data/app/models/polymorphic/comment.rb +16 -10
- data/app/models/polymorphic/email.rb +13 -6
- data/app/models/polymorphic/tag.rb +2 -2
- data/app/models/polymorphic/task.rb +45 -45
- data/{config/initializers/paper_trail.rb → app/models/polymorphic/version.rb} +26 -31
- data/app/models/setting.rb +12 -17
- data/app/models/users/ability.rb +5 -6
- data/app/models/users/authentication.rb +6 -5
- data/app/models/users/group.rb +1 -3
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +7 -7
- data/app/models/users/user.rb +36 -43
- data/app/views/accounts/_top_section.html.haml +2 -2
- data/app/views/accounts/edit.js.haml +0 -1
- data/app/views/admin/fields/_field.html.haml +1 -1
- data/app/views/admin/tags/_tag.html.haml +1 -1
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/campaigns/_top_section.html.haml +1 -1
- data/app/views/campaigns/edit.js.haml +0 -2
- data/app/views/contacts/_top_section.html.haml +1 -1
- data/app/views/contacts/edit.js.haml +0 -1
- data/app/views/entities/_basic_search.html.haml +1 -1
- data/app/views/home/_account.html.haml +2 -2
- data/app/views/home/_opportunity.html.haml +2 -2
- data/app/views/layouts/_about.html.haml +1 -1
- data/app/views/leads/_top_section.html.haml +1 -1
- data/app/views/leads/edit.js.haml +0 -2
- data/app/views/lists/_sidebar.html.haml +1 -1
- data/app/views/opportunities/_top_section.html.haml +2 -2
- data/app/views/opportunities/edit.js.haml +0 -1
- data/app/views/shared/_tags.html.haml +2 -1
- data/app/views/tasks/_edit.html.haml +2 -3
- data/app/views/tasks/_top_section.html.haml +1 -1
- data/app/views/users/_user.html.haml +2 -1
- data/app/views/users/opportunities_overview.html.haml +2 -2
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/config/application.rb +16 -33
- data/config/boot.rb +1 -1
- data/config/database.mysql.mac.yml +1 -0
- data/config/database.mysql.yml +1 -0
- data/config/database.postgres.docker.yml +1 -1
- data/config/database.postgres.yml +1 -0
- data/config/database.sqlite.yml +1 -0
- data/config/deploy.example.rb +3 -5
- data/config/environments/development.rb +13 -14
- data/config/environments/production.rb +8 -7
- data/config/environments/staging.rb +43 -41
- data/config/environments/test.rb +12 -14
- data/config/initializers/assets.rb +14 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/custom_field_ransack_translations.rb +1 -1
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +0 -1
- data/config/initializers/paginate_arrays.rb +0 -1
- data/config/initializers/ransack.rb +5 -5
- data/config/initializers/session_store.rb +5 -0
- data/config/initializers/simple_form.rb +1 -1
- data/config/initializers/views.rb +33 -33
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/cz_fat_free_crm.yml +1 -1
- data/config/locales/de_fat_free_crm.yml +2 -2
- data/config/locales/en-GB_fat_free_crm.yml +2 -3
- data/config/locales/en-US_fat_free_crm.yml +2 -3
- data/config/locales/en.yml +23 -0
- data/config/locales/es-CL.yml +227 -0
- data/config/locales/es-CL_fat_free_crm.yml +929 -0
- data/config/locales/es-CL_ransack.yml +91 -0
- data/config/locales/es.yml +53 -59
- data/config/locales/es_fat_free_crm.yml +708 -370
- data/config/locales/es_ransack.yml +91 -0
- data/config/locales/fr-CA_fat_free_crm.yml +7 -7
- data/config/locales/fr_fat_free_crm.yml +285 -81
- data/config/locales/it_fat_free_crm.yml +1 -1
- data/config/locales/ja_fat_free_crm.yml +1 -1
- data/config/locales/nl.yml +210 -0
- data/config/locales/nl_fat_free_crm.yml +920 -0
- data/config/locales/nl_ransack.yml +91 -0
- data/config/locales/pl_fat_free_crm.yml +1 -1
- data/config/locales/pt-BR_fat_free_crm.yml +111 -38
- data/config/locales/ru_fat_free_crm.yml +3 -4
- data/config/locales/sv-SE_fat_free_crm.yml +1 -1
- data/config/locales/th.rb +157 -158
- data/config/locales/th_fat_free_crm.yml +1 -1
- data/config/locales/zh-CN_fat_free_crm.yml +3 -4
- data/config/routes.rb +93 -94
- data/config/unicorn.rb +25 -2
- data/custom_plan.rb +0 -2
- data/db/demo/accounts.yml +4 -5
- data/db/demo/addresses.yml +5 -5
- data/db/demo/campaigns.yml +2 -2
- data/db/demo/comments.yml +1 -1
- data/db/demo/contacts.yml +8 -8
- data/db/demo/emails.yml +5 -5
- data/db/demo/leads.yml +10 -10
- data/db/demo/opportunities.yml +2 -2
- data/db/demo/tasks.yml +2 -2
- data/db/demo/users.yml +12 -16
- data/db/migrate/20100928030598_create_sessions.rb +1 -2
- data/db/migrate/20100928030599_create_users.rb +24 -25
- data/db/migrate/20100928030600_create_openid_tables.rb +11 -12
- data/db/migrate/20100928030601_create_accounts.rb +14 -15
- data/db/migrate/20100928030602_create_permissions.rb +2 -3
- data/db/migrate/20100928030603_create_settings.rb +4 -5
- data/db/migrate/20100928030604_create_preferences.rb +3 -4
- data/db/migrate/20100928030605_create_campaigns.rb +19 -20
- data/db/migrate/20100928030606_create_leads.rb +26 -27
- data/db/migrate/20100928030607_create_contacts.rb +26 -27
- data/db/migrate/20100928030608_create_opportunities.rb +15 -16
- data/db/migrate/20100928030609_create_account_contacts.rb +2 -3
- data/db/migrate/20100928030610_create_account_opportunities.rb +2 -3
- data/db/migrate/20100928030611_create_contact_opportunities.rb +3 -4
- data/db/migrate/20100928030612_create_tasks.rb +14 -15
- data/db/migrate/20100928030613_create_comments.rb +6 -7
- data/db/migrate/20100928030614_create_activities.rb +6 -7
- data/db/migrate/20100928030615_create_avatars.rb +5 -6
- data/db/migrate/20100928030616_rename_remember_token.rb +0 -1
- data/db/migrate/20100928030617_drop_openid_tables.rb +11 -11
- data/db/migrate/20100928030618_add_admin_to_users.rb +1 -2
- data/db/migrate/20100928030619_add_suspended_to_users.rb +0 -1
- data/db/migrate/20100928030620_remove_uuid.rb +3 -3
- data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -2
- data/db/migrate/20100928030622_add_background_info_to_models.rb +0 -1
- data/db/migrate/20100928030623_create_addresses.rb +14 -16
- data/db/migrate/20100928030624_add_index_on_permissions.rb +2 -3
- data/db/migrate/20100928030625_create_emails.rb +15 -16
- data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +2 -3
- data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -3
- data/db/migrate/20101221123456_add_single_access_token_to_users.rb +0 -1
- data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +2 -3
- data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +2 -3
- data/db/migrate/20111101083437_create_fields.rb +14 -15
- data/db/migrate/20111101090312_create_field_groups.rb +4 -5
- data/db/migrate/20111116091952_add_field_groups_tag_id.rb +0 -1
- data/db/migrate/20111117041311_change_fields_collection_to_text.rb +0 -1
- data/db/migrate/20111201030535_add_field_groups_klass_name.rb +4 -4
- data/db/migrate/20120121054235_create_lists.rb +1 -1
- data/db/migrate/20120216031616_create_versions.rb +5 -5
- data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -3
- data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
- data/db/migrate/20120316045804_activities_to_versions.rb +6 -6
- data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +5 -5
- data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +5 -5
- data/db/migrate/20120406082136_create_groups.rb +1 -1
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +2 -1
- data/db/migrate/20120528102124_increase_length_of_version_events.rb +2 -2
- data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
- data/db/migrate/20121221033947_fix_country_mapping.rb +0 -1
- data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
- data/db/migrate/20141126031837_increase_email_to254_chars.rb +14 -14
- data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +11 -0
- data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
- data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
- data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
- data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +10 -0
- data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +5 -0
- data/db/migrate/20150427131956_create_index_related_type.rb +9 -0
- data/db/migrate/20160511053730_add_account_contacts_index.rb +5 -0
- data/db/schema.rb +236 -228
- data/db/seeds.rb +1 -2
- data/db/seeds/fields.rb +36 -37
- data/{fig.yml → docker-compose.yml} +0 -0
- data/fat_free_crm.gemspec +31 -18
- data/lib/development_tasks/license.rake +29 -29
- data/lib/fat_free_crm.rb +1 -5
- data/lib/fat_free_crm/callback.rb +28 -20
- data/lib/fat_free_crm/comment_extensions.rb +1 -1
- data/lib/fat_free_crm/core_ext.rb +1 -1
- data/lib/fat_free_crm/core_ext/nil.rb +0 -3
- data/lib/fat_free_crm/core_ext/string.rb +7 -21
- data/lib/fat_free_crm/custom_fields.rb +2 -2
- data/lib/fat_free_crm/engine.rb +14 -0
- data/lib/fat_free_crm/errors.rb +0 -2
- data/lib/fat_free_crm/exceptions.rb +3 -4
- data/lib/fat_free_crm/export_csv.rb +0 -2
- data/lib/fat_free_crm/exportable.rb +5 -7
- data/lib/fat_free_crm/fields.rb +7 -8
- data/lib/fat_free_crm/gem_dependencies.rb +4 -1
- data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +2 -2
- data/lib/fat_free_crm/gem_ext/active_support/buffered_logger.rb +0 -3
- data/lib/fat_free_crm/gem_ext/rails/engine.rb +5 -12
- data/lib/fat_free_crm/gem_ext/rake/task.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -2
- data/lib/fat_free_crm/i18n.rb +2 -3
- data/lib/fat_free_crm/load_settings.rb +0 -2
- data/lib/fat_free_crm/mail_processor/base.rb +15 -16
- data/lib/fat_free_crm/mail_processor/comment_replies.rb +5 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +56 -59
- data/lib/fat_free_crm/permissions.rb +18 -15
- data/lib/fat_free_crm/renderers.rb +2 -2
- data/lib/fat_free_crm/secret_token_generator.rb +3 -9
- data/lib/fat_free_crm/sortable.rb +4 -8
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/fat_free_crm/view_factory.rb +3 -8
- data/lib/gravatar_image_tag.rb +19 -24
- data/lib/missing_translation_detector.rb +10 -10
- data/lib/tasks/ffcrm/comment_replies.rake +3 -5
- data/lib/tasks/ffcrm/config.rake +3 -5
- data/lib/tasks/ffcrm/demo.rake +14 -16
- data/lib/tasks/ffcrm/dropbox.rake +3 -5
- data/lib/tasks/ffcrm/missing_translations.rake +1 -1
- data/lib/tasks/ffcrm/secret.rake +1 -3
- data/lib/tasks/ffcrm/settings.rake +2 -4
- data/lib/tasks/ffcrm/setup.rake +3 -6
- data/lib/tasks/ffcrm/update_data.rake +110 -116
- data/spec/controllers/admin/groups_controller_spec.rb +0 -1
- data/spec/controllers/admin/users_controller_spec.rb +98 -102
- data/spec/controllers/applications_controller_spec.rb +17 -21
- data/spec/controllers/authentications_controller_spec.rb +57 -61
- data/spec/controllers/comments_controller_spec.rb +32 -39
- data/spec/controllers/emails_controller_spec.rb +6 -7
- data/spec/controllers/entities/accounts_controller_spec.rb +204 -214
- data/spec/controllers/entities/campaigns_controller_spec.rb +210 -224
- data/spec/controllers/entities/contacts_controller_spec.rb +250 -270
- data/spec/controllers/entities/leads_controller_spec.rb +415 -438
- data/spec/controllers/entities/opportunities_controller_spec.rb +344 -359
- data/spec/controllers/entities_controller_spec.rb +10 -14
- data/spec/controllers/home_controller_spec.rb +85 -92
- data/spec/controllers/lists_controller_spec.rb +0 -1
- data/spec/controllers/passwords_controller_spec.rb +5 -9
- data/spec/controllers/tasks_controller_spec.rb +193 -210
- data/spec/controllers/users_controller_spec.rb +137 -146
- data/spec/factories/account_factories.rb +11 -13
- data/spec/factories/campaign_factories.rb +6 -6
- data/spec/factories/contact_factories.rb +21 -22
- data/spec/factories/field_factories.rb +8 -10
- data/spec/factories/lead_factories.rb +16 -16
- data/spec/factories/list_factories.rb +2 -2
- data/spec/factories/opportunity_factories.rb +8 -10
- data/spec/factories/sequences.rb +8 -9
- data/spec/factories/setting_factories.rb +2 -2
- data/spec/factories/shared_factories.rb +26 -30
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +11 -11
- data/spec/factories/user_factories.rb +22 -27
- data/spec/features/acceptance_helper.rb +1 -1
- data/spec/features/accounts_spec.rb +65 -61
- data/spec/features/admin/groups_spec.rb +11 -12
- data/spec/features/admin/users_spec.rb +17 -19
- data/spec/features/campaigns_spec.rb +61 -57
- data/spec/features/contacts_spec.rb +90 -59
- data/spec/features/dashboard_spec.rb +20 -21
- data/spec/features/leads_spec.rb +88 -67
- data/spec/features/opportunities_overview_spec.rb +31 -31
- data/spec/features/opportunities_spec.rb +64 -60
- data/spec/features/support/browser.rb +2 -2
- data/spec/features/support/headless.rb +1 -1
- data/spec/features/support/helpers.rb +5 -6
- data/spec/features/support/paths.rb +1 -2
- data/spec/features/support/selector_helpers.rb +2 -2
- data/spec/features/tasks_spec.rb +60 -54
- data/spec/helpers/accounts_helper_spec.rb +2 -5
- data/spec/helpers/admin/field_groups_helper_spec.rb +4 -4
- data/spec/helpers/admin/plugins_helper_spec.rb +0 -1
- data/spec/helpers/admin/settings_helper_spec.rb +0 -1
- data/spec/helpers/admin/users_helper_spec.rb +0 -1
- data/spec/helpers/application_helper_spec.rb +30 -33
- data/spec/helpers/authentications_helper_spec.rb +2 -5
- data/spec/helpers/campaigns_helper_spec.rb +2 -5
- data/spec/helpers/comments_helper_spec.rb +2 -5
- data/spec/helpers/contacts_helper_spec.rb +2 -5
- data/spec/helpers/emails_helper_spec.rb +0 -1
- data/spec/helpers/fields_helper_spec.rb +0 -1
- data/spec/helpers/groups_helper_spec.rb +0 -1
- data/spec/helpers/home_helper_spec.rb +2 -5
- data/spec/helpers/leads_helper_spec.rb +2 -5
- data/spec/helpers/lists_helper_spec.rb +0 -1
- data/spec/helpers/opportunities_helper_spec.rb +2 -5
- data/spec/helpers/passwords_helper_spec.rb +2 -5
- data/spec/helpers/tasks_helper_spec.rb +1 -5
- data/spec/helpers/users_helper_spec.rb +9 -11
- data/spec/lib/comment_extensions_spec.rb +3 -3
- data/spec/lib/core_ext/string_spec.rb +1 -1
- data/spec/lib/errors_spec.rb +10 -10
- data/spec/lib/fields_spec.rb +23 -33
- data/spec/lib/mail_processor/base_spec.rb +41 -43
- data/spec/lib/mail_processor/comment_replies_spec.rb +17 -17
- data/spec/lib/mail_processor/dropbox_spec.rb +91 -95
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +13 -14
- data/spec/lib/permissions_spec.rb +44 -47
- data/spec/lib/secret_token_generator_spec.rb +16 -28
- data/spec/lib/view_factory_spec.rb +18 -24
- data/spec/mailers/subscription_mailer_spec.rb +14 -16
- data/spec/mailers/user_mailer_spec.rb +33 -34
- data/spec/models/entities/account_contact_spec.rb +2 -3
- data/spec/models/entities/account_opportunity_spec.rb +2 -3
- data/spec/models/entities/account_spec.rb +52 -59
- data/spec/models/entities/campaign_spec.rb +32 -39
- data/spec/models/entities/contact_opportunity_spec.rb +2 -3
- data/spec/models/entities/contact_spec.rb +71 -72
- data/spec/models/entities/lead_spec.rb +15 -22
- data/spec/models/entities/opportunity_spec.rb +104 -103
- data/spec/models/fields/custom_field_date_pair_spec.rb +38 -44
- data/spec/models/fields/custom_field_pair_spec.rb +28 -36
- data/spec/models/fields/custom_field_spec.rb +50 -56
- data/spec/models/fields/field_group_spec.rb +1 -2
- data/spec/models/fields/field_spec.rb +13 -15
- data/spec/models/list_spec.rb +4 -4
- data/spec/models/observers/entity_observer_spec.rb +18 -21
- data/spec/models/polymorphic/address_spec.rb +1 -3
- data/spec/models/polymorphic/avatar_spec.rb +6 -8
- data/spec/models/polymorphic/comment_spec.rb +7 -9
- data/spec/models/polymorphic/email_spec.rb +1 -2
- data/spec/models/polymorphic/task_spec.rb +130 -142
- data/spec/models/polymorphic/version_spec.rb +84 -91
- data/spec/models/setting_spec.rb +17 -19
- data/spec/models/users/abilities/user_ability_spec.rb +25 -20
- data/spec/models/users/authentication_spec.rb +0 -1
- data/spec/models/users/group_spec.rb +0 -1
- data/spec/models/users/permission_spec.rb +12 -13
- data/spec/models/users/preference_spec.rb +15 -15
- data/spec/models/users/user_spec.rb +53 -55
- data/spec/routing/accounts_routing_spec.rb +12 -14
- data/spec/routing/admin/users_routing_spec.rb +7 -9
- data/spec/routing/campaigns_routing_spec.rb +13 -14
- data/spec/routing/comments_routing_spec.rb +5 -6
- data/spec/routing/contacts_routing_spec.rb +12 -14
- data/spec/routing/emails_routing_spec.rb +7 -8
- data/spec/routing/leads_routing_spec.rb +19 -21
- data/spec/routing/opportunities_routing_spec.rb +13 -15
- data/spec/routing/tasks_routing_spec.rb +14 -15
- data/spec/routing/users_routing_spec.rb +18 -19
- data/spec/shared/controllers.rb +35 -35
- data/spec/shared/models.rb +52 -55
- data/spec/spec_helper.rb +21 -42
- data/spec/support/assert_select.rb +19 -18
- data/spec/support/auth_macros.rb +3 -3
- data/spec/support/macros.rb +5 -6
- data/spec/support/mail_processor_mocks.rb +11 -11
- data/spec/views/accounts/_edit.haml_spec.rb +9 -9
- data/spec/views/accounts/_new.haml_spec.rb +8 -9
- data/spec/views/accounts/create.js.haml_spec.rb +11 -12
- data/spec/views/accounts/destroy.js.haml_spec.rb +6 -7
- data/spec/views/accounts/edit.js.haml_spec.rb +12 -13
- data/spec/views/accounts/index.haml_spec.rb +8 -8
- data/spec/views/accounts/index.js.haml_spec.rb +7 -8
- data/spec/views/accounts/new.js.haml_spec.rb +7 -8
- data/spec/views/accounts/show.haml_spec.rb +11 -12
- data/spec/views/accounts/update.js.haml_spec.rb +18 -18
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +8 -10
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +7 -9
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +5 -7
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +6 -8
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +7 -9
- data/spec/views/admin/users/_create.haml_spec.rb +4 -4
- data/spec/views/admin/users/create.js.haml_spec.rb +8 -9
- data/spec/views/admin/users/destroy.js.haml_spec.rb +6 -6
- data/spec/views/admin/users/edit.js.haml_spec.rb +7 -9
- data/spec/views/admin/users/index.haml_spec.rb +4 -5
- data/spec/views/admin/users/index.js.haml_spec.rb +6 -8
- data/spec/views/admin/users/new.js.haml_spec.rb +4 -6
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +4 -4
- data/spec/views/admin/users/show.haml_spec.rb +0 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +4 -4
- data/spec/views/admin/users/update.js.haml_spec.rb +6 -7
- data/spec/views/application/auto_complete.haml_spec.rb +12 -14
- data/spec/views/authentications/new.haml_spec.rb +6 -7
- data/spec/views/campaigns/_edit.haml_spec.rb +9 -9
- data/spec/views/campaigns/_new.haml_spec.rb +8 -8
- data/spec/views/campaigns/create.js.haml_spec.rb +11 -12
- data/spec/views/campaigns/destroy.js.haml_spec.rb +7 -8
- data/spec/views/campaigns/edit.js.haml_spec.rb +12 -20
- data/spec/views/campaigns/index.haml_spec.rb +6 -7
- data/spec/views/campaigns/index.js.haml_spec.rb +9 -10
- data/spec/views/campaigns/new.js.haml_spec.rb +7 -8
- data/spec/views/campaigns/show.haml_spec.rb +12 -13
- data/spec/views/campaigns/update.js.haml_spec.rb +16 -16
- data/spec/views/comments/edit.js.haml_spec.rb +7 -7
- data/spec/views/contacts/_edit.haml_spec.rb +21 -21
- data/spec/views/contacts/_new.haml_spec.rb +12 -13
- data/spec/views/contacts/create.js.haml_spec.rb +12 -13
- data/spec/views/contacts/destroy.js.haml_spec.rb +6 -7
- data/spec/views/contacts/edit.js.haml_spec.rb +15 -17
- data/spec/views/contacts/index.haml_spec.rb +6 -7
- data/spec/views/contacts/index.js.html_spec.rb +7 -8
- data/spec/views/contacts/new.js.haml_spec.rb +8 -9
- data/spec/views/contacts/show.haml_spec.rb +9 -10
- data/spec/views/contacts/update.js.haml_spec.rb +26 -26
- data/spec/views/home/index.haml_spec.rb +4 -5
- data/spec/views/home/index.js.haml_spec.rb +6 -7
- data/spec/views/home/options.js.haml_spec.rb +10 -10
- data/spec/views/leads/_convert.haml_spec.rb +5 -6
- data/spec/views/leads/_edit.haml_spec.rb +13 -13
- data/spec/views/leads/_new.haml_spec.rb +11 -11
- data/spec/views/leads/_sidebar_show.haml_spec.rb +9 -9
- data/spec/views/leads/convert.js.haml_spec.rb +16 -17
- data/spec/views/leads/create.js.haml_spec.rb +16 -17
- data/spec/views/leads/destroy.js.haml_spec.rb +10 -11
- data/spec/views/leads/edit.js.haml_spec.rb +16 -17
- data/spec/views/leads/index.haml_spec.rb +7 -8
- data/spec/views/leads/index.js.haml_spec.rb +10 -11
- data/spec/views/leads/new.js.haml_spec.rb +8 -9
- data/spec/views/leads/promote.js.haml_spec.rb +30 -31
- data/spec/views/leads/reject.js.haml_spec.rb +10 -11
- data/spec/views/leads/show.haml_spec.rb +7 -8
- data/spec/views/leads/update.js.haml_spec.rb +28 -29
- data/spec/views/opportunities/_edit.haml_spec.rb +19 -19
- data/spec/views/opportunities/_new.haml_spec.rb +10 -10
- data/spec/views/opportunities/create.js.haml_spec.rb +19 -20
- data/spec/views/opportunities/destroy.js.haml_spec.rb +14 -15
- data/spec/views/opportunities/edit.js.haml_spec.rb +14 -16
- data/spec/views/opportunities/index.haml_spec.rb +6 -7
- data/spec/views/opportunities/index.js.haml_spec.rb +7 -8
- data/spec/views/opportunities/new.js.haml_spec.rb +8 -9
- data/spec/views/opportunities/show.haml_spec.rb +9 -10
- data/spec/views/opportunities/update.js.haml_spec.rb +35 -35
- data/spec/views/tasks/_edit.haml_spec.rb +9 -9
- data/spec/views/tasks/complete.js.haml_spec.rb +11 -12
- data/spec/views/tasks/create.js.haml_spec.rb +29 -31
- data/spec/views/tasks/destroy.js.haml_spec.rb +8 -8
- data/spec/views/tasks/edit.js.haml_spec.rb +12 -15
- data/spec/views/tasks/index.haml_spec.rb +7 -7
- data/spec/views/tasks/new.js.haml_spec.rb +7 -8
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +6 -6
- data/spec/views/tasks/update.js.haml_spec.rb +41 -44
- data/spec/views/users/avatar.js.haml_spec.rb +7 -8
- data/spec/views/users/change_password.js.haml_spec.rb +9 -10
- data/spec/views/users/edit.js.haml_spec.rb +7 -8
- data/spec/views/users/password.js.haml_spec.rb +8 -9
- data/spec/views/users/update.js.haml_spec.rb +6 -7
- data/spec/views/users/upload_avatar.js.haml_spec.rb +9 -9
- data/vendor/assets/javascripts/jquery_timeago/index.js +2 -0
- data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.es-CL.js +18 -0
- data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.nl.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es-CL.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es-CL.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-nl.js +21 -0
- data/vendor/assets/stylesheets/{jquery-ui.custom.css → jquery-ui.custom.scss} +52 -51
- data/vendor/gems/globby-0.1.2/LICENSE.txt +20 -0
- data/vendor/gems/globby-0.1.2/README.md +65 -0
- data/vendor/gems/globby-0.1.2/Rakefile +9 -0
- data/vendor/gems/globby-0.1.2/lib/globby.rb +47 -0
- data/vendor/gems/globby-0.1.2/lib/globby/glob.rb +90 -0
- data/vendor/gems/globby-0.1.2/lib/globby/globject.rb +18 -0
- data/vendor/gems/globby-0.1.2/lib/globby/result.rb +20 -0
- data/vendor/gems/globby-0.1.2/spec/gitignore_spec.rb +109 -0
- data/vendor/gems/globby-0.1.2/spec/globby_spec.rb +93 -0
- metadata +177 -55
- data/Gemfile.ci +0 -13
- data/config/initializers/sass.rb +0 -18
- data/lib/country_select.rb +0 -570
- data/lib/fat_free_crm/plugin.rb +0 -94
@@ -4,13 +4,12 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
class UsersController < ApplicationController
|
7
|
-
|
8
|
-
before_filter :set_current_tab, :only => [ :show, :opportunities_overview ] # Don't hightlight any tabs.
|
7
|
+
before_action :set_current_tab, only: [:show, :opportunities_overview] # Don't hightlight any tabs.
|
9
8
|
|
10
9
|
check_authorization
|
11
10
|
load_and_authorize_resource # handles all security
|
12
11
|
|
13
|
-
respond_to :html, :
|
12
|
+
respond_to :html, only: [:show, :new]
|
14
13
|
|
15
14
|
# GET /users/1
|
16
15
|
# GET /users/1.js
|
@@ -54,7 +53,7 @@ class UsersController < ApplicationController
|
|
54
53
|
# PUT /users/1.js
|
55
54
|
#----------------------------------------------------------------------------
|
56
55
|
def update
|
57
|
-
@user.update_attributes(
|
56
|
+
@user.update_attributes(user_params)
|
58
57
|
respond_with(@user)
|
59
58
|
end
|
60
59
|
|
@@ -75,7 +74,7 @@ class UsersController < ApplicationController
|
|
75
74
|
render
|
76
75
|
else
|
77
76
|
if params[:avatar]
|
78
|
-
avatar = Avatar.create(
|
77
|
+
avatar = Avatar.create(avatar_params)
|
79
78
|
if avatar.valid?
|
80
79
|
@user.avatar = avatar
|
81
80
|
else
|
@@ -86,7 +85,7 @@ class UsersController < ApplicationController
|
|
86
85
|
responds_to_parent do
|
87
86
|
# Without return RSpec2 screams bloody murder about rendering twice:
|
88
87
|
# within the block and after yield in responds_to_parent.
|
89
|
-
render
|
88
|
+
render && (return if Rails.env.test?)
|
90
89
|
end
|
91
90
|
end
|
92
91
|
end
|
@@ -122,7 +121,7 @@ class UsersController < ApplicationController
|
|
122
121
|
#----------------------------------------------------------------------------
|
123
122
|
def redraw
|
124
123
|
current_user.preference[:locale] = params[:locale]
|
125
|
-
render :
|
124
|
+
render js: %(window.location.href = "#{user_path(current_user)}";)
|
126
125
|
end
|
127
126
|
|
128
127
|
# GET /users/opportunities_overview
|
@@ -132,4 +131,29 @@ class UsersController < ApplicationController
|
|
132
131
|
@unassigned_opportunities = Opportunity.my.unassigned.pipeline.order(:stage)
|
133
132
|
end
|
134
133
|
|
134
|
+
protected
|
135
|
+
|
136
|
+
def user_params
|
137
|
+
params[:user].permit(
|
138
|
+
:username,
|
139
|
+
:email,
|
140
|
+
:first_name,
|
141
|
+
:last_name,
|
142
|
+
:title,
|
143
|
+
:company,
|
144
|
+
:alt_email,
|
145
|
+
:phone,
|
146
|
+
:mobile,
|
147
|
+
:aim,
|
148
|
+
:yahoo,
|
149
|
+
:google,
|
150
|
+
:skype
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
def avatar_params
|
155
|
+
params[:avatar]
|
156
|
+
.permit(:image)
|
157
|
+
.merge(entity: @user)
|
158
|
+
end
|
135
159
|
end
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module AccountsHelper
|
7
|
-
|
8
7
|
# Sidebar checkbox control for filtering accounts by category.
|
9
8
|
#----------------------------------------------------------------------------
|
10
9
|
def account_category_checkbox(category, count)
|
@@ -14,11 +13,11 @@ module AccountsHelper
|
|
14
13
|
# Quick account summary for RSS/ATOM feeds.
|
15
14
|
#----------------------------------------------------------------------------
|
16
15
|
def account_summary(account)
|
17
|
-
[
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
[number_to_currency(account.opportunities.pipeline.map(&:weighted_amount).sum, precision: 0),
|
17
|
+
t(:added_by, time_ago: time_ago_in_words(account.created_at), user: account.user_id_full_name),
|
18
|
+
t('pluralize.contact', account.contacts.count),
|
19
|
+
t('pluralize.opportunity', account.opportunities.count),
|
20
|
+
t('pluralize.comment', account.comments.count)
|
22
21
|
].join(', ')
|
23
22
|
end
|
24
23
|
|
@@ -26,37 +25,37 @@ module AccountsHelper
|
|
26
25
|
# and prepends the currently selected account, if any.
|
27
26
|
#----------------------------------------------------------------------------
|
28
27
|
def account_select(options = {})
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
options[:selected] = (@account && @account.id) || 0
|
29
|
+
accounts = ([@account] + Account.my.order(:name).limit(25)).compact.uniq
|
30
|
+
collection_select :account, :id, accounts, :id, :name, options,
|
31
|
+
:"data-placeholder" => t(:select_an_account),
|
32
|
+
:"data-url" => auto_complete_accounts_path(format: 'json'),
|
33
|
+
style: "width:330px; display:none;",
|
34
|
+
class: 'ajax_chosen'
|
36
35
|
end
|
37
36
|
|
38
37
|
# Select an existing account or create a new one.
|
39
38
|
#----------------------------------------------------------------------------
|
40
|
-
def account_select_or_create(form, &
|
39
|
+
def account_select_or_create(form, &_block)
|
41
40
|
options = {}
|
42
41
|
yield options if block_given?
|
43
42
|
|
44
|
-
content_tag(:div, :
|
43
|
+
content_tag(:div, class: 'label') do
|
45
44
|
t(:account).html_safe +
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
content_tag(:span, id: 'account_create_title') do
|
47
|
+
"(#{t :create_new} #{t :or} <a href='#' onclick='crm.select_account(); return false;'>#{t :select_existing}</a>):".html_safe
|
48
|
+
end +
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
content_tag(:span, id: 'account_select_title') do
|
51
|
+
"(<a href='#' onclick='crm.create_account(); return false;'>#{t :create_new}</a> #{t :or} #{t :select_existing}):".html_safe
|
52
|
+
end +
|
54
53
|
|
55
|
-
|
54
|
+
content_tag(:span, ':', id: 'account_disabled_title')
|
56
55
|
end +
|
57
56
|
|
58
|
-
|
59
|
-
|
57
|
+
account_select(options) +
|
58
|
+
form.text_field(:name, style: 'width:324px; display:none;')
|
60
59
|
end
|
61
60
|
|
62
61
|
# Output account url for a given contact
|
@@ -71,14 +70,14 @@ module AccountsHelper
|
|
71
70
|
#----------------------------------------------------------------------------
|
72
71
|
def account_with_title_and_department(contact)
|
73
72
|
text = if !contact.title.blank? && contact.account
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
73
|
+
# works_at: "{{h(job_title)}} at {{h(company)}}"
|
74
|
+
content_tag :div, t(:works_at, job_title: h(contact.title), company: h(account_with_url_for(contact))).html_safe
|
75
|
+
elsif !contact.title.blank?
|
76
|
+
content_tag :div, h(contact.title)
|
77
|
+
elsif contact.account
|
78
|
+
content_tag :div, account_with_url_for(contact)
|
79
|
+
else
|
80
|
+
""
|
82
81
|
end
|
83
82
|
text << t(:department_small, h(contact.department)) unless contact.department.blank?
|
84
83
|
text
|
@@ -96,17 +95,16 @@ module AccountsHelper
|
|
96
95
|
account_text = link_to_if(can?(:read, account), h(account.name), account_path(account)) if account.present?
|
97
96
|
|
98
97
|
text << if title.present? && department.present?
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
98
|
+
t(:account_with_title_department, title: h(title), department: h(department), account: account_text)
|
99
|
+
elsif title.present?
|
100
|
+
t(:account_with_title, title: h(title), account: account_text)
|
101
|
+
elsif department.present?
|
102
|
+
t(:account_with_title, title: h(department), account: account_text)
|
103
|
+
elsif account_text.present?
|
104
|
+
t(:works_at, job_title: "", company: account_text)
|
105
|
+
else
|
106
|
+
""
|
108
107
|
end
|
109
108
|
text.html_safe
|
110
109
|
end
|
111
|
-
|
112
110
|
end
|
@@ -4,16 +4,14 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module AddressesHelper
|
7
|
-
|
8
7
|
# Sets up new address when used in forms.
|
9
8
|
#----------------------------------------------------------------------------
|
10
9
|
def get_address(asset, type)
|
11
10
|
asset.send("build_#{type}".to_sym) if asset.send(type.to_sym).nil?
|
12
11
|
asset.send(type.to_sym)
|
13
12
|
end
|
14
|
-
|
13
|
+
|
15
14
|
def priority_countries
|
16
15
|
Setting[:priority_countries]
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
@@ -4,12 +4,12 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module Admin::ApplicationHelper
|
7
|
-
|
7
|
+
#----------------------------------------------------------------------------
|
8
8
|
def link_to_confirm_delete(model)
|
9
9
|
link_to(t(:yes_button),
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
url_for([:admin, model]),
|
11
|
+
method: :delete,
|
12
|
+
remote: true
|
13
13
|
)
|
14
14
|
end
|
15
15
|
end
|
@@ -4,24 +4,22 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module Admin::FieldGroupsHelper
|
7
|
-
|
8
7
|
include ::ERB::Util
|
9
8
|
|
10
9
|
def field_group_subtitle(field_group)
|
11
10
|
asset = field_group.klass_name.downcase
|
12
|
-
html = t(field_group.name, :
|
13
|
-
html << content_tag(:small, :
|
11
|
+
html = t(field_group.name, default: h(field_group.label)).html_safe
|
12
|
+
html << content_tag(:small, id: "#{asset}_field_group_#{field_group.id}_intro") do
|
14
13
|
if field_group.tag_id
|
15
|
-
t(:field_group_tag_restriction, :
|
14
|
+
t(:field_group_tag_restriction, assets: asset.pluralize, tag: field_group.tag.try(:name))
|
16
15
|
else
|
17
|
-
t(:field_group_unrestricted, :
|
16
|
+
t(:field_group_unrestricted, assets: asset.pluralize)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
html
|
21
20
|
end
|
22
21
|
|
23
22
|
def link_to_confirm(field_group)
|
24
|
-
link_to(t(:delete) + "?", confirm_admin_field_group_path(field_group), :
|
23
|
+
link_to(t(:delete) + "?", confirm_admin_field_group_path(field_group), method: :get, remote: true)
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
@@ -4,16 +4,15 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module Admin::FieldsHelper
|
7
|
-
|
8
7
|
# Returns the list of :null and :safe database column transitions.
|
9
8
|
# Only these options should be shown on the custom field edit form.
|
10
9
|
def field_edit_as_options(field = nil)
|
11
10
|
# Return every available field_type if no restriction
|
12
11
|
options = (field.as.present? ? field.available_as : Field.field_types).keys
|
13
|
-
options.map{|k| [t("field_types.#{k}.title"), k] }
|
12
|
+
options.map { |k| [t("field_types.#{k}.title"), k] }
|
14
13
|
end
|
15
14
|
|
16
15
|
def field_group_options
|
17
|
-
FieldGroup.all.map {|fg| [fg.name, fg.id]}
|
16
|
+
FieldGroup.all.map { |fg| [fg.name, fg.id] }
|
18
17
|
end
|
19
18
|
end
|
@@ -5,6 +5,6 @@
|
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module Admin::TagsHelper
|
7
7
|
def link_to_confirm(tag)
|
8
|
-
link_to(t(:delete) + "?", confirm_admin_tag_path(tag), :
|
8
|
+
link_to(t(:delete) + "?", confirm_admin_tag_path(tag), method: :get, remote: true)
|
9
9
|
end
|
10
10
|
end
|
@@ -4,20 +4,19 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module Admin::UsersHelper
|
7
|
-
|
8
7
|
def link_to_suspend(user)
|
9
|
-
link_to(t(:suspend) + "!", suspend_admin_user_path(user), :
|
8
|
+
link_to(t(:suspend) + "!", suspend_admin_user_path(user), method: :put, remote: true)
|
10
9
|
end
|
11
10
|
|
12
11
|
#----------------------------------------------------------------------------
|
13
12
|
def link_to_reactivate(user)
|
14
13
|
name = user.awaits_approval? ? t(:approve) + "!" : t(:reactivate) + "!"
|
15
|
-
link_to(name, reactivate_admin_user_path(user), :
|
14
|
+
link_to(name, reactivate_admin_user_path(user), method: :put, remote: true)
|
16
15
|
end
|
17
16
|
|
18
17
|
#----------------------------------------------------------------------------
|
19
18
|
def link_to_confirm(user)
|
20
|
-
link_to(t(:delete) + "?", confirm_admin_user_path(user), :
|
19
|
+
link_to(t(:delete) + "?", confirm_admin_user_path(user), method: :get, remote: true)
|
21
20
|
end
|
22
21
|
|
23
22
|
# User summary info for RSS/ATOM feeds.
|
@@ -27,27 +26,26 @@ module Admin::UsersHelper
|
|
27
26
|
title_and_company = user.title.blank? ? '' : h(user.title)
|
28
27
|
title_and_company << " #{t(:at)} #{user.company}" unless user.company.blank?
|
29
28
|
summary << title_and_company unless title_and_company.blank?
|
30
|
-
summary << t('pluralize.login', user.login_count) if user.
|
29
|
+
summary << t('pluralize.login', user.login_count) if user.current_login_at && user.login_count > 0
|
31
30
|
summary << user.email
|
32
31
|
summary << "#{t :phone_small}: #{user.phone}" unless user.phone.blank?
|
33
32
|
summary << "#{t :mobile_small}: #{user.mobile}" unless user.mobile.blank?
|
34
33
|
summary << if !user.suspended?
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
t(:user_since, l(user.created_at.to_date, format: :mmddyy))
|
35
|
+
elsif user.awaits_approval?
|
36
|
+
t(:user_signed_up_on, l(user.created_at, format: :mmddhhss))
|
37
|
+
else
|
38
|
+
t(:user_suspended_on, l(user.created_at.to_date, format: :mmddyy))
|
40
39
|
end
|
41
40
|
summary << if user.awaits_approval?
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
t(:user_signed_up)
|
42
|
+
elsif user.suspended?
|
43
|
+
t(:user_suspended)
|
44
|
+
elsif user.admin?
|
45
|
+
t(:user_admin)
|
46
|
+
else
|
47
|
+
t(:user_active)
|
49
48
|
end
|
50
49
|
summary.join(', ')
|
51
50
|
end
|
52
51
|
end
|
53
|
-
|
@@ -4,44 +4,43 @@
|
|
4
4
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
5
|
#------------------------------------------------------------------------------
|
6
6
|
module ApplicationHelper
|
7
|
-
|
8
7
|
def tabs(tabs = nil)
|
9
8
|
tabs ||= controller_path =~ /admin/ ? FatFreeCRM::Tabs.admin : FatFreeCRM::Tabs.main
|
10
9
|
if tabs
|
11
10
|
@current_tab ||= tabs.first[:text] # Select first tab by default.
|
12
11
|
tabs.each { |tab| tab[:active] = (@current_tab == tab[:text] || @current_tab == tab[:url][:controller]) }
|
13
12
|
else
|
14
|
-
|
13
|
+
fail FatFreeCRM::MissingSettings, "Tab settings are missing, please run <b>rake ffcrm:setup</b> command."
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
17
|
#----------------------------------------------------------------------------
|
19
18
|
def tabless_layout?
|
20
19
|
%w(authentications passwords).include?(controller.controller_name) ||
|
21
|
-
|
20
|
+
((controller.controller_name == "users") && (%w(create new).include?(controller.action_name)))
|
22
21
|
end
|
23
22
|
|
24
23
|
# Show existing flash or embed hidden paragraph ready for flash[:notice]
|
25
24
|
#----------------------------------------------------------------------------
|
26
|
-
def show_flash(options = { :
|
25
|
+
def show_flash(options = { sticky: false })
|
27
26
|
[:error, :warning, :info, :notice].each do |type|
|
28
27
|
if flash[type]
|
29
|
-
html = content_tag(:div, h(flash[type]), :
|
28
|
+
html = content_tag(:div, h(flash[type]), id: "flash")
|
30
29
|
flash[type] = nil
|
31
|
-
return html << content_tag(:script, "crm.flash('#{type}', #{options[:sticky]})".html_safe, :
|
30
|
+
return html << content_tag(:script, "crm.flash('#{type}', #{options[:sticky]})".html_safe, type: "text/javascript")
|
32
31
|
end
|
33
32
|
end
|
34
|
-
content_tag(:p, nil, :
|
33
|
+
content_tag(:p, nil, id: "flash", style: "display:none;")
|
35
34
|
end
|
36
35
|
|
37
36
|
#----------------------------------------------------------------------------
|
38
37
|
def subtitle(id, hidden = true, text = id.to_s.split("_").last.capitalize)
|
39
38
|
content_tag("div",
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
link_to("<small>#{ hidden ? '►' : '▼' }</small> #{sanitize text}".html_safe,
|
40
|
+
url_for(controller: :home, action: :toggle, id: id),
|
41
|
+
remote: true,
|
42
|
+
onclick: "crm.flip_subtitle(this)"
|
43
|
+
), class: "subtitle")
|
45
44
|
end
|
46
45
|
|
47
46
|
#----------------------------------------------------------------------------
|
@@ -52,11 +51,11 @@ module ApplicationHelper
|
|
52
51
|
create_url = controller.send(:"new_#{asset}_path")
|
53
52
|
|
54
53
|
html = tag(:br)
|
55
|
-
html << content_tag(:div, link_to(t(select_id), "#", :
|
56
|
-
html << content_tag(:div, " | ".html_safe, :
|
57
|
-
html << content_tag(:div, link_to_inline(create_id, create_url, :
|
58
|
-
html << content_tag(:div, t(assets), :
|
59
|
-
html << content_tag(:div, "", :
|
54
|
+
html << content_tag(:div, link_to(t(select_id), "#", id: select_id), class: "subtitle_tools")
|
55
|
+
html << content_tag(:div, " | ".html_safe, class: "subtitle_tools")
|
56
|
+
html << content_tag(:div, link_to_inline(create_id, create_url, related: dom_id(related), text: t(create_id)), class: "subtitle_tools")
|
57
|
+
html << content_tag(:div, t(assets), class: :subtitle, id: "create_#{asset}_title")
|
58
|
+
html << content_tag(:div, "", class: :remote, id: create_id, style: "display:none;")
|
60
59
|
end
|
61
60
|
|
62
61
|
#----------------------------------------------------------------------------
|
@@ -69,36 +68,36 @@ module ApplicationHelper
|
|
69
68
|
|
70
69
|
def generate_js_for_popups(related, *assets)
|
71
70
|
assets.map do |asset|
|
72
|
-
render(:
|
71
|
+
render(partial: "shared/select_popup", locals: { related: related, popup: asset })
|
73
72
|
end.join
|
74
73
|
end
|
75
74
|
|
76
75
|
# We need this because standard Rails [select] turns ★ into &#9733;
|
77
76
|
#----------------------------------------------------------------------------
|
78
77
|
def rating_select(name, options = {})
|
79
|
-
stars = Hash[
|
80
|
-
options_for_select = %
|
78
|
+
stars = Hash[(1..5).map { |star| [star, "★" * star] }].sort
|
79
|
+
options_for_select = %(<option value="0"#{options[:selected].to_i == 0 ? ' selected="selected"' : ''}>#{t :select_none}</option>)
|
81
80
|
options_for_select << stars.map { |star| %(<option value="#{star.first}"#{options[:selected] == star.first ? ' selected="selected"' : ''}>#{star.last}</option>) }.join
|
82
81
|
select_tag name, options_for_select.html_safe, options
|
83
82
|
end
|
84
83
|
|
85
84
|
#----------------------------------------------------------------------------
|
86
85
|
def link_to_inline(id, url, options = {})
|
87
|
-
text = options[:text] || t(id, :
|
86
|
+
text = options[:text] || t(id, default: id.to_s.titleize)
|
88
87
|
text = (arrow_for(id) + text) unless options[:plain]
|
89
88
|
related = (options[:related] ? "&related=#{options[:related]}" : '')
|
90
89
|
|
91
90
|
link_to(text,
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
url + "#{url.include?('?') ? '&' : '?'}cancel=false" + related,
|
92
|
+
remote: true,
|
93
|
+
onclick: "this.href = this.href.replace(/cancel=(true|false)/,'cancel='+ ($('##{id}').css('display') != 'none'));",
|
94
|
+
class: options[:class]
|
96
95
|
)
|
97
96
|
end
|
98
97
|
|
99
98
|
#----------------------------------------------------------------------------
|
100
99
|
def arrow_for(id)
|
101
|
-
content_tag(:span, "►".html_safe, :
|
100
|
+
content_tag(:span, "►".html_safe, id: "#{id}_arrow", class: :arrow)
|
102
101
|
end
|
103
102
|
|
104
103
|
#----------------------------------------------------------------------------
|
@@ -107,9 +106,9 @@ module ApplicationHelper
|
|
107
106
|
|
108
107
|
name = (params[:klass_name] || object.class.name).underscore.downcase
|
109
108
|
link_to(t(:edit),
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
options[:url] || polymorphic_url(record, action: :edit),
|
110
|
+
remote: true,
|
111
|
+
onclick: "this.href = this.href.split('?')[0] + '?previous='+crm.find_form('edit_#{h name}');".html_safe
|
113
112
|
)
|
114
113
|
end
|
115
114
|
|
@@ -119,22 +118,22 @@ module ApplicationHelper
|
|
119
118
|
confirm = options[:confirm] || nil
|
120
119
|
|
121
120
|
link_to(t(:delete) + "!",
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
options[:url] || url_for(record),
|
122
|
+
method: :delete,
|
123
|
+
remote: true,
|
124
|
+
confirm: confirm
|
126
125
|
)
|
127
126
|
end
|
128
127
|
|
129
128
|
#----------------------------------------------------------------------------
|
130
129
|
def link_to_discard(object)
|
131
130
|
current_url = (request.xhr? ? request.referer : request.fullpath)
|
132
|
-
parent, parent_id = current_url.scan(%r
|
131
|
+
parent, parent_id = current_url.scan(%r{/(\w+)/(\d+)}).flatten
|
133
132
|
|
134
133
|
link_to(t(:discard),
|
135
|
-
|
136
|
-
|
137
|
-
|
134
|
+
url_for(controller: parent, action: :discard, id: parent_id, attachment: object.class.name, attachment_id: object.id),
|
135
|
+
method: :post,
|
136
|
+
remote: true
|
138
137
|
)
|
139
138
|
end
|
140
139
|
|
@@ -142,61 +141,72 @@ module ApplicationHelper
|
|
142
141
|
def link_to_cancel(url, params = {})
|
143
142
|
url = params[:url] if params[:url]
|
144
143
|
link_to(t(:cancel),
|
145
|
-
|
146
|
-
|
144
|
+
url + "#{url.include?('?') ? '&' : '?'}cancel=true",
|
145
|
+
remote: true
|
147
146
|
)
|
148
147
|
end
|
149
148
|
|
150
149
|
#----------------------------------------------------------------------------
|
151
150
|
def link_to_close(url)
|
152
151
|
link_to("x", url + "#{url.include?('?') ? '&' : '?'}cancel=true",
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
remote: true,
|
153
|
+
class: "close",
|
154
|
+
title: t(:close_form)
|
156
155
|
)
|
157
156
|
end
|
158
157
|
|
159
158
|
# Bcc: to dropbox address if the dropbox has been set up.
|
160
159
|
#----------------------------------------------------------------------------
|
161
|
-
def link_to_email(email, length = nil, &
|
162
|
-
name = (length ? truncate(email, :
|
160
|
+
def link_to_email(email, length = nil, &_block)
|
161
|
+
name = (length ? truncate(email, length: length) : email)
|
163
162
|
if Setting.email_dropbox && Setting.email_dropbox[:address].present?
|
164
163
|
mailto = "#{email}?bcc=#{Setting.email_dropbox[:address]}"
|
165
164
|
else
|
166
165
|
mailto = email
|
167
166
|
end
|
168
167
|
if block_given?
|
169
|
-
link_to("mailto:#{mailto}", :
|
168
|
+
link_to("mailto:#{mailto}", title: email) do
|
170
169
|
yield
|
171
170
|
end
|
172
171
|
else
|
173
|
-
link_to(h(name), "mailto:#{mailto}", :
|
172
|
+
link_to(h(name), "mailto:#{mailto}", title: email)
|
174
173
|
end
|
175
174
|
end
|
176
175
|
|
177
176
|
#----------------------------------------------------------------------------
|
178
177
|
def jumpbox(current)
|
179
|
-
tabs = [
|
178
|
+
tabs = [:campaigns, :accounts, :leads, :contacts, :opportunities]
|
180
179
|
current = tabs.first unless tabs.include?(current)
|
181
180
|
tabs.map do |tab|
|
182
|
-
link_to_function(t("tab_#{tab}"), "crm.jumper('#{tab}')", "html-data" => tab, :
|
181
|
+
link_to_function(t("tab_#{tab}"), "crm.jumper('#{tab}')", "html-data" => tab, class: (tab == current ? 'selected' : ''))
|
183
182
|
end.join(" | ").html_safe
|
184
183
|
end
|
185
184
|
|
186
185
|
#----------------------------------------------------------------------------
|
187
186
|
def styles_for(*models)
|
188
|
-
render :
|
187
|
+
render partial: "shared/inline_styles", locals: { models: models }
|
189
188
|
end
|
190
189
|
|
191
190
|
#----------------------------------------------------------------------------
|
192
|
-
def hidden
|
193
|
-
|
194
|
-
|
195
|
-
|
191
|
+
def hidden
|
192
|
+
{ style: "display:none;" }
|
193
|
+
end
|
194
|
+
|
195
|
+
def exposed
|
196
|
+
{ style: "display:block;" }
|
197
|
+
end
|
198
|
+
|
199
|
+
def invisible
|
200
|
+
{ style: "visibility:hidden;" }
|
201
|
+
end
|
202
|
+
|
203
|
+
def visible
|
204
|
+
{ style: "visibility:visible;" }
|
205
|
+
end
|
196
206
|
|
197
207
|
#----------------------------------------------------------------------------
|
198
|
-
def one_submit_only(
|
199
|
-
{ :
|
208
|
+
def one_submit_only(_form = '')
|
209
|
+
{ onsubmit: "$('#'+this.id+' input[type=submit]').prop('disabled', true)".html_safe }
|
200
210
|
end
|
201
211
|
|
202
212
|
#----------------------------------------------------------------------------
|
@@ -212,7 +222,7 @@ module ApplicationHelper
|
|
212
222
|
#----------------------------------------------------------------------------
|
213
223
|
def confirm_delete(model, params = {})
|
214
224
|
question = %(<span class="warn">#{t(:confirm_delete, model.class.to_s.downcase)}</span>)
|
215
|
-
yes = link_to(t(:yes_button), params[:url] || model, :
|
225
|
+
yes = link_to(t(:yes_button), params[:url] || model, method: :delete)
|
216
226
|
no = link_to_function(t(:no_button), "$('#menu').html($('#confirm').html());")
|
217
227
|
text = "$('#confirm').html( $('#menu').html() );\n"
|
218
228
|
text << "$('#menu').html('#{question} #{yes} : #{no}');"
|
@@ -221,7 +231,7 @@ module ApplicationHelper
|
|
221
231
|
|
222
232
|
#----------------------------------------------------------------------------
|
223
233
|
def spacer(width = 10)
|
224
|
-
image_tag "1x1.gif", :
|
234
|
+
image_tag "1x1.gif", width: width, height: 1, alt: nil
|
225
235
|
end
|
226
236
|
|
227
237
|
# Reresh sidebar using the action view within the current controller.
|
@@ -234,7 +244,7 @@ module ApplicationHelper
|
|
234
244
|
#----------------------------------------------------------------------------
|
235
245
|
def refresh_sidebar_for(view, action = nil, shake = nil)
|
236
246
|
text = ""
|
237
|
-
text << "$('#sidebar').html('#{ j render(:
|
247
|
+
text << "$('#sidebar').html('#{ j render(partial: 'layouts/sidebar', locals: { view: view, action: action }) }');"
|
238
248
|
text << "$('##{j shake.to_s}').effect('shake', { duration:200, distance: 3 });" if shake
|
239
249
|
text.html_safe
|
240
250
|
end
|
@@ -242,15 +252,15 @@ module ApplicationHelper
|
|
242
252
|
# Display web presence mini-icons for Contact or Lead.
|
243
253
|
#----------------------------------------------------------------------------
|
244
254
|
def web_presence_icons(person)
|
245
|
-
[
|
255
|
+
[:blog, :linkedin, :facebook, :twitter, :skype].map do |site|
|
246
256
|
url = person.send(site)
|
247
257
|
unless url.blank?
|
248
|
-
if site == :skype
|
258
|
+
if site == :skype
|
249
259
|
url = "callto:" << url
|
250
260
|
else
|
251
261
|
url = "http://" << url unless url.match(/^https?:\/\//)
|
252
262
|
end
|
253
|
-
link_to(image_tag("#{site}.gif", :
|
263
|
+
link_to(image_tag("#{site}.gif", size: "15x15"), h(url), :"data-popup" => true, title: t(:open_in_window, h(url)))
|
254
264
|
end
|
255
265
|
end.compact.join("\n").html_safe
|
256
266
|
end
|
@@ -261,7 +271,7 @@ module ApplicationHelper
|
|
261
271
|
if value.is_a?(Array)
|
262
272
|
param, value = value.first, value.last
|
263
273
|
end
|
264
|
-
%
|
274
|
+
%{
|
265
275
|
if ($('##{option}').html() != '#{value}') {
|
266
276
|
$('##{option}').html('#{value}');
|
267
277
|
$('#loading').show();
|
@@ -276,15 +286,15 @@ module ApplicationHelper
|
|
276
286
|
def options_menu_item(option, key, url = send("redraw_#{controller.controller_name}_path"))
|
277
287
|
name = t("option_#{key}")
|
278
288
|
"{ name: \"#{name.titleize}\", on_select: function() {" +
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
289
|
+
%{
|
290
|
+
if ($('##{option}').html() != '#{name}') {
|
291
|
+
$('##{option}').html('#{name}');
|
292
|
+
$('#loading').show();
|
293
|
+
$.get('#{url}', {#{option}: '#{key}', query: $('#query').val()}, function () {
|
294
|
+
$('#loading').hide();
|
295
|
+
});
|
296
|
+
}
|
297
|
+
} + "}}"
|
288
298
|
end
|
289
299
|
|
290
300
|
# Ajax helper to pass browser timezone offset to the server.
|
@@ -300,15 +310,13 @@ module ApplicationHelper
|
|
300
310
|
# publically available: http://en.gravatar.com/site/implement/images
|
301
311
|
#----------------------------------------------------------------------------
|
302
312
|
def avatar_for(model, args = {})
|
303
|
-
args = { :
|
304
|
-
|
305
|
-
|
306
|
-
image_tag(model.avatar.image.url(args[:size]), args)
|
313
|
+
args = { class: 'gravatar', size: :large }.merge(args)
|
314
|
+
if model.respond_to?(:avatar) && model.avatar.present?
|
315
|
+
image_tag(model.avatar.image.url(args.delete(:size)), args)
|
307
316
|
else
|
308
317
|
args = Avatar.size_from_style!(args) # convert size format :large => '75x75'
|
309
318
|
gravatar_image_tag(model.email, args)
|
310
319
|
end
|
311
|
-
|
312
320
|
end
|
313
321
|
|
314
322
|
# Returns default permissions intro.
|
@@ -327,13 +335,13 @@ module ApplicationHelper
|
|
327
335
|
hint = "#{t(attribute)}..."
|
328
336
|
if object.send(attribute).blank?
|
329
337
|
form.text_field(attribute,
|
330
|
-
|
331
|
-
|
338
|
+
style: "margin-top: 6px; #{extra_styles}",
|
339
|
+
placeholder: hint
|
332
340
|
)
|
333
341
|
else
|
334
342
|
form.text_field(attribute,
|
335
|
-
|
336
|
-
|
343
|
+
style: "margin-top: 6px; #{extra_styles}",
|
344
|
+
placeholder: hint
|
337
345
|
)
|
338
346
|
end
|
339
347
|
end
|
@@ -344,42 +352,42 @@ module ApplicationHelper
|
|
344
352
|
# - we're actually showing asset landing page.
|
345
353
|
#----------------------------------------------------------------------------
|
346
354
|
def shown_on_landing_page?
|
347
|
-
!!((request.xhr? && request.referer =~ %r
|
348
|
-
(!request.xhr? && request.fullpath =~ %r
|
355
|
+
!!((request.xhr? && request.referer =~ %r{/\w+/\d+}) ||
|
356
|
+
(!request.xhr? && request.fullpath =~ %r{/\w+/\d+}))
|
349
357
|
end
|
350
358
|
|
351
359
|
# Helper to display links to supported data export formats.
|
352
360
|
#----------------------------------------------------------------------------
|
353
|
-
def links_to_export(action
|
361
|
+
def links_to_export(action = :index)
|
354
362
|
token = current_user.single_access_token
|
355
|
-
url_params = {:action
|
356
|
-
url_params.merge!(:
|
357
|
-
url_params.merge!(:
|
358
|
-
url_params.merge!(:
|
359
|
-
url_params.merge!(:
|
360
|
-
url_params.merge!(:
|
363
|
+
url_params = { action: action }
|
364
|
+
url_params.merge!(id: params[:id]) unless params[:id].blank?
|
365
|
+
url_params.merge!(query: params[:query]) unless params[:query].blank?
|
366
|
+
url_params.merge!(q: params[:q]) unless params[:q].blank?
|
367
|
+
url_params.merge!(view: @view) unless @view.blank? # tasks
|
368
|
+
url_params.merge!(id: params[:id]) unless params[:id].blank?
|
361
369
|
|
362
370
|
exports = %w(xls csv).map do |format|
|
363
|
-
link_to(format.upcase, url_params.merge(:
|
371
|
+
link_to(format.upcase, url_params.merge(format: format), title: I18n.t(:"to_#{format}")) unless action.to_s == "show"
|
364
372
|
end
|
365
373
|
|
366
374
|
feeds = %w(rss atom).map do |format|
|
367
|
-
link_to(format.upcase, url_params.merge(:
|
375
|
+
link_to(format.upcase, url_params.merge(format: format, authentication_credentials: token), title: I18n.t(:"to_#{format}"))
|
368
376
|
end
|
369
377
|
|
370
|
-
links = %
|
371
|
-
link_to(format.upcase, url_params, :
|
378
|
+
links = %w(perm).map do |format|
|
379
|
+
link_to(format.upcase, url_params, title: I18n.t(:"to_#{format}"))
|
372
380
|
end
|
373
381
|
|
374
382
|
(exports + feeds + links).compact.join(' | ')
|
375
383
|
end
|
376
384
|
|
377
385
|
def user_options
|
378
|
-
User.all.map {|u| [u.full_name, u.id]}
|
386
|
+
User.all.map { |u| [u.full_name, u.id] }
|
379
387
|
end
|
380
388
|
|
381
389
|
def group_options
|
382
|
-
Group.all.map {|g| [g.name, g.id]}
|
390
|
+
Group.all.map { |g| [g.name, g.id] }
|
383
391
|
end
|
384
392
|
|
385
393
|
def list_of_entities
|
@@ -388,8 +396,8 @@ module ApplicationHelper
|
|
388
396
|
|
389
397
|
def entity_filter_checkbox(name, value, count)
|
390
398
|
checked = (session["#{controller_name}_filter"].present? ? session["#{controller_name}_filter"].split(",").include?(value.to_s) : count.to_i > 0)
|
391
|
-
url = url_for(:
|
392
|
-
onclick = %
|
399
|
+
url = url_for(action: :filter)
|
400
|
+
onclick = %{
|
393
401
|
var query = $('#query').val(),
|
394
402
|
values = [];
|
395
403
|
$('input[name="#{h name}[]"]').filter(':checked').each(function () {
|
@@ -400,13 +408,13 @@ module ApplicationHelper
|
|
400
408
|
$('#loading').hide();
|
401
409
|
});
|
402
410
|
}.html_safe
|
403
|
-
check_box_tag("#{name}[]", value, checked, :
|
411
|
+
check_box_tag("#{name}[]", value, checked, id: value, onclick: onclick)
|
404
412
|
end
|
405
413
|
|
406
414
|
# Create a column in the 'asset_attributes' table.
|
407
415
|
# If a block is given, render it inside the td
|
408
416
|
#----------------------------------------------------------------------------
|
409
|
-
def col(title, value = nil, last = false, email = false, &
|
417
|
+
def col(title, value = nil, last = false, email = false, &_block)
|
410
418
|
last_class = (last ? 'last' : nil)
|
411
419
|
out = content_tag(:th, title, class: last_class)
|
412
420
|
if block_given?
|
@@ -417,9 +425,9 @@ module ApplicationHelper
|
|
417
425
|
# Parse and format urls as links.
|
418
426
|
fmt_value = (value.to_s || "").gsub("\n", "<br />")
|
419
427
|
fmt_value = if email
|
420
|
-
|
421
|
-
|
422
|
-
|
428
|
+
link_to_email(fmt_value)
|
429
|
+
else
|
430
|
+
fmt_value.gsub(/((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/\+#]*[\w\-\@?^=%&\/\+#])?)/, "<a href=\"\\1\">\\1</a>")
|
423
431
|
end
|
424
432
|
out << content_tag(:td, fmt_value, class: last_class)
|
425
433
|
end
|
@@ -429,14 +437,14 @@ module ApplicationHelper
|
|
429
437
|
#----------------------------------------------------------------------------
|
430
438
|
# Combines the 'subtitle' helper with the small info text on the same line.
|
431
439
|
def section_title(id, hidden = true, text = nil, info_text = nil)
|
432
|
-
text = id.to_s.split("_").last.capitalize if text
|
433
|
-
content_tag("div", :
|
434
|
-
content = link_to("<small>#{ hidden ?
|
435
|
-
|
436
|
-
|
437
|
-
|
440
|
+
text = id.to_s.split("_").last.capitalize if text.nil?
|
441
|
+
content_tag("div", class: "subtitle show_attributes") do
|
442
|
+
content = link_to("<small>#{ hidden ? '►' : '▼' }</small> #{sanitize text}".html_safe,
|
443
|
+
url_for(controller: :home, action: :toggle, id: id),
|
444
|
+
remote: true,
|
445
|
+
onclick: "crm.flip_subtitle(this)"
|
438
446
|
)
|
439
|
-
content << content_tag("small", info_text.to_s,
|
447
|
+
content << content_tag("small", info_text.to_s, class: "subtitle_inline_info", id: "#{id}_intro", style: hidden ? "" : "display:none;")
|
440
448
|
end
|
441
449
|
end
|
442
450
|
|
@@ -453,7 +461,7 @@ module ApplicationHelper
|
|
453
461
|
def template_for_current_view
|
454
462
|
controller = params['controller']
|
455
463
|
action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view
|
456
|
-
template = FatFreeCRM::ViewFactory.template_for_current_view(:
|
464
|
+
template = FatFreeCRM::ViewFactory.template_for_current_view(controller: controller, action: action, name: current_view_name)
|
457
465
|
template
|
458
466
|
end
|
459
467
|
|
@@ -462,19 +470,19 @@ module ApplicationHelper
|
|
462
470
|
def view_buttons
|
463
471
|
controller = params['controller']
|
464
472
|
action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view
|
465
|
-
views = FatFreeCRM::ViewFactory.views_for(:
|
473
|
+
views = FatFreeCRM::ViewFactory.views_for(controller: controller, action: action)
|
466
474
|
return nil unless views.size > 1
|
467
475
|
lis = ''.html_safe
|
468
|
-
content_tag :ul, :
|
476
|
+
content_tag :ul, class: 'format-buttons' do
|
469
477
|
views.collect do |view|
|
470
|
-
classes = if (current_view_name == view.name)
|
471
|
-
|
472
|
-
|
473
|
-
|
478
|
+
classes = if (current_view_name == view.name) || (current_view_name.nil? && view.template.nil?) # nil indicates default template.
|
479
|
+
"#{h view.name}-button active"
|
480
|
+
else
|
481
|
+
"#{h view.name}-button"
|
474
482
|
end
|
475
483
|
lis << content_tag(:li) do
|
476
484
|
url = (action == "index") ? send("redraw_#{controller}_path") : send("#{controller.singularize}_path")
|
477
|
-
link_to('#', :
|
485
|
+
link_to('#', title: t(view.name, default: h(view.title)), :"data-view" => h(view.name), :"data-url" => h(url), :"data-context" => action, class: classes) do
|
478
486
|
icon = view.icon || 'fa-bars'
|
479
487
|
content_tag(:i, nil, class: "fa #{h icon}")
|
480
488
|
end
|
@@ -489,7 +497,7 @@ module ApplicationHelper
|
|
489
497
|
# <span class="timeago" datetime="2008-07-17T09:24:17Z">July 17, 2008</span>
|
490
498
|
def timeago(time, options = {})
|
491
499
|
options[:class] ||= "timeago"
|
492
|
-
content_tag(:span, h(time.to_s), options.merge(
|
500
|
+
content_tag(:span, h(time.to_s), options.merge(title: time.getutc.iso8601)) if time
|
493
501
|
end
|
494
502
|
|
495
503
|
#----------------------------------------------------------------------------
|
@@ -512,8 +520,8 @@ module ApplicationHelper
|
|
512
520
|
# options = { renderer: {...} , params: {...}
|
513
521
|
def paginate(options = {})
|
514
522
|
collection = options.delete(:collection)
|
523
|
+
options = { params: { action: 'index'}}.merge(options) if params['action'] == 'filter'
|
515
524
|
options = { renderer: RemoteLinkPaginationHelper::LinkRenderer }.merge(options)
|
516
525
|
will_paginate(collection, options)
|
517
526
|
end
|
518
|
-
|
519
527
|
end
|