scrivito_resourcebrowser 0.0.4 → 0.0.5

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: e9b8db9c0c1ec3589c28f0cfb57912fa653c7290
4
- data.tar.gz: b8090d83c3a11d3017a165a34b91f58c7c199a42
3
+ metadata.gz: 3a776d207d54700e9fb70dba52e61df3d4ab345f
4
+ data.tar.gz: e97becbc05eaf0d1904f18d47cecdd595063f3ac
5
5
  SHA512:
6
- metadata.gz: 4d61ea74dbde427eb752e6cf15b08d97ffb1b7af685f48546237cca277a0c0f03edc8bd7ff74c6e5013800ab662f4a40085e1e3f8bc28bd60bba119b30c48751
7
- data.tar.gz: 6a04de77ef1d62f0af2f1d2e40bb2c7aaaae3ee7ecbc3f75855f89be2980344f9506fe8ba921bc7a5389537eea218f5ed8cedf9ed34cd32b1a952d537063b06d
6
+ metadata.gz: 60fc3266ebb1b3466261eb0d9f16d8fbbdc80a0ceba888519fbb6d7808ed2301431403abba41b755657c2e0c520f9a9997388b36c086b73ecc5f278677843d4b
7
+ data.tar.gz: d2589336876293d65a7114a2af538929fe57a4bee72f2e51804e3461bf9dac4c9e7c812e6e4fa74882d195583acb2d6e370cc79108b5ec978b55fc1c02eeef20
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.0.5
2
+ * Uploading a MIME type with no configured `obj_class` shows sensible error message.
3
+ * Show the app configurable `description_for_editor` as subtitle.
4
+ * Some visual improvements.
5
+
1
6
  # v0.0.4
2
7
  * The filters are now a simple hash instead of a function that returns a hash. This allows to
3
8
  extend the filters multiple times. This is useful, when a gem wants to add filters to the ones
data/README.md CHANGED
@@ -3,7 +3,6 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/scrivito_resourcebrowser.png)](http://badge.fury.io/rb/scrivito_resourcebrowser)
4
4
  [![Code Climate](https://codeclimate.com/github/infopark/scrivito_resourcebrowser.png)](https://codeclimate.com/github/infopark/scrivito_resourcebrowser)
5
5
  [![Dependency Status](https://gemnasium.com/infopark/scrivito_resourcebrowser.png)](https://gemnasium.com/infopark/scrivito_resourcebrowser)
6
- [![Build Status](https://travis-ci.org/infopark/scrivito_resourcebrowser.png)](https://travis-ci.org/infopark/scrivito_resourcebrowser)
7
6
 
8
7
  The [Scrivito](http://scrivito.com) Resource Browser is a JavaScript based tool to add, update and
9
8
  delete resources. It provides flexible configuration options and can easily be integrated into your
@@ -265,7 +265,7 @@
265
265
 
266
266
  _itemTemplate: (object) ->
267
267
  url = object.preview
268
- title = object.title || object.name
268
+ title = object.title || object.id
269
269
  id = object.id
270
270
 
271
271
  wrapper = $('<div></div>')
@@ -447,8 +447,12 @@
447
447
  ResourcebrowserInspector.init(@modal)
448
448
  ResourcebrowserUploader.init(@modal)
449
449
 
450
- ResourcebrowserUploader.onUploadFailure = (error) =>
451
- console.error('Resourcebrowser Uploader Error:', error)
450
+ ResourcebrowserUploader.onUploadStart = (files) =>
451
+ @upload_errors = false
452
+
453
+ ResourcebrowserUploader.onUploadFailure = (errors) =>
454
+ @upload_errors = errors
455
+ # console.error('Resourcebrowser uploader errors: ', JSON.stringify(upload_errors))
452
456
 
453
457
  ResourcebrowserUploader.onUploadSuccess = (objs) =>
454
- @_renderPlaceholder(@_activeQuery())
458
+ @_renderPlaceholder(@_activeQuery()) unless @upload_errors
@@ -27,7 +27,7 @@
27
27
 
28
28
  undefined
29
29
 
30
- _processQueue: (queue, createdObjs, promise) ->
30
+ _processQueue: (queue, createdObjs, failedUploads, promise) ->
31
31
  file = queue.pop()
32
32
 
33
33
  if file?
@@ -35,9 +35,14 @@
35
35
  .done (obj) =>
36
36
  @_updateProgress(file, '100%')
37
37
  createdObjs.push(obj)
38
- @_processQueue(queue, createdObjs, promise)
38
+ @_processQueue(queue, createdObjs, failedUploads, promise)
39
+ .fail (args) =>
40
+ @_updateError(file, args.message || "Upload failed. Please check your network connection.")
41
+ @_updateProgress(file, '0%')
42
+ failedUploads.push(args)
43
+ @_processQueue(queue, createdObjs, failedUploads, promise)
39
44
  else
40
- return promise.resolve(createdObjs)
45
+ return promise.resolve(createdObjs, failedUploads)
41
46
 
42
47
  _addProgressWrapper: () ->
43
48
  itemsElement = $('.editing-resourcebrowser-items').empty()
@@ -62,17 +67,25 @@
62
67
  fileName = $('<p></p>')
63
68
  .html(file.name)
64
69
 
70
+ error = $('<p></p>')
71
+ .addClass('editing-resourcebrowser-error')
72
+
65
73
  $('<div></div>')
66
74
  .addClass('editing-resourcebrowser-progress-file')
67
75
  .append(fileName)
76
+ .append(error)
68
77
  .append(progress)
69
78
  .prependTo $('.editing-resourcebrowser-progress-wrapper')
70
79
 
71
- file['progressBar'] = progressBar
80
+ file.progressBar = progressBar
81
+ file.error = error
72
82
 
73
83
  _updateProgress: (file, percent) ->
74
84
  file.progressBar.css('width', percent)
75
85
 
86
+ _updateError: (file, message) ->
87
+ file.error.text(message)
88
+
76
89
  _onDrop: (event) ->
77
90
  dataTransfer = event.originalEvent.dataTransfer
78
91
 
@@ -84,19 +97,19 @@
84
97
  if files.length == 0
85
98
  return
86
99
 
87
- @onUploadStart(queue)
88
100
  @_addProgressWrapper()
89
101
 
90
- promise = $.Deferred()
91
- .done (data) =>
92
- @onUploadSuccess(data)
93
-
94
102
  queue = for file in files
95
103
  @_addProgress(file)
96
104
  file
97
105
 
98
- @_processQueue(queue, [], promise)
106
+ @onUploadStart(queue)
107
+ promise = $.Deferred()
108
+ .done (createdObjs, failedUploads) =>
109
+ @onUploadFailure(failedUploads) if failedUploads.length > 0
110
+ @onUploadSuccess(createdObjs) if createdObjs.length > 0
99
111
 
112
+ @_processQueue(queue, [], [], promise)
100
113
  promise
101
114
 
102
115
  _randomResourceId: ->
@@ -110,11 +123,18 @@
110
123
  _createResource: (file) ->
111
124
  objName = file.name.replace(/[^a-z0-9_.$\-]/ig, '-')
112
125
  path = "_resources/#{@_randomResourceId()}/#{objName}"
126
+ objClass = @_objClassForMimeType(file.type)
113
127
 
114
- scrivito.create_obj
115
- blob: file
116
- _path: path
117
- _obj_class: @_objClassForMimeType(file.type)
128
+ if objClass
129
+ scrivito.create_obj
130
+ blob: file
131
+ _path: path
132
+ _obj_class: objClass
133
+ else
134
+ $.Deferred().reject
135
+ id: "no_obj_class_for_mime_type"
136
+ file_name: file.name
137
+ message: "File type #{file.type} rejected by resource configuration."
118
138
 
119
139
  init: (@modal) ->
120
140
  @_initializeBindings()
@@ -123,7 +143,7 @@
123
143
  onUploadStart: (files) ->
124
144
 
125
145
  # Hook for 3rd parties when the upload fails.
126
- onUploadFailure: (error) ->
146
+ onUploadFailure: (errors) ->
127
147
 
128
148
  # Hook for 3rd parties when the upload was successful.
129
149
  onUploadSuccess: (objs) ->
@@ -115,8 +115,10 @@
115
115
 
116
116
  .editing-resourcebrowser .editing-resourcebrowser-search {
117
117
  float: left;
118
+ overflow: hidden;
118
119
  position: relative;
119
120
  width: 65%;
121
+ white-space: nowrap;
120
122
  }
121
123
 
122
124
  .editing-resourcebrowser .editing-resourcebrowser-search .search-field {
@@ -173,8 +175,7 @@
173
175
  border-left: none;
174
176
  color: #fff;
175
177
  cursor: pointer;
176
- display: block;
177
- float: left;
178
+ display: inline;
178
179
  font-size: 14px;
179
180
  font-weight: normal;
180
181
  height: 30px;
@@ -394,7 +395,7 @@
394
395
 
395
396
  .editing-resourcebrowser ul.editing-resourcebrowser-filter-items .editing-icon {
396
397
  color: #666;
397
- display: inline-block;
398
+ display: inline;
398
399
  font-size: 12px;
399
400
  line-height: 20px;
400
401
  padding: 0 7px 0 0;
@@ -403,10 +404,11 @@
403
404
 
404
405
  .editing-resourcebrowser ul.editing-resourcebrowser-filter-items .editing-resourcebrowser-filter-name {
405
406
  color: #666;
406
- display: inline-block;
407
+ display: inline;
407
408
  font-size: 11px;
408
409
  font-weight: bold;
409
410
  line-height: 20px;
411
+ word-wrap: break-word;
410
412
  }
411
413
 
412
414
  .editing-resourcebrowser ul.editing-resourcebrowser-filter-items li:hover .editing-resourcebrowser-counter,
@@ -504,8 +506,14 @@
504
506
 
505
507
  .editing-resourcebrowser ul.editing-resourcebrowser-thumbnails li .editing-resourcebrowser-preview img {
506
508
  display: block;
507
- height: 100%;
508
- margin: 0 auto;
509
+ max-height: 100%;
510
+ max-width: 100%;
511
+ margin: auto;
512
+ position: absolute;
513
+ top: 0;
514
+ left: 0;
515
+ right: 0;
516
+ bottom: 0;
509
517
  }
510
518
 
511
519
  .editing-resourcebrowser ul.editing-resourcebrowser-thumbnails li .editing-resourcebrowser-preview .editing-icon {
@@ -574,6 +582,7 @@
574
582
  vertical-align: middle;
575
583
  width: 40px;
576
584
  font-size: 11px;
585
+ z-index: 1;
577
586
  }
578
587
 
579
588
  .editing-resourcebrowser ul.editing-resourcebrowser-thumbnails li .editing-resourcebrowser-thumbnails-select:before {
@@ -852,6 +861,17 @@
852
861
  text-overflow: ellipsis;
853
862
  }
854
863
 
864
+ .editing-resourcebrowser-progress-wrapper .editing-resourcebrowser-progress-file .editing-resourcebrowser-error:empty {
865
+ display: none;
866
+ }
867
+
868
+ .editing-resourcebrowser-progress-wrapper .editing-resourcebrowser-progress-file .editing-resourcebrowser-error {
869
+ color: #aa4040;
870
+ font-size: 13px;
871
+ font-weight: normal;
872
+ margin: 0 3px 6px 3px;
873
+ }
874
+
855
875
  .editing-resourcebrowser-progress-wrapper .editing-resourcebrowser-progress {
856
876
  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
857
877
  -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
@@ -2,7 +2,7 @@
2
2
  Scrivito::Configuration.register_obj_format('resourcebrowser') do |obj|
3
3
  format = {
4
4
  id: obj.id,
5
- title: obj.title || obj.name,
5
+ title: obj.description_for_editor,
6
6
  }
7
7
 
8
8
  if obj.respond_to?(:image?) && obj.image?
@@ -1,3 +1,3 @@
1
1
  module ScrivitoResourcebrowser
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '1.8'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.4.1
131
+ rubygems_version: 2.2.2
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Scrivito Resource Browser