abstracted 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: 6858c1c6cc52f262eb7ff058188474ec419890bd
4
- data.tar.gz: 8bb94db2212e137053e04396e0f13913f83abfd7
3
+ metadata.gz: aff5b25e98fbac0db0277def4b26dac60ade157e
4
+ data.tar.gz: 900baf74932298877889d24f5398b07cc60f217f
5
5
  SHA512:
6
- metadata.gz: 71edad58522f01e10586aa5a096ffad64ca6e6c42ae3193939e3c09d7ee573df751aef81ec7ebf8d78d71301f64c44892cbc09d520867c15c90d4943b0d250c2
7
- data.tar.gz: faea0155df6b1e166fe0995bdd9ed947b813a1ba3d71ab772ed3a7c7e741bb29ea8df62c223fe42029a91c0b85e90ef2964901755b93108c9d9db42ee1981e7a
6
+ metadata.gz: f6b21d0f05200e511c0545614298932effbdac83fd6a8c18199d92be0957c8c50acd1156a7f3411648f80def83139c0d3466a9c22e3d988e72fb46e08cf0be1f
7
+ data.tar.gz: b04bfc2af2be21c664f698dacf1a894711cc42934e03d2850c2f056998649d5352c4a109e92bd9c55edd3a279b452fb8c59293e0d6bae62daa05d8028c2ac560
@@ -156,24 +156,55 @@ class App.ResourcesList
156
156
 
157
157
  #
158
158
  # handlePreferredLinks
159
- # allows for activating/deactivating resources - like: /admin/users/2/activate
159
+ # allows for preferring/deferring resources - like: /admin/printers/2/prefer & /admin/printers/2/defer
160
160
  #
161
161
  handlePreferredLinks: (e) =>
162
162
  e.preventDefault()
163
163
  e.stopPropagation()
164
164
 
165
165
  $elem = $(e.currentTarget)
166
+ # are we preferring?
167
+ prefer = $elem.attr('href').match /prefer/
166
168
  request = $.ajax
167
169
  url: $elem.attr('href'),
168
170
  type: "get",
169
171
  dataType: 'html'
170
172
  .done (data) =>
171
- # here we have to write all the existing preferred ones
172
- $.when $('i.preferred').each (k,e) =>
173
- $e = $(e)
174
- $( $e[0].parentElement).html( data.replace /{{id}}/, $e.data('id'))
175
- # $( $elem[0].parentElement).html(data)
176
- .then $( $elem[0].parentElement).html('<i class="preferred material-icons green-text" data-id="' + $elem.data('id') + '">bookmark</i>')
173
+ if prefer
174
+ sel='a.preferred'
175
+ if $elem.attr('ref')!=undefined
176
+ sel='a.preferred[ref="x"]'.replace /x/, $elem.attr('ref')
177
+ $(sel).each (k,e) =>
178
+ $e=$(e)
179
+ if $e!=$elem
180
+ url=$e.attr('href').replace 'defer', 'prefer'
181
+ $e.attr 'href', url
182
+ $e.html '<i class="deferred material-icons grey-text">bookmark_border</i>'
183
+
184
+ $elem.html(data)
185
+ # if prefer
186
+ # sel='a.preferred'
187
+ # if $elem.attr('ref')!=undefined
188
+ # sel='a.preferred[ref="x"]'.replace /x/, $elem.attr('ref')
189
+ #
190
+ # $(sel).each (k,e) =>
191
+ # $e = $(e)
192
+ # if $e != $elem
193
+ # console.log $e
194
+ # $e.attr('href').replace 'defer', 'prefer'
195
+ # $e.html '<i class="deferred material-icons grey-text">bookmark_border</i>'
196
+ #
197
+ # $elem.html '<i class="preferred material-icons green-text">bookmark</i>'
198
+
199
+
200
+ # # here we have to write all the existing preferred ones
201
+ # $.when $(sel).each (k,e) =>
202
+ # $e = $(e)
203
+ # $e.attr('href').replace 'defer', 'prefer'
204
+ # $e.html '<i class="deferred material-icons grey-text">bookmark_border</i>'
205
+ # # $( $elem[0].parentElement).html(data)
206
+ # .then $elem.html '<i class="preferred material-icons green-text">bookmark</i>'
207
+
177
208
 
178
209
  .error (data) =>
179
210
  swal("Oops", "We couldn't connect to the server!", "error")
@@ -161,7 +161,7 @@ module AbstractResourcesHelper
161
161
  end
162
162
 
163
163
  def defer_url parent, resource
164
- '%s/%s/%s/defer' % [url_for( parent), resource.class.to_s.downcase.pluralize, "{{id}}"]
164
+ '%s/%s/%s/defer' % [url_for( parent), resource.class.to_s.downcase.pluralize, resource.id]
165
165
  end
166
166
 
167
167
 
@@ -1,5 +1,5 @@
1
- = link_to prefer_url( parent,resource), class: 'deferred green-text', title: t('prefer_%s' % resource_name) do
2
- %i.material-icons bookmark_border
1
+ = link_to prefer_url( parent,resource), class: 'deferred grey-text', ref: resource._ref, data: { id: resource.id }, title: t('prefer_%s' % resource_name) do
2
+ %i.material-icons.deferred.grey-text bookmark_border
3
3
 
4
4
  :javascript
5
5
  eval("#{set_toasts}");
@@ -1,5 +1,5 @@
1
- = link_to prefer_url( parent,resource), class: 'deferred grey-text', title: t('prefer_%s' % resource_name) do
2
- %i.material-icons bookmark_border
1
+ = link_to defer_url( parent,resource), class: 'preferred green-text', ref: resource._ref, data: { id: resource.id }, title: t('prefer_%s' % resource_name) do
2
+ %i.material-icons.preferred.green-text bookmark
3
3
 
4
4
  :javascript
5
5
  eval("#{set_toasts}");
@@ -1,3 +1,3 @@
1
1
  module Abstracted
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstracted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walther H Diechmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails