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 @@
<%= form.label "#{name}_#{value.downcase}" do %> <%= form.radio_button name.to_sym, value %> - <%= t("helpers.label.jr_form_presenter.#{name}_option.#{value.downcase}") %> + <%= t("helpers.label.crm_form_presenter.#{name}_option.#{value.downcase}") %> <% end %>
<% end %> diff --git a/app/views/jr_form_widget/_jr_multienum.html.erb b/app/views/crm_form_widget/_crm_multienum.html.erb similarity index 100% rename from app/views/jr_form_widget/_jr_multienum.html.erb rename to app/views/crm_form_widget/_crm_multienum.html.erb diff --git a/app/views/jr_form_widget/_jr_string.html.erb b/app/views/crm_form_widget/_crm_string.html.erb similarity index 100% rename from app/views/jr_form_widget/_jr_string.html.erb rename to app/views/crm_form_widget/_crm_string.html.erb diff --git a/app/views/jr_form_widget/_jr_text.html.erb b/app/views/crm_form_widget/_crm_text.html.erb similarity index 100% rename from app/views/jr_form_widget/_jr_text.html.erb rename to app/views/crm_form_widget/_crm_text.html.erb diff --git a/app/views/crm_form_widget/_form.html.erb b/app/views/crm_form_widget/_form.html.erb new file mode 100644 index 0000000..a36526a --- /dev/null +++ b/app/views/crm_form_widget/_form.html.erb @@ -0,0 +1,12 @@ +<%= form_for CrmFormPresenter.new(widget, request, controller), url: scrivito_path(widget.obj), html: { class: "form-horizontal"} do |form| %> + <% if widget.subject %> + <%= form.hidden_field(:title, value: widget.subject) %> + <% end %> + + <% widget.attributes.each do |name, options| %> + <%= render "crm_form_widget/crm_#{options["attribute_type"]}", form: form, name: name, options: options %> + <% end %> + + <%= form.submit widget.submit_button, class: "btn btn-primary pull-right" %> + +<% end %> \ No newline at end of file diff --git a/app/views/jr_form_widget/details.html.erb b/app/views/crm_form_widget/details.html.erb similarity index 91% rename from app/views/jr_form_widget/details.html.erb rename to app/views/crm_form_widget/details.html.erb index 3661732..9b2ebf5 100644 --- a/app/views/jr_form_widget/details.html.erb +++ b/app/views/crm_form_widget/details.html.erb @@ -23,7 +23,7 @@

Activity

