Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
366eeba3
Commit
366eeba3
authored
Oct 02, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve snapshot remark
parent
25adb8bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
product_snapshots_controller.rb
...engai/controller/merchant/product_snapshots_controller.rb
+2
-1
snapshot.rb
lib/shotengai/snapshot.rb
+4
-3
No files found.
lib/shotengai/controller/merchant/product_snapshots_controller.rb
View file @
366eeba3
...
@@ -22,9 +22,10 @@ module Shotengai
...
@@ -22,9 +22,10 @@ module Shotengai
private
private
def
resource_params
def
resource_params
remark_input
=
params
.
require
(
resource_key
).
fetch
(
:remark_input
,
nil
)
&
.
map
(
&
:permit!
)
params
.
require
(
resource_key
).
permit
(
params
.
require
(
resource_key
).
permit
(
:revised_amount
:revised_amount
)
)
.
merge
({
remark_input:
remark_input
})
end
end
def
edit_only_unpaid
def
edit_only_unpaid
...
...
lib/shotengai/snapshot.rb
View file @
366eeba3
...
@@ -180,10 +180,11 @@ module Shotengai
...
@@ -180,10 +180,11 @@ module Shotengai
def
check_remark
def
check_remark
errors
.
add
(
:remark
,
'remark 必须是个 Hash'
)
unless
remark
.
is_a?
(
Hash
)
errors
.
add
(
:remark
,
'remark 必须是个 Hash'
)
unless
remark
.
is_a?
(
Hash
)
nullable_key
=
series
.
remark
.
select
{
|
k
,
v
|
v
}.
keys
nullable_keys
=
series
.
remark
.
select
{
|
k
,
v
|
v
}.
keys
required_key
=
product
.
remark
.
keys
-
nullable_key
required_keys
=
product
.
remark
.
keys
-
nullable_keys
absent_keys
=
required_keys
-
remark
.
keys
# remark 可添加多余字段
# remark 可添加多余字段
errors
.
add
(
:remark
,
'非法的关键字,或关键字缺失'
)
unless
(
required_key
-
remark
.
keys
)
.
empty?
errors
.
add
(
:remark
,
"必填remark值为空,
#{
absent_keys
}
"
)
unless
absent_keys
.
empty?
end
end
# NOTE: Shotengai::Snapshot.find_by_id(self.id) to get the self before changed
# NOTE: Shotengai::Snapshot.find_by_id(self.id) to get the self before changed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment