engine2 1.0.0 → 1.0.1

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: bc80e81843c9720bf34223f646d6f2bb747e33d0
4
- data.tar.gz: d4e47ca39797d61936f7322d3e181db9ba27486b
3
+ metadata.gz: ee392cd291e6908be3d724216be1ad7f79ece1e1
4
+ data.tar.gz: 5a198484207426f1596052de6542fe27730fabf1
5
5
  SHA512:
6
- metadata.gz: 6f2c82ff8b62c2a45745afb59e8095ac27b370d64a2f4ada1c294e403fb456573f719a7de636bc281ec8405190c63029e7afcd48df3f86db287ffcc5848852ee
7
- data.tar.gz: f64cf30cacc5c8de8a8f3370b62bc50f9b30b94284da7354bfdf5a29135e188acef864ad71f50782c49723cf5f5b781ebd3cbcb06ab3b32fa4438d9f670c5d97
6
+ metadata.gz: 0273154703273cbdb46f21a26049dad06ad12924e9e1f10c15fc278b1bbb79f7569e821e7fe1c4db9a93a26d519bc7c716115bf76528bee4c2bf5155cfacccbe
7
+ data.tar.gz: e53351d9d0af5d5da010f94f28c2a5f73277cc1c92400c56d473d78d595ec3f272db23ef603724440891a2b39f2a2d1c7f7efce7bd048a4946be2bcb56428fa3
@@ -6,6 +6,7 @@
6
6
  :default_time_format: HH:mm:ss
7
7
  :default_time_model_format: HH:mm:ss
8
8
 
9
+ :error: Error
9
10
  :no_entry: Entry doesnt exist
10
11
  :decode_selected: selected
11
12
 
@@ -38,7 +39,7 @@
38
39
  :confirm_bulk_unlink: Detach selected
39
40
  :confirm_bulk_unlink_title: <span class='glyphicon glyphicon-minus'></span> Confirmation
40
41
  :debug_info: Debug info
41
- :show_meta: Show metainfo
42
+ :show_meta: Metainfo
42
43
  # :meta: Meta
43
44
  :view_title: <span class='glyphicon glyphicon-book'></span> Details
44
45
  :create_title: <span class='glyphicon glyphicon-pencil'></span> Create
@@ -6,6 +6,7 @@
6
6
  :default_time_format: HH:mm:ss
7
7
  :default_time_model_format: HH:mm:ss
8
8
 
9
+ :error: Błąd
9
10
  :no_entry: Wpis nie istnieje
10
11
  :decode_selected: wybranych
11
12
 
@@ -38,7 +39,7 @@
38
39
  :confirm_bulk_unlink: Odłącz zaznacznone
39
40
  :confirm_bulk_unlink_title: <span class='glyphicon glyphicon-minus'></span> Potwierdzenie
40
41
  :debug_info: Debug info
41
- :show_meta: Pokaż metainformacje
42
+ :show_meta: Metainfo
42
43
  # :meta: Meta
43
44
  :view_title: <span class='glyphicon glyphicon-book'></span> Szczegóły
44
45
  :create_title: <span class='glyphicon glyphicon-pencil'></span> Utwórz
@@ -4,7 +4,7 @@ module Engine2
4
4
  class Action < BasicObject
5
5
  ACCESS_FORBIDDEN ||= ->h{false}
6
6
  attr_reader :parent, :name, :number, :actions, :recheck_access
7
- attr_reader :meta_proc
7
+ attr_reader :meta_proc, :meta_proc_chained
8
8
 
9
9
  class << self
10
10
  attr_accessor :count
@@ -21,12 +21,21 @@ module Engine2
21
21
 
22
22
  def * &blk
23
23
  if blk
24
- ::Kernel.raise E2Error.new("Meta #{name} with proc already defined for action #{self.inspect}") if @meta_proc
25
- @meta_proc = blk
24
+ @meta_proc = if meta_proc = @meta_proc
25
+ @meta_proc_chained = true
26
+ ::Kernel::lambda do |obj|
27
+ obj.instance_eval(&meta_proc)
28
+ obj.instance_eval(&blk)
29
+ end
30
+ else
31
+ blk
32
+ end
26
33
  end
27
34
  @meta
28
35
  end
29
36
 
37
+ alias :meta :*
38
+
30
39
  def access! &blk
31
40
  ::Kernel.raise E2Error.new("Access for action #{name} already defined") if @access_block
32
41
  @access_block = blk
@@ -59,6 +68,12 @@ module Engine2
59
68
  action
60
69
  end
61
70
 
71
+ def define_action_meta name, meta_class = DummyMeta, assets = {}, &blk
72
+ define_action name, meta_class, assets do
73
+ self.* &blk
74
+ end
75
+ end
76
+
62
77
  def undefine_action name
63
78
  ::Kernel.raise E2Error.new("No action #{name} defined") unless @actions[name]
64
79
  @actions.delete(name)
@@ -285,6 +285,7 @@ module E2Model
285
285
 
286
286
  def ensure_primary_key
287
287
  pk = @model.primary_keys
288
+ raise Engine2::E2Error.new("No primary key defined for model #{model}") unless pk && pk.all?
288
289
 
289
290
  if opts_select = @opts[:select]
290
291
  sel_pk = []
@@ -456,15 +457,24 @@ module Engine2
456
457
  @boot_blk = blk
457
458
  end
458
459
 
460
+ def self.model_boot &blk
461
+ @model_boot_blk = blk
462
+ end
463
+
459
464
  def self.bootstrap app = APP_LOCATION
460
465
  require 'engine2/pre_bootstrap'
