rails-contact 0.1.8 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +16 -0
- data/app/controllers/rails/contact/contacts_controller.rb +11 -0
- data/app/views/rails/contact/_google_sync_panel.html.erb +27 -0
- data/app/views/rails/contact/index.html.erb +1 -15
- data/config/routes.rb +1 -0
- data/lib/generators/rails/contact/install/templates/rails_contact.rb.tt +2 -0
- data/lib/rails/contact/configuration.rb +3 -1
- data/lib/rails/contact/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50cd2c0740daf7405d8085d2956f810cf0bf8883388ff12afb72ee07a6497b6c
|
|
4
|
+
data.tar.gz: 64db2836ff0701a348e215ea294dae2cef1326ef3fb633a4a69676c4b5e477ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b8653a3e39f49d9d6aa1bb04463df1f4b5b10ac31d759af6b5bb465b8b2b4ecfbf9a83ee8cbf60a70296d805b5df91e942031ea85f0d530075d00e18bb5a4bc
|
|
7
|
+
data.tar.gz: e42099d4322b591d5ae7646560afda7178e5ce1674512efab58ef172d34fe74b99b46583553e6cad43ff2a47c96cf95efe34bdd9d2e68958fc77a3a164585812
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.11
|
|
4
|
+
|
|
5
|
+
- Default **Google sync panel** back on the engine index via `_google_sync_panel` when `google_sync_enabled` and `google_sync_ui_on_index` (default true). Host apps can override the partial or disable with `google_sync_ui_on_index = false`.
|
|
6
|
+
|
|
7
|
+
## 0.1.10
|
|
8
|
+
|
|
9
|
+
- Short-lived: engine index omitted the Google panel (use **0.1.11** instead).
|
|
10
|
+
|
|
11
|
+
## 0.1.9
|
|
12
|
+
|
|
13
|
+
- `POST /google_sync_rolling_window` → `ContactsController#google_sync_rolling_window` → `GoogleSyncJob` (re-sync rolling window: creates + updates).
|
|
14
|
+
|
|
3
15
|
## 0.1.8
|
|
4
16
|
|
|
5
17
|
- Contacts index: paginated search (total count, previous/next, page indicator) with Elasticsearch and database backends.
|
data/README.md
CHANGED
|
@@ -134,6 +134,22 @@ Rails::Contact.configure do |config|
|
|
|
134
134
|
end
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
### Google sync UI: gem default vs host override
|
|
138
|
+
|
|
139
|
+
**Recommendation:** keep the **default panel in the gem** so every app gets working buttons when `google_sync_enabled` is true. You avoid copy-paste and stay aligned with new endpoints.
|
|
140
|
+
|
|
141
|
+
- The index template renders `rails/contact/_google_sync_panel` when `google_sync_ui_on_index` is **true** (default).
|
|
142
|
+
- **Customize without forking the engine:** add `app/views/rails/contact/_google_sync_panel.html.erb` in the host app; Rails resolves that file instead of the gem’s partial.
|
|
143
|
+
- **Hide the default panel:** set `config.google_sync_ui_on_index = false` and render your own UI anywhere (same `POST` targets below).
|
|
144
|
+
- **Custom index only:** override `rails/contact/index` and `<%= render "rails/contact/google_sync_panel" %>` wherever it fits (e.g. after a CSV upload section).
|
|
145
|
+
|
|
146
|
+
Endpoints (used by the default partial):
|
|
147
|
+
|
|
148
|
+
- `google_sync_rolling_window_contacts_path` — `GoogleSyncJob` (rolling window re-sync).
|
|
149
|
+
- `google_sync_unsynced_contacts_path` — `GoogleSyncUnsyncedJob` (contacts with no `google_resource_name`).
|
|
150
|
+
|
|
151
|
+
`ContactsController#index` sets `@google_contacts_pending_sync` when sync is enabled.
|
|
152
|
+
|
|
137
153
|
---
|
|
138
154
|
|
|
139
155
|
## Rake tasks
|
|
@@ -34,6 +34,17 @@ module Rails
|
|
|
34
34
|
redirect_to contacts_path, notice: "Google sync has been queued for contacts not yet linked."
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def google_sync_rolling_window
|
|
38
|
+
unless Rails::Contact.configuration.google_sync_enabled
|
|
39
|
+
redirect_to contacts_path, alert: "Google Contacts sync is disabled."
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
GoogleSyncJob.perform_later
|
|
44
|
+
redirect_to contacts_path,
|
|
45
|
+
notice: "Google re-sync has been queued for contacts in the recent window (creates and updates)."
|
|
46
|
+
end
|
|
47
|
+
|
|
37
48
|
def show
|
|
38
49
|
render "rails/contact/show"
|
|
39
50
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<% if Rails::Contact.configuration.google_sync_enabled && Rails::Contact.configuration.google_sync_ui_on_index %>
|
|
2
|
+
<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm space-y-4">
|
|
3
|
+
<h2 class="text-sm font-semibold text-gray-900">Google Contacts</h2>
|
|
4
|
+
|
|
5
|
+
<div>
|
|
6
|
+
<%= form_with url: google_sync_rolling_window_contacts_path, method: :post, local: true, class: "flex flex-wrap items-center gap-3" do %>
|
|
7
|
+
<%= submit_tag "Re-sync recent contacts with Google",
|
|
8
|
+
class: "inline-flex rounded-md bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-700",
|
|
9
|
+
data: { confirm: "Queue Google sync for the recent contact window? This updates contacts already in Google and creates any that are missing. Runs in the background." } %>
|
|
10
|
+
<% end %>
|
|
11
|
+
<p class="mt-2 text-xs text-gray-500">
|
|
12
|
+
Pushes the most recently updated contacts (up to your configured limit) to Google—new rows and changes to names, emails, phones, etc.
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<% if @google_contacts_pending_sync.to_i.positive? %>
|
|
17
|
+
<div class="border-t border-gray-100 pt-4">
|
|
18
|
+
<%= form_with url: google_sync_unsynced_contacts_path, method: :post, local: true, class: "flex flex-wrap items-center gap-3" do %>
|
|
19
|
+
<%= submit_tag "Sync #{@google_contacts_pending_sync} contact#{'s' if @google_contacts_pending_sync != 1} with no Google link yet (any age)",
|
|
20
|
+
class: "inline-flex rounded-md border border-emerald-700 bg-white px-4 py-2 text-sm font-semibold text-emerald-800 hover:bg-emerald-50",
|
|
21
|
+
data: { confirm: "Queue Google sync for #{@google_contacts_pending_sync} contact(s) that are not linked yet? This runs in the background." } %>
|
|
22
|
+
<% end %>
|
|
23
|
+
<p class="mt-2 text-xs text-gray-500">For contacts outside the recent window or older imports that never received a Google <code class="rounded bg-gray-100 px-1">resourceName</code>.</p>
|
|
24
|
+
</div>
|
|
25
|
+
<% end %>
|
|
26
|
+
</div>
|
|
27
|
+
<% end %>
|
|
@@ -26,21 +26,7 @@
|
|
|
26
26
|
<% end %>
|
|
27
27
|
</div>
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm">
|
|
31
|
-
<h2 class="mb-2 text-sm font-semibold text-gray-900">Google Contacts</h2>
|
|
32
|
-
<% if @google_contacts_pending_sync.to_i.positive? %>
|
|
33
|
-
<%= form_with url: google_sync_unsynced_contacts_path, method: :post, local: true, class: "flex flex-wrap items-center gap-3" do %>
|
|
34
|
-
<%= submit_tag "Sync #{@google_contacts_pending_sync} contact#{'s' if @google_contacts_pending_sync != 1} not yet in Google",
|
|
35
|
-
class: "inline-flex rounded-md bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-700",
|
|
36
|
-
data: { confirm: "Queue Google sync for #{@google_contacts_pending_sync} contact(s)? This runs in the background." } %>
|
|
37
|
-
<% end %>
|
|
38
|
-
<p class="mt-2 text-xs text-gray-500">Creates or updates People entries for contacts with no Google link yet. Already-linked contacts are unchanged.</p>
|
|
39
|
-
<% else %>
|
|
40
|
-
<p class="text-sm text-gray-600">Every contact in the database is already linked to Google (or there are no contacts).</p>
|
|
41
|
-
<% end %>
|
|
42
|
-
</div>
|
|
43
|
-
<% end %>
|
|
29
|
+
<%= render "rails/contact/google_sync_panel" %>
|
|
44
30
|
|
|
45
31
|
<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm">
|
|
46
32
|
<%= form_with url: bulk_destroy_contacts_path, method: :post, local: true, class: "inline-flex items-center gap-2" do |f| %>
|
data/config/routes.rb
CHANGED
|
@@ -2,6 +2,7 @@ Rails::Contact::Engine.routes.draw do
|
|
|
2
2
|
post "/bulk_destroy", to: "contacts#bulk_destroy", as: :bulk_destroy_contacts
|
|
3
3
|
post "/merge", to: "contacts#merge", as: :merge_contacts
|
|
4
4
|
post "/google_sync_unsynced", to: "contacts#google_sync_unsynced", as: :google_sync_unsynced_contacts
|
|
5
|
+
post "/google_sync_rolling_window", to: "contacts#google_sync_rolling_window", as: :google_sync_rolling_window_contacts
|
|
5
6
|
get "/", to: "contacts#index", as: :contacts
|
|
6
7
|
get "/new", to: "contacts#new", as: :new_contact
|
|
7
8
|
post "/", to: "contacts#create"
|
|
@@ -4,6 +4,8 @@ Rails::Contact.configure do |config|
|
|
|
4
4
|
config.elasticsearch_url = ENV.fetch("ELASTICSEARCH_URL", "http://127.0.0.1:9200")
|
|
5
5
|
|
|
6
6
|
config.google_sync_enabled = ENV.fetch("RAILS_CONTACT_GOOGLE_SYNC_ENABLED", "false") == "true"
|
|
7
|
+
# When true (default), contacts index renders the gem’s Google sync panel; set false to supply your own UI.
|
|
8
|
+
# config.google_sync_ui_on_index = false
|
|
7
9
|
config.google_max_contacts = 25_000
|
|
8
10
|
config.rolling_window_sort = :updated_at
|
|
9
11
|
|
|
@@ -2,7 +2,7 @@ module Rails
|
|
|
2
2
|
module Contact
|
|
3
3
|
class Configuration
|
|
4
4
|
attr_accessor :contact_class_name, :elasticsearch_url, :search_backend,
|
|
5
|
-
:google_sync_enabled, :google_max_contacts, :rolling_window_sort,
|
|
5
|
+
:google_sync_enabled, :google_sync_ui_on_index, :google_max_contacts, :rolling_window_sort,
|
|
6
6
|
:google_client_id, :google_client_secret, :google_redirect_uri,
|
|
7
7
|
:google_token_path, :reset_index_on_boot, :default_per_page,
|
|
8
8
|
:inherit_host_layout,
|
|
@@ -13,6 +13,8 @@ module Rails
|
|
|
13
13
|
@elasticsearch_url = ENV.fetch("ELASTICSEARCH_URL", "http://127.0.0.1:9200")
|
|
14
14
|
@search_backend = :elasticsearch
|
|
15
15
|
@google_sync_enabled = false
|
|
16
|
+
# When true with google_sync_enabled, the default index renders _google_sync_panel (host can override that partial).
|
|
17
|
+
@google_sync_ui_on_index = true
|
|
16
18
|
@google_max_contacts = 25_000
|
|
17
19
|
@rolling_window_sort = :updated_at
|
|
18
20
|
@google_client_id = ENV["GOOGLE_CLIENT_ID"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-contact
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kshitiz Sinha
|
|
@@ -138,6 +138,7 @@ files:
|
|
|
138
138
|
- app/views/rails/contact/_email_fields.html.erb
|
|
139
139
|
- app/views/rails/contact/_event_fields.html.erb
|
|
140
140
|
- app/views/rails/contact/_form.html.erb
|
|
141
|
+
- app/views/rails/contact/_google_sync_panel.html.erb
|
|
141
142
|
- app/views/rails/contact/_index_pagination.html.erb
|
|
142
143
|
- app/views/rails/contact/_nested_fields_script.html.erb
|
|
143
144
|
- app/views/rails/contact/_phone_fields.html.erb
|