ish_manager 0.1.8.355 → 0.1.8.356

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ish_manager/application.js +67 -15
  3. data/app/assets/javascripts/ish_manager/email_contexts.js +1 -1
  4. data/app/assets/javascripts/ish_manager/email_templates.js +20 -0
  5. data/app/assets/stylesheets/ish_manager/application.scss +48 -9
  6. data/app/assets/stylesheets/ish_manager/email.scss +44 -0
  7. data/app/assets/stylesheets/ish_manager/{email_contexts_templates.scss → email_contexts.scss} +29 -49
  8. data/app/assets/stylesheets/ish_manager/email_conversations.scss +99 -21
  9. data/app/assets/stylesheets/ish_manager/email_templates.scss +59 -0
  10. data/app/assets/stylesheets/ish_manager/leads_leadsets.scss +96 -3
  11. data/app/assets/stylesheets/ish_manager/scheduled_actions_emails.scss +25 -0
  12. data/app/assets/stylesheets/ish_manager/tags.scss +5 -0
  13. data/app/controllers/ish_manager/application_controller.rb +15 -0
  14. data/app/controllers/ish_manager/email_actions_controller.rb +80 -0
  15. data/app/controllers/ish_manager/email_campaigns_controller.rb +13 -0
  16. data/app/controllers/ish_manager/email_contexts_controller.rb +41 -48
  17. data/app/controllers/ish_manager/email_conversations_controller.rb +6 -2
  18. data/app/controllers/ish_manager/email_filters_controller.rb +47 -0
  19. data/app/controllers/ish_manager/email_messages_controller.rb +1 -1
  20. data/app/controllers/ish_manager/email_templates_controller.rb +23 -10
  21. data/app/controllers/ish_manager/leads_controller.rb +3 -9
  22. data/app/controllers/ish_manager/leadset_tags_controller.rb +18 -0
  23. data/app/controllers/ish_manager/leadsets_controller.rb +13 -0
  24. data/app/controllers/ish_manager/scheduled_email_actions_controller.rb +38 -0
  25. data/app/helpers/ish_manager/application_helper.rb +4 -0
  26. data/app/mailers/ish_manager/office_mailer.rb +10 -9
  27. data/app/views/ish_manager/application/_debug.haml +2 -1
  28. data/app/views/ish_manager/application/_main_header_admin.haml +47 -60
  29. data/app/views/ish_manager/email_actions/_form.haml +42 -0
  30. data/app/views/ish_manager/email_actions/edit.haml +7 -0
  31. data/app/views/ish_manager/email_actions/index.haml +24 -0
  32. data/app/views/ish_manager/email_actions/new.haml +7 -0
  33. data/app/views/ish_manager/email_contexts/_form.haml +32 -30
  34. data/app/views/ish_manager/email_contexts/edit.haml +1 -1
  35. data/app/views/ish_manager/email_contexts/index.haml +27 -22
  36. data/app/views/ish_manager/email_contexts/show.haml +26 -15
  37. data/app/views/ish_manager/email_conversations/index.haml +46 -9
  38. data/app/views/ish_manager/email_conversations/show.haml +56 -21
  39. data/app/views/ish_manager/email_filters/_form.haml +12 -0
  40. data/app/views/ish_manager/email_filters/edit.haml +5 -0
  41. data/app/views/ish_manager/email_filters/index.haml +24 -0
  42. data/app/views/ish_manager/email_filters/new.haml +5 -0
  43. data/app/views/ish_manager/email_templates/_form.haml +30 -14
  44. data/app/views/ish_manager/email_templates/_form_reply_2_mini.haml +15 -0
  45. data/app/views/ish_manager/email_templates/_form_reply_mini.haml +1 -1
  46. data/app/views/ish_manager/email_templates/_index.haml +24 -11
  47. data/app/views/ish_manager/email_templates/_piousbox_roundborders.html.erb +4 -1
  48. data/app/views/ish_manager/email_templates/done/_form.haml +22 -0
  49. data/app/views/ish_manager/email_templates/done/_form2.haml +26 -0
  50. data/app/views/ish_manager/email_templates/edit.haml +2 -1
  51. data/app/views/ish_manager/email_templates/iframe_src.haml +4 -3
  52. data/app/views/ish_manager/email_templates/new.haml +5 -0
  53. data/app/views/ish_manager/email_templates/show.haml +9 -3
  54. data/app/views/ish_manager/leads/_form.haml +11 -6
  55. data/app/views/ish_manager/leads/_form_import.haml +3 -3
  56. data/app/views/ish_manager/leads/edit.haml +19 -16
  57. data/app/views/ish_manager/leads/index.haml +25 -16
  58. data/app/views/ish_manager/leads/new.haml +8 -7
  59. data/app/views/ish_manager/leadsets/index.haml +60 -12
  60. data/app/views/ish_manager/leadsets/index_dataTables.haml +33 -0
  61. data/app/views/ish_manager/scheduled_actions/_form_mini.haml +16 -0
  62. data/app/views/ish_manager/scheduled_email_actions/_form.haml +26 -0
  63. data/app/views/ish_manager/scheduled_email_actions/index.haml +15 -0
  64. data/app/views/ish_manager/scheduled_email_actions/new.haml +4 -0
  65. data/app/views/ish_manager/scheduled_email_actions/show.haml +0 -0
  66. data/app/views/layouts/ish_manager/application.haml +2 -2
  67. data/app/views/layouts/ish_manager/application_fullwidth.haml +2 -2
  68. data/config/routes.rb +10 -2
  69. metadata +30 -6
  70. data/app/controllers/ish_manager/office_actions_controller.rb +0 -59
  71. data/app/views/ish_manager/office_actions/_form.haml +0 -83
  72. data/app/views/ish_manager/office_actions/index.haml +0 -9
@@ -12,10 +12,103 @@
12
12
  .manager-leadsets-index {
13
13
  padding: 1em;
14
14
 
15
- .actions label {
16
- border: 1px solid gold;
15
+ > .actions label {
16
+ border: 1px solid #fff;
17
17
  padding: 0.5em;
18
18
  border-radius: 0.5em;
19
- background: #999900;
19
+ background: #eee;
20
+
21
+ > * {
22
+ display: inline;
23
+ }
24
+ }
25
+
26
+ tr {
27
+ border-bottom: 1px solid yellow;
28
+
29
+ // :hover {
30
+ // background: #eee;
31
+ // }
32
+ }
33
+
34
+ th.leads {
35
+ margin-left: 1em;
36
+ }
37
+ td.leads {
38
+ margin-left: 1em;
39
+ vertical-align: top;
40
+
41
+ .item {
42
+ display: flex;
43
+ align-items: flex-start;
44
+
45
+ .actions {
46
+ display: flex;
47
+ }
48
+ }
49
+ }
50
+
51
+ form.form-mini {
52
+ border: 1px solid red;
53
+ border-radius: .5em;
54
+ padding: 1em;
55
+ background: white;
56
+
57
+ display: flex;
58
+ flex-direction: column;
59
+ align-items: center;
60
+
61
+ position: absolute;
62
+ top: 0;
63
+ width: 300px;
64
+ right: -300px;
65
+
66
+ z-index: 2;
67
+
68
+ .field {
69
+ display: flex;
70
+ }
71
+
72
+ .actions {
73
+ margin-top: .5em;
74
+ width: 100%;
75
+ text-align: right;
76
+ }
20
77
  }
78
+
79
+ .scheduled {
80
+ position: relative;
81
+ display: flex;
82
+
83
+ .chip {
84
+ border: 2px solid cyan;
85
+ display: flex;
86
+ flex-direction: column;
87
+ }
88
+ }
89
+
90
+ .tags {
91
+ // background: #eee;
92
+
93
+ display: flex;
94
+ flex-wrap: wrap;
95
+
96
+ max-width: 400px;
97
+ }
98
+
99
+ .tags-add {
100
+ position: relative;
101
+ vertical-align: top;
102
+ }
103
+
104
+ .chip {
105
+ display: inline;
106
+
107
+ border: 1px solid #eee;
108
+ border-radius: 0.5em;
109
+ padding: 0.1em .3em;
110
+ background: #fff;
111
+ }
112
+
21
113
  }
114
+
@@ -0,0 +1,25 @@
1
+
2
+ .scheduled-emails-new {
3
+
4
+
5
+ border: 1px solid red;
6
+ border-radius: .5em;
7
+ padding: .5em;
8
+ background: white;
9
+
10
+ form {
11
+ display: flex;
12
+ align-items: flex-end;
13
+ }
14
+
15
+ }
16
+
17
+ .scheduled-actions--form-mini {
18
+ display: inline-block;
19
+
20
+ form {
21
+ border: 1px solid blue;
22
+
23
+ display: flex;
24
+ }
25
+ }
@@ -0,0 +1,5 @@
1
+
2
+ form.tags--form-mini {
3
+ display: flex;
4
+ }
5
+
@@ -5,6 +5,7 @@ module IshManager
5
5
  before_action :set_current_ability
6
6
  before_action :set_changelog
7
7
  before_action :set_title
8
+ before_action :set_jwt
8
9
  check_authorization
9
10
  rescue_from ::CanCan::AccessDenied, :with => :access_denied
10
11
 
@@ -44,6 +45,15 @@ module IshManager
44
45
  @current_ability ||= ::IshManager::Ability.new( @current_profile )
45
46
  end
46
47
 
48
+ def set_jwt
49
+ @jwt_token = encode(user_profile_id: @current_user.profile.id.to_s)
50
+ end
51
+
52
+ def encode(payload, exp = 48.hours.from_now) # @TODO: definitely change, right now I expire once in 2 days.
53
+ payload[:exp] = exp.to_i
54
+ JWT.encode(payload, Rails.application.secrets.secret_key_base.to_s)
55
+ end
56
+
47
57
  def set_lists
48
58
  @galleries_list = Gallery.all.list
49
59
  @locations_list = ::Gameui::Map.list
@@ -51,6 +61,11 @@ module IshManager
51
61
  @reports_list = Report.all.list
52
62
  @user_profiles_list = Ish::UserProfile.list
53
63
  @videos_list = Video.all.list
64
+
65
+ @leads_list = Lead.list
66
+ @leadsets_list = Leadset.list
67
+ @email_actions_list = ::Office::EmailAction.all.map { |a| [ a.slug, a.id ] }
68
+ @email_templates_list = Ish::EmailTemplate.all.map { |t| [ t.slug, t.id ] }
54
69
  end
55
70
 
56
71
  def set_title
@@ -0,0 +1,80 @@
1
+
2
+ class ::IshManager::EmailActionsController < IshManager::ApplicationController
3
+
4
+ before_action :set_lists
5
+
6
+ ## Alphabetized : )
7
+
8
+ def create
9
+ @act = @email_action = Office::EmailAction.new
10
+ authorize! :create, @act
11
+
12
+ next_ids = params[:email_action].delete(:next_email_actions)
13
+ next_ids.delete("")
14
+ Office::EmailAction.where(prev_email_action_id: params[:id] ).update_all(prev_email_action_id: nil)
15
+ next_ids.each do |next_id|
16
+ next_action = ::Office::EmailAction.find next_id
17
+ next_action.update_attribute( :prev_email_action_id, params[:id] )
18
+ end
19
+
20
+ flag = @act.update_attributes( params[:email_action].permit! )
21
+ if flag
22
+ flash[:notice] = 'Success'
23
+ else
24
+ flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}"
25
+ end
26
+
27
+ redirect_to action: 'index'
28
+ end
29
+
30
+ def edit
31
+ @act = @email_action = Office::EmailAction.find( params[:id] )
32
+ authorize! :edit, @act
33
+ end
34
+
35
+ def index
36
+ @email_actions = Office::EmailAction.all
37
+
38
+ authorize! :index, @new_email_action
39
+ end
40
+
41
+ def new
42
+ authorize! :new, @new_email_action
43
+ end
44
+
45
+ def show
46
+ end
47
+
48
+ def update
49
+ @act = @email_action = Office::EmailAction.find( params[:id] )
50
+ authorize! :update, @act
51
+
52
+ next_ids = params[:email_action].delete(:next_email_actions)
53
+ next_ids.delete("")
54
+ Office::EmailAction.where(prev_email_action_id: params[:id] ).update_all(prev_email_action_id: nil)
55
+ next_ids.each do |next_id|
56
+ next_action = ::Office::EmailAction.find next_id
57
+ next_action.update_attribute( :prev_email_action_id, params[:id] )
58
+ end
59
+
60
+ flag = @act.update_attributes( params[:email_action].permit! )
61
+ if flag
62
+ flash[:notice] = 'Success'
63
+ else
64
+ flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}"
65
+ end
66
+
67
+ redirect_to action: 'index'
68
+ end
69
+
70
+ ##
71
+ ## private
72
+ ##
73
+ private
74
+
75
+ def set_lists
76
+ @new_email_action = Office::EmailAction.new
77
+ super
78
+ end
79
+
80
+ end
@@ -1,6 +1,19 @@
1
1
 
2
2
  class ::IshManager::EmailCampaignsController < IshManager::ApplicationController
3
3
 
4
+ def do_send
5
+
6
+ # case @ctx.type
7
+ # when ::Ish::EmailContext::TYPE_SINGLE
8
+ # flash[:notice] = 'Scheduled a single send - v2'
9
+ # @ctx.send_at = Time.now
10
+ # @ctx.save
11
+ # when ::Ish::EmailContext::TYPE_CAMPAIGN
12
+ # flash[:notice] = 'Scheduled campaign send'
13
+ # IshManager::EmailCampaignJob.new.perform(params[:id])
14
+ # end
15
+ end
16
+
4
17
  def index
5
18
  authorize! :index, Ish::EmailCampaign
6
19
  @campaigns = Ish::EmailCampaign.where( :profile => @current_profile, :is_trash => false )
@@ -9,23 +9,23 @@ class ::IshManager::EmailContextsController < ::IshManager::ApplicationControlle
9
9
  authorize! :create, ::Ish::EmailContext
10
10
  pparams = params[:ish_email_context].permit!
11
11
  pparams[:tmpl] = JSON.parse(pparams[:tmpl])
12
- @email_ctx = ::Ish::EmailContext.new pparams
13
- if @email_ctx.save
12
+ @ctx = ::Ish::EmailContext.new pparams
13
+ if @ctx.save
14
14
  flash[:notice] = 'Saved.'
15
- redirect_to action: 'show', id: @email_ctx.id
15
+ redirect_to action: 'show', id: @ctx.id
16
16
  return
17
17
  else
18
- # flash[:alert] = "Could not save: #{@email_ctx.errors.full_messages.join(', ')}"
19
- flash[:alert] = ['Could not save:'] + @email_ctx.errors.full_messages
18
+ # flash[:alert] = "Could not save: #{@ctx.errors.full_messages.join(', ')}"
19
+ flash[:alert] = ['Could not save:'] + @ctx.errors.full_messages
20
20
  render action: :new
21
21
  return
22
22
  end
23
23
  end
24
24
 
25
25
  def destroy
26
- @email_ctx = Ish::EmailContext.find params[:id]
27
- authorize! :destroy, @email_ctx
28
- flag = @email_ctx.destroy
26
+ @ctx = Ish::EmailContext.find params[:id]
27
+ authorize! :destroy, @ctx
28
+ flag = @ctx.destroy
29
29
  if flag
30
30
  flash[:notice] = 'Destroyed the email context'
31
31
  else
@@ -37,52 +37,44 @@ class ::IshManager::EmailContextsController < ::IshManager::ApplicationControlle
37
37
  def do_send
38
38
  @ctx = ::Ish::EmailContext.find params[:id]
39
39
  authorize! :do_send, @ctx
40
- case @ctx.type
41
- when ::Ish::EmailContext::TYPE_SINGLE
42
- flash[:notice] = 'Scheduled a single send - v2'
43
- @ctx.send_at = Time.now
44
- @ctx.save
45
- when ::Ish::EmailContext::TYPE_CAMPAIGN
46
- flash[:notice] = 'Scheduled campaign send'
47
- IshManager::EmailCampaignJob.new.perform(params[:id])
48
- end
40
+
41
+ flash[:notice] = 'Scheduled a single send - v2'
42
+ @ctx.send_at = Time.now
43
+ @ctx.save
49
44
 
50
45
  redirect_to action: 'index'
51
46
  end
52
47
 
53
48
  def edit
54
- @email_ctx = ::Ish::EmailContext.find params[:id]
55
- authorize! :edit, @email_ctx
49
+ @ctx = ::Ish::EmailContext.find params[:id]
50
+ authorize! :edit, @ctx
56
51
  end
57
52
 
58
53
  def iframe_src
