bookingsync_portal 0.7.0 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c409dc3f373173cf63975b3e7deea34767d19a3d
4
- data.tar.gz: bea7083a6fb9bde9eeeb60da4101db6b1d501206
3
+ metadata.gz: 90a5f5b87509d851d09d5adecfe7aefbe2a3d9c0
4
+ data.tar.gz: 6cfa15d7ab2a8bdccafbf4ce77eb667a6fdb1a6f
5
5
  SHA512:
6
- metadata.gz: b86598c7bca993d3105cbb5518f22cbce58c90355dc2f09c16b4ac65168423e389f4b60f07897b7ec6921f48fdc5f315f6f9efc58934c1c0a1af54bbd4195da4
7
- data.tar.gz: 30dbf6577ba6ddfcaf4206c0e96c2f7bddcc264fe2ae4b0a99a96c0e93dd35fa2095b82a6c4af1b1a715de5e8096cb64a46c0fd78774ba5c574799595481113c
6
+ metadata.gz: 0b43d1c7f39fc7b5b8ee0e618dbe6c2be81a9122e24449aa8feed9928fccc6b331b4d55cf3b882153b472e29f37227f2d6e119d879025090da5dc46b6ac7ac78
7
+ data.tar.gz: 61c627baccb81333491250cf8e9129e1fb02e8e30c7807831151f252950972c4162bafb114a6cad6568df483c0eb28a054db5c99e1e71997b59a1cfaf80a44ba
@@ -27,3 +27,58 @@
27
27
  window.extractIdFromDomId = (attribute) ->
28
28
  if attribute
29
29
  attribute.split("_").pop()
30
+ $.fn.extend
31
+ draggableRental: ->
32
+ settings =
33
+ revert: "invalid"
34
+ zIndex: 50
35
+ revertDuration: 100
36
+ cursor: "move"
37
+ containment: '.rentals-container'
38
+ appendTo: '.rentals-container'
39
+ helper: "clone"
40
+ scroll: false
41
+
42
+ start: (e, ui) ->
43
+ $(ui.helper).addClass "ui-draggable-helper"
44
+
45
+ @each () ->
46
+ $(this).draggable(settings)
47
+
48
+ droppableRemoteRental: ->
49
+ settings =
50
+ accept: ".bookingsync-rental"
51
+ activeClass: "dropzone-active"
52
+ hoverClass: "dropzone-hover"
53
+ greedy: true
54
+ tolerance: "pointer"
55
+ drop: (event, ui) ->
56
+ remoteRentalDropZone = $(@)
57
+
58
+ rentalId = extractIdFromDomId($(ui.draggable).attr("id"))
59
+ remoteRentalId = extractIdFromDomId(remoteRentalDropZone.attr("id"))
60
+ remoteAccountId = remoteRentalDropZone.data("remote-account-id")
61
+ remoteRentalUid = remoteRentalDropZone.data("uid")
62
+
63
+ if remoteRentalId
64
+ postData = { "rental_id": rentalId, "remote_rental_id": remoteRentalId }
65
+ else
66
+ postData = { "rental_id": rentalId, "remote_account_id": remoteAccountId }
67
+ # clone new remote rental drop zone and append to the end
68
+ remoteRentalDropZone.clone().insertBefore(remoteRentalDropZone).addClass('new_rental_placeholder');
69
+
70
+ $(ui.draggable).remove()
71
+
72
+ connect_url = $('.remote-rentals-list.rentals-list').data('connect-url')
73
+
74
+ $.ajax
75
+ url: connect_url
76
+ type: "POST"
77
+ data: postData
78
+ dataType: 'script'
79
+ beforeSend: ->
80
+ $(@).addClass('loading')
81
+ success: ->
82
+ $(@).removeClass('loading')
83
+ @each () ->
84
+ $(this).droppable(settings)
@@ -1,48 +1,3 @@
1
1
  $ ->
