kms_models 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/javascripts/kms_models/application/controllers/{entries_controller.coffee → entries_controller.coffee.erb} +8 -7
- data/app/assets/javascripts/kms_models/application/controllers/fields_controller.coffee.erb +1 -1
- data/app/assets/javascripts/kms_models/application/controllers/{models_controller.coffee → models_controller.coffee.erb} +9 -9
- data/app/assets/javascripts/templates/entries/form.html.slim +1 -1
- data/app/assets/javascripts/templates/help/models_endpoints.html.slim +26 -0
- data/app/assets/javascripts/templates/models/fields.html.slim +2 -2
- data/app/assets/javascripts/templates/models/form.html.slim +6 -1
- data/app/controllers/kms/models/models_controller.rb +7 -12
- data/app/controllers/kms/public/entries_controller.rb +25 -0
- data/app/models/kms/file_field.rb +1 -1
- data/app/models/kms/has_many_field.rb +7 -0
- data/app/models/kms/model.rb +2 -0
- data/app/serializers/kms/entry_serializer.rb +1 -1
- data/app/serializers/kms/field_serializer.rb +6 -0
- data/app/serializers/kms/model_serializer.rb +12 -0
- data/config/initializers/help.rb +1 -1
- data/config/locales/en.yml +9 -0
- data/config/locales/ru.yml +8 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20150409124420_create_kms_models.rb +1 -1
- data/db/migrate/20150409125056_create_kms_fields.rb +1 -1
- data/db/migrate/20150413143711_create_kms_entries.rb +1 -1
- data/db/migrate/20150820080436_add_label_field_to_kms_models.rb +1 -1
- data/db/migrate/20150820132142_add_slug_to_kms_entries.rb +1 -1
- data/db/migrate/20150821201250_fix_models_column_name.rb +1 -1
- data/db/migrate/20150901115303_add_class_name_to_kms_fields.rb +1 -1
- data/db/migrate/20150910081440_add_position_to_kms_entries.rb +1 -1
- data/db/migrate/20170209125819_add_allow_creation_using_form_to_models.rb +5 -0
- data/lib/{kms/drops → drops/kms}/entry_drop.rb +0 -0
- data/lib/{kms/drops → drops/kms}/models_wrapper_drop.rb +0 -0
- data/lib/kms/models/engine.rb +0 -1
- data/lib/kms/models/version.rb +1 -1
- metadata +62 -98
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -29
- data/test/dummy/config/application.rb +0 -26
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/config.ru +0 -4
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +0 -10
- data/test/kms_models_test.rb +0 -7
- data/test/test_helper.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf7d34f10f2c3f33b4a50bdbac4badec6e3ce73a
|
4
|
+
data.tar.gz: 4dee3caa9f3dd22a3f454e35bfc1185fc38bc257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b1c5100a0d19634d64b03b21cd54c93390eb2b9fce4168e110878e4ef2a4089ee7bbd2f4ccbf38e456503573d59944f88c4a1fe787fdc694528043039a96917
|
7
|
+
data.tar.gz: b2a23bb80c33e1e2d28962288e5db3598cb2d0f849f761f9aa5dc75a9d14e5f6467364baf3930ca0be5d21f6f5822a32343c7b6ff80be1ac3b8008adf20591e7
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/internal/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
20
|
|
@@ -27,8 +27,9 @@ EntriesController = ($scope, $state, Restangular, $stateParams, Alertify, Errors
|
|
27
27
|
|
28
28
|
$scope.initAssociationField = (field)->
|
29
29
|
if field.type == 'Kms::HasManyField'
|
30
|
-
|
31
|
-
_.
|
30
|
+
fieldEntries = _.map $scope.entry.values[field.liquor_name], (entryId)->
|
31
|
+
_.find $scope[field.liquor_name], { 'id': parseInt(entryId) }
|
32
|
+
$scope.entry.values[field.liquor_name] = _.compact fieldEntries
|
32
33
|
else
|
33
34
|
$scope.entry.values[field.liquor_name] = _.find $scope[field.liquor_name], (element)->
|
34
35
|
$scope.entry.values[field.liquor_name] == element.id.toString()
|
@@ -43,7 +44,7 @@ EntriesController = ($scope, $state, Restangular, $stateParams, Alertify, Errors
|
|
43
44
|
$scope.entry = {values: {}}
|
44
45
|
|
45
46
|
$scope.getAssociationFields = (model)->
|
46
|
-
_.filter model.
|
47
|
+
_.filter model.fields_attributes, (field) -> field.type == 'Kms::HasManyField' or field.type == 'Kms::BelongsToField'
|
47
48
|
|
48
49
|
$scope.getFieldTemplateName = (field)->
|
49
50
|
typeSplitted = field.type.split '::'
|
@@ -65,8 +66,8 @@ EntriesController = ($scope, $state, Restangular, $stateParams, Alertify, Errors
|
|
65
66
|
if $scope.entry.slug
|
66
67
|
fd.append("entry[slug]", $scope.entry.slug)
|
67
68
|
for key, value of $scope.entry.values
|
68
|
-
continue if value == undefined
|
69
|
-
|
69
|
+
# continue if value == undefined
|
70
|
+
unless _.isEmpty(value)
|
70
71
|
if value.constructor.name == 'Array'
|
71
72
|
for element in value
|
72
73
|
id = if element.constructor.name == 'Object' then element.id else element
|
@@ -74,14 +75,14 @@ EntriesController = ($scope, $state, Restangular, $stateParams, Alertify, Errors
|
|
74
75
|
else if value.constructor.name != 'Object'
|
75
76
|
fd.append("entry[values][#{key}]", value || '')
|
76
77
|
else
|
77
|
-
fd.append("entry[values][#{key}]", value
|
78
|
+
fd.append("entry[values][#{key}]", if value? then value else '')
|
78
79
|
$scope.entry.withHttpConfig({ transformRequest: angular.identity }).post('', fd, '', {"Content-Type": undefined}).then ->
|
79
80
|
$state.go('models.entries', modelId: $scope.model.id)
|
80
81
|
,(response)->
|
81
82
|
Alertify.error(ErrorsService.prepareErrorsString(response.data.errors))
|
82
83
|
|
83
84
|
$scope.destroy = (entry)->
|
84
|
-
if(confirm('
|
85
|
+
if(confirm('<%= I18n.t(:are_you_sure) %>'))
|
85
86
|
entry.remove().then ->
|
86
87
|
$scope.entries = _.without($scope.entries, entry)
|
87
88
|
|
@@ -30,7 +30,7 @@ FieldsController = ($scope, $state, Restangular, $stateParams) ->
|
|
30
30
|
|
31
31
|
$scope.addField = ->
|
32
32
|
if $scope.field.name and $scope.field.type
|
33
|
-
$scope.model.
|
33
|
+
$scope.model.fields_attributes.push($scope.field)
|
34
34
|
$scope.field = {}
|
35
35
|
|
36
36
|
$scope.removeField = (field)->
|
@@ -1,4 +1,4 @@
|
|
1
|
-
ModelsController = ($scope, $state, Restangular, $stateParams) ->
|
1
|
+
ModelsController = ($scope, $state, Restangular, $stateParams, Alertify, ErrorsService) ->
|
2
2
|
$scope.store = Restangular.all('models')
|
3
3
|
|
4
4
|
Restangular.all('users').customGET('kms_user').then (current_user) ->
|
@@ -12,9 +12,9 @@ ModelsController = ($scope, $state, Restangular, $stateParams) ->
|
|
12
12
|
$scope.store.get($stateParams.id).then (model)->
|
13
13
|
$scope.model = model
|
14
14
|
else
|
15
|
-
$scope.model = {
|
15
|
+
$scope.model = {fields_attributes: []}
|
16
16
|
|
17
|
-
$scope.$watchCollection 'model.
|
17
|
+
$scope.$watchCollection 'model.fields_attributes', (newFields, oldFields) ->
|
18
18
|
if newFields and newFields.length > 0 and oldFields and oldFields.length == 0
|
19
19
|
$scope.model.label_field =newFields[0].liquor_name
|
20
20
|
|
@@ -23,20 +23,20 @@ ModelsController = ($scope, $state, Restangular, $stateParams) ->
|
|
23
23
|
# for adding to Menu - better to render resources via js
|
24
24
|
window.location.reload()
|
25
25
|
#$state.go('models')
|
26
|
-
|
27
|
-
|
26
|
+
,(response)->
|
27
|
+
Alertify.error(ErrorsService.prepareErrorsString(response.data.errors))
|
28
28
|
|
29
29
|
$scope.update = ->
|
30
30
|
$scope.model.put().then ->
|
31
31
|
$state.go('models')
|
32
|
-
|
33
|
-
|
32
|
+
,(response)->
|
33
|
+
Alertify.error(ErrorsService.prepareErrorsString(response.data.errors))
|
34
34
|
|
35
35
|
$scope.destroy = (model)->
|
36
|
-
if confirm('
|
36
|
+
if confirm('<%= I18n.t(:are_you_sure) %>')
|
37
37
|
model.remove().then ->
|
38
38
|
window.location.reload()
|
39
39
|
|
40
40
|
|
41
41
|
angular.module('KMS')
|
42
|
-
.controller('ModelsController', ['$scope', '$state', 'Restangular', '$stateParams', ModelsController])
|
42
|
+
.controller('ModelsController', ['$scope', '$state', 'Restangular', '$stateParams', 'Alertify', 'ErrorsService', ModelsController])
|
@@ -1,3 +1,3 @@
|
|
1
|
-
.form-group ng-repeat="field in model.
|
1
|
+
.form-group ng-repeat="field in model.fields_attributes"
|
2
2
|
ng-include src="'fields/' + getFieldTemplateName(field) + '.html'"
|
3
3
|
/input.form-control type="text" ng-model="entry.values[field.liquor_name]" ng-attr-id="{{field.liquor_name}}"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
h4 = I18n.t("liquor_help.endpoints_title")
|
2
|
+
p
|
3
|
+
ul
|
4
|
+
li
|
5
|
+
var POST /entries/:collection_name
|
6
|
+
p
|
7
|
+
span = I18n.t('liquor_help.endpoints.entries.post.main_description')
|
8
|
+
p
|
9
|
+
code ng-non-bindable=''
|
10
|
+
| <form action="/entries/:collection_name" method="post">
|
11
|
+
br
|
12
|
+
| <input type="hidden" name='authenticity_token' value='{{ request.form_authenticity_token }}'>
|
13
|
+
br
|
14
|
+
| <input type="text" name="entry[name]">
|
15
|
+
br
|
16
|
+
| <input type="submit" value="Send">
|
17
|
+
br
|
18
|
+
| </form>
|
19
|
+
p
|
20
|
+
table.table
|
21
|
+
tr
|
22
|
+
th #{ I18n.t('liquor_help.parameter') } /entries/:collection_name
|
23
|
+
th = I18n.t('liquor_help.description')
|
24
|
+
tr
|
25
|
+
td entry[:field_liquor_name]
|
26
|
+
td = I18n.t('liquor_help.endpoints.entries.post.parameters.entry')
|
@@ -4,7 +4,7 @@
|
|
4
4
|
tr
|
5
5
|
th colspan="4" = Kms::Model.human_attribute_name(:fields)
|
6
6
|
tbody
|
7
|
-
tr ng-repeat="field in model.
|
7
|
+
tr ng-repeat="field in model.fields_attributes" ng-hide="field._destroy"
|
8
8
|
td
|
9
9
|
| {{ field.name }}
|
10
10
|
td
|
@@ -17,7 +17,7 @@
|
|
17
17
|
.btn-group.pull-right
|
18
18
|
a.btn.btn-sm.btn-danger ng-click="removeField(field)"
|
19
19
|
i.fa.fa-times
|
20
|
-
tr ng-hide="model.
|
20
|
+
tr ng-hide="model.fields_attributes.length > 0"
|
21
21
|
td
|
22
22
|
i = I18n.t(:no_fields_yet)
|
23
23
|
.row
|
@@ -7,4 +7,9 @@
|
|
7
7
|
small.help-block = I18n.t(:collection_name_field_hint)
|
8
8
|
.form-group
|
9
9
|
label for="label_field" = Kms::Model.human_attribute_name(:label_field)
|
10
|
-
select#label_field.form-control ng-model="model.label_field" ng-options="field.liquor_name as field.name for field in model.
|
10
|
+
select#label_field.form-control ng-model="model.label_field" ng-options="field.liquor_name as field.name for field in model.fields_attributes"
|
11
|
+
.form-group
|
12
|
+
label for="allow_creation_using_form" style="margin-right:10px;"
|
13
|
+
= Kms::Model.human_attribute_name(:allow_creation_using_form)
|
14
|
+
toggle-switch ng-model="model.allow_creation_using_form" on-label=I18n.t(:yes_word) off-label=I18n.t(:no_word)
|
15
|
+
small.help-block = I18n.t(:allow_creation_using_form_field_hint)
|
@@ -1,35 +1,31 @@
|
|
1
1
|
module Kms
|
2
2
|
module Models
|
3
3
|
class ModelsController < ApplicationController
|
4
|
+
wrap_parameters :model, include: [:kms_model_name, :collection_name, :label_field, :fields_attributes, :allow_creation_using_form]
|
4
5
|
|
5
6
|
def index
|
6
|
-
render json: Model.all
|
7
|
+
render json: Model.all, root: false
|
7
8
|
end
|
8
9
|
|
9
10
|
def show
|
10
11
|
@model = Model.find(params[:id])
|
11
|
-
render json: @model
|
12
|
+
render json: @model, root: false
|
12
13
|
end
|
13
14
|
|
14
15
|
def create
|
15
|
-
params[:model].merge!(fields_attributes: params[:fields])
|
16
16
|
@model = Model.new(model_params)
|
17
17
|
if @model.save
|
18
18
|
Kms::ResourceService.register(:models, @model, "fa-tasks")
|
19
19
|
Kms::ModelsWrapperDrop.register_model @model.collection_name
|
20
|
-
render json: @model.to_json
|
21
20
|
else
|
22
|
-
render json: @model.to_json
|
21
|
+
render json: {errors: @model.errors}.to_json, status: :unprocessable_entity
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
25
|
def update
|
27
|
-
params[:model].merge!(fields_attributes: params[:fields])
|
28
26
|
@model = Model.find(params[:id])
|
29
|
-
|
30
|
-
render json: @model.to_json
|
31
|
-
else
|
32
|
-
render json: @model.to_json(methods: :errors), status: :unprocessable_entity
|
27
|
+
unless @model.update_attributes(model_params)
|
28
|
+
render json: {errors: @model.errors}.to_json, status: :unprocessable_entity
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
@@ -37,13 +33,12 @@ module Kms
|
|
37
33
|
@model = Model.find(params[:id])
|
38
34
|
@model.destroy
|
39
35
|
Kms::ResourceService.unregister(:models, @model)
|
40
|
-
render json: @model.to_json
|
41
36
|
end
|
42
37
|
|
43
38
|
protected
|
44
39
|
|
45
40
|
def model_params
|
46
|
-
params.require(:model).permit
|
41
|
+
params.require(:model).permit(:kms_model_name, :collection_name, :label_field, :allow_creation_using_form, fields_attributes: [:id, :name, :liquor_name, :type, :class_name, :_destroy])
|
47
42
|
end
|
48
43
|
|
49
44
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Kms
|
2
|
+
module Public
|
3
|
+
class EntriesController < ActionController::Base
|
4
|
+
protect_from_forgery with: :exception
|
5
|
+
before_action :find_model
|
6
|
+
|
7
|
+
def create
|
8
|
+
entry = @model.entries.new(values: entry_params)
|
9
|
+
unless @model.allow_creation_using_form? && entry.save
|
10
|
+
render json: {errors: entry.errors}.to_json, status: :unprocessable_entity
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def find_model
|
17
|
+
@model = Model.find_by!(collection_name: params[:collection_name])
|
18
|
+
end
|
19
|
+
|
20
|
+
def entry_params
|
21
|
+
params.require(:entry).permit(@model.fields.pluck(:liquor_name))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -3,6 +3,13 @@ module Kms
|
|
3
3
|
def get_value(entry)
|
4
4
|
entry_ids = entry.values[liquor_name]
|
5
5
|
association_records = Kms::Entry.where(id: entry_ids)
|
6
|
+
if entry_ids.present?
|
7
|
+
# this one allows ORDER BY the IN value list like this example:
|
8
|
+
# SELECT * FROM "comments" WHERE ("comments"."id" IN (1,3,2,4))
|
9
|
+
# ORDER BY id=1 DESC, id=3 DESC, id=2 DESC, id=4 DESC
|
10
|
+
order_sql = entry_ids.map {|entry_id| "id=#{entry_id} DESC"}
|
11
|
+
association_records = association_records.order(order_sql.join(','))
|
12
|
+
end
|
6
13
|
Liquor::DropDelegation.wrap_scope(association_records)
|
7
14
|
end
|
8
15
|
end
|
data/app/models/kms/model.rb
CHANGED
@@ -11,7 +11,7 @@ module Kms
|
|
11
11
|
object.model.fields.file_fields.each do |file_field|
|
12
12
|
uploader = EntryFileUploader.new(OpenStruct.new(model: object, field_name: file_field.liquor_name))
|
13
13
|
uploader.retrieve_from_store! values_with_urls[file_field.liquor_name]
|
14
|
-
values_with_urls[file_field.liquor_name] = { url: uploader.url }
|
14
|
+
values_with_urls[file_field.liquor_name] = { url: uploader.file.exists? ? uploader.url : nil }
|
15
15
|
end
|
16
16
|
# prepare checkbox fields - cause PostgreSQL json stored as strings
|
17
17
|
object.model.fields.checkbox_fields.each do |checkbox_field|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Kms
|
2
|
+
class ModelSerializer < ActiveModel::Serializer
|
3
|
+
attributes :id, :kms_model_name, :collection_name, :label_field, :allow_creation_using_form, :fields_attributes
|
4
|
+
|
5
|
+
has_many :fields_attributes, serializer: Kms::FieldSerializer
|
6
|
+
|
7
|
+
def fields_attributes
|
8
|
+
object.fields
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
data/config/initializers/help.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Kms::HelpService.register_templates Kms::Models::Engine, 'help/models_variables.html'
|
1
|
+
Kms::HelpService.register_templates Kms::Models::Engine, 'help/models_variables.html', 'help/models_endpoints.html'
|
data/config/locales/en.yml
CHANGED
@@ -12,6 +12,7 @@ en:
|
|
12
12
|
select_field_type: "Select field type"
|
13
13
|
select_model: "Select Model"
|
14
14
|
collection_name_field_hint: "You can access model collection like this: models.your_collection_name (ex., models.services)"
|
15
|
+
allow_creation_using_form_field_hint: "On website you can place a form allowing to create model entries"
|
15
16
|
has_many_field_placeholder: "Select related objects..."
|
16
17
|
belongs_to_field_placeholder: "Select related object..."
|
17
18
|
field_types:
|
@@ -25,6 +26,13 @@ en:
|
|
25
26
|
variables:
|
26
27
|
models:
|
27
28
|
main_description: 'Variable "models" gives access to models collections of entries. You can access collection using model collection name - "Collection name (for Liquor)" field. For example, if you created some Model with "services" collection name, then you could iterate its collection using "for" tag like this:'
|
29
|
+
endpoints:
|
30
|
+
entries:
|
31
|
+
post:
|
32
|
+
main_description: This endpoint allows you to setup form submitting Model's elements. For example, if you have a model with collection name "posts" (and field with "title" Liquor name), you could create a form with action="/entries/posts" and an input with name="entry[title]"
|
33
|
+
parameters:
|
34
|
+
entry: Value of each parameter will be saved to corresponding Model's entry field
|
35
|
+
|
28
36
|
activerecord:
|
29
37
|
models:
|
30
38
|
kms/model:
|
@@ -43,6 +51,7 @@ en:
|
|
43
51
|
collection_name: "Collection name (for Liquor)"
|
44
52
|
fields: "Fields"
|
45
53
|
label_field: "Label field (used for URL/slug generating)"
|
54
|
+
allow_creation_using_form: "Allow creation using form"
|
46
55
|
kms/field:
|
47
56
|
name: "Name"
|
48
57
|
liquor_name: "Name for Liquor"
|
data/config/locales/ru.yml
CHANGED
@@ -12,6 +12,7 @@ ru:
|
|
12
12
|
select_field_type: "Выберите тип свойства"
|
13
13
|
select_model: "Выберите модель"
|
14
14
|
collection_name_field_hint: "К коллекции можно будет обратиться так: models.your_collection_name (напр., models.services)"
|
15
|
+
allow_creation_using_form_field_hint: "На сайте можно будет разместить форму для создания элементов модели"
|
15
16
|
has_many_field_placeholder: "Выберите связанные объекты..."
|
16
17
|
belongs_to_field_placeholder: "Выберите связанный объект..."
|
17
18
|
field_types:
|
@@ -25,6 +26,12 @@ ru:
|
|
25
26
|
variables:
|
26
27
|
models:
|
27
28
|
main_description: 'Переменная models предоставляет доступ к коллекциям моделей, определённых пользователем на вкладке "Модели". Доступ осуществляется через название коллекции модели - поле "Название коллекции (для Liquor)" при создании модели. Например, если создана модель с названием коллекции services, то можно использовать for для итерации по элементам коллекции следующим образом:'
|
29
|
+
endpoints:
|
30
|
+
entries:
|
31
|
+
post:
|
32
|
+
main_description: Этот запрос позволяет создавать формы для отправки элементов модели. Например, если есть модель с названием коллекции "posts" (и поле с названием для Liquor - "title"), то можно создать форму с action="/entries/posts" и input с name="entry[title]"
|
33
|
+
parameters:
|
34
|
+
entry: Значение каждого параметра такого вида будет сохранено в соответствующее поле элемента модели
|
28
35
|
activerecord:
|
29
36
|
models:
|
30
37
|
kms/model:
|
@@ -43,6 +50,7 @@ ru:
|
|
43
50
|
collection_name: "Название коллекции (для Liquor)"
|
44
51
|
fields: "Свойства"
|
45
52
|
label_field: "Поле, используемое для генерации ссылок на объекты"
|
53
|
+
allow_creation_using_form: "Разрешить создание элементов с помощью форм"
|
46
54
|
kms/field:
|
47
55
|
name: "Название"
|
48
56
|
liquor_name: "Название для Liquor"
|
data/config/routes.rb
CHANGED
File without changes
|
File without changes
|
data/lib/kms/models/engine.rb
CHANGED
data/lib/kms/models/version.rb
CHANGED