59
- @email_ctx = Ish::EmailContext.find params[:id]
60
- authorize! :iframe_src, @email_ctx
61
- @email_template = @email_ctx.email_template
62
- case @email_template.type
63
- when 'partial'
64
- render 'ish_manager/email_templates/iframe_src', layout: false
65
- return
66
- when 'plain'
67
- @body = @email_ctx.body_templated
68
- render 'ish_manager/email_templates/plain', layout: false
69
- return
70
- end
54
+ @ctx = @email_context = Ish::EmailContext.find params[:id]
55
+ authorize! :iframe_src, @ctx
56
+ @tmpl = @email_template = @ctx.email_template
57
+ @lead = @ctx.lead
58
+ # @body = @ctx.body_templated
59
+ render "ish_manager/email_templates/_#{@tmpl.layout}", layout: false
71
60
  end
72
61
 
73
62
  def index
74
63
  authorize! :index, ::Ish::EmailContext
75
- @email_ctxs = ::Ish::EmailContext.all
64
+ @ctxs = ::Ish::EmailContext.all
76
65
 
77
66
  if params[:notsent]
78
- @email_ctxs = @email_ctxs.where( sent_at: nil )
67
+ @ctxs = @ctxs.where( sent_at: nil )
79
68
  end
80
69
 
81
- if params[:type]
82
- @email_ctxs = @email_ctxs.where( type: params[:type] )
70
+ if params[:lead_id]
71
+ @lead = Lead.find params[:lead_id]
72
+ @ctxs = @ctxs.where( to_email: @lead.email )
83
73
  end
84
74
 
85
- @email_ctxs = @email_ctxs.page( params[Ish::EmailContext::PAGE_PARAM_NAME] )
75
+ @ctxs = @ctxs.page( params[Ish::EmailContext::PAGE_PARAM_NAME] )
76
+
77
+ render layout: 'ish_manager/application_fullwidth'
86
78
  end
87
79
 
88
80
  def new
@@ -93,37 +85,38 @@ class ::IshManager::EmailContextsController < ::IshManager::ApplicationControlle
93
85
  if @template
94
86
  attrs = @template.attributes.slice( :subject, :body, :from_email )
95
87
  end
96
- @email_ctx = ::Ish::EmailContext.new( { email_template: @template }.merge(attrs) )
88
+ @ctx = ::Ish::EmailContext.new( { email_template: @template }.merge(attrs) )
97
89
  end
98
90
 
99
91
  def show
100
- @email_ctx = ::Ish::EmailContext.find( params[:id] )
101
- authorize! :show, @email_ctx
92
+ @ctx = @email_context = ::Ish::EmailContext.find( params[:id] )
93
+ authorize! :show, @ctx
102
94
  end
103
95
 
104
96
  def update
105
- @email_ctx = ::Ish::EmailContext.find params[:id]
106
- authorize! :update, @email_ctx
97
+ @ctx = ::Ish::EmailContext.find params[:id]
98
+ authorize! :update, @ctx
107
99
  pparams = params[:ish_email_context].permit!
108
- pparams[:tmpl] = JSON.parse(pparams[:tmpl])
109
- if @email_ctx.update_attributes pparams
100
+
101
+ if @ctx.update_attributes pparams
110
102
  flash[:notice] = 'Saved.'
111
- redirect_to action: 'show', id: @email_ctx.id
103
+ redirect_to action: 'show', id: @ctx.id
112
104
  return
113
105
  else
114
- flash[:alert] = "Could not save: #{@email_ctx.errors.full_messages.join(', ')}"
106
+ flash[:alert] = "Could not save: #{@ctx.errors.full_messages.join(', ')}"
115
107
  render action: :edit
116
108
  return
117
109
  end
118
110
  end
119
111
 
120
- #
121
- # private
122
- #
112
+ ##
113
+ ## Private
114
+ ##
123
115
  private
124
116
 
125
117
  def set_lists
126
118
  @email_templates_list = [ [nil, nil] ] + ::Ish::EmailTemplate.all.map { |tmpl| [ tmpl.slug, tmpl.id ] }
119
+ @leads_list = Lead.list
127
120
  end
128
121
 
129
122
  end
@@ -1,16 +1,20 @@
1
1
 
2
2
  class ::IshManager::EmailConversationsController < IshManager::ApplicationController
3
3
 
4
+ layout 'ish_manager/application_fullwidth'
5
+
6
+ before_action :set_lists
7
+
4
8
  def index
5
9
  authorize! :email_conversations_index, IshManager::Ability
6
10
  @email_conversations = ::Office::EmailConversation.all.order_by( latest_date: :desc )
7
-
8
11
  end
9
12
 
10
13
  def show
11
14
  authorize! :email_conversations_show, IshManager::Ability
12
15
  @email_conversation = ::Office::EmailConversation.find( params[:id] )
13
- @email_messages = @email_conversation.email_messages.order_by( date: :desc )
16
+ @email_messages = @email_conversation.email_messages.order_by( date: :asc )
17
+ @email_conversation.update_attributes({ state: Conv::STATE_READ })
14
18
  end
15
19
 
16
20
  end
@@ -0,0 +1,47 @@
1
+
2
+ class ::IshManager::EmailFiltersController < ::IshManager::ApplicationController
3
+
4
+ # before_action :set_lists
5
+
6
+ # alphabetized : )
7
+
8
+ def create
9
+ authorize! :create, Office::EmailFilter
10
+ @email_filter = Office::EmailFilter.create params[:email_filter].permit!
11
+ if @email_filter.persisted?
12
+ flash[:notice] = 'Success'
13
+ else
14
+ flash[:alert] = "No luck: #{@email_filter.errors.full_messages.join(', ')}."
15
+ end
16
+ redirect_to action: 'index'
17
+ end
18
+
19
+ def edit
20
+ @email_filter = Office::EmailFilter.find params[:id]
21
+ authorize! :edit, @email_filter
22
+ end
23
+
24
+ def index
25
+ authorize! :index, Office::EmailFilter.new
26
+ @email_filters = Office::EmailFilter.active
27
+ end
28
+
29
+ def new
30
+ @email_filter = Office::EmailFilter.new
31
+ authorize! :new, @email_filter
32
+ end
33
+
34
+ def update
35
+ @email_filter = Office::EmailFilter.find params[:id]
36
+ authorize! :update, @email_filter
37
+ @email_filter.update_attributes( params[:email_filter].permit! )
38
+ if @email_filter.persisted?
39
+ flash[:notice] = 'Success'
40
+ else
41
+ flash[:alert] = "No luck: #{@email_filter.errors.full_messages.join(', ')}."
42
+ end
43
+ redirect_to action: 'index'
44
+ end
45
+
46
+ end
47
+
@@ -3,7 +3,7 @@ class ::IshManager::EmailMessagesController < IshManager::ApplicationController
3
3
 
4
4
  def index
5
5
  authorize! :email_messages_index, IshManager::Ability
6
- @email_messages = Office::EmailMessage.all
6
+ @email_messages = Office::EmailMessage.all.order_by( date: :desc )
7
7
  end
8
8
 
9
9
  def show
@@ -1,6 +1,8 @@
1
1
 
2
2
  class ::IshManager::EmailTemplatesController < ::IshManager::ApplicationController
3
3
 
4
+ # before_action :set_lists, only: %i| new |
5
+
4
6
  def create
5
7
  authorize! :create, ::Ish::EmailTemplate
6
8
  template = ::Ish::EmailTemplate.create params[:ish_email_template].permit!
@@ -24,30 +26,37 @@ class ::IshManager::EmailTemplatesController < ::IshManager::ApplicationControll
24
26
  end
25
27
 
26
28
  def edit
27
- @template = Ish::EmailTemplate.where({ id: params[:id] }).first
28
- authorize! :edit, @template
29
+ @tmpl = @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first
30
+ authorize! :edit, @tmpl
31
+
32
+ # @ctx = @email_context = Ish::EmailContext.new
33
+ render layout: 'ish_manager/application_fullwidth'
29
34
  end
30
35
 
31
36
  def iframe_src
32
- authorize! :iframe_src, Ish::EmailTemplate
33
- @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first ||
37
+ @tmpl = @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first ||
34
38
  Ish::EmailTemplate.find_by({ slug: params[:id] })
35
- @email_ctx = Ish::EmailContext.new({ body: Ish::LoremIpsum.html })
39
+ authorize! :iframe_src, @email_template
36
40
  render layout: false
37
41
  end
38
42
 
39
43
  def index
40
44
  authorize! :index, Ish::EmailTemplate
