wco_email 0.1.1.81 → 0.1.1.83

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb4cda304553c3ccdc232709927e68ce17be6511d0bb26df1fa7880f8a4974b8
4
- data.tar.gz: 9de4dd2f1c693a4cfe1e814d6925cb496c6edc3e253561a61411ba0ed9bf3d69
3
+ metadata.gz: 719582a97ebd0fd983baed326967e48df5c08662ab874f95ec29bb3c54f8e336
4
+ data.tar.gz: 49e79e9b494639ebe800d3fc23913d0d3d8629972b7a5e5bffd1ef18400b1849
5
5
  SHA512:
6
- metadata.gz: 20216f0274fbce9ffb1fcdc554db12b9034e9e3f0c74a83f6da2d1872504e9ab9c2f8de6077cbd997bb9230b94d0dee40f643cb281c1283ee045fb7eaa801279
7
- data.tar.gz: 283b1a319bec4a25a2642c3cbb73a60d0b383287cdfe41cf32974fa41b5d5a6a35cb02b4f4982fee7eeaa9e4e4f793773e9f36bbbfe2adb194d5e76ac8419a78
6
+ metadata.gz: ce5caa2b693a76232ba3da967722e32bbfbc7ec974365dc813d3e0bf3ce200cf4f55788c637fc3c702515f34fe0d72ef76a9528a86acc8d22375525e529f0676
7
+ data.tar.gz: af953710ceb0829f19d0d2200ae33f717405ab997e082bf04b97ec503d026d0ee80a3f79ffe88d8721262e07e77360577c34a869b66ba7e0db96cc84c6a97bee
@@ -0,0 +1,10 @@
1
+
2
+ class WcoEmail::Api::ConversationsController < WcoEmail::ApiController
3
+
4
+ def index
5
+ authorize! :index, WcoEmail::Conversation
6
+ @conversations, @messages, @tag = WcoEmail::Conversation.load_conversations_messages_tag_by_params_and_profile( params, current_profile )
7
+ end
8
+
9
+ end
10
+
@@ -30,6 +30,10 @@ class WcoEmail::ApiController < ActionController::Base
30
30
  end
31
31
  end
32
32
 
33
+ def current_profile
34
+ Wco::Profile.find_by email: current_user.email
35
+ end
36
+
33
37
  def decode_jwt
34
38
  if Rails.env.test?
35
39
  sign_in User.find_by({ email: 'victor@wasya.co' })
@@ -46,23 +46,24 @@ class WcoEmail::ContextsController < WcoEmail::ApplicationController
46
46
 
47
47
  def index
48
48
  authorize! :index, WcoEmail::Context
49
- @ctxs = WcoEmail::Context.where(
50
- :send_at.ne => nil,
51
- sent_at: nil,
52
- ).order_by( sent_at: :desc, send_at: :desc
53
- ).page( params[:ctxs_page]
54
- ).per( current_profile.per_page )
55
-
49
+ @ctxs = WcoEmail::Context.all
56
50
  if params[:lead_id]
57
51
  @lead = Lead.find params[:lead_id]
58
52
  @ctxs = @ctxs.where( lead_id: @lead.id )
53
+ end
54
+
55
+ if 'true' == params[:sent]
56
+ @ctxs = @ctxs.where( :sent_at.ne => nil )
57
+ elsif 'false' == params[:sent]
58
+ @ctxs = @ctxs.where( sent_at: nil )
59
59
  else
60
- if my_truthy? params[:sent]
61
- @ctxs = @ctxs.or({ :sent_at.ne => nil }, { :unsubscribed_at.ne => nil })
62
- else
63
- @ctxs = @ctxs.where( sent_at: nil, unsubscribed_at: nil )
64
- end
60
+ ## default, show notsent.
61
+ @ctxs = @ctxs.where( :sent_at.ne => nil )
65
62
  end
63
+
64
+ @ctxs = @ctxs.order_by( sent_at: :desc, send_at: :desc
65
+ ).page( params[:ctxs_page]
66
+ ).per( current_profile.per_page )
66
67
  end
67
68
 
68
69
  def new
@@ -29,44 +29,7 @@ class WcoEmail::ConversationsController < WcoEmail::ApplicationController
29
29
 
30
30
  def index
31
31
  authorize! :index, WcoEmail::Conversation
32
- @conversations = WcoEmail::Conversation.all
33
-
34
- if params[:tagname]
35
- @tag = Wco::Tag.find_by slug: params[:tagname]
36
- @conversations = @conversations.where( :tag_ids.in => [ @tag.id ] )
37
- end
38
- if params[:tagname_not]
39
- @tag_not = Wco::Tag.find_by slug: params[:tagname_not]
40
- @conversations = @conversations.where( :tag_ids.nin => [ @tag_not.id ] )
41
- end
42
-
43
- if params[:subject].present?
44
- @conversations = @conversations.where({ subject: /.*#{params[:subject]}.*/i })
45
- end
46
-
47
- if params[:from_email].present?
48
- @conversations = @conversations.where({ from_emails: /.*#{params[:from_email]}.*/i })
49
- end
50
-
51
- if params[:lead_id].present?
52
- @conversations = @conversations.where( lead_ids: params[:lead_id] )
53
- end
54
-
55
- @conversations = @conversations.where(
56
- ).includes( :leads, :messages, :tags
57
- ).order_by( latest_at: :desc
58
- ).page( params[:conv_page] ).per( current_profile.per_page )
59
-
60
- conversation_ids = @conversations.map &:id
61
-
62
- @messages_hash = {}
63
- messages = WcoEmail::Message.where(
64
- :conversation_id.in => conversation_ids,
65
- read_at: nil,
66
- )
67
- messages.map do |msg|
68
- @messages_hash[msg.id.to_s] = msg
69
- end
32
+ @conversations, @messages, @tag = WcoEmail::Conversation.load_conversations_messages_tag_by_params_and_profile( params, current_profile )
70
33
  end
71
34
 
72
35
  ## merge conv1 into conv2, and delete conv1
@@ -0,0 +1,4 @@
1
+
2
+ json.conversations @conversations
3
+ json.messages @messages
4
+ json.tag @tag
@@ -2,16 +2,11 @@
2
2
  - ctxs = @ctxs || WcoEmail::Context.all
3
3
 
4
4
  .a
5
- = link_to contexts_path({ sent: false }) do
6
- Email Contexts (#{ctxs.length})
7
- - if @lead
8
- For lead #{@lead.email}
9
- - if my_truthy? params[:sent]
10
- = link_to '[notsent]', contexts_path({ sent: false })
11
- <b>sent</b>
12
- - else
13
- <b>notsent</b>
14
- = link_to '[sent]', contexts_path({ sent: true })
5
+ Email Contexts (#{ctxs.length})
6
+ - if @lead
7
+ For lead #{@lead.email}
8
+ = link_to '[notsent]', contexts_path({ sent: false }), class: "#{'false' == params[:sent] ? 'active' : ''}"
9
+ = link_to '[sent]', contexts_path({ sent: true }), class: "#{'true' == params[:sent] ? 'active' : ''}"
15
10
  = form_tag contexts_path, method: :get do
16
11
  = text_field_tag :q
17
12
  = link_to '[+]', new_context_path
@@ -7,7 +7,7 @@
7
7
  .W0
8
8
  = render 'wco/paginate', resource: @ctxs, param_name: :ctxs_page, views_prefix: :wco
9
9
 
10
- %table.bordered.data-table
10
+ %table.bordered
11
11
  %thead
12
12
  %tr
13
13
  %th.actions
@@ -39,11 +39,13 @@
39
39
  = ctx.subject ? ctx.subject : "t| #{ctx.tmpl.subject}"
40
40
  %td= ctx.email_template.slug
41
41
  %td.send_at.padded
42
- .datetime
42
+ .datetime.p-1
43
43
  .date= pp_date ctx.send_at
44
44
  .time= pp_time ctx.send_at
45
45
  %td
46
- .datetime.padded= pp_date ctx.sent_at
46
+ .datetime.p-1
47
+ .date= pp_date ctx.sent_at
48
+ .time= pp_time ctx.sent_at
47
49
  %td
48
50
  .datetime.padded= pp_date ctx.unsubscribed_at
49
51
 
data/config/routes.rb CHANGED
@@ -7,6 +7,8 @@ WcoEmail::Engine.routes.draw do
7
7
  get 'tinymce', to: 'application#tinymce', as: :application_tinymce
8
8
 
9
9
  get 'api/contexts/summary', to: '/wco_email/api/contexts#summary'
10
+ get 'api/conversations', to: '/wco_email/api/conversations#index'
11
+ get 'api/tags/:tagname/conversations', to: '/wco_email/api/conversations#index'
10
12
 
11
13
  get 'conversations/in/:tagname', to: '/wco_email/conversations#index', as: :conversations_in
12
14
  get 'conversations/not-in/:tagname_not', to: '/wco_email/conversations#index', as: :conversations_not_in
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.81
4
+ version: 0.1.1.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-29 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -310,6 +310,7 @@ files:
310
310
  - app/assets/stylesheets/wco_email/messages.scss
311
311
  - app/assets/stylesheets/wco_email/tags.scss
312
312
  - app/controllers/wco_email/api/contexts_controller.rb
313
+ - app/controllers/wco_email/api/conversations_controller.rb
313
314
  - app/controllers/wco_email/api_controller.rb
314
315
  - app/controllers/wco_email/application_controller.rb
315
316
  - app/controllers/wco_email/contexts_controller.rb
@@ -368,6 +369,7 @@ files:
368
369
  - app/views/wco_email/_main_header.haml
369
370
  - app/views/wco_email/_sidebar.haml
370
371
  - app/views/wco_email/api/contexts/summary.json.jbuilder
372
+ - app/views/wco_email/api/conversations/index.json.jbuilder
371
373
  - app/views/wco_email/contexts/_form.haml
372
374
  - app/views/wco_email/contexts/_form_reply.haml
373
375
  - app/views/wco_email/contexts/_header.haml