kms_models 0.7.0 → 0.8.0

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/javascripts/kms_models/application/controllers/{entries_controller.coffee → entries_controller.coffee.erb} +8 -7
  4. data/app/assets/javascripts/kms_models/application/controllers/fields_controller.coffee.erb +1 -1
  5. data/app/assets/javascripts/kms_models/application/controllers/{models_controller.coffee → models_controller.coffee.erb} +9 -9
  6. data/app/assets/javascripts/templates/entries/form.html.slim +1 -1
  7. data/app/assets/javascripts/templates/help/models_endpoints.html.slim +26 -0
  8. data/app/assets/javascripts/templates/models/fields.html.slim +2 -2
  9. data/app/assets/javascripts/templates/models/form.html.slim +6 -1
  10. data/app/controllers/kms/models/models_controller.rb +7 -12
  11. data/app/controllers/kms/public/entries_controller.rb +25 -0
  12. data/app/models/kms/file_field.rb +1 -1
  13. data/app/models/kms/has_many_field.rb +7 -0
  14. data/app/models/kms/model.rb +2 -0
  15. data/app/serializers/kms/entry_serializer.rb +1 -1
  16. data/app/serializers/kms/field_serializer.rb +6 -0
  17. data/app/serializers/kms/model_serializer.rb +12 -0
  18. data/config/initializers/help.rb +1 -1
  19. data/config/locales/en.yml +9 -0
  20. data/config/locales/ru.yml +8 -0
  21. data/config/routes.rb +3 -0
  22. data/db/migrate/20150409124420_create_kms_models.rb +1 -1
  23. data/db/migrate/20150409125056_create_kms_fields.rb +1 -1
  24. data/db/migrate/20150413143711_create_kms_entries.rb +1 -1
  25. data/db/migrate/20150820080436_add_label_field_to_kms_models.rb +1 -1
  26. data/db/migrate/20150820132142_add_slug_to_kms_entries.rb +1 -1
  27. data/db/migrate/20150821201250_fix_models_column_name.rb +1 -1
  28. data/db/migrate/20150901115303_add_class_name_to_kms_fields.rb +1 -1
  29. data/db/migrate/20150910081440_add_position_to_kms_entries.rb +1 -1
  30. data/db/migrate/20170209125819_add_allow_creation_using_form_to_models.rb +5 -0
  31. data/lib/{kms/drops → drops/kms}/entry_drop.rb +0 -0
  32. data/lib/{kms/drops → drops/kms}/models_wrapper_drop.rb +0 -0
  33. data/lib/kms/models/engine.rb +0 -1
  34. data/lib/kms/models/version.rb +1 -1
  35. metadata +62 -98
  36. data/test/dummy/README.rdoc +0 -28
  37. data/test/dummy/Rakefile +0 -6
  38. data/test/dummy/app/assets/javascripts/application.js +0 -13
  39. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  40. data/test/dummy/app/controllers/application_controller.rb +0 -5
  41. data/test/dummy/app/helpers/application_helper.rb +0 -2
  42. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  43. data/test/dummy/bin/bundle +0 -3
  44. data/test/dummy/bin/rails +0 -4
  45. data/test/dummy/bin/rake +0 -4
  46. data/test/dummy/bin/setup +0 -29
  47. data/test/dummy/config/application.rb +0 -26
  48. data/test/dummy/config/boot.rb +0 -5
  49. data/test/dummy/config/database.yml +0 -25
  50. data/test/dummy/config/environment.rb +0 -5
  51. data/test/dummy/config/environments/development.rb +0 -41
  52. data/test/dummy/config/environments/production.rb +0 -79
  53. data/test/dummy/config/environments/test.rb +0 -42
  54. data/test/dummy/config/initializers/assets.rb +0 -11
  55. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  56. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  57. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  58. data/test/dummy/config/initializers/inflections.rb +0 -16
  59. data/test/dummy/config/initializers/mime_types.rb +0 -4
  60. data/test/dummy/config/initializers/session_store.rb +0 -3
  61. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  62. data/test/dummy/config/locales/en.yml +0 -23
  63. data/test/dummy/config/routes.rb +0 -4
  64. data/test/dummy/config/secrets.yml +0 -22
  65. data/test/dummy/config.ru +0 -4
  66. data/test/dummy/public/404.html +0 -67
  67. data/test/dummy/public/422.html +0 -67
  68. data/test/dummy/public/500.html +0 -66
  69. data/test/dummy/public/favicon.ico +0 -0
  70. data/test/integration/navigation_test.rb +0 -10
  71. data/test/kms_models_test.rb +0 -7
  72. data/test/test_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dc36ed60108e1abb7b3210d652bac2afffe538e
4
- data.tar.gz: 74981584dff01d19b74893f47a5fa572324a2cf1
3
+ metadata.gz: bf7d34f10f2c3f33b4a50bdbac4badec6e3ce73a
4
+ data.tar.gz: 4dee3caa9f3dd22a3f454e35bfc1185fc38bc257
5
5
  SHA512:
6
- metadata.gz: ae80e9ae8c89722e0f81ce79be9d66c6983e8f2a98c9a6893829187a62e88ca3b378c259de50216d52bac7212b7f536b0d22b1723a6e6255f20e6c863e63bbae
7
- data.tar.gz: c80cfee5be37fd4b9843d3af7e1a4770e0d82be15592beec2cd759930b7ef2711a098e4481035e44321c02b82a593d30261e9b21a19eb9c79cf3ae474254a041
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("../test/dummy/Rakefile", __FILE__)
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
- $scope.entry.values[field.liquor_name] = _.filter $scope[field.liquor_name], (element)->
31
- _.contains $scope.entry.values[field.liquor_name], element.id.toString()
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.fields, (field) -> field.type == 'Kms::HasManyField' or field.type == 'Kms::BelongsToField'
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
- if value
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.fields.push($scope.field)
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 = {fields: []}
15
+ $scope.model = {fields_attributes: []}
16
16
 
17
- $scope.$watchCollection 'model.fields', (newFields, oldFields) ->
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
- console.log('bug')
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
- console.log('bug')
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.fields"
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
+ | &lt;form action="/entries/:collection_name" method="post"&gt;
11
+ br
12
+ | &lt;input type="hidden" name='authenticity_token' value='{{ request.form_authenticity_token }}'&gt;
13
+ br
14
+ | &lt;input type="text" name="entry[name]"&gt;
15
+ br
16
+ | &lt;input type="submit" value="Send"&gt;
17
+ br
18
+ | &lt;/form&gt;
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.fields" ng-hide="field._destroy"
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.fields.length > 0"
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.fields"
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.to_json
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.to_json(include: {:fields => {methods: :type}})
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(methods: :errors), status: :unprocessable_entity
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
- if @model.update_attributes(model_params)
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
@@ -4,7 +4,7 @@ module Kms
4
4
  value = entry.values[liquor_name]
5
5
  uploader = EntryFileUploader.new(OpenStruct.new(model: entry, field_name: liquor_name))
6
6
  uploader.retrieve_from_store! value
7
- uploader.url
7
+ uploader.file.exists? ? uploader.url : nil
8
8
  end
9
9
  end
10
10
  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
@@ -4,6 +4,8 @@ module Kms
4
4
  has_many :entries, class_name: 'Kms::Entry', dependent: :destroy
5
5
  accepts_nested_attributes_for :fields, allow_destroy: true
6
6
 
7
+ validates :kms_model_name, :collection_name, presence: true
8
+
7
9
  def name
8
10
  id.to_s
9
11
  end
@@ -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,6 @@
1
+ module Kms
2
+ class FieldSerializer < ActiveModel::Serializer
3
+ attributes :id, :name, :liquor_name, :type, :class_name
4
+ end
5
+
6
+ end
@@ -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
@@ -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'
@@ -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"
@@ -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
@@ -9,3 +9,6 @@ Kms::Models::Engine.routes.draw do
9
9
  end
10
10
  end
11
11
  end
12
+ Rails.application.routes.draw do
13
+ post '/entries/:collection_name' => 'kms/public/entries#create'
14
+ end
@@ -1,4 +1,4 @@
1
- class CreateKmsModels < ActiveRecord::Migration
1
+ class CreateKmsModels < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :kms_models do |t|
4
4
  t.string :model_name
@@ -1,4 +1,4 @@
1
- class CreateKmsFields < ActiveRecord::Migration
1
+ class CreateKmsFields < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :kms_fields do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateKmsEntries < ActiveRecord::Migration
1
+ class CreateKmsEntries < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :kms_entries do |t|
4
4
  t.belongs_to :model, index: true
@@ -1,4 +1,4 @@
1
- class AddLabelFieldToKmsModels < ActiveRecord::Migration
1
+ class AddLabelFieldToKmsModels < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :kms_models, :label_field, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddSlugToKmsEntries < ActiveRecord::Migration
1
+ class AddSlugToKmsEntries < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :kms_entries, :slug, :string
4
4
  add_index :kms_entries, :slug, unique: true
@@ -1,4 +1,4 @@
1
- class FixModelsColumnName < ActiveRecord::Migration
1
+ class FixModelsColumnName < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  rename_column :kms_models, :model_name, :kms_model_name
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddClassNameToKmsFields < ActiveRecord::Migration
1
+ class AddClassNameToKmsFields < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :kms_fields, :class_name, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddPositionToKmsEntries < ActiveRecord::Migration
1
+ class AddPositionToKmsEntries < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :kms_entries, :position, :integer, default: 0, null: false
4
4
  end
@@ -0,0 +1,5 @@
1
+ class AddAllowCreationUsingFormToModels < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :kms_models, :allow_creation_using_form, :boolean, default: false
4
+ end
5
+ end
File without changes
File without changes
@@ -1,5 +1,4 @@
1
1
  require "friendly_id"
2
- require 'kms/drops/models_wrapper_drop'
3
2
  module Kms
4
3
  module Models
5
4
  class Engine < ::Rails::Engine
@@ -1,5 +1,5 @@
1
1
  module Kms
2
2
  module Models
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  end