lanes 0.6.0 → 0.6.1

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: 3733c06e6d643586d352406448ab55ed6812e860
4
- data.tar.gz: 79c1d5bdebb6522539c01b5844e67cb25a404431
3
+ metadata.gz: 61899d6310319e01eeb5f8d3143de6381d59ef22
4
+ data.tar.gz: 7684de7e8724e81d9bb3a294dc995d3f74a7a8e5
5
5
  SHA512:
6
- metadata.gz: 3ee768c759d3cefbc9a8f855b88842efbba485873d9f3f11121710826b93e13469cf46ee635338802ecb8d06c0aa064b78233947215db3751a98d58fdbab4746
7
- data.tar.gz: 2ce0dcc798cce89666e00a7c4da30a90c9821f5a366460b5f9ccb8e4161ed15d8a90af3984cf94d073e2e004abd30c320d6280ef96ce3ea031046cf1396048fb
6
+ metadata.gz: 6037b22dcff009ca206df7145b6058bd8b0e4403e0459f1ce0367afc63a94db7cdd700d225d9cd1c29d86e065392bb087927e71b0f9d039a5c023a14d52b031e
7
+ data.tar.gz: b227ee2a57df19679fff4767d23734ff4fff44cb92d98494ec1f75c97669793356a6b4610470de0885dba064d91a455ec93e8b0eeac092493ebe50331f67779c
@@ -0,0 +1,17 @@
1
+ class Lanes.Components.AssetsListing extends Lanes.React.Component
2
+
3
+ propTypes:
4
+ assets: Lanes.PropTypes.Collection.isRequired
5
+ size: React.PropTypes.oneOf([
6
+ 'thumb', 'medium', 'original'
7
+ ]).isRequired
8
+
9
+ modelBindings:
10
+ assets: 'props'
11
+
12
+ render: ->
13
+ <div className="assets-listing">
14
+ {@assets.map (asset) ->
15
+ <LC.ImageAsset key={asset.cid}
16
+ asset={asset} size="thumb" />}
17
+ </div>
@@ -1,11 +1,12 @@
1
1
  class Lanes.Components.FieldSet extends Lanes.React.Component
2
2
 
3
- getDefaultProps: ->
4
- expanded: true
5
-
6
3
  propTypes:
7
4
  title: React.PropTypes.string.isRequired
8
5
  expanded: React.PropTypes.bool
6
+ containerClassName: React.PropTypes.string
7
+
8
+ getDefaultProps: ->
9
+ expanded: true
9
10
 
10
11
  getInitialState: ->
11
12
  expanded: @props.expanded
@@ -17,7 +18,8 @@ class Lanes.Components.FieldSet extends Lanes.React.Component
17
18
  @setState(expanded: not @state.expanded)
18
19
 
19
20
  render: ->
20
- colProps = _.omit(@props, 'name', 'expanded')
21
+ colProps = _.omit(@props, 'name', 'expanded', 'bodyClassName')
22
+ bodyClassName = _.classnames("container", @props.containerClassName)
21
23
  <BS.Col {...colProps}>
22
24
  <fieldset className={
23
25
  _.classnames("collapsible", @props.className, @state.icon
@@ -27,7 +29,7 @@ class Lanes.Components.FieldSet extends Lanes.React.Component
27
29
  {@props.title}
28
30
  </legend>
29
31
  <BS.Collapse in={@state.expanded}>
30
- <div ref="body" className="fieldset-fields">
32
+ <div ref="body" className={bodyClassName} >
31
33
  {@props.children}
32
34
  </div>
33
35
  </BS.Collapse>
@@ -1,14 +1,13 @@
1
1
  class Lanes.Components.ImageAsset extends Lanes.React.Component
2
2
 
3
3
  propTypes:
4
- model: Lanes.PropTypes.Model.isRequired
5
- name: React.PropTypes.string.isRequired
4
+ asset: Lanes.PropTypes.Model.isRequired
6
5
  size: React.PropTypes.oneOf([
7
6
  'thumb', 'medium', 'original'
8
7
  ]).isRequired
9
8
 
10
9
  modelBindings:
11
- asset: -> @props.model[@props.name]
10
+ asset: 'props'
12
11
 
13
12
  listenNetworkEvents: true
14
13
 
@@ -30,20 +29,18 @@ class Lanes.Components.ImageAsset extends Lanes.React.Component
30
29
  className = _.classnames('image-asset', @props.className, {
31
30
  'with-image': @asset.hasImage
32
31
  })
33
- console.log @asset.file_data
34
- <LC.FieldWrapper
35
- {...@props}
32
+ <BS.Col
33
+ {...Lanes.u.bsSizes(@props)}
36
34
  className={className}
37
- displayComponent={Component}
38
35
  >
39
36
  <Component />
40
37
  <form>
41
38
  <label className="selector">
42
39
  <span>
43
- {if @asset.hasImage then 'Update' else 'Choose'}
40
+ {if @asset.isPresent then 'Change' else 'Add'}
44
41
  </span>
45
42
  <input id='file' className="file" type="file"
46
43
  onChange={@handleImageChange} />
47
44
  </label>
48
45
  </form>
49
- </LC.FieldWrapper>
46
+ </BS.Col>
@@ -1,6 +1,7 @@
1
1
  @import "../../styles/bootstrap/buttons";
2
2
 
3
3
  .image-asset {
4
+ position: relative;
4
5
  &.field {
5
6
  .value {
6
7
  border-bottom: 0;
@@ -36,3 +37,17 @@
36
37
  width: 100%;
37
38
  }
38
39
  }
40
+
41
+ .assets-listing {
42
+
43
+ display: flex;
44
+
45
+ .image-asset {
46
+ max-width: 200px;
47
+ & + .image-asset {
48
+ border-left: 1px dotted lightgrey;
49
+ padding-left: 10px;
50
+ margin-left: 10px;
51
+ }
52
+ }
53
+ }
@@ -16,10 +16,14 @@ distillTypes = (type, ns) ->
16
16
 
17
17
  Lanes.u = {
18
18
  cleanBsSizes: (props) ->
19
- _.omit(props,
20
- 'xs', 'sm', 'md', 'lg',
21
- 'xsOffset', 'smOffset', 'mdOffset', 'lgOffset'
22
- )
19
+ _.omit(props, @getBsSizeProps() )
20
+
21
+ bsSizes: (props) ->
22
+ _.pick(props, @getBsSizeProps())
23
+
24
+ getBsSizeProps: ->
25
+ [ 'xs', 'sm', 'md', 'lg',
26
+ 'xsOffset', 'smOffset', 'mdOffset', 'lgOffset' ]
23
27
 
24
28
  makeComparatorUsing: (method) ->
25
29
  (a, b) -> Lanes.u.comparator(a[method], b[method])
@@ -31,6 +31,10 @@ class Lanes.Models.Asset extends Lanes.Models.Base
31
31
  deps: ['data', 'file_data'], fn: ->
32
32
  if @data then @data else @urlFor('thumbnail')
33
33
 
34
+ isPresent:
35
+ deps: ['data', 'file_data'], fn: ->
36
+ @data || !_.isEmpty(@file_data)
37
+
34
38
  hasImage:
35
39
  deps: ['data', 'file_data'], fn: ->
36
40
  (@data && IS_IMAGE(@metadata.content_type)) ||
@@ -55,14 +59,11 @@ class Lanes.Models.Asset extends Lanes.Models.Base
55
59
 
56
60
  onBlobChange: ->
57
61
  if @blob
58
- @metadata = {
59
- content_type: @blob.type
60
- }
62
+ @metadata = { content_type: @blob.type }
61
63
  reader = new FileReader()
62
64
  reader.onloadend = (ev) =>
63
65
  @data = reader.result if ev.type is 'loadend'
64
66
  reader.readAsDataURL(@blob)
65
-
66
67
  else
67
68
  @data = null
68
69
  @mdatadata?.content_type = undefined
@@ -80,8 +80,9 @@ class Lanes.Models.AssociationMap
80
80
  new target_class(options.models || [], options)
81
81
  else
82
82
  options.model = target_class
83
- options.association_name=name
84
- new Lanes.Models.AssociationCollection(options.models || [], options)
83
+ options.association_name = name
84
+ klass = options.collectionClass or Lanes.Models.AssociationCollection
85
+ new klass(options.models || [], options)
85
86
 
86
87
  # returns a collection for the given association.
87
88
  collectionFor: (name, model, options = {}) ->
@@ -62,12 +62,15 @@ ProxyMethods = {
62
62
 
63
63
  on: (ev, rest...) ->
64
64
  rememberEvents( @_proxied_events ||= {}, ev, rest )
65
+ @
65
66
 
66
67
  once: (ev, rest...) ->
67
68
  rememberEvents( @_proxied_once_events ||= {}, ev, rest )
69
+ @
68
70
 
69
71
  off: (ev, rest...) ->
70
72
  delete @_proxied_events[ev]
73
+ @
71
74
 
72
75
  }
73
76
 
@@ -81,9 +81,8 @@ CableChannel = {
81
81
  @perform("off", {channel})
82
82
 
83
83
  received: (data) ->
84
- [channel, model, id] = data.channel.match(/(.*)\/(\d+)/)
84
+ [channel, model, id] = data.channel.match(/(.*)\/([^\/]+)/)
85
85
  Lanes.log.info "[pubsub] change recvd for: #{channel}"
86
-
87
86
  Lanes.Models.PubSub.onChange(
88
87
  model, id, _.omit(data, 'channel')
89
88
  )
@@ -55,7 +55,8 @@ class Lanes.Screens.SystemSettings extends Lanes.React.Screen
55
55
  </BS.NavItem>
56
56
  </BS.Nav>
57
57
  <BS.Row>
58
- <LC.ImageAsset sm=4 model={@config} name='logo'
58
+
59
+ <LC.ImageAsset sm=4 asset={@config.logo}
59
60
  label='Logo' size='thumb' />
60
61
  </BS.Row>
61
62
  {for id, Ext of Lanes.Extensions.instances when Ext.getSettingsElement
@@ -1,5 +1,15 @@
1
+ require_relative "handlers/asset.rb"
2
+
1
3
  module Lanes
2
4
  API.routes.draw do
5
+ # WS endpoint must come first
6
+ get Lanes.config.api_path + '/ws' do
7
+ API::Cable.server.call(env)
8
+ end
9
+
10
+ Extensions.each(reversed: true) do | ext |
11
+ ext.route(self)
12
+ end
3
13
 
4
14
  put Lanes.config.api_path + '/system-settings.json',
5
15
  &SystemSettings.update_handler
@@ -10,18 +20,9 @@ module Lanes
10
20
  get Lanes.config.api_path + '/asset/*',
11
21
  &API::Handlers::Asset.getter
12
22
 
13
- get Lanes.config.api_path + '/ws' do
14
- API::Cable.server.call(env)
15
- end
16
-
17
23
  post Lanes.config.api_path + '/dev-file-change.json' do
18
24
  API::PubSub.publish("file-change", data)
19
25
  "OK"
20
26
  end
21
-
22
- Extensions.each(reversed: true) do | ext |
23
- ext.route(self)
24
- end
25
-
26
27
  end
27
28
  end
@@ -4,6 +4,7 @@ module Lanes::API::Handlers
4
4
 
5
5
  def self.saver
6
6
  lambda do
7
+
7
8
  path = "#{params['extension_id']}/#{params['owner_type']}"
8
9
  model = path.underscore.camelize.constantize
9
10
 
@@ -13,7 +14,14 @@ module Lanes::API::Handlers
13
14
  asset = if params['id']
14
15
  ::Lanes::Asset.find(params['id'])
15
16
  else
16
- owner.send("build_#{params['owner_association']}")
17
+ assoc = owner.class.reflections[
18
+ params['owner_association']
19
+ ]
20
+ if assoc.collection?
21
+ owner.send(params['owner_association']).build
22
+ else
23
+ owner.send("build_#{params['owner_association']}")
24
+ end
17
25
  end
18
26
 
19
27
  asset.update(file: params['file'])
@@ -1,3 +1,5 @@
1
+ require_relative 'cable'
2
+
1
3
  module Lanes
2
4
  module API
3
5
 
@@ -16,8 +18,10 @@ module Lanes
16
18
  end
17
19
 
18
20
  def self.publish(channel, data)
19
- ActionCable.server.broadcast PREFIX + channel,
20
- data.merge(channel: channel)
21
+ ActionCable.server.broadcast(
22
+ PREFIX + channel,
23
+ data.merge(channel: channel)
24
+ )
21
25
  end
22
26
 
23
27
  end
@@ -33,11 +33,11 @@ module Lanes
33
33
  set :show_exceptions, false
34
34
  require_relative 'routing'
35
35
  Extensions.load_controlling_config
36
- Cable.configure
37
36
  # late load in case an extension has provided an alternative implementation
38
37
  unless API.const_defined?(:AuthenticationProvider)
39
38
  require "lanes/api/null_authentication_provider"
40
39
  end
40
+ require_relative './default_routes'
41
41
  Lanes::Configuration.apply
42
42
  end
43
43
 
data/lib/lanes/api.rb CHANGED
@@ -13,6 +13,3 @@ require_relative 'api/root'
13
13
  Lanes.config.get(:environment) do
14
14
  require_relative("api/test_specs") unless Lanes.env.production?
15
15
  end
16
-
17
- require_relative "api/handlers/asset.rb"
18
- require_relative 'api/default_routes'
data/lib/lanes/asset.rb CHANGED
@@ -8,31 +8,6 @@ module Lanes
8
8
 
9
9
  validates :owner, set: true
10
10
 
11
- # after_update :remove_changed_file, if: lambda{ file_changed? }
12
-
13
- # def serializable_hash(options = nil)
14
- # values = super
15
- # values.delete('file')
16
- # values.merge!(file.as_json[:file].stringify_keys)
17
- # values['original'] = { 'url' => values.delete('url') }
18
- # values
19
- # end
20
-
21
- # def store_uploaded_file(f)
22
- # ext = File.extname(f[:filename])
23
- # if ext.blank?
24
- # ext = '.' + FastImage.type(f[:tempfile]).to_s
25
- # end
26
- # self[:file] = ::Lanes::Strings.random + ext
27
- # file.store!(f)
28
- # end
29
-
30
- # protected
31
-
32
- # def remove_changed_file
33
- # self.file_was.remove!
34
- # end
35
-
36
11
  end
37
12
 
38
13
  end
@@ -55,7 +55,7 @@ module Lanes
55
55
  config.redis_options = Lanes.config.redis
56
56
  config.namespace = "#{identifier}::jobba"
57
57
  end
58
-
58
+ API::Cable.configure
59
59
  Resque.redis.namespace = "#{identifier}::resque"
60
60
  Resque.redis = Lanes.config.redis
61
61
 
data/lib/lanes/job.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'jobba'
2
+ require_relative 'api/pub_sub'
3
+
2
4
 
3
5
  module Jobba
4
6
  module RecordStatus
@@ -36,7 +38,10 @@ module Lanes
36
38
  }
37
39
 
38
40
  def deliver_progress_to_clients
39
- API::PubSub.publish("/lanes/job-statuses/#{job_id}", update: Job.status_for_id(job_id))
41
+ ::Lanes::API::PubSub.publish(
42
+ "/lanes/job-statuses/#{job_id}",
43
+ update: Job.status_for_id(job_id)
44
+ )
40
45
  end
41
46
 
42
47
  def save_progress(output, progress=1.0)
data/lib/lanes/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Lanes
2
2
 
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lanes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Stitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-30 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -640,6 +640,7 @@ files:
640
640
  - client/lanes/components/select-field/SelectField.cjsx
641
641
  - client/lanes/components/select-field/index.js
642
642
  - client/lanes/components/select-field/styles.scss
643
+ - client/lanes/components/shared/AssetsListing.cjsx
643
644
  - client/lanes/components/shared/Checkbox.cjsx
644
645
  - client/lanes/components/shared/CountBadge.cjsx
645
646
  - client/lanes/components/shared/DateTime.cjsx