scrivito_resourcebrowser 0.0.2 → 0.0.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: 22954b1594aa0ff0220c82cc5c861ec92545d907
4
- data.tar.gz: bbd59e66cb869d48c8e064b4ba9928582542a0a8
3
+ metadata.gz: 61d54d510c1edf96bced6adb3617648a7135e295
4
+ data.tar.gz: 6e9088de1291df9865a3b0c914aa21d5ca73cf30
5
5
  SHA512:
6
- metadata.gz: c417363f8bd0ef31bb6ad9e4618f6e677556f2234db308d18285db41c064c87e7e6f816cfcc503ffe1339510275e09f8cc3ad4549b5df92632ddb9b2cef1be71
7
- data.tar.gz: e30796d4321b04a0d39e0a8eb62bf3662f616e9bb7a17c2697c0bdad3bdf9a8d74eeae64ce69c26cba89f7352307d1378698530aff85915bc21c336e4f1f6aec
6
+ metadata.gz: f476f5289b1fe86f5069b3d2083675070beea31e3697919b7dc647830135480edbb2eb60a8ddd382e073b33e15af24a9868c66cc3c3043cd12ccbc5355bb9d4e
7
+ data.tar.gz: 28541dfb09b77499ccf095b7c8d5e4a6549a3eaf179d2ff983a3341911c715441019e6beed452e145266772b917191c1665356eb9d697556cd6a866142e299a3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.0.3
2
+ * Change the icon to open the details view from a magnifying glass to a pen.
3
+ * Added option "selectionMode", which can be set to `single` in order to allow only one selected
4
+ item at a time. Any other value will allow to select an arbitrary number of items.
5
+ * Added "selected" filter that displays all currently selected items.
6
+ * Display "missing title" when a custom filter has no title configured.
7
+ * Added installation and usage section in the README.
8
+
1
9
  # v0.0.2
2
10
  * Bugfix: An error on assets:precompile was caused by a typo. (Thanks @dcsaszar)
3
11
 
data/README.md CHANGED
@@ -11,7 +11,20 @@ application.
11
11
 
12
12
  ## Installation and Usage
13
13
 
14
- TODO
14
+ If you already use the gem [scrivito_editors](https://github.com/infopark/scrivito_editors) then you
15
+ don't have to change anything, because it is a dependency that will be installed automatically.
16
+
17
+ If you want to use this gem separately, please add it to your `Gemfile`.
18
+
19
+ gem 'scrivito_resourcebrowser'
20
+
21
+ Then require it in your stylesheet manifest.
22
+
23
+ *= require scrivito_resourcebrowser
24
+
25
+ And require it in your JavaScript manifest.
26
+
27
+ //= require scrivito_resourcebrowser
15
28
 
16
29
 
17
30
  ## Changelog
@@ -20,13 +20,24 @@
20
20
  .addClass('editing-resourcebrowser-filter-items')
21
21
 
22
22
  for name, options of filters
23
- title = options.title
23
+ title = options.title || 'missing title'
24
24
  icon = options.icon || 'editing-icon-generic'
25
- query = @_prepareQuery(options.query)
25
+ query = options.query
26
26
 
27
27
  @_filterTemplate(title, icon, query)
28
+ .addClass('filter')
28
29
  .appendTo(list)
29
30
 
31
+ separator = $('<li></li>')
32
+ .addClass('separator')
33
+ .appendTo(list)
34
+
35
+ title = 'Selected <span class="editing-resourcebrowser-counter selected-total"></span>'
36
+ icon = 'editing-icon-ok'
37
+ @_filterTemplate(title, icon)
38
+ .addClass('selected-filter')
39
+ .appendTo(list)
40
+
30
41
  list
31
42
 
32
43
  _loadFilter: () ->
@@ -69,7 +80,7 @@
69
80
  @_getFilterQuery(filter)
70
81
 
71
82
  _filterItems: ->
72
- @modal.find('li.filter')
83
+ @modal.find('ul.editing-resourcebrowser-filter-items li')
73
84
 
74
85
  _deactivateAllFilter: ->
75
86
  @_getSearch().val('')
@@ -83,10 +94,21 @@
83
94
  query = @_getFilterQuery(filter)
84
95
  @_renderPlaceholder(query)
85
96
 
97
+ _triggerSelectedFilter: (filter) ->
98
+ if @selected.length > 0
99
+ query = @_prepareQuery(scrivito.obj_where('id', 'equals', @selected))
100
+ filter.data('query', query)
101
+ else
102
+ filter.removeData('query')
103
+
104
+ @_triggerFilter(filter)
105
+
86
106
  _filterTemplate: (title, icon, query) ->
87
107
  filter = $('<li></li>')
88
- .addClass('filter')
89
- .data('query', query)
108
+
109
+ if query?
110
+ query = @_prepareQuery(query)
111
+ filter.data('query', query)
90
112
 
91
113
  icon = $('<span></span>')
92
114
  .addClass('editing-icon')
@@ -101,8 +123,7 @@
101
123
  filter
102
124
 
103
125
  _prepareQuery: (query) ->
104
- params = $.extend(true, {}, query.query())
105
- scrivito.chainable_search.create_instance(params)
126
+ query.clone()
106
127
  .order('_last_changed')
107
128
  .reverse_order()
108
129
  .format('resourcebrowser')
@@ -136,6 +157,9 @@
136
157
  if (item.hasClass('active'))
137
158
  @_removeItem(item)
138
159
  else
160
+ if @options.selectionMode == 'single'
161
+ @_deselectAllItems()
162
+
139
163
  @_addItem(item)
140
164
 
141
165
  _addItem: (item) ->
@@ -202,21 +226,19 @@
202
226
  $(item).html(loading)
203
227
 
204
228
  _renderPlaceholder: (query) ->
205
- query ||= @_defaultQuery()
206
-
207
- return unless query?
208
-
209
229
  @_getItems()
210
230
  .empty()
211
- .html(@_loadingTemplate())
212
231
 
213
- query.size()
214
- .then (total) =>
215
- if total > 0
216
- @_itemsPlaceholder(total)
217
- @_renderItems(query)
218
- else
219
- @_getItems().empty()
232
+ if query?
233
+ @_getItems().html(@_loadingTemplate())
234
+
235
+ query.size()
236
+ .then (total) =>
237
+ if total > 0
238
+ @_itemsPlaceholder(total)
239
+ @_renderItems(query)
240
+ else
241
+ @_getItems().empty()
220
242
 
221
243
  _renderItems: (query, index = 0) ->
222
244
  query
@@ -328,6 +350,10 @@
328
350
  event.preventDefault()
329
351
  @_triggerFilter($(event.currentTarget))
330
352
 
353
+ @modal.on 'click', 'li.selected-filter', (event) =>
354
+ event.preventDefault()
355
+ @_triggerSelectedFilter($(event.currentTarget))
356
+
331
357
  @modal.on 'click', @thumbnailViewButtonSelector, (event) =>
332
358
  size = $(event.currentTarget).data('size')
333
359
  @_changeThumbnailSize(size)
@@ -405,9 +431,9 @@
405
431
  @options = options
406
432
 
407
433
  @_loadModal(json.content)
408
- @_setSelected()
409
434
  @_loadFilter()
410
- @_renderPlaceholder()
435
+ @_setSelected()
436
+ @_renderPlaceholder(@_defaultQuery())
411
437
  @_changeThumbnailSize()
412
438
 
413
439
  ResourcebrowserInspector.init(@modal)
@@ -417,4 +443,4 @@
417
443
  console.error('Resourcebrowser Uploader Error:', error)
418
444
 
419
445
  ResourcebrowserUploader.onUploadSuccess = (objs) =>
420
- @_renderPlaceholder()
446
+ @_renderPlaceholder(@_defaultQuery())
@@ -558,7 +558,7 @@
558
558
  background: #7EA46A;
559
559
  top: 0;
560
560
  color: #fff;
561
- content: '\F043';
561
+ content: '\F026';
562
562
  display: block;
563
563
  font-family: 'editing_iconsregular';
564
564
  font-style: normal;
@@ -1,3 +1,3 @@
1
1
  module ScrivitoResourcebrowser
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_resourcebrowser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties