linked_rails 0.0.2 → 0.0.4.pre.gaa82a222d
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -674
- data/app/controllers/linked_rails/actions/objects_controller.rb +9 -0
- data/app/controllers/linked_rails/bulk_controller.rb +71 -21
- data/app/controllers/linked_rails/enum_values_controller.rb +0 -42
- data/app/models/linked_rails/actions/item.rb +64 -55
- data/app/models/linked_rails/actions/list.rb +6 -31
- data/app/models/linked_rails/actions/object.rb +38 -0
- data/app/models/linked_rails/collection/configuration.rb +55 -0
- data/app/models/linked_rails/collection/filter.rb +1 -1
- data/app/models/linked_rails/collection/filter_field.rb +19 -2
- data/app/models/linked_rails/collection/filter_option.rb +1 -1
- data/app/models/linked_rails/collection/filterable.rb +6 -9
- data/app/models/linked_rails/collection/infinite.rb +113 -0
- data/app/models/linked_rails/collection/infinite_view.rb +1 -90
- data/app/models/linked_rails/collection/iri.rb +47 -43
- data/app/models/linked_rails/collection/iri_mapping.rb +15 -7
- data/app/models/linked_rails/collection/paginated.rb +46 -0
- data/app/models/linked_rails/collection/paginated_view.rb +1 -33
- data/app/models/linked_rails/collection/sortable.rb +1 -9
- data/app/models/linked_rails/collection/sorting.rb +1 -1
- data/app/models/linked_rails/collection/view.rb +51 -14
- data/app/models/linked_rails/collection.rb +53 -85
- data/app/models/linked_rails/creative_work.rb +1 -1
- data/app/models/linked_rails/entry_point.rb +8 -5
- data/app/models/linked_rails/enum_value.rb +40 -2
- data/app/models/linked_rails/form/field/association_input.rb +7 -1
- data/app/models/linked_rails/form/field/file_input.rb +1 -0
- data/app/models/linked_rails/form/field/resource_field.rb +2 -0
- data/{lib/linked_rails/enhancements/indexable/model.rb → app/models/linked_rails/form/field/url_input.rb} +3 -3
- data/app/models/linked_rails/form/field.rb +37 -13
- data/app/models/linked_rails/form/field_factory.rb +48 -18
- data/app/models/linked_rails/form/group.rb +4 -6
- data/app/models/linked_rails/form/page.rb +8 -4
- data/app/models/linked_rails/form.rb +16 -21
- data/app/models/linked_rails/manifest.rb +8 -2
- data/app/models/linked_rails/menus/item.rb +10 -13
- data/app/models/linked_rails/menus/list.rb +16 -7
- data/app/models/linked_rails/ontology/base.rb +3 -1
- data/app/models/linked_rails/ontology/class.rb +3 -3
- data/app/models/linked_rails/ontology.rb +5 -5
- data/app/models/linked_rails/property_query.rb +2 -0
- data/app/models/linked_rails/sequence.rb +4 -13
- data/app/models/linked_rails/shacl/property_shape.rb +1 -1
- data/app/models/linked_rails/web_page.rb +0 -4
- data/app/models/linked_rails/web_site.rb +0 -4
- data/app/models/linked_rails/widget.rb +4 -11
- data/app/policies/linked_rails/actions/object_policy.rb +11 -0
- data/app/policies/linked_rails/collection_policy.rb +2 -2
- data/app/serializers/linked_rails/actions/item_serializer.rb +5 -5
- data/app/serializers/linked_rails/actions/object_serializer.rb +9 -0
- data/app/serializers/linked_rails/collection/filter_field_serializer.rb +3 -2
- data/app/serializers/linked_rails/collection/filter_option_serializer.rb +1 -1
- data/app/serializers/linked_rails/collection/filter_serializer.rb +1 -1
- data/app/serializers/linked_rails/collection/sorting_serializer.rb +1 -1
- data/app/serializers/linked_rails/collection/view_serializer.rb +3 -3
- data/app/serializers/linked_rails/collection_serializer.rb +8 -7
- data/app/serializers/linked_rails/condition_serializer.rb +3 -3
- data/app/serializers/linked_rails/entry_point_serializer.rb +3 -3
- data/app/serializers/linked_rails/enum_value_serializer.rb +1 -0
- data/app/serializers/linked_rails/form/field/association_input_serializer.rb +1 -0
- data/app/serializers/linked_rails/form/field/file_input_serializer.rb +11 -0
- data/app/serializers/linked_rails/form/field_serializer.rb +3 -1
- data/app/serializers/linked_rails/form/group_serializer.rb +1 -1
- data/app/serializers/linked_rails/form/page_serializer.rb +1 -1
- data/app/serializers/linked_rails/menus/item_serializer.rb +3 -3
- data/app/serializers/linked_rails/menus/list_serializer.rb +1 -1
- data/app/serializers/linked_rails/ontology_serializer.rb +2 -2
- data/app/serializers/linked_rails/property_query_serializer.rb +7 -0
- data/app/serializers/linked_rails/sequence_serializer.rb +2 -5
- data/app/serializers/linked_rails/shacl/node_shape_serializer.rb +1 -1
- data/app/serializers/linked_rails/shacl/property_shape_serializer.rb +1 -1
- data/app/serializers/linked_rails/shacl/shape_serializer.rb +5 -5
- data/app/serializers/linked_rails/web_page_serializer.rb +3 -3
- data/app/serializers/linked_rails/web_site_serializer.rb +1 -1
- data/app/serializers/linked_rails/widget_serializer.rb +3 -3
- data/lib/generators/linked_rails/install/install_generator.rb +7 -8
- data/lib/generators/linked_rails/install/templates/README +7 -0
- data/lib/generators/linked_rails/install/templates/app_menu_list.rb +36 -7
- data/lib/generators/linked_rails/install/templates/application_menu_list.rb +40 -1
- data/lib/generators/linked_rails/install/templates/initializer.rb +1 -2
- data/lib/generators/linked_rails/install/templates/locales.yml +14 -0
- data/lib/generators/linked_rails/install/templates/rdf_serializers_initializer.rb +1 -1
- data/lib/generators/linked_rails/install/templates/vocab.rb +1 -0
- data/lib/generators/linked_rails/install/templates/vocab.yml +2 -2
- data/lib/generators/linked_rails/model/model_generator.rb +0 -1
- data/lib/generators/linked_rails/model/templates/controller.rb.tt +5 -1
- data/lib/generators/linked_rails/model/templates/form.rb.tt +3 -0
- data/lib/generators/linked_rails/model/templates/menu_list.rb.tt +15 -0
- data/lib/generators/linked_rails/model/templates/policy.rb.tt +13 -0
- data/lib/generators/linked_rails/model/templates/serializer.rb.tt +5 -1
- data/lib/linked_rails/active_response/controller/collections.rb +1 -1
- data/lib/linked_rails/active_response/controller/crud_defaults.rb +4 -4
- data/lib/linked_rails/active_response/controller/params.rb +10 -10
- data/lib/linked_rails/active_response/controller.rb +8 -18
- data/lib/linked_rails/active_response/responders/rdf.rb +19 -10
- data/lib/linked_rails/callable_variable.rb +1 -1
- data/lib/linked_rails/collection_params_parser.rb +93 -0
- data/lib/linked_rails/controller/actionable.rb +121 -0
- data/lib/linked_rails/controller/authorization.rb +6 -0
- data/lib/linked_rails/controller/default_actions/create.rb +52 -0
- data/lib/linked_rails/controller/default_actions/destroy.rb +42 -0
- data/lib/linked_rails/controller/default_actions/update.rb +43 -0
- data/lib/linked_rails/controller/delta.rb +78 -0
- data/lib/linked_rails/controller/error_handling.rb +11 -9
- data/lib/linked_rails/controller/rendering.rb +48 -0
- data/lib/linked_rails/controller.rb +24 -4
- data/lib/linked_rails/enhanceable.rb +1 -1
- data/lib/linked_rails/enhancements/creatable/controller.rb +1 -1
- data/lib/linked_rails/enhancements/destroyable/controller.rb +1 -1
- data/lib/linked_rails/enhancements/updatable/controller.rb +1 -1
- data/lib/linked_rails/enhancements.rb +0 -16
- data/lib/linked_rails/helpers/delta_helper.rb +26 -57
- data/lib/linked_rails/helpers/ontola_actions_helper.rb +2 -2
- data/lib/linked_rails/helpers/resource_helper.rb +4 -2
- data/lib/linked_rails/iri_mapper.rb +17 -39
- data/lib/linked_rails/middleware/error_handling.rb +51 -0
- data/lib/linked_rails/middleware/linked_data_params.rb +30 -151
- data/lib/linked_rails/model/actionable.rb +68 -0
- data/lib/linked_rails/model/collections.rb +201 -39
- data/lib/linked_rails/model/dirty.rb +7 -8
- data/lib/linked_rails/model/enhancements.rb +1 -6
- data/lib/linked_rails/model/filtering.rb +4 -6
- data/lib/linked_rails/model/indexable.rb +6 -16
- data/lib/linked_rails/model/iri.rb +28 -19
- data/lib/linked_rails/model/iri_mapping.rb +37 -8
- data/lib/linked_rails/model/menuable.rb +28 -0
- data/lib/linked_rails/model/serialization.rb +2 -15
- data/lib/linked_rails/model/singularable.rb +57 -0
- data/lib/linked_rails/model/sorting.rb +0 -5
- data/lib/linked_rails/model/tables.rb +26 -0
- data/lib/linked_rails/model.rb +17 -7
- data/lib/linked_rails/params_parser.rb +133 -55
- data/lib/linked_rails/policy/attribute_conditions.rb +2 -2
- data/lib/linked_rails/policy.rb +40 -46
- data/lib/linked_rails/railtie.rb +11 -0
- data/lib/linked_rails/rdf_error.rb +2 -2
- data/lib/linked_rails/renderers.rb +1 -0
- data/lib/linked_rails/routes.rb +38 -22
- data/lib/linked_rails/serializer/actionable.rb +27 -0
- data/lib/linked_rails/serializer/menuable.rb +31 -0
- data/lib/linked_rails/serializer/singularable.rb +26 -0
- data/lib/linked_rails/serializer.rb +28 -11
- data/lib/linked_rails/test_methods.rb +114 -0
- data/lib/linked_rails/translate.rb +31 -9
- data/lib/linked_rails/types/iri_type.rb +37 -0
- data/lib/linked_rails/uri_template.rb +30 -0
- data/lib/linked_rails/version.rb +1 -1
- data/lib/linked_rails/vocab.rb +9 -0
- data/lib/linked_rails.rb +30 -13
- data/lib/rails/welcome_controller.rb +3 -2
- data/lib/rdf/list.rb +9 -0
- data/lib/rdf/query_fix.rb +15 -0
- metadata +58 -33
- data/app/models/linked_rails/actions/default_actions/create.rb +0 -60
- data/app/models/linked_rails/actions/default_actions/destroy.rb +0 -45
- data/app/models/linked_rails/actions/default_actions/update.rb +0 -50
- data/app/models/linked_rails/actions/default_actions.rb +0 -17
- data/lib/generators/linked_rails/install/templates/application_action_list.rb +0 -3
- data/lib/generators/linked_rails/model/templates/action_list.rb.tt +0 -6
- data/lib/linked_rails/enhancements/actionable/model.rb +0 -71
- data/lib/linked_rails/enhancements/actionable/serializer.rb +0 -25
- data/lib/linked_rails/enhancements/creatable/action.rb +0 -15
- data/lib/linked_rails/enhancements/destroyable/action.rb +0 -15
- data/lib/linked_rails/enhancements/destroyable/routing.rb +0 -19
- data/lib/linked_rails/enhancements/menuable/model.rb +0 -36
- data/lib/linked_rails/enhancements/menuable/serializer.rb +0 -33
- data/lib/linked_rails/enhancements/route_concerns.rb +0 -56
- data/lib/linked_rails/enhancements/singularable/controller.rb +0 -43
- data/lib/linked_rails/enhancements/singularable/model.rb +0 -47
- data/lib/linked_rails/enhancements/singularable/serializer.rb +0 -28
- data/lib/linked_rails/enhancements/tableable/model.rb +0 -28
- data/lib/linked_rails/enhancements/updatable/action.rb +0 -15
- data/lib/linked_rails/enhancements/updatable/routing.rb +0 -20
@@ -6,13 +6,13 @@ module LinkedRails
|
|
6
6
|
attr_accessor :groups, :label, :description
|
7
7
|
attr_writer :key
|
8
8
|
|
9
|
-
def initialize(attrs
|
10
|
-
super(attrs)
|
9
|
+
def initialize(**attrs)
|
10
|
+
super(**attrs)
|
11
11
|
self.groups = []
|
12
12
|
end
|
13
13
|
|
14
|
-
def add_group(opts)
|
15
|
-
group = Form::Group.new(opts)
|
14
|
+
def add_group(**opts)
|
15
|
+
group = Form::Group.new(**opts)
|
16
16
|
groups << group
|
17
17
|
group
|
18
18
|
end
|
@@ -21,6 +21,10 @@ module LinkedRails
|
|
21
21
|
@footer_group ||= add_group(collapsible: false, footer: true, key: :footer)
|
22
22
|
end
|
23
23
|
|
24
|
+
def footer_group!
|
25
|
+
@footer_group
|
26
|
+
end
|
27
|
+
|
24
28
|
class << self
|
25
29
|
def iri
|
26
30
|
Vocab.form[:Page]
|
@@ -6,9 +6,9 @@ module LinkedRails
|
|
6
6
|
class Form # rubocop:disable Metrics/ClassLength
|
7
7
|
include LinkedRails::Model
|
8
8
|
|
9
|
-
class_attribute :pages, :model_class
|
9
|
+
class_attribute :abstract_form, :pages, :model_class
|
10
10
|
|
11
|
-
def root_relative_iri(_opts
|
11
|
+
def root_relative_iri(**_opts)
|
12
12
|
self.class.form_iri_path
|
13
13
|
end
|
14
14
|
|
@@ -63,10 +63,6 @@ module LinkedRails
|
|
63
63
|
@serializer_reflections ||= serializer_class&.relationships_to_serialize || {}
|
64
64
|
end
|
65
65
|
|
66
|
-
def preview_includes
|
67
|
-
[pages: {groups: [fields: [:fail, :pass, shape: [:property, nested_shapes: :property]]]}]
|
68
|
-
end
|
69
|
-
|
70
66
|
private
|
71
67
|
|
72
68
|
def current_group
|
@@ -85,7 +81,7 @@ module LinkedRails
|
|
85
81
|
@default_page ||= page(:default)
|
86
82
|
end
|
87
83
|
|
88
|
-
def field(key, opts
|
84
|
+
def field(key, **opts)
|
89
85
|
current_group.fields << Form::FieldFactory.new(
|
90
86
|
field_options: opts,
|
91
87
|
form: self,
|
@@ -94,9 +90,10 @@ module LinkedRails
|
|
94
90
|
end
|
95
91
|
|
96
92
|
def find_form_class(params)
|
97
|
-
|
93
|
+
form_name = [params[:module], "#{params[:id]&.singularize}_forms"].compact.join('/').classify
|
94
|
+
requested_class = form_name.safe_constantize
|
98
95
|
|
99
|
-
|
96
|
+
requested_class if requested_class && requested_class < LinkedRails::Form
|
100
97
|
end
|
101
98
|
|
102
99
|
def footer
|
@@ -108,10 +105,10 @@ module LinkedRails
|
|
108
105
|
current_page.footer_group
|
109
106
|
end
|
110
107
|
|
111
|
-
def group(key, opts
|
108
|
+
def group(key, **opts)
|
112
109
|
opts[:collapsible] = true unless opts.key?(:collapsible)
|
113
110
|
opts[:key] = key
|
114
|
-
group = current_page.add_group(opts)
|
111
|
+
group = current_page.add_group(**opts)
|
115
112
|
@current_group = group
|
116
113
|
|
117
114
|
yield if block_given?
|
@@ -120,26 +117,24 @@ module LinkedRails
|
|
120
117
|
group
|
121
118
|
end
|
122
119
|
|
123
|
-
|
124
|
-
def has_many(key, opts = {})
|
120
|
+
def has_many(key, **opts)
|
125
121
|
opts[:input_field] = Form::Field::AssociationInput
|
126
122
|
opts[:max_count] = 99
|
127
|
-
field(key, opts)
|
123
|
+
field(key, **opts)
|
128
124
|
end
|
129
125
|
|
130
|
-
def has_one(key, opts
|
126
|
+
def has_one(key, **opts)
|
131
127
|
opts[:input_field] = Form::Field::AssociationInput
|
132
128
|
opts[:max_count] = 1
|
133
|
-
field(key, opts)
|
129
|
+
field(key, **opts)
|
134
130
|
end
|
135
|
-
# rubocop:enable Naming/PredicateName
|
136
131
|
|
137
132
|
def hidden(&block)
|
138
133
|
group(:hidden, collapsible: false, hidden: true, &block)
|
139
134
|
end
|
140
135
|
|
141
|
-
def page(key, opts
|
142
|
-
page = Form::Page.new(opts.merge(key: key))
|
136
|
+
def page(key, **opts)
|
137
|
+
page = Form::Page.new(**opts.merge(key: key))
|
143
138
|
@current_page = page
|
144
139
|
pages << @current_page
|
145
140
|
yield if block_given?
|
@@ -147,9 +142,9 @@ module LinkedRails
|
|
147
142
|
page
|
148
143
|
end
|
149
144
|
|
150
|
-
def resource(key, opts
|
145
|
+
def resource(key, **opts)
|
151
146
|
opts[:input_field] = Form::Field::ResourceField
|
152
|
-
field(key, opts)
|
147
|
+
field(key, **opts)
|
153
148
|
end
|
154
149
|
end
|
155
150
|
end
|
@@ -79,7 +79,7 @@ module LinkedRails
|
|
79
79
|
}
|
80
80
|
end
|
81
81
|
|
82
|
-
def web_manifest_ontola_section
|
82
|
+
def web_manifest_ontola_section # rubocop:disable Metrics/MethodLength
|
83
83
|
{
|
84
84
|
css_class: css_class,
|
85
85
|
header_background: header_background,
|
@@ -88,7 +88,9 @@ module LinkedRails
|
|
88
88
|
primary_color: site_theme_color,
|
89
89
|
secondary_color: site_secondary_color,
|
90
90
|
theme: theme,
|
91
|
-
theme_options: theme_options.to_query
|
91
|
+
theme_options: theme_options.to_query,
|
92
|
+
website_iri: LinkedRails.iri.to_s,
|
93
|
+
websocket_path: websocket_path
|
92
94
|
}
|
93
95
|
end
|
94
96
|
|
@@ -98,5 +100,9 @@ module LinkedRails
|
|
98
100
|
scope: scope
|
99
101
|
}
|
100
102
|
end
|
103
|
+
|
104
|
+
def websocket_path
|
105
|
+
Rails.application.config.try(:action_cable).try(:mount_path).try(:[], 1..-1)
|
106
|
+
end
|
101
107
|
end
|
102
108
|
end
|
@@ -12,7 +12,7 @@ module LinkedRails
|
|
12
12
|
delegate :iri_opts, to: :parent
|
13
13
|
|
14
14
|
alias id iri
|
15
|
-
%i[action href image label
|
15
|
+
%i[action href image label iri_base].each do |method|
|
16
16
|
callable_variable(method, instance: :parent)
|
17
17
|
end
|
18
18
|
|
@@ -26,7 +26,7 @@ module LinkedRails
|
|
26
26
|
def iri_template
|
27
27
|
return parent.send(:iri_template) unless parent.is_a?(LinkedRails::Menus::List)
|
28
28
|
|
29
|
-
return URITemplate.new("#{iri_base}{/tag}{#fragment}") if iri_base
|
29
|
+
return LinkedRails::URITemplate.new("#{iri_base}{/tag}{#fragment}") if iri_base
|
30
30
|
|
31
31
|
iri_template_expand_path(parent.send(:iri_template), '{/tag}')
|
32
32
|
end
|
@@ -36,7 +36,7 @@ module LinkedRails
|
|
36
36
|
|
37
37
|
@menu_sequence ||=
|
38
38
|
LinkedRails::Sequence.new(
|
39
|
-
-> { menus
|
39
|
+
-> { menus },
|
40
40
|
id: menu_sequence_iri,
|
41
41
|
parent: self,
|
42
42
|
scope: false
|
@@ -52,6 +52,12 @@ module LinkedRails
|
|
52
52
|
sequence_iri
|
53
53
|
end
|
54
54
|
|
55
|
+
def menus
|
56
|
+
return @menus unless @menus.respond_to?(:call)
|
57
|
+
|
58
|
+
@menus = parent.instance_exec(&@menus).compact.each { |menu| menu.parent = self }
|
59
|
+
end
|
60
|
+
|
55
61
|
def rdf_type
|
56
62
|
type || Vocab.ontola[:MenuItem]
|
57
63
|
end
|
@@ -67,17 +73,8 @@ module LinkedRails
|
|
67
73
|
end
|
68
74
|
|
69
75
|
class << self
|
70
|
-
def base_includes
|
71
|
-
[action: :target]
|
72
|
-
end
|
73
|
-
|
74
76
|
def preview_includes
|
75
|
-
|
76
|
-
menu_sequence: [
|
77
|
-
members: base_includes +
|
78
|
-
[menu_sequence: [members: base_includes]]
|
79
|
-
]
|
80
|
-
]
|
77
|
+
[menu_sequence: [members: [menu_sequence: :members]]]
|
81
78
|
end
|
82
79
|
|
83
80
|
def requested_index_resource(params, user_context)
|
@@ -20,21 +20,28 @@ module LinkedRails
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def iri_opts
|
23
|
-
|
23
|
+
return {} if resource.blank?
|
24
|
+
|
25
|
+
resource.try(:singular_resource?) ? resource.singular_iri_opts : resource.iri_opts
|
24
26
|
end
|
25
27
|
|
26
28
|
def menus
|
27
|
-
@menus ||= available_menus.map(&method(:
|
29
|
+
@menus ||= available_menus.map(&method(:memoised_menu_item))
|
28
30
|
end
|
29
31
|
|
30
32
|
def menu(tag)
|
31
|
-
|
33
|
+
memoized_menu_item(tag, available_menus[tag].dup) if available_menus.key?(tag)
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
35
37
|
|
36
38
|
def default_label(tag, options)
|
37
|
-
I18n.t("menus.#{resource&.class&.name&.tableize}.#{tag}", options[:label_params])
|
39
|
+
I18n.t("menus.#{resource&.class&.name&.tableize}.#{tag}", **options[:label_params])
|
40
|
+
end
|
41
|
+
|
42
|
+
def memoized_menu_item(tag, options)
|
43
|
+
@memoized_menu_item ||= {}
|
44
|
+
@memoized_menu_item[tag] ||= menu_item(tag, options)
|
38
45
|
end
|
39
46
|
|
40
47
|
def menu_available?(_tag, options)
|
@@ -48,6 +55,7 @@ module LinkedRails
|
|
48
55
|
options[:label_params] ||= {}
|
49
56
|
options[:label_params][:default] ||= ["menus.default.#{tag}".to_sym, tag.to_s.capitalize]
|
50
57
|
options[:label] ||= default_label(tag, options)
|
58
|
+
options[:action] = ontola_dialog_action(options[:href]) if options.delete(:dialog)
|
51
59
|
options.except!(:policy_resource, :policy, :policy_arguments, :label_params)
|
52
60
|
LinkedRails.menus_item_class.new(resource: resource, tag: tag, parent: self, **options)
|
53
61
|
end
|
@@ -62,7 +70,9 @@ module LinkedRails
|
|
62
70
|
end
|
63
71
|
|
64
72
|
def iri_template
|
65
|
-
|
73
|
+
base_template = resource.send(resource.try(:singular_resource?) ? :singular_iri_template : :iri_template)
|
74
|
+
|
75
|
+
@iri_template ||= iri_template_expand_path(base_template, '/menus')
|
66
76
|
end
|
67
77
|
|
68
78
|
class << self
|
@@ -88,7 +98,7 @@ module LinkedRails
|
|
88
98
|
_defined_menus || {}
|
89
99
|
end
|
90
100
|
|
91
|
-
def has_menu(tag, opts
|
101
|
+
def has_menu(tag, **opts)
|
92
102
|
defined_menus[tag] = opts
|
93
103
|
end
|
94
104
|
|
@@ -100,7 +110,6 @@ module LinkedRails
|
|
100
110
|
LinkedRails::Sequence.new(
|
101
111
|
menu_list.menus,
|
102
112
|
id: menu_list.iri,
|
103
|
-
member_includes: Item.preview_includes,
|
104
113
|
scope: false
|
105
114
|
)
|
106
115
|
end
|
@@ -9,7 +9,7 @@ module LinkedRails
|
|
9
9
|
|
10
10
|
def data
|
11
11
|
data = []
|
12
|
-
iri.each_statement do |statement|
|
12
|
+
iri.try(:each_statement) do |statement|
|
13
13
|
next unless include_data_statement?(statement)
|
14
14
|
|
15
15
|
statement.graph_name = ::RDF::Serializers.config.default_graph
|
@@ -41,6 +41,8 @@ module LinkedRails
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def include_data_statement?(statement)
|
44
|
+
return false if statement.subject.node? || statement.object.node?
|
45
|
+
|
44
46
|
statement.predicate != Vocab.rdfs.label &&
|
45
47
|
statement.predicate != Vocab.rdfs.range &&
|
46
48
|
statement.predicate != Vocab.rdfs.domain
|
@@ -12,10 +12,10 @@ module LinkedRails
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def parent_class
|
15
|
-
if klass
|
15
|
+
if klass&.superclass == ApplicationRecord
|
16
16
|
Vocab.schema.Thing
|
17
17
|
else
|
18
|
-
klass
|
18
|
+
klass&.superclass.try(:iri) || Vocab.schema.Thing
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -26,7 +26,7 @@ module LinkedRails
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def properties
|
29
|
-
@properties ||= klass
|
29
|
+
@properties ||= klass&.predicate_mapping&.keys&.map { |key| LinkedRails.ontology_property_class.new(iri: key) }
|
30
30
|
end
|
31
31
|
|
32
32
|
class << self
|
@@ -6,11 +6,11 @@ module LinkedRails
|
|
6
6
|
include LinkedRails::Model
|
7
7
|
|
8
8
|
def classes
|
9
|
-
@classes ||=
|
9
|
+
@classes ||= LinkedRails.linked_models.map do |klass|
|
10
10
|
iri = klass.iri.is_a?(Array) ? klass.iri.first : klass.iri
|
11
11
|
|
12
|
-
LinkedRails.ontology_class_class.new(klass: klass, iri: iri)
|
13
|
-
end
|
12
|
+
LinkedRails.ontology_class_class.new(klass: klass, iri: iri) if iri
|
13
|
+
end.compact
|
14
14
|
end
|
15
15
|
|
16
16
|
def properties
|
@@ -26,8 +26,8 @@ module LinkedRails
|
|
26
26
|
%i[classes properties]
|
27
27
|
end
|
28
28
|
|
29
|
-
def requested_resource(
|
30
|
-
LinkedRails.ontology_class.new
|
29
|
+
def requested_resource(opts, _user_context)
|
30
|
+
LinkedRails.ontology_class.new if opts[:iri].include?(new.root_relative_iri)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class Sequence
|
5
|
-
attr_accessor :node, :
|
5
|
+
attr_accessor :node, :parent, :raw_members, :scope, :user_context
|
6
6
|
alias read_attribute_for_serialization send
|
7
7
|
|
8
|
-
def initialize(members, opts
|
9
|
-
self.member_includes = opts[:member_includes]
|
8
|
+
def initialize(members, **opts)
|
10
9
|
self.node = opts[:id] || RDF::Node.new
|
11
10
|
self.parent = opts[:parent]
|
12
11
|
self.raw_members = members
|
@@ -14,7 +13,7 @@ module LinkedRails
|
|
14
13
|
self.user_context = opts[:user_context]
|
15
14
|
end
|
16
15
|
|
17
|
-
def iri(_opts
|
16
|
+
def iri(**_opts)
|
18
17
|
node
|
19
18
|
end
|
20
19
|
alias id iri
|
@@ -26,21 +25,13 @@ module LinkedRails
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def preview_includes
|
29
|
-
[members
|
28
|
+
[:members]
|
30
29
|
end
|
31
30
|
|
32
31
|
def rdf_type
|
33
32
|
self.class.iri
|
34
33
|
end
|
35
34
|
|
36
|
-
def sequence
|
37
|
-
return [] unless members
|
38
|
-
|
39
|
-
members.map.with_index do |item, index|
|
40
|
-
[iri, RDF["_#{index}"], item_iri(item), Vocab.ll[:supplant]]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
35
|
private
|
45
36
|
|
46
37
|
def apply_scope(association)
|
@@ -8,7 +8,7 @@ module LinkedRails
|
|
8
8
|
attr_writer :resources, :size
|
9
9
|
attr_accessor :parent, :topology
|
10
10
|
|
11
|
-
def iri(_opts
|
11
|
+
def iri(**_opts)
|
12
12
|
@iri ||= RDF::Node.new
|
13
13
|
end
|
14
14
|
|
@@ -19,12 +19,9 @@ module LinkedRails
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def resource_sequence
|
22
|
-
@resource_sequence ||=
|
23
|
-
|
24
|
-
|
25
|
-
parent: self,
|
26
|
-
scope: false
|
27
|
-
)
|
22
|
+
@resource_sequence ||= @resources.map do |iri, predicate|
|
23
|
+
predicate.present? ? property_shape(iri, predicate) : RDF::URI(iri)
|
24
|
+
end
|
28
25
|
end
|
29
26
|
|
30
27
|
def size
|
@@ -46,10 +43,6 @@ module LinkedRails
|
|
46
43
|
def iri
|
47
44
|
Vocab.ontola[:Widget]
|
48
45
|
end
|
49
|
-
|
50
|
-
def preview_includes
|
51
|
-
%i[resource_sequence property_shapes]
|
52
|
-
end
|
53
46
|
end
|
54
47
|
end
|
55
48
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class CollectionPolicy < LinkedRails.policy_parent_class
|
5
|
-
delegate :permitted_attributes, to: :child_policy
|
5
|
+
delegate :permitted_attributes, :permitted_attributes_from_filters, to: :child_policy
|
6
6
|
|
7
7
|
def create_child?
|
8
8
|
policy = Pundit.policy!(user_context, child_resource)
|
@@ -29,7 +29,7 @@ module LinkedRails
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def child_resource
|
32
|
-
record.
|
32
|
+
record.child_resource
|
33
33
|
end
|
34
34
|
|
35
35
|
def parent_policy
|
@@ -12,17 +12,17 @@ module LinkedRails
|
|
12
12
|
end
|
13
13
|
attribute :action_status, predicate: Vocab.schema.actionStatus
|
14
14
|
attribute :favorite, predicate: Vocab.ontola[:favoriteAction]
|
15
|
-
attribute :
|
15
|
+
attribute :one_click, predicate: Vocab.ontola[:oneClick]
|
16
|
+
attribute :target_url, predicate: Vocab.schema.url do |object|
|
16
17
|
object.target[:id] if object.target.is_a?(Hash)
|
17
18
|
end
|
18
19
|
attribute :error, predicate: Vocab.schema.error
|
19
20
|
|
20
|
-
has_one :parent, predicate: Vocab.schema.isPartOf
|
21
|
+
has_one :parent, predicate: Vocab.schema.isPartOf do |object|
|
21
22
|
object.parent unless object.parent.try(:anonymous_iri?)
|
22
23
|
end
|
23
|
-
|
24
|
-
has_one :target, predicate: Vocab.schema.target
|
25
|
-
has_one :included_object, polymorphic: true
|
24
|
+
attribute :object_iri, predicate: Vocab.schema.object
|
25
|
+
has_one :target, predicate: Vocab.schema.target
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -5,8 +5,9 @@ module LinkedRails
|
|
5
5
|
class FilterFieldSerializer < LinkedRails.serializer_parent_class
|
6
6
|
attribute :key, predicate: Vocab.ontola[:filterKey]
|
7
7
|
attribute :options_in, predicate: Vocab.ontola[:filterOptionsIn]
|
8
|
-
|
9
|
-
|
8
|
+
attribute :visible?, predicate: Vocab.ontola[:visible]
|
9
|
+
has_one :collection, predicate: Vocab.schema.isPartOf
|
10
|
+
has_many :options, predicate: Vocab.ontola[:filterOptions]
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -6,7 +6,7 @@ module LinkedRails
|
|
6
6
|
attribute :count, predicate: Vocab.ontola[:filterCount]
|
7
7
|
attribute :key, predicate: Vocab.ontola[:filterKey]
|
8
8
|
attribute :value, predicate: Vocab.ontola[:filterValue]
|
9
|
-
has_one :collection, predicate: Vocab.schema[:isPartOf]
|
9
|
+
has_one :collection, predicate: Vocab.schema[:isPartOf]
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -7,7 +7,7 @@ module LinkedRails
|
|
7
7
|
|
8
8
|
attribute :key, predicate: Vocab.ontola[:filterKey]
|
9
9
|
attribute :value, predicate: Vocab.ontola[:filterValue]
|
10
|
-
has_one :collection, predicate: Vocab.schema.isPartOf
|
10
|
+
has_one :collection, predicate: Vocab.schema.isPartOf
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -7,7 +7,7 @@ module LinkedRails
|
|
7
7
|
|
8
8
|
attribute :key, predicate: Vocab.ontola[:sortKey]
|
9
9
|
attribute :direction, predicate: Vocab.ontola[:sortDirection]
|
10
|
-
has_one :collection, predicate: Vocab.schema.isPartOf
|
10
|
+
has_one :collection, predicate: Vocab.schema.isPartOf
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -14,9 +14,9 @@ module LinkedRails
|
|
14
14
|
attribute attr, predicate: Vocab.as[attr]
|
15
15
|
end
|
16
16
|
|
17
|
-
has_one :collection, predicate: Vocab.as.partOf
|
18
|
-
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
|
19
|
-
has_one :member_sequence, predicate: Vocab.as.items
|
17
|
+
has_one :collection, predicate: Vocab.as.partOf
|
18
|
+
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
|
19
|
+
has_one :member_sequence, predicate: Vocab.as.items
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -11,12 +11,13 @@ module LinkedRails
|
|
11
11
|
attribute :total_count, predicate: Vocab.as.totalItems do |object|
|
12
12
|
object.total_count if object.type == :paginated
|
13
13
|
end
|
14
|
-
attribute :
|
14
|
+
attribute :serialized_iri_template, predicate: Vocab.ontola[:iriTemplate]
|
15
15
|
attribute :iri_template_opts, predicate: Vocab.ontola[:iriTemplateOpts]
|
16
16
|
attribute :default_type, predicate: Vocab.ontola[:defaultType], &:type
|
17
17
|
attribute :display, predicate: Vocab.ontola[:collectionDisplay] do |object|
|
18
18
|
Vocab.ontola["collectionDisplay/#{object.display || :default}"]
|
19
19
|
end
|
20
|
+
attribute :call_to_action, predicate: Vocab.ontola[:callToAction]
|
20
21
|
attribute :columns, predicate: Vocab.ontola[:columns]
|
21
22
|
attribute :collection_type, predicate: Vocab.ontola[:collectionType] do |object|
|
22
23
|
Vocab.ontola["collectionType/#{object.type || :paginated}"]
|
@@ -25,17 +26,17 @@ module LinkedRails
|
|
25
26
|
attribute :sort_options, predicate: Vocab.ontola[:sortOptions]
|
26
27
|
attribute :view, predicate: Vocab.ll[:view]
|
27
28
|
|
28
|
-
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
|
29
|
-
has_one :part_of, predicate: Vocab.schema.isPartOf
|
29
|
+
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
|
30
|
+
has_one :part_of, predicate: Vocab.schema.isPartOf do |object|
|
30
31
|
object.part_of unless object.part_of.try(:anonymous_iri?)
|
31
32
|
end
|
32
|
-
has_one :default_view, predicate: Vocab.ontola[:pages]
|
33
|
+
has_one :default_view, predicate: Vocab.ontola[:pages]
|
33
34
|
|
34
|
-
has_many :filter_fields, predicate: Vocab.ontola[:filterFields],
|
35
|
-
has_many :filters, predicate: Vocab.ontola[:
|
35
|
+
has_many :filter_fields, predicate: Vocab.ontola[:filterFields], sequence: true
|
36
|
+
has_many :filters, predicate: Vocab.ontola[:activeFilters] do |object|
|
36
37
|
object.filters.reject(&:default_filter)
|
37
38
|
end
|
38
|
-
has_many :sortings,
|
39
|
+
has_many :sortings, predicate: Vocab.ontola[:collectionSorting]
|
39
40
|
|
40
41
|
%i[first last].each do |attr|
|
41
42
|
attribute attr, predicate: Vocab.as[attr]
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class ConditionSerializer < LinkedRails.serializer_parent_class
|
5
|
-
has_one :fail, predicate: Vocab.ontola[:fail]
|
6
|
-
has_one :pass, predicate: Vocab.ontola[:pass]
|
7
|
-
has_one :shape, predicate: Vocab.sh.node
|
5
|
+
has_one :fail, predicate: Vocab.ontola[:fail]
|
6
|
+
has_one :pass, predicate: Vocab.ontola[:pass]
|
7
|
+
has_one :shape, predicate: Vocab.sh.node
|
8
8
|
end
|
9
9
|
end
|