@@ -6,42 +6,10 @@ export default function Model(
66 model : typeof BaseModel
77) : void {
88 /**
9- * Add supporting attributes to models.
10- */
11- const $fields = model . prototype . $fields
12-
13- model . prototype . $fields = function ( ) {
14- const fields = $fields . call ( this )
15-
16- const { key, flagName } = context . createConfig (
17- this . $self ( ) . softDeleteConfig
18- )
19-
20- return Object . assign ( { } , fields , {
21- [ key ] : this . $self ( ) . attr ( null ) ,
22- [ flagName ] : this . $self ( ) . attr ( false )
23- } )
24- }
25-
26- /**
27- * Flags are visible by default during model serialization. They can be hidden
28- * by setting `exposeFlagsExternally` to false globally or locally on models.
9+ * Trash record(s) matching a condition.
2910 */
30- const $toJson = model . prototype . $toJson
31-
32- model . prototype . $toJson = function ( ) {
33- const toJson = $toJson . call ( this )
34-
35- const config = context . createConfig ( this . $self ( ) . softDeleteConfig )
36-
37- if ( config . exposeFlagsExternally !== true ) {
38- /* istanbul ignore next */
39- const { [ config . key ] : k , [ config . flagName ] : fn , ...json } = toJson
40-
41- return json
42- }
43-
44- return toJson
11+ model . softDelete = function ( payload : any ) {
12+ return this . dispatch ( 'softDelete' , payload )
4513 }
4614
4715 /**
@@ -95,9 +63,41 @@ export default function Model(
9563 }
9664
9765 /**
98- * Trash record(s) matching a condition .
66+ * Add supporting attributes to models .
9967 */
100- model . softDelete = function ( payload : any ) {
101- return this . dispatch ( 'softDelete' , payload )
68+ const $fields = model . prototype . $fields
69+
70+ model . prototype . $fields = function ( ) {
71+ const fields = $fields . call ( this )
72+
73+ const { key, flagName } = context . createConfig (
74+ this . $self ( ) . softDeleteConfig
75+ )
76+
77+ return Object . assign ( { } , fields , {
78+ [ key ] : this . $self ( ) . attr ( null ) ,
79+ [ flagName ] : this . $self ( ) . attr ( false )
80+ } )
81+ }
82+
83+ /**
84+ * Flags are visible by default during model serialization. They can be hidden
85+ * by setting `exposeFlagsExternally` to false globally or locally on models.
86+ */
87+ const $toJson = model . prototype . $toJson
88+
89+ model . prototype . $toJson = function ( ) {
90+ const toJson = $toJson . call ( this )
91+
92+ const config = context . createConfig ( this . $self ( ) . softDeleteConfig )
93+
94+ if ( config . exposeFlagsExternally !== true ) {
95+ /* istanbul ignore next */
96+ const { [ config . key ] : k , [ config . flagName ] : fn , ...json } = toJson
97+
98+ return json
99+ }
100+
101+ return toJson
102102 }
103103}
0 commit comments