- <%= scrivito_toggle_button_editor widget, :activity_id, JrFormWidget.activities.map { |a| a.id } %> + <%= scrivito_toggle_button_editor widget, :activity_id, CrmFormWidget.activities.map { |a| a.id } %>
\ No newline at end of file diff --git a/app/views/jr_form_widget/show.html.erb b/app/views/crm_form_widget/show.html.erb similarity index 71% rename from app/views/jr_form_widget/show.html.erb rename to app/views/crm_form_widget/show.html.erb index 78b0c9c..68b0efa 100644 --- a/app/views/jr_form_widget/show.html.erb +++ b/app/views/crm_form_widget/show.html.erb @@ -1,5 +1,5 @@ <% if widget.activity_id? %> - <%= render 'jr_form_widget/form', widget: widget %> + <%= render 'crm_form_widget/form', widget: widget %> <% else %>
Select an activty add the details view. diff --git a/app/views/jr_form_widget/thumbnail.html.erb b/app/views/crm_form_widget/thumbnail.html.erb similarity index 75% rename from app/views/jr_form_widget/thumbnail.html.erb rename to app/views/crm_form_widget/thumbnail.html.erb index e4bc418..293f235 100644 --- a/app/views/jr_form_widget/thumbnail.html.erb +++ b/app/views/crm_form_widget/thumbnail.html.erb @@ -7,5 +7,5 @@
- Add a formular to your page based on an activty from just relate CRM. + Add a formular to your page based on an activty from the Infopark-CRM.
diff --git a/app/views/jr_form_widget/_form.html.erb b/app/views/jr_form_widget/_form.html.erb deleted file mode 100644 index dae4c1c..0000000 --- a/app/views/jr_form_widget/_form.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%= form_for JrFormPresenter.new(widget, request, controller), url: scrivito_path(widget.obj), html: { class: "form-horizontal"} do |form| %> - <% if widget.subject %> - <%= form.hidden_field(:title, value: widget.subject) %> - <% end %> - - <% widget.attributes.each do |name, options| %> - <%= render "jr_form_widget/jr_#{options["attribute_type"]}", form: form, name: name, options: options %> - <% end %> - - <%= form.submit widget.submit_button, class: "btn btn-primary pull-right" %> - -<% end %> \ No newline at end of file diff --git a/lib/scrivito_jr_form_widget/engine.rb b/lib/scrivito_crm_form_widget/engine.rb similarity index 58% rename from lib/scrivito_jr_form_widget/engine.rb rename to lib/scrivito_crm_form_widget/engine.rb index a71455a..413a8cf 100644 --- a/lib/scrivito_jr_form_widget/engine.rb +++ b/lib/scrivito_crm_form_widget/engine.rb @@ -1,8 +1,8 @@ require 'scrivito_advanced_editors' require 'active_attr' -module ScrivitoJrFormWidget +module ScrivitoCrmFormWidget class Engine < ::Rails::Engine - isolate_namespace ScrivitoJrFormWidget + isolate_namespace ScrivitoCrmFormWidget end end diff --git a/lib/scrivito_crm_form_widget/version.rb b/lib/scrivito_crm_form_widget/version.rb new file mode 100644 index 0000000..0282ef8 --- /dev/null +++ b/lib/scrivito_crm_form_widget/version.rb @@ -0,0 +1,3 @@ +module ScrivitoCrmFormWidget + VERSION = "0.0.5" +end diff --git a/lib/scrivito_jr_form_widget.rb b/lib/scrivito_jr_form_widget.rb index 4311070..11e00b3 100644 --- a/lib/scrivito_jr_form_widget.rb +++ b/lib/scrivito_jr_form_widget.rb @@ -1,4 +1,4 @@ -require "scrivito_jr_form_widget/engine" +require "scrivito_crm_form_widget/engine" -module ScrivitoJrFormWidget +module ScrivitoCrmFormWidget end diff --git a/lib/scrivito_jr_form_widget/version.rb b/lib/scrivito_jr_form_widget/version.rb deleted file mode 100644 index 8c10c1b..0000000 --- a/lib/scrivito_jr_form_widget/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module ScrivitoJrFormWidget - VERSION = "0.0.5" -end diff --git a/lib/tasks/scrivito_jr_form_widget_tasks.rake b/lib/tasks/scrivito_jr_form_widget_tasks.rake index e3c18aa..5d5e94a 100644 --- a/lib/tasks/scrivito_jr_form_widget_tasks.rake +++ b/lib/tasks/scrivito_jr_form_widget_tasks.rake @@ -1,4 +1,4 @@ # desc "Explaining what the task does" -# task :scrivito_jr_form_widget do +# task :scrivito_crm_form_widget do # # Task goes here # end diff --git a/scrivito/migrate/0_create_jr_form_widget.rb b/scrivito/migrate/0_create_crm_form_widget.rb similarity index 73% rename from scrivito/migrate/0_create_jr_form_widget.rb rename to scrivito/migrate/0_create_crm_form_widget.rb index d2d26bf..84527a9 100644 --- a/scrivito/migrate/0_create_jr_form_widget.rb +++ b/scrivito/migrate/0_create_crm_form_widget.rb @@ -1,9 +1,9 @@ -class CreateJrFormWidget < ::Scrivito::Migration +class CreateCrmFormWidget < ::Scrivito::Migration def up Scrivito::ObjClass.create( - name: 'JrFormWidget', + name: 'CrmFormWidget', type: 'publication', - title: 'Just Relate Fromular Widget', + title: 'CRM Fromular Widget', attributes: [ {name: "activity_id", type: "string"}, {name: "subject", type: "string"}, diff --git a/scrivito_jr_form_widget.gemspec b/scrivito_crm_form_widget.gemspec similarity index 63% rename from scrivito_jr_form_widget.gemspec rename to scrivito_crm_form_widget.gemspec index 190475d..67bf5e5 100644 --- a/scrivito_jr_form_widget.gemspec +++ b/scrivito_crm_form_widget.gemspec @@ -1,19 +1,19 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: -require "scrivito_jr_form_widget/version" +require "scrivito_crm_form_widget/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "scrivito_jr_form_widget" - s.version = ScrivitoJrFormWidget::VERSION + s.name = "scrivito_crm_form_widget" + s.version = ScrivitoCrmFormWidget::VERSION s.authors = ["Scrivito"] s.email = ["support@scrivito.com"] s.homepage = "https://www.scrivito.com" - s.summary = "A widget for Scrivito to show a form using just relate api." - s.description = "A widget for Scrivito to show a form using just relate api." + s.summary = "A widget for Scrivito to show a form using crm 2.0 api." + s.description = "A widget for Scrivito to show a form using crm 2.0 api." s.license = "LGPL-3.0" s.files = Dir[ @@ -25,6 +25,7 @@ Gem::Specification.new do |s| s.add_dependency 'bundler' s.add_dependency 'scrivito_sdk' s.add_dependency 'scrivito_advanced_editors' + s.add_dependency 'infopark_webcrm_sdk' s.add_dependency 'active_attr' s.add_development_dependency 'rake'