461
466
  t = Time.now
462
467
  Action.count = 0
463
468
  SCHEMES.clear
464
469
 
470
+ Sequel::DATABASES.each do |db|
471
+ db.models.each{|n, m| Object.send(:remove_const, n) if Object.const_defined?(n)} unless db == E2DB || db == DUMMYDB
472
+ end
473
+
465
474
  load "#{app}/boot.rb"
466
475
 
467
476
  Sequel::DATABASES.each &:load_schema_cache_from_file
477
+ @model_boot_blk.() if @model_boot_blk
468
478
  load 'engine2/models/Files.rb'
469
479
  load 'engine2/models/UserInfo.rb'
470
480
  Dir["#{app}/models/*"].each{|m| load m}
@@ -46,6 +46,8 @@ module Engine2
46
46
 
47
47
  type_info do
48
48
  schema = @model.db_schema
49
+ @model.primary_keys.each{|pk| (schema[pk]||={})[:primary_key] = true} if @model.primary_key
50
+
49
51
  schema.each_pair do |name, db_info|
50
52
  @info[name] = {otype: db_info[:type]}
51
53
 
@@ -66,7 +68,7 @@ module Engine2
66
68
  when :datetime
67
69
  datetime_field name, LOCS[:default_date_format], LOCS[:default_time_format], LOCS[:default_date_model_format], LOCS[:default_time_model_format]
68
70
  when :decimal
69
- size, scale = db_info[:column_size], db_info[:scale]
71
+ size, scale = db_info[:column_size], db_info[:scale].to_i
70
72
  unless size && scale
71
73
  db_info[:db_type] =~ /decimal\((\d+),(\d+)\)/i
72
74
  size, scale = $1.to_i, $2.to_i
@@ -75,6 +77,8 @@ module Engine2
75
77
  decimal_field name, size, scale
76
78
  when :blob
77
79
  blob_field name, 100000
80
+ when nil
81
+ # ignore nil type
78
82
  else
79
83
  p db_info
80
84
  raise E2Error.new("Unknown column type: #{db_info[:type].inspect} for #{name}")
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Engine2
4
4
  class UserInfo < Sequel::Model(DUMMYDB)
5
- extend MemoryModel
6
5
  set_natural_key :name
6
+ extend MemoryModel
7
7
 
8
8
  type_info do
9
9
  string_field :name, 10
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Engine2
4
- MAJOR, MINOR, TINY = [1, 0, 0]
4
+ MAJOR, MINOR, TINY = [1, 0, 1]
5
5
  VERSION = [MAJOR, MINOR, TINY].join('.').freeze
6
6
  def self.version
7
7
  VERSION
@@ -554,4 +554,4 @@ angular.module('Engine2', ['ngRoute', 'ngSanitize', 'ngAnimate', 'ngCookies', 'm
554
554
  link: (scope, elem, attr, controller) ->
555
555
  controller.$parsers.unshift (v) ->
556
556
  vs = v.toString()
557
- if vs.match(/^\-?\d+$/) then parseInt(vs) else null
557
+ if vs.match(/^\-?\d+$/) then parseInt(vs) else (if scope.action.query? then null else vs)
@@ -26,7 +26,7 @@ angular.module('Engine2')
26
26
  constructor: (response, scope, parent, element, action_info) ->
27
27
  @find_action_info = (name, raise = true) ->
28
28
  act = response.actions[name]
29
- throw "Undefined action '#{name}' for action #{@action_info().name} (under #{@parent().action_info().action_resource})" if raise && !act
29
+ throw "Undefined action '#{name}' for action #{@action_info().name} (under #{@parent()?.action_info().action_resource})" if raise && !act
30
30
  act
31
31
 
32
32
  _.each response.actions, (act, nm) -> act.name = nm
@@ -307,7 +307,7 @@ angular.module('Engine2')
307
307
  @ui_state = {}
308
308
  @load_state()
309
309
 
310
- delete @query.order unless _.includes(@meta.fields, @query.order)
310
+ delete @query.order unless @meta.info[@query.order]?.sort # _.includes(@meta.fields, @query.order)
311
311
  _.each @query.search, ((sv, sn) => delete @query.search[sn] unless _.includes(@meta.search_fields, sn))
312
312
 
313
313
  _.each @meta.info, (info, name) =>
@@ -3,7 +3,7 @@ e2-action action="'inspect'"
3
3
  br
4
4
  div title="API" bs-pane=""
5
5
  .row
6
- .col-lg-4
6
+ .col-lg-5
7
7
  .panel.panel-default
8
8
  .panel-body
9
9
  script type="text/ng-template" id="nodes_renderer.html"
@@ -18,7 +18,7 @@ e2-action action="'inspect'"
18
18
  ol ui-tree-nodes="" ng-model="action.tree.actions"
19
19
  li ng-repeat="node in action.tree.actions" ui-tree-node="" data-collapsed="true" ng-include="'nodes_renderer.html'" ng-init="stack = []"
20
20
 
21
- .col-lg-8
21
+ .col-lg-7
22
22
  .panel.panel-default
23
23
  .panel-body
24
24
  div bs-tabs="" bs-active-pane="actionTab" ng-init="actionTab = 0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engine2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - lopex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +184,8 @@ files:
184
184
  - lib/engine2/templates.rb
185
185
  - lib/engine2/type_info.rb
186
186
  - lib/engine2/version.rb
187
+ - public/__sinatra__/404.png
188
+ - public/__sinatra__/500.png
187
189
  - public/assets/javascripts.js
188
190
  - public/assets/styles.css
189
191
  - public/css/angular-motion.css