Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename JR into CRM since the final release of JR is delayed a bit. #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
115 changes: 73 additions & 42 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,86 +1,117 @@
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)
jquery-rails (3.1.2)
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)
Expand All @@ -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)
Expand All @@ -120,4 +151,4 @@ PLATFORMS

DEPENDENCIES
rake
scrivito_jr_form_widget!
scrivito_crm_form_widget!
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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, ...
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ScrivitoJrFormWidget
module ScrivitoCrmFormWidget
class ApplicationController < ActionController::Base
end
end
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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
activity.attribute_definitions
end

def activity
JustRelate::Type.find(activity_id)
Crm::Type.find(activity_id)
end

def activity_id?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class JrFormPresenter < JrFormAttributes
class CrmFormPresenter < CrmFormAttributes

def attribute_names
@type.standard_attrs.keys + @type.custom_attrs.keys
Expand All @@ -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)
Expand All @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="radio">
<%= 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 %>
</div>
<% end %>
Expand Down
12 changes: 12 additions & 0 deletions app/views/crm_form_widget/_form.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<div class="tab-panel" id="edit-activity">
<h4>Activity</h4>
<%= 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 } %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if widget.activity_id? %>
<%= render 'jr_form_widget/form', widget: widget %>
<%= render 'crm_form_widget/form', widget: widget %>
<% else %>
<div class="alert alert-warning">
Select an activty add the details view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
</div>

<div class="scrivito_editing_widget_description">
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.
</div>
12 changes: 0 additions & 12 deletions app/views/jr_form_widget/_form.html.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions lib/scrivito_crm_form_widget/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ScrivitoCrmFormWidget
VERSION = "0.0.5"
end
4 changes: 2 additions & 2 deletions lib/scrivito_jr_form_widget.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "scrivito_jr_form_widget/engine"
require "scrivito_crm_form_widget/engine"

module ScrivitoJrFormWidget
module ScrivitoCrmFormWidget
end
3 changes: 0 additions & 3 deletions lib/scrivito_jr_form_widget/version.rb

This file was deleted.

Loading