hippo-fw 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.nvmrc +2 -0
- data/.travis.yml +1 -1
- data/client/hippo/access/login-dialog.jsx +3 -5
- data/client/hippo/boot.jsx +2 -2
- data/client/hippo/components/asset.jsx +0 -1
- data/client/hippo/components/data-list.jsx +16 -15
- data/client/hippo/components/data-list/data-list.scss +10 -0
- data/client/hippo/components/data-table.jsx +14 -14
- data/client/hippo/components/data-table/header-cell.jsx +0 -1
- data/client/hippo/components/data-table/table-styles.scss +7 -0
- data/client/hippo/components/date-time.jsx +19 -16
- data/client/hippo/components/date-time/calendar.jsx +5 -7
- data/client/hippo/components/date-time/date-time-drop.jsx +0 -2
- data/client/hippo/components/date-time/time.jsx +0 -1
- data/client/hippo/components/form.jsx +1 -1
- data/client/hippo/components/form/{model.js → api.js} +25 -7
- data/client/hippo/components/form/fields.jsx +12 -11
- data/client/hippo/components/form/fields/date-wrapper.jsx +1 -1
- data/client/hippo/components/form/fields/form-field.scss +9 -1
- data/client/hippo/components/form/fields/label.jsx +14 -0
- data/client/hippo/components/form/fields/select-wrapper.jsx +2 -3
- data/client/hippo/components/form/wrapper.jsx +1 -3
- data/client/hippo/components/icon.jsx +2 -69
- data/client/hippo/components/master-detail.jsx +0 -2
- data/client/hippo/components/network-activity-overlay.jsx +1 -4
- data/client/hippo/components/query-builder.jsx +15 -16
- data/client/hippo/components/record-finder.jsx +2 -5
- data/client/hippo/components/record-finder/query-layer.jsx +1 -5
- data/client/hippo/components/screen.jsx +7 -3
- data/client/hippo/components/text-editor.jsx +2 -8
- data/client/hippo/components/tool-tip.jsx +2 -3
- data/client/hippo/components/warning-notification.jsx +3 -3
- data/client/hippo/lib/date-range.js +28 -0
- data/client/hippo/lib/util.js +6 -0
- data/client/hippo/models/asset.js +6 -3
- data/client/hippo/models/config.js +1 -1
- data/client/hippo/models/pub_sub.js +12 -7
- data/client/hippo/models/pub_sub/channel.js +6 -4
- data/client/hippo/models/query.js +19 -4
- data/client/hippo/models/query/array-result.js +9 -8
- data/client/hippo/models/query/clause.js +21 -13
- data/client/hippo/models/query/field.js +7 -2
- data/client/hippo/models/query/info.js +7 -3
- data/client/hippo/models/sync.js +11 -14
- data/client/hippo/react/Root.jsx +1 -2
- data/client/hippo/react/{DefaultComponentNotFound.jsx → component-not-found.jsx} +1 -3
- data/client/hippo/screens/index.js +6 -2
- data/client/hippo/screens/system-settings.jsx +10 -6
- data/client/hippo/screens/system-settings/mailer-config.jsx +0 -2
- data/client/hippo/screens/system-settings/tenant.jsx +1 -4
- data/client/hippo/screens/user-management.jsx +0 -1
- data/client/hippo/screens/user-management/edit-form.jsx +1 -2
- data/client/hippo/workspace/index.jsx +21 -12
- data/client/hippo/workspace/menu-group.jsx +4 -7
- data/client/hippo/workspace/menu-option.jsx +1 -3
- data/client/hippo/workspace/menu.jsx +29 -11
- data/client/hippo/workspace/navbar.jsx +1 -2
- data/client/hippo/workspace/root-view.jsx +5 -2
- data/client/hippo/workspace/screen.jsx +2 -3
- data/client/hippo/workspace/styles.scss +17 -0
- data/command-reference-files/screen/client/appy-app/screens/ready-set-go.jsx +2 -1
- data/db/migrate/20170530120004_create_users.rb +1 -1
- data/hippo-fw.gemspec +3 -2
- data/lib/hippo/api/cable.rb +13 -13
- data/lib/hippo/api/controller_base.rb +1 -0
- data/lib/hippo/api/handlers/tenant.rb +1 -1
- data/lib/hippo/api/handlers/user_session.rb +2 -1
- data/lib/hippo/api/helper_methods.rb +4 -1
- data/lib/hippo/api/pub_sub.rb +7 -6
- data/lib/hippo/api/to_json.rb +1 -1
- data/lib/hippo/api/updates.rb +2 -0
- data/lib/hippo/command/console.rb +11 -3
- data/lib/hippo/command/jest.rb +2 -0
- data/lib/hippo/configuration.rb +4 -7
- data/lib/hippo/rake_tasks.rb +1 -1
- data/lib/hippo/screen.rb +31 -93
- data/lib/hippo/screen/definition.rb +76 -0
- data/lib/hippo/screen/group.rb +26 -0
- data/lib/hippo/spec_helper.rb +3 -0
- data/lib/hippo/system_settings.rb +6 -0
- data/lib/hippo/user.rb +11 -3
- data/lib/hippo/version.rb +1 -1
- data/package-lock.json +419 -533
- data/package.json +32 -30
- data/spec/client/access/login-dialog.spec.jsx +4 -5
- data/spec/client/components/__snapshots__/query-builder.spec.jsx.snap +1 -1
- data/spec/client/components/__snapshots__/record-finder.spec.jsx.snap +72 -0
- data/spec/client/components/asset.spec.jsx +2 -6
- data/spec/client/components/data-list.spec.jsx +2 -6
- data/spec/client/components/data-table.spec.jsx +3 -5
- data/spec/client/components/date-time.spec.jsx +1 -1
- data/spec/client/components/form.spec.jsx +2 -2
- data/spec/client/components/master-detail.spec.jsx +1 -2
- data/spec/client/components/network-activity-overlay.spec.jsx +2 -3
- data/spec/client/components/query-builder.spec.jsx +3 -6
- data/spec/client/components/record-finder.spec.jsx +4 -4
- data/spec/client/models/pub_sub.spec.js +3 -1
- data/spec/client/models/query.spec.js +4 -9
- data/spec/client/screens/system-settings-tenants.spec.jsx +1 -1
- data/spec/client/screens/system-settings.spec.jsx +1 -4
- data/spec/client/workspace/__snapshots__/menu.spec.jsx.snap +15 -20
- data/spec/client/workspace/menu.spec.jsx +1 -2
- data/spec/server/api/user_sessions_spec.rb +15 -0
- data/templates/client/screens/screen.jsx +2 -1
- data/views/hippo_root_view.erb +1 -0
- metadata +30 -52
- data/client/hippo/components/calendar/Calendar.jsx +0 -25
- data/client/hippo/components/calendar/index.js +0 -3
- data/client/hippo/components/calendar/styles.scss +0 -3
- data/client/hippo/components/shared/AssetsListing.jsx +0 -23
- data/client/hippo/components/shared/Checkbox.jsx +0 -49
- data/client/hippo/components/shared/CountBadge.jsx +0 -13
- data/client/hippo/components/shared/DateTime.jsx +0 -58
- data/client/hippo/components/shared/DisplayValue.jsx +0 -15
- data/client/hippo/components/shared/ErrorDisplay.jsx +0 -37
- data/client/hippo/components/shared/FieldMixin.jsx +0 -254
- data/client/hippo/components/shared/FieldSet.jsx +0 -52
- data/client/hippo/components/shared/FieldWrapper.jsx +0 -94
- data/client/hippo/components/shared/FormGroup.jsx +0 -41
- data/client/hippo/components/shared/GenericField.jsx +0 -7
- data/client/hippo/components/shared/IconButton.jsx +0 -13
- data/client/hippo/components/shared/ImageAsset.jsx +0 -78
- data/client/hippo/components/shared/IndeterminateCheckbox.jsx +0 -31
- data/client/hippo/components/shared/Input.jsx +0 -16
- data/client/hippo/components/shared/InputFieldMixin.jsx +0 -78
- data/client/hippo/components/shared/JobProgress.jsx +0 -46
- data/client/hippo/components/shared/NumberInput.jsx +0 -37
- data/client/hippo/components/shared/PanelHeader.jsx +0 -15
- data/client/hippo/components/shared/RadioField.jsx +0 -33
- data/client/hippo/components/shared/ResizeSensor.jsx +0 -18
- data/client/hippo/components/shared/ScreenWrapper.jsx +0 -17
- data/client/hippo/components/shared/TextArea.jsx +0 -19
- data/client/hippo/components/shared/Throbber.jsx +0 -8
- data/client/hippo/components/shared/ToggleField.jsx +0 -2
- data/client/hippo/components/shared/Tooltip.jsx +0 -23
- data/client/hippo/components/shared/fields.scss +0 -58
- data/client/hippo/components/shared/fieldset.scss +0 -27
- data/client/hippo/components/shared/image-asset.scss +0 -53
- data/client/hippo/components/shared/index.js +0 -5
- data/client/hippo/components/shared/overlay.scss +0 -83
- data/client/hippo/components/shared/resize-sensor.scss +0 -30
- data/client/hippo/components/shared/styles.scss +0 -64
- data/client/hippo/components/shared/throbber.scss +0 -53
- data/client/hippo/fonts/fontawesome-webfont.woff +0 -0
- data/client/hippo/fonts/fontawesome-webfont.woff2 +0 -0
- data/client/hippo/workspace/content.jsx +0 -22
- data/client/hippo/workspace/tabs.jsx +0 -60
- data/client/hippo/workspace/viewport.jsx +0 -82
- data/spec/client/screens/__snapshots__/tabs.spec.jsx.snap +0 -127
- data/spec/client/screens/tabs.spec.jsx +0 -36
@@ -36,3 +36,20 @@ pre {
|
|
36
36
|
display: flex;
|
37
37
|
}
|
38
38
|
}
|
39
|
+
|
40
|
+
.sidebar-toggle {
|
41
|
+
position: fixed;
|
42
|
+
left: 0;
|
43
|
+
bottom: 0;
|
44
|
+
z-index: 1;
|
45
|
+
border-top-left-radius: 0;
|
46
|
+
border-bottom-right-radius: 0;
|
47
|
+
opacity: 0.2;
|
48
|
+
transistion: all 0.4s;
|
49
|
+
&:hover {
|
50
|
+
opacity: 1.0;
|
51
|
+
}
|
52
|
+
&.is-open {
|
53
|
+
display:none;
|
54
|
+
}
|
55
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
2
3
|
import { observer } from 'mobx-react';
|
3
4
|
import Screen from 'hippo/components/screen';
|
4
5
|
|
@@ -6,7 +7,7 @@ import Screen from 'hippo/components/screen';
|
|
6
7
|
export default class ReadySetGo extends React.PureComponent {
|
7
8
|
|
8
9
|
static propTypes = {
|
9
|
-
screen:
|
10
|
+
screen: PropTypes.instanceOf(Screen.Instance).isRequired,
|
10
11
|
}
|
11
12
|
|
12
13
|
render() {
|
data/hippo-fw.gemspec
CHANGED
@@ -26,9 +26,10 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_dependency "activejob", "~> 5.1.0"
|
28
28
|
spec.add_dependency "activerecord", "~> 5.1.0"
|
29
|
-
spec.add_dependency "activerecord-multi-tenant", "~> 0.
|
29
|
+
spec.add_dependency "activerecord-multi-tenant", "~> 0.7"
|
30
30
|
|
31
31
|
spec.add_dependency "litecable", "~> 0.4.1"
|
32
|
+
spec.add_dependency "anycable", "~> 0.4.6"
|
32
33
|
spec.add_dependency "websocket", "~> 1.2.4"
|
33
34
|
spec.add_dependency "mail", "~> 2.6"
|
34
35
|
spec.add_dependency "scenic", "~> 1.4"
|
@@ -65,7 +66,7 @@ Gem::Specification.new do |spec|
|
|
65
66
|
spec.add_dependency "jwt", "~> 1.5"
|
66
67
|
spec.add_dependency "mini_magick", "~> 4.3"
|
67
68
|
|
68
|
-
spec.add_dependency "oj", "~>
|
69
|
+
spec.add_dependency "oj", "~> 3.3"
|
69
70
|
spec.add_dependency "pg", "~> 0.8"
|
70
71
|
spec.add_dependency "rake", "~> 12.0"
|
71
72
|
spec.add_dependency "require_all", "~> 1.3"
|
data/lib/hippo/api/cable.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "action_cable"
|
2
2
|
|
3
3
|
module Hippo
|
4
4
|
module API
|
@@ -10,14 +10,13 @@ module Hippo
|
|
10
10
|
@@server.call(request.env)
|
11
11
|
end
|
12
12
|
|
13
|
-
class
|
14
|
-
end
|
15
|
-
|
16
|
-
class Connection < LiteCable::Connection::Base
|
13
|
+
class Connection < ActionCable::Connection::Base
|
17
14
|
identified_by :current_user
|
18
15
|
|
19
16
|
def connect
|
20
17
|
token = request.params['token']
|
18
|
+
Hippo.logger_debug("NEW WS CONN: #{token}")
|
19
|
+
|
21
20
|
begin
|
22
21
|
self.current_user = User.for_jwt_token(token) if token
|
23
22
|
rescue JWT::DecodeError
|
@@ -37,15 +36,16 @@ module Hippo
|
|
37
36
|
|
38
37
|
def self.configure
|
39
38
|
require_relative './updates'
|
39
|
+
@@config = ActionCable::Server::Configuration.new
|
40
|
+
config.logger = Hippo.logger
|
41
|
+
config.cable = Hippo.config.cable
|
42
|
+
config.connection_class = -> { Connection }
|
43
|
+
config.allowed_request_origins = -> (host) {
|
44
|
+
host
|
45
|
+
}
|
46
|
+
ActionCable::Server::Base.config = config
|
47
|
+
@@server = ActionCable.server
|
40
48
|
|
41
|
-
if Hippo.config.api_use_any_cable
|
42
|
-
|
43
|
-
else
|
44
|
-
require "lite_cable/server"
|
45
|
-
@@server = LiteCable::Server::Middleware.new(
|
46
|
-
Hippo::API::Root, connection_class: Hippo::API::Cable::Connection
|
47
|
-
)
|
48
|
-
end
|
49
49
|
Updates.relay!
|
50
50
|
end
|
51
51
|
|
@@ -212,6 +212,7 @@ module Hippo
|
|
212
212
|
def add_modifiers_to_query(query)
|
213
213
|
query = query.limit(query_limit_size)
|
214
214
|
query = query.offset(query_offset.to_i) if query_offset.present?
|
215
|
+
|
215
216
|
if include_associations.any?
|
216
217
|
allowed_includes = include_associations.each_with_object([]) do |desired, results|
|
217
218
|
if desired.is_a?(Hash)
|
@@ -12,7 +12,7 @@ module Hippo::API::Handlers
|
|
12
12
|
tenant = Hippo::Tenant.current
|
13
13
|
tenant.assign_attributes(data.slice(*PUBLIC_ATTRS))
|
14
14
|
success = tenant.save
|
15
|
-
if success
|
15
|
+
if success && tenant.slug_previously_changed?
|
16
16
|
Hippo::Tenant.system.perform do
|
17
17
|
Hippo::Templates::TenantChange.create(tenant).deliver
|
18
18
|
end
|
@@ -8,7 +8,8 @@ module Hippo::API::Handlers
|
|
8
8
|
def self.create
|
9
9
|
lambda do
|
10
10
|
wrap_reply(with_transaction: false) do
|
11
|
-
user = Hippo::User.
|
11
|
+
user = Hippo::User.with_login(data['login']).first
|
12
|
+
|
12
13
|
if user && user.authenticate(data['password'])
|
13
14
|
{ success: true, message: "Login succeeded",
|
14
15
|
data: user.workspace_data }
|
data/lib/hippo/api/pub_sub.rb
CHANGED
@@ -3,8 +3,7 @@ require_relative 'cable'
|
|
3
3
|
module Hippo
|
4
4
|
module API
|
5
5
|
|
6
|
-
class PubSub <
|
7
|
-
identifier :pubsub
|
6
|
+
class PubSub < ActionCable::Channel::Base
|
8
7
|
|
9
8
|
PREFIX = 'ps:'
|
10
9
|
|
@@ -14,14 +13,16 @@ module Hippo
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def off(data)
|
17
|
-
|
18
|
-
|
16
|
+
channel = channel_prefix + data['channel']
|
17
|
+
subscribers = pubsub
|
18
|
+
.instance_variable_get('@listener')
|
19
|
+
.instance_variable_get('@subscribers')[channel]
|
20
|
+
pubsub.unsubscribe(channel, subscribers.first) if subscribers.any?
|
19
21
|
end
|
20
22
|
|
21
23
|
def self.publish(channel, data)
|
22
|
-
Hippo.logger.info "pubsub pub: #{channel}"
|
23
24
|
channel = channel_prefix + channel
|
24
|
-
|
25
|
+
ActionCable.server.broadcast(channel, data.merge(channel: channel))
|
25
26
|
end
|
26
27
|
|
27
28
|
def self.channel_prefix
|
data/lib/hippo/api/to_json.rb
CHANGED
data/lib/hippo/api/updates.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../api/updates'
|
2
|
+
|
1
3
|
module Hippo
|
2
4
|
module Command
|
3
5
|
|
@@ -19,10 +21,16 @@ module Hippo
|
|
19
21
|
ext.root_path.join('spec/factories')
|
20
22
|
end
|
21
23
|
FactoryGirl.find_definitions
|
22
|
-
|
24
|
+
Hippo::API::Cable.configure
|
25
|
+
MultiTenant.current_tenant = Hippo::Tenant.find_by_slug(
|
26
|
+
Hippo.env.development? ? 'test' : 'system'
|
27
|
+
)
|
23
28
|
ext.on_dev_console
|
24
|
-
|
25
|
-
|
29
|
+
Pry::Commands.block_command "tenant", "set current tenant to <slug>" do |slug|
|
30
|
+
MultiTenant.current_tenant=Hippo::Tenant.find_by_slug!(slug)
|
31
|
+
puts "Current tenant id = #{MultiTenant.current_tenant.id}"
|
32
|
+
end
|
33
|
+
Pry.start
|
26
34
|
end
|
27
35
|
|
28
36
|
end
|
data/lib/hippo/command/jest.rb
CHANGED
@@ -17,6 +17,7 @@ module Hippo
|
|
17
17
|
|
18
18
|
|
19
19
|
def configure
|
20
|
+
@extension ||= Command.load_current_extension(raise_on_fail:true)
|
20
21
|
@config = Hippo::Webpack::ClientConfig.new
|
21
22
|
@config.invoke_all
|
22
23
|
self
|
@@ -33,6 +34,7 @@ module Hippo
|
|
33
34
|
options.each do |key, value|
|
34
35
|
cmd << " --#{key}" if value
|
35
36
|
end
|
37
|
+
say cmd, :green
|
36
38
|
exec(cmd)
|
37
39
|
end
|
38
40
|
end
|
data/lib/hippo/configuration.rb
CHANGED
@@ -50,6 +50,8 @@ module Hippo
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.apply
|
53
|
+
Oj.default_options = { mode: :rails, time_format: :xmlschema }
|
54
|
+
|
53
55
|
controlling_ext = Hippo::Extensions.bootstrap
|
54
56
|
secrets = controlling_ext.root_path.join('config', 'secrets.yml')
|
55
57
|
@@secrets = Hashie::Mash.new(
|
@@ -114,11 +116,8 @@ module Hippo
|
|
114
116
|
# prefix to use for all urls
|
115
117
|
config_option :mounted_at, '/'
|
116
118
|
|
117
|
-
#
|
118
|
-
config_option :
|
119
|
-
|
120
|
-
# Screen to display on load (if workspace extension is used)
|
121
|
-
config_option :initial_workspace_screen_id, ''
|
119
|
+
# Configuration for action cable
|
120
|
+
config_option :cable, { 'adapter' => 'redis' }
|
122
121
|
|
123
122
|
# types of assets to include into compiled package
|
124
123
|
config_option :static_asset_types, ['images','fonts']
|
@@ -127,8 +126,6 @@ module Hippo
|
|
127
126
|
|
128
127
|
config_option :product_name, 'Hippo Funtime'
|
129
128
|
|
130
|
-
config_option :api_use_any_cable, false
|
131
|
-
|
132
129
|
def api_path
|
133
130
|
mounted_at + 'api'
|
134
131
|
end
|
data/lib/hippo/rake_tasks.rb
CHANGED
data/lib/hippo/screen.rb
CHANGED
@@ -1,29 +1,49 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'oj'
|
3
3
|
require 'pry'
|
4
|
+
require_relative 'screen/group'
|
5
|
+
require_relative 'screen/definition'
|
4
6
|
|
5
7
|
module Hippo
|
6
8
|
|
7
9
|
module Screen
|
8
10
|
|
9
11
|
GROUPS=Hash.new{|h,k| g=Group.new; g.identifier=k; h[k]=g }
|
10
|
-
DEFINITIONS=Hash.new
|
12
|
+
DEFINITIONS = Hash.new
|
13
|
+
EXTENSIONS = Hash.new
|
11
14
|
|
12
15
|
mattr_accessor :enabled_group_ids
|
13
16
|
|
14
17
|
class DefinitionList
|
18
|
+
attr_reader :ids
|
19
|
+
|
20
|
+
include Enumerable
|
21
|
+
|
15
22
|
def initialize(extension_id)
|
23
|
+
@ids = []
|
16
24
|
@extension_id = extension_id
|
17
25
|
end
|
18
26
|
|
19
27
|
def define(id)
|
28
|
+
ids.push(id)
|
20
29
|
definition = (DEFINITIONS[id] ||= Definition.new(id, @extension_id))
|
21
30
|
yield definition
|
22
31
|
end
|
32
|
+
|
33
|
+
def extend(id)
|
34
|
+
ids.push(id)
|
35
|
+
definition = DEFINITIONS[id]
|
36
|
+
definition.extension_id = @extension_id
|
37
|
+
yield definition if block_given?
|
38
|
+
end
|
39
|
+
|
40
|
+
def each
|
41
|
+
ids.each { |id| yield DEFINITIONS[id] }
|
42
|
+
end
|
43
|
+
|
23
44
|
end
|
24
45
|
|
25
46
|
class << self
|
26
|
-
|
27
47
|
include Enumerable
|
28
48
|
|
29
49
|
def [](config)
|
@@ -34,8 +54,14 @@ module Hippo
|
|
34
54
|
end
|
35
55
|
end
|
36
56
|
|
57
|
+
def each
|
58
|
+
DEFINITIONS.values.each { |s| yield s }
|
59
|
+
end
|
60
|
+
|
37
61
|
def for_extension(id)
|
38
|
-
|
62
|
+
definition = EXTENSIONS[id] ||= DefinitionList.new(id)
|
63
|
+
yield definition if block_given?
|
64
|
+
definition
|
39
65
|
end
|
40
66
|
|
41
67
|
def define_group(id)
|
@@ -43,9 +69,9 @@ module Hippo
|
|
43
69
|
yield group
|
44
70
|
end
|
45
71
|
|
46
|
-
def
|
72
|
+
def active_ids
|
47
73
|
Extensions.load_screens
|
48
|
-
|
74
|
+
for_extension(Hippo::Extensions.controlling.identifier).map(&:identifier)
|
49
75
|
end
|
50
76
|
|
51
77
|
def each_group
|
@@ -59,94 +85,6 @@ module Hippo
|
|
59
85
|
|
60
86
|
end
|
61
87
|
|
62
|
-
|
63
|
-
class Group
|
64
|
-
include Concerns::AttrAccessorWithDefault
|
65
|
-
|
66
|
-
attr_accessor_with_default :identifier
|
67
|
-
attr_accessor_with_default :title
|
68
|
-
attr_accessor_with_default :description
|
69
|
-
attr_accessor_with_default :icon
|
70
|
-
attr_accessor_with_default :order
|
71
|
-
|
72
|
-
def to_json
|
73
|
-
Oj.dump({
|
74
|
-
id: identifier,
|
75
|
-
title: title,
|
76
|
-
description: description,
|
77
|
-
icon: icon
|
78
|
-
}, mode: :compat)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Definition
|
83
|
-
include Concerns::AttrAccessorWithDefault
|
84
|
-
|
85
|
-
attr_accessor_with_default :identifier
|
86
|
-
attr_accessor_with_default :title
|
87
|
-
attr_accessor_with_default :description
|
88
|
-
attr_accessor_with_default :icon
|
89
|
-
attr_accessor_with_default :group_id
|
90
|
-
attr_accessor_with_default :extension
|
91
|
-
attr_accessor_with_default :view_class
|
92
|
-
attr_accessor_with_default :model_class
|
93
|
-
attr_accessor_with_default :model_access, 'read'
|
94
|
-
attr_accessor_with_default :asset
|
95
|
-
|
96
|
-
def initialize(id, extension_id)
|
97
|
-
self.identifier = id
|
98
|
-
@extension_id = extension_id
|
99
|
-
@extension = extension_id.underscore.camelize
|
100
|
-
end
|
101
|
-
|
102
|
-
def group
|
103
|
-
GROUPS[@group_id]
|
104
|
-
end
|
105
|
-
|
106
|
-
def has_file_matching?(pattern)
|
107
|
-
Pathname.glob(root_path.join(pattern)).any?
|
108
|
-
end
|
109
|
-
|
110
|
-
def root_path
|
111
|
-
ext = Hippo::Extensions.for_identifier(@extension_id)
|
112
|
-
raise "Unable to find extension '#{@extension_id}' for screen group" unless ext
|
113
|
-
ext.root_path.join('client', url_prefix, identifier)
|
114
|
-
end
|
115
|
-
|
116
|
-
def model
|
117
|
-
return nil if @model_class.blank?
|
118
|
-
ext = Hippo::Extensions.for_identifier(@extension_id)
|
119
|
-
(@extension_id.camelize + '::' + @model_class).constantize
|
120
|
-
end
|
121
|
-
|
122
|
-
def viewable_by?(user)
|
123
|
-
model.nil? || user.can_read?(self)
|
124
|
-
end
|
125
|
-
|
126
|
-
def asset_path
|
127
|
-
(asset && asset =~ /\//) ? asset : "#{@extension_id}/screens/#{asset || identifier}"
|
128
|
-
end
|
129
|
-
|
130
|
-
def as_json
|
131
|
-
{
|
132
|
-
id: identifier,
|
133
|
-
title: title,
|
134
|
-
icon: icon,
|
135
|
-
model: model_class,
|
136
|
-
view: view_class,
|
137
|
-
access: model_access,
|
138
|
-
group_id: group_id,
|
139
|
-
extension: extension,
|
140
|
-
description: description,
|
141
|
-
asset: asset_path
|
142
|
-
}
|
143
|
-
end
|
144
|
-
|
145
|
-
def to_json
|
146
|
-
Oj.dump(as_json, mode: :compat)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
88
|
end
|
151
89
|
|
152
90
|
end
|