2
- $(".bookingsync-rental").draggable
3
- revert: "invalid"
4
- zIndex: 50
5
- revertDuration: 100
6
- cursor: "move"
7
- containment: '.rentals-container'
8
- appendTo: '.rentals-container'
9
- helper: "clone"
10
- scroll: false
11
-
12
- start: (e, ui) ->
13
- $(ui.helper).addClass "ui-draggable-helper"
14
-
15
- $(".panel.panel-remote").droppable
16
- accept: ".bookingsync-rental"
17
- activeClass: "dropzone-active"
18
- hoverClass: "dropzone-hover"
19
- greedy: true
20
- tolerance: "pointer"
21
- drop: (event, ui) ->
22
- remoteRentalDropZone = $(@)
23
-
24
- rentalId = extractIdFromDomId($(ui.draggable).attr("id"))
25
- remoteRentalId = extractIdFromDomId(remoteRentalDropZone.attr("id"))
26
- remoteAccountId = remoteRentalDropZone.data("remote-account-id")
27
- remoteRentalUid = remoteRentalDropZone.data("uid")
28
-
29
- if remoteRentalId
30
- postData = { "rental_id": rentalId, "remote_rental_id": remoteRentalId }
31
- else
32
- postData = { "rental_id": rentalId, "remote_account_id": remoteAccountId }
33
- # clone new remote rental drop zone and append to the end
34
- remoteRentalDropZone.clone().insertBefore(remoteRentalDropZone).addClass('new_rental_placeholder');
35
-
36
- $(ui.draggable).remove()
37
-
38
- connect_url = $('.remote-rentals-list.rentals-list').data('connect-url')
39
-
40
- $.ajax
41
- url: connect_url
42
- type: "POST"
43
- data: postData
44
- dataType: 'script'
45
- beforeSend: ->
46
- $(@).addClass('loading')
47
- success: ->
48
- $(@).removeClass('loading')
2
+ $(".bookingsync-rental").draggableRental()
3
+ $(".panel.panel-remote").droppableRemoteRental()
@@ -189,6 +189,11 @@ body > .footer {
189
189
  position: relative;
190
190
  }
191
191
 
192
+ h4 small {
193
+ color: $gray-lighter;
194
+ display: block;
195
+ }
196
+
192
197
  .status {
193
198
  position: absolute;
194
199
  right: 3px;
@@ -16,10 +16,13 @@ module BookingsyncPortal
16
16
  end
17
17
 
18
18
  def destroy
19
- connection = current_account.connections.find(params[:id]).destroy
19
+ @connection = current_account.connections.find(params[:id]).destroy
20
+ @not_connected_rentals = current_account.rentals.visible.ordered.not_connected
21
+ @visible_rentals = current_account.rentals.visible
20
22
 
21
23
  respond_to do |wants|
22
24
  wants.html { redirect_to admin_rentals_path }
25
+ wants.js
23
26
  end
24
27
  end
25
28
 
@@ -6,7 +6,7 @@ module BookingsyncPortal
6
6
 
7
7
  def index
8
8
  @not_connected_rentals = current_account.rentals.visible.ordered.not_connected
9
- @visible_rentals_count = current_account.rentals.visible.count
9
+ @visible_rentals = current_account.rentals.visible
10
10
  @remote_accounts = current_account.remote_accounts
11
11
  @remote_rentals_by_account = current_account.remote_rentals.ordered
12
12
  .includes(:remote_account).group_by(&:remote_account)
@@ -0,0 +1,6 @@
1
+ <%- if @connection.persisted? %>
2
+ $("#<%= dom_id @connection.remote_rental %>, .new_rental_placeholder").first().replaceWith(
3
+ "<%=j render 'bookingsync_portal/admin/rentals/connected_rental', rental: @connection.rental, remote_rental: @connection.remote_rental %>");
4
+ $(".bookingsync-rental").draggableRental()
5
+ $(".panel.panel-remote").droppableRemoteRental()
6
+ <%- end %>
@@ -0,0 +1,7 @@
1
+ $("#<%= dom_id @connection.rental %>").first().replaceWith(
2
+ "<%=j render 'bookingsync_portal/admin/rentals/remote_rental', remote_rental: @connection.remote_rental %>")
3
+ $(".bookingsync-rentals-list .rentals-list-scroll").first().html(
4
+ "<%=j render 'bookingsync_portal/admin/rentals/rentals', visible_rentals: @visible_rentals, not_connected_rentals: @not_connected_rentals %>");
5
+
6
+ $(".bookingsync-rental").draggableRental()
7
+ $(".panel.panel-remote").droppableRemoteRental()
@@ -9,12 +9,13 @@
9
9
  </div>
10
10
  <div class="panel-body-grid-text">
11
11
  <h4 title="<%= RemoteRental.human_attribute_name(:uid) %>: <%= remote_rental.uid %>">
12
- <%= remote_rental.display_name %> / <%= rental.name %>
12
+ <%= rental.name %><br>
13
+ <small><%= remote_rental.display_name %></small>
13
14
  </h4>
14
15
  <div class="status">
15
16
  <%= link_to bookingsync_portal.admin_connection_path(rental.connection),
16
17
  class: ["btn", "btn-xs", "remove-connection", rental.remote_rental.synchronized? ? "btn-success" : "btn-warning"],
17
- data: { disable_with: t('.disconnecting_rental') }, method: :delete do %>
18
+ data: { disable_with: t('.disconnecting_rental') }, method: :delete, remote: true do %>
18
19
  <% unless rental.remote_rental.synchronized? %>
19
20
  <span class="hover_hide"><%= icon('spinner') %></span>
20
21
  <% else %>
@@ -0,0 +1,14 @@
1
+ <%- if visible_rentals.count == 0 -%>
2
+ <div class="lead text-center well">
3
+ <p><%= t('.no_published_rentals_html', id: current_account.synced_id) %></p>
4
+ </div>
5
+ <%- elsif not_connected_rentals.count > 0 -%>
6
+ <% not_connected_rentals.each do |rental| %>
7
+ <%= render rental %>
8
+ <% end %>
9
+ <%- else -%>
10
+ <div class="lead text-center well">
11
+ <p class=""><%= icon 'thumbs-up fa-lg' %></p>
12
+ <p><%=t '.all_synchronized' %></p>
13
+ </div>
14
+ <%- end -%>
@@ -10,20 +10,7 @@
10
10
  <legend class="text-center"><%= image_tag('bookingsync_portal/bookingsync.png', alt: 'BookingSync') %></legend>
11
11
  </div>
12
12
  <div class="rentals-list-scroll">
13
- <%- if @visible_rentals_count == 0 -%>
14
- <div class="lead text-center well">
15
- <p><%= t('.no_published_rentals_html', id: current_account.synced_id) %></p>
16
- </div>
17
- <%- elsif @not_connected_rentals.count > 0 -%>
18
- <% @not_connected_rentals.each do |rental| %>
19
- <%= render rental %>
20
- <% end %>
21
- <%- else -%>
22
- <div class="lead text-center well">
23
- <p class=""><%= icon 'thumbs-up fa-lg' %></p>
24
- <p><%=t '.all_synchronized' %></p>
25
- </div>
26
- <%- end -%>
13
+ <%= render "rentals", visible_rentals: @visible_rentals, not_connected_rentals: @not_connected_rentals %>
27
14
  </div>
28
15
  </div>
29
16
  </div>
@@ -1,3 +1,3 @@
1
1
  module BookingsyncPortal
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookingsync_portal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Marciniak
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-18 00:00:00.000000000 Z
13
+ date: 2016-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -359,7 +359,8 @@ files:
359
359
  - app/models/bookingsync_portal/rental.rb
360
360
  - app/synchronizers/bookingsync_portal/write/ensure_source_exists.rb
361
361
  - app/synchronizers/bookingsync_portal/write/source.rb
362
- - app/views/bookingsync_portal/admin/connections/create.js.erb
362
+ - app/views/bookingsync_portal/admin/connections/create.js.coffee
363
+ - app/views/bookingsync_portal/admin/connections/destroy.js.coffee
363
364
  - app/views/bookingsync_portal/admin/help/_help.html.erb
364
365
  - app/views/bookingsync_portal/admin/help/index.html.erb
365
366
  - app/views/bookingsync_portal/admin/remote_accounts/_form.html.erb
@@ -370,6 +371,7 @@ files:
370
371
  - app/views/bookingsync_portal/admin/rentals/_new_remote_rental.html.erb
371
372
  - app/views/bookingsync_portal/admin/rentals/_remote_rental.html.erb
372
373
  - app/views/bookingsync_portal/admin/rentals/_rental.html.erb
374
+ - app/views/bookingsync_portal/admin/rentals/_rentals.html.erb
373
375
  - app/views/bookingsync_portal/admin/rentals/index.html.erb
374
376
  - app/views/bookingsync_portal/admin/rentals/show.js.erb
375
377
  - app/views/layouts/bookingsync_portal/_flash.html.erb
@@ -1,5 +0,0 @@
1
- <%- if @connection.persisted? %>
2
- $("#<%= dom_id @connection.remote_rental %>, .new_rental_placeholder").replaceWith(
3
- "<%=j render 'bookingsync_portal/admin/rentals/connected_rental', rental: @connection.rental, remote_rental: @connection.remote_rental,
4
- disconnect_url: bookingsync_portal.admin_connection_url(@connection) %>");
5
- <%- end %>