habarico 7.2.0.pre.beta.5
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +82 -0
- data/Rakefile +15 -0
- data/VERSION +1 -0
- data/app/controllers/habarico/action_schema_controller.rb +41 -0
- data/app/controllers/habarico/application_controller.rb +15 -0
- data/app/controllers/habarico/contrib/preferences/user_preferences_controller.rb +105 -0
- data/app/controllers/habarico/global_schema_controller.rb +11 -0
- data/app/controllers/habarico/local_schema_controller.rb +35 -0
- data/app/helpers/habarico/application_helper.rb +4 -0
- data/app/models/habarico/application_record.rb +5 -0
- data/app/views/layouts/habarico/application.html.erb +17 -0
- data/config/locales/cs.yml +39 -0
- data/config/locales/de.yml +39 -0
- data/config/locales/en.yml +39 -0
- data/config/locales/es.yml +39 -0
- data/config/locales/fr.yml +39 -0
- data/config/locales/it.yml +39 -0
- data/config/locales/ja.yml +39 -0
- data/config/locales/nl.yml +39 -0
- data/config/locales/pl.yml +39 -0
- data/config/locales/pt.yml +39 -0
- data/config/locales/ro.yml +39 -0
- data/config/locales/sk.yml +39 -0
- data/config/locales/uk.yml +39 -0
- data/config/routes.rb +1 -0
- data/lib/generators/habarico/preferences/install_generator.rb +27 -0
- data/lib/generators/habarico/preferences/templates/create_habarico_user_preferences.rb.tt +15 -0
- data/lib/habarico/active_model/references.rb +68 -0
- data/lib/habarico/authenticatable.rb +31 -0
- data/lib/habarico/config.rb +71 -0
- data/lib/habarico/context.rb +126 -0
- data/lib/habarico/contrib/preferences/base_preferences.rb +40 -0
- data/lib/habarico/contrib/preferences/config.rb +31 -0
- data/lib/habarico/contrib/preferences/errors.rb +79 -0
- data/lib/habarico/contrib/preferences/locales/cs.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/de.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/en.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/es.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/fr.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/it.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/ja.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/nl.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/pl.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/pt.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/ro.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/sk.yml +8 -0
- data/lib/habarico/contrib/preferences/locales/uk.yml +8 -0
- data/lib/habarico/contrib/preferences/registry.rb +293 -0
- data/lib/habarico/contrib/preferences/routes.rb +17 -0
- data/lib/habarico/contrib/preferences/schemas.rb +129 -0
- data/lib/habarico/contrib/preferences/serializer.rb +19 -0
- data/lib/habarico/contrib/preferences/user_preference.rb +16 -0
- data/lib/habarico/contrib/preferences.rb +32 -0
- data/lib/habarico/controller.rb +584 -0
- data/lib/habarico/definition/action_reference.rb +18 -0
- data/lib/habarico/definition/actions/action.rb +14 -0
- data/lib/habarico/definition/actions/create_action.rb +18 -0
- data/lib/habarico/definition/actions/delete_action.rb +20 -0
- data/lib/habarico/definition/actions/edit_action.rb +18 -0
- data/lib/habarico/definition/actions/link_action.rb +11 -0
- data/lib/habarico/definition/actions/resource_action.rb +12 -0
- data/lib/habarico/definition/actions/save_action.rb +14 -0
- data/lib/habarico/definition/actions/show_action.rb +18 -0
- data/lib/habarico/definition/actions/upload_images_action.rb +11 -0
- data/lib/habarico/definition/actions/view_action.rb +11 -0
- data/lib/habarico/definition/boxes/array_box.rb +10 -0
- data/lib/habarico/definition/boxes/box.rb +32 -0
- data/lib/habarico/definition/boxes/gallery_box.rb +10 -0
- data/lib/habarico/definition/boxes/grid_box.rb +10 -0
- data/lib/habarico/definition/boxes/grid_item_box.rb +10 -0
- data/lib/habarico/definition/boxes/list_box.rb +10 -0
- data/lib/habarico/definition/boxes/object_box.rb +10 -0
- data/lib/habarico/definition/boxes/tab_box.rb +10 -0
- data/lib/habarico/definition/boxes/tab_item_box.rb +10 -0
- data/lib/habarico/definition/boxes/wizard_box.rb +10 -0
- data/lib/habarico/definition/concerns/definition_model.rb +38 -0
- data/lib/habarico/definition/definition.rb +206 -0
- data/lib/habarico/definition/field_reference.rb +9 -0
- data/lib/habarico/definition/filter_reference.rb +7 -0
- data/lib/habarico/definition/menu/link_menu_item.rb +12 -0
- data/lib/habarico/definition/menu/menu_item.rb +9 -0
- data/lib/habarico/definition/menu/text_menu_item.rb +12 -0
- data/lib/habarico/definition/menu/view_menu_item.rb +13 -0
- data/lib/habarico/definition/response.rb +13 -0
- data/lib/habarico/definition/views/action_view.rb +11 -0
- data/lib/habarico/definition/views/create_view.rb +15 -0
- data/lib/habarico/definition/views/edit_view.rb +15 -0
- data/lib/habarico/definition/views/list_view.rb +17 -0
- data/lib/habarico/definition/views/show_view.rb +15 -0
- data/lib/habarico/definition/views/view.rb +10 -0
- data/lib/habarico/engine.rb +6 -0
- data/lib/habarico/file_validations.rb +119 -0
- data/lib/habarico/generators/abstract_generator.rb +21 -0
- data/lib/habarico/generators/action/action_schema_generator.rb +111 -0
- data/lib/habarico/generators/action/confirm_dialog_properties_generator.rb +30 -0
- data/lib/habarico/generators/action/global_resource_action_schema_generator.rb +46 -0
- data/lib/habarico/generators/action/link_action_parameters_generator.rb +31 -0
- data/lib/habarico/generators/action/resource_action_endpoint_parameters_generator.rb +70 -0
- data/lib/habarico/generators/action/resource_action_parameters_generator.rb +40 -0
- data/lib/habarico/generators/action/resource_action_schema_generator.rb +51 -0
- data/lib/habarico/generators/action/save_action_parameters_generator.rb +26 -0
- data/lib/habarico/generators/action/upload_images_action_parameters_generator.rb +41 -0
- data/lib/habarico/generators/action/view_action_endpoint_parameters_generator.rb +37 -0
- data/lib/habarico/generators/action/view_action_parameters_generator.rb +56 -0
- data/lib/habarico/generators/endpoint/dynamic_render_options_generator.rb +26 -0
- data/lib/habarico/generators/endpoint/endpoints_schema_generator.rb +61 -0
- data/lib/habarico/generators/endpoint/enum_type_generator.rb +45 -0
- data/lib/habarico/generators/endpoint/field_options_generator.rb +179 -0
- data/lib/habarico/generators/endpoint/field_schema_generator.rb +381 -0
- data/lib/habarico/generators/endpoint/fields_schema_generator.rb +35 -0
- data/lib/habarico/generators/endpoint/filter_schema_generator.rb +201 -0
- data/lib/habarico/generators/endpoint/filters_schema_generator.rb +25 -0
- data/lib/habarico/generators/endpoint/method_schema_generator.rb +34 -0
- data/lib/habarico/generators/endpoint/number_field_options_generator.rb +45 -0
- data/lib/habarico/generators/endpoint/phone_field_options_generator.rb +29 -0
- data/lib/habarico/generators/endpoint/relation_field_options_generator.rb +90 -0
- data/lib/habarico/generators/endpoint/search_filter_schema_generator.rb +44 -0
- data/lib/habarico/generators/menu/menu_group_schema_generator.rb +63 -0
- data/lib/habarico/generators/menu/menu_link_parameters_generator.rb +31 -0
- data/lib/habarico/generators/menu/menu_schema_generator.rb +105 -0
- data/lib/habarico/generators/menu/menu_view_endpoint_parameters_generator.rb +44 -0
- data/lib/habarico/generators/menu/menu_view_parameters_generator.rb +50 -0
- data/lib/habarico/generators/resource/action_resource_schema_generator.rb +84 -0
- data/lib/habarico/generators/resource/global_resource_schema_generator.rb +70 -0
- data/lib/habarico/generators/resource/local_resource_schema_generator.rb +111 -0
- data/lib/habarico/generators/resource/object_resource_schema_generator.rb +49 -0
- data/lib/habarico/generators/resource/resource_schema_generator.rb +31 -0
- data/lib/habarico/generators/view/action_descriptor_generator.rb +88 -0
- data/lib/habarico/generators/view/array_box_parameters_generator.rb +34 -0
- data/lib/habarico/generators/view/box_options_generator.rb +23 -0
- data/lib/habarico/generators/view/box_schema_generator.rb +194 -0
- data/lib/habarico/generators/view/detail_view_parameters_generator.rb +57 -0
- data/lib/habarico/generators/view/field_descriptor_generator.rb +107 -0
- data/lib/habarico/generators/view/filter_descriptor_generator.rb +75 -0
- data/lib/habarico/generators/view/gallery_box_parameters_generator.rb +71 -0
- data/lib/habarico/generators/view/global_view_schema_generator.rb +59 -0
- data/lib/habarico/generators/view/grid_item_box_parameters_generator.rb +44 -0
- data/lib/habarico/generators/view/list_box_parameters_generator.rb +124 -0
- data/lib/habarico/generators/view/list_view_parameters_generator.rb +120 -0
- data/lib/habarico/generators/view/object_box_parameters_generator.rb +26 -0
- data/lib/habarico/generators/view/sort_descriptor_generator.rb +30 -0
- data/lib/habarico/generators/view/tab_box_parameters_generator.rb +26 -0
- data/lib/habarico/generators/view/view_endpoint_parameters_generator.rb +71 -0
- data/lib/habarico/generators/view/view_schema_generator.rb +87 -0
- data/lib/habarico/generators/view/wizard_box_parameters_generator.rb +32 -0
- data/lib/habarico/helpers/action_helper.rb +9 -0
- data/lib/habarico/helpers/attributes_helper.rb +67 -0
- data/lib/habarico/helpers/box_helper.rb +19 -0
- data/lib/habarico/helpers/callable_helper.rb +15 -0
- data/lib/habarico/helpers/filter_params_helper.rb +49 -0
- data/lib/habarico/helpers/order_by_helper.rb +56 -0
- data/lib/habarico/helpers/reflection_helper.rb +61 -0
- data/lib/habarico/helpers/sorting_helper.rb +136 -0
- data/lib/habarico/schema/action/action_schema.rb +46 -0
- data/lib/habarico/schema/action/confirm_dialog_properties.rb +13 -0
- data/lib/habarico/schema/action/global_resource_action_schema.rb +29 -0
- data/lib/habarico/schema/action/link_action_parameters.rb +15 -0
- data/lib/habarico/schema/action/resource_action_endpoint_parameters.rb +24 -0
- data/lib/habarico/schema/action/resource_action_parameters.rb +17 -0
- data/lib/habarico/schema/action/resource_action_schema.rb +14 -0
- data/lib/habarico/schema/action/save_action_parameters.rb +10 -0
- data/lib/habarico/schema/action/upload_images_action_parameters.rb +23 -0
- data/lib/habarico/schema/action/view_action_endpoint_parameters.rb +16 -0
- data/lib/habarico/schema/action/view_action_parameters.rb +27 -0
- data/lib/habarico/schema/endpoint/ai_field_options.rb +10 -0
- data/lib/habarico/schema/endpoint/box_options.rb +10 -0
- data/lib/habarico/schema/endpoint/choices_field_options.rb +10 -0
- data/lib/habarico/schema/endpoint/dynamic_render_options.rb +14 -0
- data/lib/habarico/schema/endpoint/endpoints_schema.rb +22 -0
- data/lib/habarico/schema/endpoint/enum_type.rb +21 -0
- data/lib/habarico/schema/endpoint/field_options.rb +56 -0
- data/lib/habarico/schema/endpoint/field_schema.rb +65 -0
- data/lib/habarico/schema/endpoint/filter_schema.rb +44 -0
- data/lib/habarico/schema/endpoint/image_field_options.rb +13 -0
- data/lib/habarico/schema/endpoint/key_value.rb +13 -0
- data/lib/habarico/schema/endpoint/method_schema.rb +13 -0
- data/lib/habarico/schema/endpoint/number_field_options.rb +24 -0
- data/lib/habarico/schema/endpoint/phone_field_options.rb +13 -0
- data/lib/habarico/schema/endpoint/relation_field_options.rb +39 -0
- data/lib/habarico/schema/extensible_enum.rb +20 -0
- data/lib/habarico/schema/menu/action_view_choice.rb +13 -0
- data/lib/habarico/schema/menu/menu_group_schema.rb +26 -0
- data/lib/habarico/schema/menu/menu_schema.rb +36 -0
- data/lib/habarico/schema/resource/global_resource_schema.rb +14 -0
- data/lib/habarico/schema/resource/local_resource_schema.rb +14 -0
- data/lib/habarico/schema/resource/object_resource_schema.rb +8 -0
- data/lib/habarico/schema/resource/resource_schema.rb +16 -0
- data/lib/habarico/schema/types.rb +102 -0
- data/lib/habarico/schema/view/action_descriptor.rb +30 -0
- data/lib/habarico/schema/view/array_box_parameters.rb +13 -0
- data/lib/habarico/schema/view/box_schema.rb +67 -0
- data/lib/habarico/schema/view/detail_view_parameters.rb +16 -0
- data/lib/habarico/schema/view/field_descriptor.rb +50 -0
- data/lib/habarico/schema/view/field_wrapper_properties.rb +13 -0
- data/lib/habarico/schema/view/filter_descriptor.rb +24 -0
- data/lib/habarico/schema/view/gallery_box_parameters.rb +31 -0
- data/lib/habarico/schema/view/global_view_schema.rb +25 -0
- data/lib/habarico/schema/view/grid_item_box_parameters.rb +13 -0
- data/lib/habarico/schema/view/list_box_parameters.rb +44 -0
- data/lib/habarico/schema/view/list_view_parameters.rb +31 -0
- data/lib/habarico/schema/view/object_box_parameters.rb +10 -0
- data/lib/habarico/schema/view/sort_descriptor.rb +15 -0
- data/lib/habarico/schema/view/sortable_parameters.rb +13 -0
- data/lib/habarico/schema/view/tab_box_parameters.rb +10 -0
- data/lib/habarico/schema/view/view_action_descriptor_parameters.rb +21 -0
- data/lib/habarico/schema/view/view_endpoint_parameters.rb +22 -0
- data/lib/habarico/schema/view/view_schema.rb +33 -0
- data/lib/habarico/schema/view/wizard_box_parameters.rb +13 -0
- data/lib/habarico/search/field_resolver.rb +138 -0
- data/lib/habarico/search/search_matcher.rb +152 -0
- data/lib/habarico/serializers/meta_serializer.rb +42 -0
- data/lib/habarico/serializers/record_serializer.rb +33 -0
- data/lib/habarico/serializers/serializer.rb +61 -0
- data/lib/habarico/services/resource_service.rb +69 -0
- data/lib/habarico/services/routing_service.rb +160 -0
- data/lib/habarico/services/schema_service.rb +72 -0
- data/lib/habarico/version.rb +5 -0
- data/lib/habarico.rb +262 -0
- metadata +324 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class GlobalResourceActionSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Name of the action used for coupling with the action descriptor
|
|
8
|
+
string_attr :name
|
|
9
|
+
|
|
10
|
+
# Type of the action.
|
|
11
|
+
# `view` - opens a new view as redirect or dialog
|
|
12
|
+
# `link` - opens an external link
|
|
13
|
+
# `resource` - performs an action on the resource (like delete, update, etc.
|
|
14
|
+
string_attr :type
|
|
15
|
+
# Deliberately a subset of Types::ACTION_TYPE - the global schema only advertises the action
|
|
16
|
+
# types that can be rendered without a resource context.
|
|
17
|
+
enum_attr :type, %i[view link resource]
|
|
18
|
+
|
|
19
|
+
# Flag indicating if the action uses primary key or not
|
|
20
|
+
boolean_attr :is_detail
|
|
21
|
+
|
|
22
|
+
# Flag indicating if the action should be shown in detail view
|
|
23
|
+
boolean_attr :show_in_detail
|
|
24
|
+
|
|
25
|
+
# Flag indicating if the action should be shown in list view
|
|
26
|
+
boolean_attr :show_in_list
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class LinkActionParameters
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# External URL for the action link
|
|
8
|
+
string_attr :url
|
|
9
|
+
|
|
10
|
+
# Target for opening the link, either in the same tab or a new tab
|
|
11
|
+
string_attr :target
|
|
12
|
+
enum_attr :target, Types::LINK_TARGET_TYPE
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ResourceActionEndpointParameters
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# API path for the requested endpoint
|
|
8
|
+
string_attr :path
|
|
9
|
+
|
|
10
|
+
# HTTP method for the requested endpoint
|
|
11
|
+
string_attr :method
|
|
12
|
+
enum_attr :method, Types::REQUEST_METHOD_TYPE
|
|
13
|
+
|
|
14
|
+
# Reference to another resource, if applicable
|
|
15
|
+
string_attr :reference
|
|
16
|
+
|
|
17
|
+
# Name of the controller action associated with the endpoint, if applicable
|
|
18
|
+
string_attr :action_name
|
|
19
|
+
|
|
20
|
+
# Primary key of the requested record, if applicable
|
|
21
|
+
string_attr :record_pk
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ResourceActionParameters
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Flag indicating if the resource action is a background task
|
|
8
|
+
boolean_attr :is_background
|
|
9
|
+
|
|
10
|
+
# Additional data which will be sent to the action
|
|
11
|
+
any_attr :data
|
|
12
|
+
|
|
13
|
+
# Definition of the endpoint
|
|
14
|
+
has_one_attr :endpoint, 'Habarico::ResourceActionEndpointParameters'
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ResourceActionSchema < ActionSchema
|
|
3
|
+
|
|
4
|
+
# Name of the action used for coupling with the action descriptor
|
|
5
|
+
string_attr :name
|
|
6
|
+
|
|
7
|
+
# Flag indicating if the action should be shown in detail view
|
|
8
|
+
boolean_attr :show_in_detail
|
|
9
|
+
|
|
10
|
+
# Flag indicating if the action should be shown in list view
|
|
11
|
+
boolean_attr :show_in_list
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class UploadImagesActionParameters
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Resource where images will be created. When set, uploads to this resource
|
|
7
|
+
# instead of the current resource context.
|
|
8
|
+
string_attr :reference
|
|
9
|
+
|
|
10
|
+
# Field name on the image model linking to the parent record.
|
|
11
|
+
# When set together with reference, the current record's ID is used as the target value.
|
|
12
|
+
string_attr :target
|
|
13
|
+
|
|
14
|
+
# Array of accepted file extensions (e.g. [".png", ".jpg"]).
|
|
15
|
+
# When not set, the frontend uses its own default (.png,.jpg,.jpeg,.bmp,.gif).
|
|
16
|
+
any_attr :accept
|
|
17
|
+
|
|
18
|
+
# Field name on the target model that holds the uploaded file. Required by the
|
|
19
|
+
# frontend to know which attribute to set on the record it creates for each upload.
|
|
20
|
+
string_attr :image_field
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ViewActionEndpointParameters
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Reference to another resource, if applicable
|
|
7
|
+
string_attr :reference
|
|
8
|
+
|
|
9
|
+
# Name of the controller action associated with the endpoint, if applicable
|
|
10
|
+
string_attr :action_name
|
|
11
|
+
|
|
12
|
+
# Primary key of the requested record, if applicable
|
|
13
|
+
string_attr :record_pk
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ViewActionParameters
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Name of the view to be rendered, used for coupling with view schema
|
|
8
|
+
string_attr :name
|
|
9
|
+
|
|
10
|
+
# Mode in which to display the action view: redirect to a standalone page, dialog, or side panel
|
|
11
|
+
string_attr :mode
|
|
12
|
+
enum_attr :mode, Types::VIEW_MODE_TYPE
|
|
13
|
+
|
|
14
|
+
# Width of the dialog, only used when mode is dialog (MUI breakpoint or CSS width value)
|
|
15
|
+
string_attr :dialog_width
|
|
16
|
+
|
|
17
|
+
# Definition of the endpoint
|
|
18
|
+
has_one_attr :endpoint, 'Habarico::ViewActionEndpointParameters'
|
|
19
|
+
|
|
20
|
+
# Additional parameters to be passed to the view
|
|
21
|
+
has_many_attr :parameters, 'String', underlying_type: :hash
|
|
22
|
+
|
|
23
|
+
# Keep linked parent in the URL when navigating to the linked resource
|
|
24
|
+
boolean_attr :keep_linked_parent
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class BoxOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Options for dynamic rendering of the box (conditional show/required)
|
|
7
|
+
has_one_attr :dynamic_render, 'Habarico::DynamicRenderOptions'
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class DynamicRenderOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# The field will be shown if query is true
|
|
8
|
+
string_attr :show_query
|
|
9
|
+
|
|
10
|
+
# The field will be required if query is true
|
|
11
|
+
string_attr :required_query
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class EndpointsSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Endpoint definition for GET method
|
|
7
|
+
has_one_attr :get, 'Habarico::MethodSchema'
|
|
8
|
+
|
|
9
|
+
# Endpoint definition for POST method
|
|
10
|
+
has_one_attr :post, 'Habarico::MethodSchema'
|
|
11
|
+
|
|
12
|
+
# Endpoint definition for PATCH method
|
|
13
|
+
has_one_attr :patch, 'Habarico::MethodSchema'
|
|
14
|
+
|
|
15
|
+
# Endpoint definition for PUT method
|
|
16
|
+
has_one_attr :put, 'Habarico::MethodSchema'
|
|
17
|
+
|
|
18
|
+
# Endpoint definition for DELETE method
|
|
19
|
+
has_one_attr :delete, 'Habarico::MethodSchema'
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class EnumType
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Value of the enum item
|
|
8
|
+
string_attr :value
|
|
9
|
+
|
|
10
|
+
# Human-readable label of the enum item
|
|
11
|
+
string_attr :label
|
|
12
|
+
|
|
13
|
+
# Color of the enum item. Uses standard MUI color types
|
|
14
|
+
string_attr :color
|
|
15
|
+
enum_attr :color, Types::COLOR_TYPE
|
|
16
|
+
|
|
17
|
+
# Icon of the enum item
|
|
18
|
+
string_attr :icon
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class FieldOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Prefix to add before the field value
|
|
8
|
+
string_attr :prefix
|
|
9
|
+
|
|
10
|
+
# Postfix to add after the field value
|
|
11
|
+
string_attr :postfix
|
|
12
|
+
|
|
13
|
+
# Alignment of the field value
|
|
14
|
+
string_attr :text_align
|
|
15
|
+
enum_attr :text_align, Types::TEXT_ALIGN_TYPE
|
|
16
|
+
|
|
17
|
+
# Where the field's link opens when the value is clicked. Stored without the leading underscore
|
|
18
|
+
# ('blank', not '_blank') - the frontend prepends it when rendering the anchor.
|
|
19
|
+
# Unrelated to a box's 'target', which names the nested attribute or foreign key.
|
|
20
|
+
string_attr :target
|
|
21
|
+
enum_attr :target, Types::LINK_TARGET_TYPE
|
|
22
|
+
|
|
23
|
+
# Options for formatting the number values
|
|
24
|
+
has_one_attr :number, 'Habarico::NumberFieldOptions'
|
|
25
|
+
|
|
26
|
+
# Options for dynamic rendering of the field value
|
|
27
|
+
has_one_attr :dynamic_render, 'Habarico::DynamicRenderOptions'
|
|
28
|
+
|
|
29
|
+
# Options for relation fields (how the related resource is displayed and linked)
|
|
30
|
+
has_one_attr :relation, 'Habarico::RelationFieldOptions'
|
|
31
|
+
|
|
32
|
+
# Options for the phone number field
|
|
33
|
+
has_one_attr :phone, 'Habarico::PhoneFieldOptions'
|
|
34
|
+
|
|
35
|
+
# Options for choices fields (icon lookup, etc.)
|
|
36
|
+
has_one_attr :choices, 'Habarico::ChoicesFieldOptions'
|
|
37
|
+
|
|
38
|
+
# Options for image fields (resizing, cropping)
|
|
39
|
+
has_one_attr :image, 'Habarico::ImageFieldOptions'
|
|
40
|
+
|
|
41
|
+
# Options for AI-generated fields
|
|
42
|
+
has_one_attr :ai, 'Habarico::AiFieldOptions'
|
|
43
|
+
|
|
44
|
+
# Largest file (bytes) the frontend accepts for this field, checked before the upload starts.
|
|
45
|
+
# Derived from a `file_attr`'s own `active_storage_validations` size declaration (HAB-966); see
|
|
46
|
+
# `Habarico::FileValidations`. `habarico_enterprise.uploads` additionally folds in its
|
|
47
|
+
# project-wide `Config.max_upload_size` ceiling for a field a chunked-upload provider serves.
|
|
48
|
+
integer_attr :max_size
|
|
49
|
+
|
|
50
|
+
# File types the frontend accepts for this field, checked before the upload starts. Derived
|
|
51
|
+
# from a `file_attr`'s own `active_storage_validations` content-type declaration (HAB-966); see
|
|
52
|
+
# `Habarico::FileValidations`.
|
|
53
|
+
has_many_attr :accept, 'String'
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class FieldSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
include Habarico::ExtensibleEnum
|
|
7
|
+
|
|
8
|
+
# Name of the field in the data model, used for coupling with field descriptor
|
|
9
|
+
string_attr :name
|
|
10
|
+
|
|
11
|
+
# Data type of the field
|
|
12
|
+
string_attr :type
|
|
13
|
+
extensible_enum_attr :type, :FIELD_TYPE
|
|
14
|
+
|
|
15
|
+
# Format of the field, applied to specific data types such as string
|
|
16
|
+
string_attr :format
|
|
17
|
+
extensible_enum_attr :format, :FIELD_FORMAT_TYPE
|
|
18
|
+
|
|
19
|
+
# Human-readable label for the field
|
|
20
|
+
string_attr :label
|
|
21
|
+
|
|
22
|
+
# Short label for the field, used in compact displays
|
|
23
|
+
string_attr :short_label
|
|
24
|
+
|
|
25
|
+
# Human-readable help text for the field displayed usually under the field or as placeholder
|
|
26
|
+
string_attr :help_text
|
|
27
|
+
|
|
28
|
+
# Flag indicating if the field is read-only
|
|
29
|
+
boolean_attr :read_only
|
|
30
|
+
|
|
31
|
+
# Flag indicating if the field is write-only
|
|
32
|
+
boolean_attr :write_only
|
|
33
|
+
|
|
34
|
+
# Flag indicating if the field can be null
|
|
35
|
+
boolean_attr :nullable
|
|
36
|
+
|
|
37
|
+
# Flag indicating if the field is required
|
|
38
|
+
boolean_attr :required
|
|
39
|
+
|
|
40
|
+
# Default value for the field
|
|
41
|
+
any_attr :default_value
|
|
42
|
+
|
|
43
|
+
# Flag indicating if the field is sortable
|
|
44
|
+
boolean_attr :sortable
|
|
45
|
+
|
|
46
|
+
# Field name to use for sorting if different from the field name
|
|
47
|
+
string_attr :sort_by
|
|
48
|
+
|
|
49
|
+
# Reference to another resource
|
|
50
|
+
string_attr :reference
|
|
51
|
+
|
|
52
|
+
# Enumeration items for field with predefined choices, usually used with 'choices' format
|
|
53
|
+
has_many_attr :enum, 'Habarico::EnumType'
|
|
54
|
+
|
|
55
|
+
# Schema of items in case of 'array' type
|
|
56
|
+
has_one_attr :items, 'Habarico::FieldSchema'
|
|
57
|
+
|
|
58
|
+
# Schema of properties in case of 'object' type
|
|
59
|
+
has_many_attr :properties, 'Habarico::FieldSchema'
|
|
60
|
+
|
|
61
|
+
# Additional options for the value formating and display
|
|
62
|
+
has_one_attr :options, 'Habarico::FieldOptions'
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class FilterSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
include Habarico::ExtensibleEnum
|
|
7
|
+
|
|
8
|
+
# Name of the filter in API, used for coupling with filter descriptor
|
|
9
|
+
string_attr :name
|
|
10
|
+
|
|
11
|
+
# Data type of the filter field
|
|
12
|
+
string_attr :type
|
|
13
|
+
extensible_enum_attr :type, :FIELD_TYPE
|
|
14
|
+
|
|
15
|
+
# Format of the filter field, applied to specific data types such as string
|
|
16
|
+
string_attr :format
|
|
17
|
+
extensible_enum_attr :format, :FIELD_FORMAT_TYPE
|
|
18
|
+
|
|
19
|
+
# Human-readable label for the filter
|
|
20
|
+
string_attr :label
|
|
21
|
+
|
|
22
|
+
# Human-readable help text for the filter displayed usually under the field or as placeholder
|
|
23
|
+
string_attr :help_text
|
|
24
|
+
|
|
25
|
+
# Reference to another resource
|
|
26
|
+
string_attr :reference
|
|
27
|
+
|
|
28
|
+
# Enumeration items for field with predefined choices, usually used with 'choices' format
|
|
29
|
+
has_many_attr :enum, 'Habarico::EnumType'
|
|
30
|
+
|
|
31
|
+
# Schema of items in case of 'array' type
|
|
32
|
+
has_one_attr :items, 'Habarico::FieldSchema'
|
|
33
|
+
|
|
34
|
+
# Schema of properties in case of 'object' type
|
|
35
|
+
has_many_attr :properties, 'Habarico::FieldSchema'
|
|
36
|
+
|
|
37
|
+
# Additional options for the value formating and display
|
|
38
|
+
has_one_attr :options, 'Habarico::FieldOptions'
|
|
39
|
+
|
|
40
|
+
# Flag indicating if the filter is always visible in the filters panel and cannot be removed by the user
|
|
41
|
+
boolean_attr :is_always_on
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ImageFieldOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Width to resize the image to (in pixels)
|
|
7
|
+
integer_attr :resize_width
|
|
8
|
+
|
|
9
|
+
# Aspect ratio to crop the image to (e.g. '16:9', '4:3')
|
|
10
|
+
string_attr :crop_aspect_ratio
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class MethodSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# List of fields supported by the API
|
|
7
|
+
has_many_attr :fields, 'Habarico::FieldSchema'
|
|
8
|
+
|
|
9
|
+
# List of filters supported by the API
|
|
10
|
+
has_many_attr :filters, 'Habarico::FilterSchema'
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class NumberFieldOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Style of the number formatting
|
|
8
|
+
string_attr :style
|
|
9
|
+
enum_attr :style, %i[currency unit]
|
|
10
|
+
|
|
11
|
+
# Currency code used in case of "currency" format
|
|
12
|
+
string_attr :currency
|
|
13
|
+
|
|
14
|
+
# Unit used in case of "unit" format
|
|
15
|
+
string_attr :unit
|
|
16
|
+
|
|
17
|
+
# Minimum number of fraction digits
|
|
18
|
+
integer_attr :minimum_fraction_digits
|
|
19
|
+
|
|
20
|
+
# Maximum number of fraction digits
|
|
21
|
+
integer_attr :maximum_fraction_digits
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class PhoneFieldOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Default region code for phone number parsing and formatting (e.g. 'CZ')
|
|
7
|
+
string_attr :default_region
|
|
8
|
+
|
|
9
|
+
# List of allowed region codes (e.g. ['CZ', 'SK'])
|
|
10
|
+
has_many_attr :allowed_regions, 'String'
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class RelationFieldOptions
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Show a link to the related resource detail
|
|
8
|
+
boolean_attr :show_link
|
|
9
|
+
|
|
10
|
+
# How to open the linked resource detail (redirect to page or open in a dialog)
|
|
11
|
+
string_attr :link_mode
|
|
12
|
+
enum_attr :link_mode, %i[redirect dialog]
|
|
13
|
+
|
|
14
|
+
# Width of the dialog, only used when link_mode is dialog (MUI breakpoint or CSS width value)
|
|
15
|
+
string_attr :dialog_width
|
|
16
|
+
|
|
17
|
+
# Keep the linked parent in the URL when navigating to linked resource
|
|
18
|
+
boolean_attr :keep_linked_parent
|
|
19
|
+
|
|
20
|
+
# Show edit button for inline editing of the related resource
|
|
21
|
+
boolean_attr :show_edit_button
|
|
22
|
+
|
|
23
|
+
# Show create button for inline creation of a new related resource
|
|
24
|
+
boolean_attr :show_create_button
|
|
25
|
+
|
|
26
|
+
# Preserve the order of the values according to the order in the source field
|
|
27
|
+
boolean_attr :preserve_order
|
|
28
|
+
|
|
29
|
+
# Static key-value filters applied to the relation resource query
|
|
30
|
+
has_many_attr :filters, 'Habarico::KeyValue'
|
|
31
|
+
|
|
32
|
+
# Default sorting applied to the relation resource query
|
|
33
|
+
has_one_attr :sort, 'Habarico::SortDescriptor'
|
|
34
|
+
|
|
35
|
+
# Name of the parent field this field depends on (used for tree/hierarchical relations)
|
|
36
|
+
string_attr :parent
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
# Declares an `enum_attr` whose choices come from an extensible list in `Habarico::Types`.
|
|
3
|
+
#
|
|
4
|
+
# Identical to calling `enum_attr :type, Types::FIELD_TYPE` directly, except that the class is
|
|
5
|
+
# recorded as a consumer of that list, so `Types.register` can re-declare the enum when a
|
|
6
|
+
# pro/enterprise gem adds a value (HAB-812). Without the record the registration would be
|
|
7
|
+
# invisible here: `enum_attr` copies the choices into the class at declaration time.
|
|
8
|
+
module ExtensibleEnum
|
|
9
|
+
def self.included(base)
|
|
10
|
+
base.extend(ClassMethods)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module ClassMethods
|
|
14
|
+
def extensible_enum_attr(attr_name, list_name)
|
|
15
|
+
Types.consumers[list_name.to_sym] << [self, attr_name.to_sym]
|
|
16
|
+
enum_attr attr_name, Types.const_get(list_name)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class ActionViewChoice
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
|
|
6
|
+
# Human-readable label of the choice
|
|
7
|
+
string_attr :label
|
|
8
|
+
|
|
9
|
+
# Parameters associated with the choice, passed to the view when selected
|
|
10
|
+
has_many_attr :parameters, 'String', underlying_type: :hash
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class MenuGroupSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Name of the menu item or group, used for coupling with each other
|
|
8
|
+
string_attr :name
|
|
9
|
+
|
|
10
|
+
# Human-readable label for the menu item or group
|
|
11
|
+
string_attr :label
|
|
12
|
+
|
|
13
|
+
# Icon for the menu item or group
|
|
14
|
+
string_attr :icon
|
|
15
|
+
|
|
16
|
+
# Color of the menu item or group. Uses standard MUI color types
|
|
17
|
+
string_attr :color
|
|
18
|
+
enum_attr :color, Types::COLOR_TYPE
|
|
19
|
+
|
|
20
|
+
# Priority for ordering menu items in the menu
|
|
21
|
+
integer_attr :priority
|
|
22
|
+
|
|
23
|
+
# Parent menu group for nested menu structures
|
|
24
|
+
has_one_attr :parent, 'Habarico::MenuGroupSchema'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
class MenuSchema
|
|
3
|
+
include ::ActiveModel::Model
|
|
4
|
+
include Eluvia::ActiveModel::Attributes
|
|
5
|
+
include Eluvia::ActiveModel::EnumAttribute
|
|
6
|
+
|
|
7
|
+
# Name of the menu item or group, used for coupling with each other
|
|
8
|
+
string_attr :name
|
|
9
|
+
|
|
10
|
+
# Human-readable label for the menu item or group
|
|
11
|
+
string_attr :label
|
|
12
|
+
|
|
13
|
+
# Icon for the menu item or group
|
|
14
|
+
string_attr :icon
|
|
15
|
+
|
|
16
|
+
# Color of the menu item or group. Uses standard MUI color types
|
|
17
|
+
string_attr :color
|
|
18
|
+
enum_attr :color, Types::COLOR_TYPE
|
|
19
|
+
|
|
20
|
+
# Priority for ordering menu items in the menu
|
|
21
|
+
integer_attr :priority
|
|
22
|
+
|
|
23
|
+
# Type of the menu item
|
|
24
|
+
string_attr :type
|
|
25
|
+
enum_attr :type, Types::MENU_TYPE
|
|
26
|
+
|
|
27
|
+
# View parameters for menu items of type 'view'
|
|
28
|
+
has_one_attr :view, 'Habarico::ViewActionParameters'
|
|
29
|
+
|
|
30
|
+
# Link parameters for menu items of type 'link'
|
|
31
|
+
has_one_attr :link, 'Habarico::LinkActionParameters'
|
|
32
|
+
|
|
33
|
+
# Parent menu group for nested menu structures
|
|
34
|
+
has_one_attr :parent, 'Habarico::MenuGroupSchema'
|
|
35
|
+
end
|
|
36
|
+
end
|