File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,25 @@ export class JsonApiModel {
4343 return hasDirtyAttributes ;
4444 }
4545
46+ rollbackAttributes ( ) {
47+ let attributesMetadata = Reflect . getMetadata ( 'Attribute' , this ) ;
48+ let metadata : any ;
49+ for ( let propertyName in attributesMetadata ) {
50+ if ( attributesMetadata . hasOwnProperty ( propertyName ) ) {
51+ if ( attributesMetadata [ propertyName ] . hasDirtyAttributes ) {
52+ this [ propertyName ] = attributesMetadata [ propertyName ] . oldValue ;
53+ metadata = {
54+ hasDirtyAttributes : false ,
55+ newValue : attributesMetadata [ propertyName ] . oldValue ,
56+ oldValue : undefined
57+ } ;
58+ attributesMetadata [ propertyName ] = metadata ;
59+ }
60+ }
61+ }
62+ Reflect . defineMetadata ( 'Attribute' , attributesMetadata , this ) ;
63+ }
64+
4665 private parseHasMany ( data : any , included : any , level : number ) {
4766 let hasMany = Reflect . getMetadata ( 'HasMany' , this ) ;
4867 if ( hasMany ) {
You can’t perform that action at this time.
0 commit comments