wco_email 0.1.1.80 → 0.1.1.82

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: 4c75364c487acb06734974d75ed8b1ec8e3c2f170e770b0c03f6c9589cf6ee4a
4
- data.tar.gz: 9358b7cabd07fc5d0ccf675216fce4f1a1acf329d81eca41cd6845380a8d5445
3
+ metadata.gz: 25aa0ee19f524e32baf66b2d9c6a3d0d8309d4d3d152a2ce0b18ff312fc71507
4
+ data.tar.gz: 7cd5659cdf4fab3c45bf4afd6ebfa62b099874fe3edaefdf66baf8227e5aac05
5
5
  SHA512:
6
- metadata.gz: e88f5abb24e1d5eb216db6596235cb230e179c2c3a6894f195c4fcf6924d11c69b657e5312f577c8f328bea99a1b1c1766fdfac2d8f68719b00738f31a782893
7
- data.tar.gz: 9c8de2194ce44663dcc887b5cfa0ce3d943adb29146adbd6d43619a3ce76ebcf10cbc71d17cd3de913087f65577f189cf016bf234eba86520d77c01c126c6605
6
+ metadata.gz: 8e78e8dda9333d121c654eac15815c4da7d5187300a36a8753391bc2fad347fb067daa7bfa8e02d2d5adf6461e17e732f15fadb0085163143692794c8e2521c0
7
+ data.tar.gz: b9891c94d3cc5ec4fae1527d9dab6191301c7b203009ac25195ec429059a876b0ac6518caec9fdbc8937badcddd1ff6688047ca8cf652f9c9ff08f876ff3f57e
@@ -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' })
@@ -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
@@ -34,7 +34,14 @@ class WcoEmail::EmailFiltersController < WcoEmail::ApplicationController
34
34
  def index
35
35
  authorize! :index, WcoEmail::EmailFilter.new
36
36
  @email_filter = WcoEmail::EmailFilter.new
37
- @email_filters = WcoEmail::EmailFilter.all.includes( :email_template, :conversations )
37
+ @email_filters = WcoEmail::EmailFilter.all().includes( :email_template, :conversations )
38
+
39
+ if params[:q]
40
+ @email_filters = @email_filters.where( from_exact: /#{params[:q]}/i )
41
+ end
42
+
43
+ @email_filters = @email_filters.page( params[WcoEmail::EmailFilter::PAGE_PARAM_NAME]
44
+ ).per( current_profile.per_page )
38
45
  end
39
46
 
40
47
  def new
@@ -0,0 +1,4 @@
1
+
2
+ json.conversations @conversations
3
+ json.messages @messages
4
+ json.tag @tag
@@ -12,8 +12,8 @@
12
12
  = render 'form', email_filter: @email_filter
13
13
  %hr
14
14
 
15
- -# = paginate @email_filters, param_name: WcoEmail::EmailFilter::PAGE_PARAM_NAME, views_prefix: 'wco'
16
- %table.bordered.data-table
15
+ = paginate @email_filters, param_name: WcoEmail::EmailFilter::PAGE_PARAM_NAME, views_prefix: 'wco'
16
+ %table.bordered
17
17
  %thead
18
18
  %tr
19
19
  %th &nbsp;
@@ -64,6 +64,6 @@
64
64
  - if ef.kind == EF::KIND_REMOVE_TAG
65
65
  .a <b>#{EF::KIND_REMOVE_TAG}:</b> #{ef.tag&.slug}
66
66
 
67
- -# = paginate @email_filters, param_name: WcoEmail::EmailFilter::PAGE_PARAM_NAME, views_prefix: 'wco'
67
+ = paginate @email_filters, param_name: WcoEmail::EmailFilter::PAGE_PARAM_NAME, views_prefix: 'wco'
68
68
 
69
69
 
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.80
4
+ version: 0.1.1.82
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-24 00:00:00.000000000 Z
11
+ date: 2024-09-05 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