dynamic_scaffold 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c5c6ffc040bc5b732799e02be73ade7950d28950e8b1769f574c61ecb126f7e
4
- data.tar.gz: c34716b1c1896bd321616d6d5ad8018a7299ef892317ad9d8ea4ed02cedbc5e7
3
+ metadata.gz: 457314cf971c919f920535659152e9062cd0f095c51d3f4626fb12f956bda42e
4
+ data.tar.gz: a9fe3e3a6041b2dc15d305f291f63d07447427e673988c5acd68313d8f643351
5
5
  SHA512:
6
- metadata.gz: d09f5c854cdecebcbfdfa42230871e8438684399d088f275603dc326741488e31543f74ac3ddc5a391e71775c2f3ed4d10f1a6b01395a5e54f5c7e08987d19fa
7
- data.tar.gz: c8ad8ed86a3d2e56894c067fb95c05ba52a89a8858ac7f1289ad1fca5ec6d2737be056c511d0c39cf36feb1bfb112d9c8c472be7afa784622155b51bd0a2c68f
6
+ metadata.gz: 525cf1961b472037098f5d1425ae9177b2b175712c6c353a2f80692fc630dfa93d082d4d95977a3d2e3f7fc0004053e068ee5481dfd65e34802550482662542f
7
+ data.tar.gz: 79896456eaaff29d55b69fad3eb63508fe6ceb199f49fdab356f4b76db9373401cb3b4becee9cd682492713c4211616964753ce42df0f6ed9d47eda7ac9e729c
@@ -9,12 +9,22 @@ en:
9
9
  index: 'List'
10
10
  edit: 'Edit'
11
11
  new: 'Create'
12
+ button:
13
+ add: 'Add'
14
+ edit: 'Edit'
15
+ save_order: 'Sort'
16
+ save: 'Save'
17
+ back: 'Back'
12
18
  message:
13
19
  no_records: '%{model} was not found.'
14
20
  destroy_confirm: 'Are you sure you want to delete this?'
15
21
  confirm_cancel: 'Cancel'
16
22
  confirm_ok: 'OK'
23
+ sort_error: 'The sort has been failed, because the following record failed to save.'
17
24
  alert:
18
25
  destroy:
19
26
  invalid_foreign_key: 'That item can not be deleted because it has associated record(s).'
20
- failed: 'That item can not be deleted'
27
+ failed: 'That item can not be deleted'
28
+ views:
29
+ pagination:
30
+ truncate: '…'
@@ -20,6 +20,7 @@ ja:
20
20
  destroy_confirm: '削除します。よろしいですか?'
21
21
  confirm_cancel: 'キャンセル'
22
22
  confirm_ok: 'OK'
23
+ sort_error: '下記のレコードの保存に失敗したため、ソートを完了できませんでした。'
23
24
  alert:
24
25
  destroy:
25
26
  invalid_foreign_key: '関連づいたレコードがあるので削除できません。'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicScaffold
4
- module Controller
4
+ module Controller # rubocop:disable Metrics/ModuleLength
5
5
  extend ActiveSupport::Concern
6
6
  include ControllerUtilities
7
7
 
@@ -137,18 +137,26 @@ module DynamicScaffold
137
137
  redirect_to dynamic_scaffold_path(:index, request_queries)
138
138
  end
139
139
 
140
- def sort
140
+ def sort # rubocop:disable Metrics/AbcSize
141
141
  pkeys_list = sort_params
142
142
  reset_sequence(pkeys_list.size)
143
- dynamic_scaffold.model.transaction do
144
- pkeys_list.each do |pkeys|
145
- rec = find_record(pkeys.to_hash)
146
- next_sec = next_sequence!
147
- rec[dynamic_scaffold.list.sorter_attribute] = next_sec
148
- yield(rec) if block_given?
149
- rec.save!
143
+
144
+ begin
145
+ dynamic_scaffold.model.transaction do
146
+ pkeys_list.each do |pkeys|
147
+ rec = find_record(pkeys.to_hash)
148
+ next_sec = next_sequence!
149
+ rec[dynamic_scaffold.list.sorter_attribute] = next_sec
150
+ yield(rec) if block_given?
151
+ rec.save!
152
+ end
150
153
  end
154
+ rescue ActiveRecord::RecordInvalid => e
155
+ messages = [I18n.t('dynamic_scaffold.message.sort_error'), '', sort_validation_error_title(e.record)]
156
+ messages.concat(e.record.errors.full_messages)
157
+ flash[:dynamic_scaffold_danger] = messages.join('<br>')
151
158
  end
159
+
152
160
  redirect_to dynamic_scaffold_path(:index, request_queries)
153
161
  end
154
162
  end
@@ -147,5 +147,9 @@ module DynamicScaffold
147
147
  .page(params[dynamic_scaffold.list.pagination.param_name])
148
148
  .per(dynamic_scaffold.list.pagination.per_page)
149
149
  end
150
+
151
+ def sort_validation_error_title(record)
152
+ "ID: #{record.id}"
153
+ end
150
154
  end
151
155
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicScaffold
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masamoto Miyata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-20 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: classnames-rails-view