41
- @templates = Ish::EmailTemplate.all.page( params[:templates_page] )
45
+ @templates = Ish::EmailTemplate.all.order_by( slug: :asc ).page( params[:templates_page] )
46
+ end
47
+
48
+ def new
49
+ @new_email_template = Ish::EmailTemplate.new
50
+ authorize! :new, Ish::EmailTemplate
42
51
  end
43
52
 
44
53
  def show
45
54
  authorize! :show, Ish::EmailTemplate
46
55
  @templates = Ish::EmailTemplate.all.page( params[:templates_page] )
47
56
 
48
- @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first ||
57
+ @tmpl = @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first ||
49
58
  Ish::EmailTemplate.find_by({ slug: params[:id] })
50
- @email_ctx = ::Ish::EmailContext.new({ body: Ish::LoremIpsum.html })
59
+ @ctx = @email_context = ::Ish::EmailContext.new({ body: Ish::LoremIpsum.html })
51
60
  end
52
61
 
53
62
  def update
@@ -56,11 +65,15 @@ class ::IshManager::EmailTemplatesController < ::IshManager::ApplicationControll
56
65
  flag = @template.update_attributes( params[:ish_email_template].permit! )
57
66
  if flag
58
67
  flash[:notice] = 'Success.'
59
- redirect_to action: 'index'
60
68
  else
61
69
  flash[:alert] = "No luck. #{@template.errors.full_messages.join(', ')}"
62
- render :edit
63
70
  end
71
+ redirect_to action: :edit
64
72
  end
65
73
 
74
+ ##
75
+ ## private
76
+ ##
77
+ private
78
+
66
79
  end
@@ -3,6 +3,8 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
3
3
 
4
4
  before_action :set_lists
5
5
 
6
+ layout 'ish_manager/application_fullwidth'
7
+
6
8
  ## alphabetized : )
7
9
 
8
10
  def bulkop
@@ -69,7 +71,7 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
69
71
 
70
72
  def index
71
73
  authorize! :index, ::Lead
72
- @leads = ::Lead.all.includes( :leadset, :email_campaign_leads )
74
+ @leads = ::Lead.all # .includes( :leadset, :email_campaign_leads )
73
75
  lead_emails = @leads.map( &:email ).compact.reject(&:empty?)
74
76
 
75
77
  map = %Q{
@@ -117,12 +119,4 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
117
119
  redirect_to :action => 'index'
118
120
  end
119
121
 
120
- private
121
-
122
- def set_lists
123
- super
124
- @leadsets_list = [ [nil,nil] ] + ::Leadset.all.map { |k| [ k.name, k.id ] }
125
- @email_campaigns_list = [ [nil,nil] ] # + Ish::EmailContext.unsent_campaigns.map { |k| [ k.slug, k.id ] }
126
- end
127
-
128
122
  end
@@ -0,0 +1,18 @@
1
+
2
+ class IshManager::LeadsetTagsController < IshManager::ApplicationController
3
+
4
+ ## params[ :leadset_id, :term_id, ]
5
+ def create
6
+ authorize! :leadset_tags_create, ::IshManager
7
+
8
+ lt = LeadsetTag.new( leadset_id: params[:leadset_id], term_id: params[:term_id] )
9
+ flag = lt.save
10
+ if flag
11
+ flash[:notice] = 'Success'
12
+ else
13
+ flash[:alert] = "No luck: #{lt.errors.full_messages.join(', ')}"
14
+ end
15
+ redirect_to request.referrer ? request.referrer : leadsets_path
16
+ end
17
+
18
+ end
@@ -1,6 +1,8 @@
1
1
 
2
2
  class ::IshManager::LeadsetsController < IshManager::ApplicationController
3
3
 
4
+ before_action :set_lists
5
+
4
6
  ## alphabetized : )
5
7
 
6
8
  def create
@@ -65,4 +67,15 @@ class ::IshManager::LeadsetsController < IshManager::ApplicationController
65
67
  redirect_to :action => 'index'
66
68
  end
67
69
 
70
+ ##
71
+ ## private
72
+ ##
73
+ private
74
+
75
+ def set_lists
76
+ @tags_list = WpTag.all.map { |t| [ t.name, t.id ] }
77
+ @leads_list = Lead.all.map { |lead| [ lead.email, lead.id ] }
78
+ @templates_list = Ish::EmailTemplate.all.map { |t| [ t.slug, t.id ] }
79
+ end
80
+
68
81
  end