diff --git a/Gemfile b/Gemfile index 33908de..6763038 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -# Declare your gem's dependencies in scrivito_jr_form_widget.gemspec. +# Declare your gem's dependencies in scrivito_crm_form_widget.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 5447ef9..58aee1f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,74 @@ PATH remote: . specs: - scrivito_jr_form_widget (0.0.5) + scrivito_crm_form_widget (0.0.5) active_attr bundler + infopark_webcrm_sdk scrivito_advanced_editors scrivito_sdk GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.10) - actionpack (= 4.1.10) - actionview (= 4.1.10) + actionmailer (4.2.1) + actionpack (= 4.2.1) + actionview (= 4.2.1) + activejob (= 4.2.1) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.10) - actionview (= 4.1.10) - activesupport (= 4.1.10) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.1) + actionview (= 4.2.1) + activesupport (= 4.2.1) + rack (~> 1.6) rack-test (~> 0.6.2) - actionview (4.1.10) - activesupport (= 4.1.10) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.1) + activesupport (= 4.2.1) builder (~> 3.1) erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) active_attr (0.8.5) activemodel (>= 3.0.2, < 5.0) activesupport (>= 3.0.2, < 5.0) - activemodel (4.1.10) - activesupport (= 4.1.10) + activejob (4.2.1) + activesupport (= 4.2.1) + globalid (>= 0.3.0) + activemodel (4.2.1) + activesupport (= 4.2.1) builder (~> 3.1) - activerecord (4.1.10) - activemodel (= 4.1.10) - activesupport (= 4.1.10) - arel (~> 5.0.0) - activesupport (4.1.10) - i18n (~> 0.6, >= 0.6.9) + activerecord (4.2.1) + activemodel (= 4.2.1) + activesupport (= 4.2.1) + arel (~> 6.0) + activesupport (4.2.1) + i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.3.7) - arel (5.0.1.20140414130214) + addressable (2.3.8) + arel (6.0.0) builder (3.2.2) diff-lcs (1.2.5) erubis (2.7.0) font-awesome-rails (4.3.0.0) railties (>= 3.2, < 5.0) + globalid (0.3.3) + activesupport (>= 4.1.0) hike (1.2.3) - hyp_diff (0.0.3) + hyp_diff (0.0.4) diff-lcs (~> 1.2.5) - nokogiri (~> 1.5.6) + nokogiri (~> 1.6.5) i18n (0.7.0) + infopark_webcrm_sdk (1.0.0.rc3) + actionpack (~> 4.0) + activesupport (~> 4.0) + addressable (~> 2.0) + multi_json (~> 1.0) + multipart-post (~> 2.0) jbuilder (2.2.12) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) @@ -58,29 +76,42 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.2) + loofah (2.0.1) + nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.4.3) + mini_portile (0.6.2) minitest (5.5.1) multi_json (1.11.0) multipart-post (2.0.0) - nokogiri (1.5.11) - rack (1.5.2) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + rack (1.6.0) rack-test (0.6.3) rack (>= 1.0) - rails (4.1.10) - actionmailer (= 4.1.10) - actionpack (= 4.1.10) - actionview (= 4.1.10) - activemodel (= 4.1.10) - activerecord (= 4.1.10) - activesupport (= 4.1.10) + rails (4.2.1) + actionmailer (= 4.2.1) + actionpack (= 4.2.1) + actionview (= 4.2.1) + activejob (= 4.2.1) + activemodel (= 4.2.1) + activerecord (= 4.2.1) + activesupport (= 4.2.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.10) - sprockets-rails (~> 2.0) - railties (4.1.10) - actionpack (= 4.1.10) - activesupport (= 4.1.10) + railties (= 4.2.1) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.6) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + railties (4.2.1) + actionpack (= 4.2.1) + activesupport (= 4.2.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.4.2) @@ -89,16 +120,16 @@ GEM font-awesome-rails rails scrivito_sdk - scrivito_sdk (0.42.0) + scrivito_sdk (0.50.0) addressable (~> 2.3.2) diff-lcs (~> 1.2.5) - hyp_diff (~> 0.0.3) + hyp_diff (~> 0.0.4) jbuilder (~> 2.2.2) jquery-rails (~> 3.1.1) json (>= 1.7.7) multipart-post (~> 2.0.0) - nokogiri (~> 1.5.6) - rails (~> 4.1.1) + nokogiri (~> 1.6.5) + rails (~> 4.2.0) rake (>= 0.9.2.2) sprockets (2.12.3) hike (~> 1.2) @@ -120,4 +151,4 @@ PLATFORMS DEPENDENCIES rake - scrivito_jr_form_widget! + scrivito_crm_form_widget! diff --git a/README.md b/README.md index e3aa095..0ad8142 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,27 @@ -# scrivito_jr_form_widget +# scrivito_crm_form_widget ## Description -A Widget for Scrivito to add an formular based on an activity type from Justrelate using API 2. +A Widget for Scrivito to add an formular based on an activity type from Crm using API 2. ## Installation Add this lines to your application's `Gemfile`: - gem 'scrivito_jr_form_widget' + gem 'scrivito_crm_form_widget' Add this line to your stylsheet manifest: - *= require scrivito_jr_form_widget + *= require scrivito_crm_form_widget Add this line to your Javascript manifest: - //= require scrivito_jr_form_widget + //= require scrivito_crm_form_widget -Create a Model with name `JrFormAttribtues`. It is used by the presenter to make your custom attributes accessible by the form. You can define prefill values here. +Create a Model with name `CrmFormAttribtues`. It is used by the presenter to make your custom attributes accessible by the form. You can define prefill values here. ```ruby -class JrFormAttributes +class CrmFormAttributes include ActiveModel::Model attr_accessor :custom_attribute_1, :custom_attribute_2, ... @@ -69,10 +69,10 @@ If the creation of a new activity fails at a form submit, the `flash[:alert]` va You can use this to create a message for the user. -Using more than one Page with your just relate and activities should be seperated. You can add a hook with your separation strategy. Simply add the method `self.jr_activity_filter` to your obj.rb. +Using more than one Page with your crm and activities should be seperated. You can add a hook with your separation strategy. Simply add the method `self.crm_activity_filter` to your obj.rb. - def self.jr_activity_filter - JustRelate::Type.all.select { |a| a.id.starts_with? 'page-' } + def self.crm_activity_filter + Crm::Type.all.select { |a| a.id.starts_with? 'page-' } end This will select activities by its id. diff --git a/Rakefile b/Rakefile index 65c094d..911c15d 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ScrivitoJrFormWidget' + rdoc.title = 'ScrivitoCrmFormWidget' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.rdoc') rdoc.rdoc_files.include('lib/**/*.rb') diff --git a/app/assets/scripts/scrivito_jr_form_widget.js b/app/assets/scripts/scrivito_crm_form_widget.js similarity index 100% rename from app/assets/scripts/scrivito_jr_form_widget.js rename to app/assets/scripts/scrivito_crm_form_widget.js diff --git a/app/assets/styles/scrivito_jr_form_widget.css b/app/assets/styles/scrivito_crm_form_widget.css similarity index 100% rename from app/assets/styles/scrivito_jr_form_widget.css rename to app/assets/styles/scrivito_crm_form_widget.css diff --git a/app/controllers/scrivito_jr_form_widget/application_controller.rb b/app/controllers/scrivito_crm_form_widget/application_controller.rb similarity index 69% rename from app/controllers/scrivito_jr_form_widget/application_controller.rb rename to app/controllers/scrivito_crm_form_widget/application_controller.rb index 2fca064..061f7c0 100644 --- a/app/controllers/scrivito_jr_form_widget/application_controller.rb +++ b/app/controllers/scrivito_crm_form_widget/application_controller.rb @@ -1,4 +1,4 @@ -module ScrivitoJrFormWidget +module ScrivitoCrmFormWidget class ApplicationController < ActionController::Base end end diff --git a/app/models/jr_form_widget.rb b/app/models/crm_form_widget.rb similarity index 62% rename from app/models/jr_form_widget.rb rename to app/models/crm_form_widget.rb index ef26dfc..24ff68e 100644 --- a/app/models/jr_form_widget.rb +++ b/app/models/crm_form_widget.rb @@ -1,8 +1,8 @@ -class JrFormWidget < Widget - include JustRelate +class CrmFormWidget < Widget + include Crm def self.activities - Obj.try(:jr_activity_filter) || JustRelate::Type.all.to_a + Obj.try(:crm_activity_filter) || Crm::Type.all.to_a end def attributes @@ -10,7 +10,7 @@ def attributes end def activity - JustRelate::Type.find(activity_id) + Crm::Type.find(activity_id) end def activity_id? diff --git a/app/presenter/jr_form_presenter.rb b/app/presenter/crm_form_presenter.rb similarity index 84% rename from app/presenter/jr_form_presenter.rb rename to app/presenter/crm_form_presenter.rb index 20b375c..cbf7fae 100644 --- a/app/presenter/jr_form_presenter.rb +++ b/app/presenter/crm_form_presenter.rb @@ -1,4 +1,4 @@ -class JrFormPresenter < JrFormAttributes +class CrmFormPresenter < CrmFormAttributes def attribute_names @type.standard_attrs.keys + @type.custom_attrs.keys @@ -8,7 +8,7 @@ def initialize(widget, request, controller) @widget = widget @activity = widget.activity @page = widget.obj - @params = request.params["jr_form_presenter"] + @params = request.params["crm_form_presenter"] if request.post? redirect_after_submit(controller, widget, self.submit) @@ -30,18 +30,18 @@ def submit @params["type_id"] = @activity.id @params["state"] = @activity.attributes['states'].first - activity = JustRelate::Activity.create(@params) + activity = Crm::Activity.create(@params) return {status: "success", message: "Your form was send successfully"} - rescue JustRelate::Errors::InvalidValues => e + rescue Crm::Errors::InvalidValues => e return {status: "error", message: e.validation_errors} end private def manipulate_or_create_user - contact = JustRelate::Contact.where(:email, :equals, @params['custom_email']).and(:last_name, :equals, @params['custom_last_name']).first + contact = Crm::Contact.where(:email, :equals, @params['custom_email']).and(:last_name, :equals, @params['custom_last_name']).first unless contact - contact = JustRelate::Contact.create({ + contact = Crm::Contact.create({ first_name: @params['custom_first_name'], last_name: @params['custom_last_name'], email: @params['custom_email'], diff --git a/app/views/jr_form_widget/_jr_enum.html.erb b/app/views/crm_form_widget/_crm_enum.html.erb similarity index 82% rename from app/views/jr_form_widget/_jr_enum.html.erb rename to app/views/crm_form_widget/_crm_enum.html.erb index a146760..e108d0b 100644 --- a/app/views/jr_form_widget/_jr_enum.html.erb +++ b/app/views/crm_form_widget/_crm_enum.html.erb @@ -5,7 +5,7 @@