@@ -2,6 +2,8 @@ import {Action} from "../../internal/Action.js";
2
2
import { QualifierValue } from "../../internal/qualifier/QualifierValue.js" ;
3
3
import { Qualifier } from "../../internal/qualifier/Qualifier.js" ;
4
4
import { stringOrNumber } from "../../types/types.js" ;
5
+ import { ImproveActionModel } from "../../internal/models/IAdjustActionModel.js" ;
6
+ import { IActionModel } from "../../internal/models/IActionModel.js" ;
5
7
6
8
/**
7
9
* @description Defines how to improve an image by automatically adjusting image colors, contrast and brightness.</br>
@@ -11,6 +13,7 @@ import {stringOrNumber} from "../../types/types.js";
11
13
class ImproveAction extends Action {
12
14
private modeValue :stringOrNumber ;
13
15
private blendValue :number ;
16
+ protected _actionModel : ImproveActionModel = { actionType : 'improve' } ;
14
17
constructor ( ) {
15
18
super ( ) ;
16
19
}
@@ -22,6 +25,7 @@ class ImproveAction extends Action {
22
25
*/
23
26
mode ( value : 'outdoor' | 'indoor' | string ) : this {
24
27
this . modeValue = value ;
28
+ this . _actionModel . mode = value ;
25
29
return this ;
26
30
}
27
31
@@ -31,6 +35,7 @@ class ImproveAction extends Action {
31
35
*/
32
36
blend ( value :number ) : this {
33
37
this . blendValue = value ;
38
+ this . _actionModel . blend = value ;
34
39
return this ;
35
40
}
36
41
@@ -39,6 +44,18 @@ class ImproveAction extends Action {
39
44
this . addQualifier ( new Qualifier ( 'e' , qualifierValue ) ) ;
40
45
return this ;
41
46
}
47
+
48
+ static fromJson ( actionModel : IActionModel ) : ImproveAction {
49
+ const { mode, blend} = ( actionModel as ImproveActionModel ) ;
50
+
51
+ // We are using this() to allow inheriting classes to use super.fromJson.apply(this, [actionModel])
52
+ // This allows the inheriting classes to determine the class to be created
53
+ const result = new this ( ) ;
54
+ mode && result . mode ( mode ) ;
55
+ blend && result . blend ( blend ) ;
56
+
57
+ return result ;
58
+ }
42
59
}
43
60
44
61
export { ImproveAction } ;
0 commit comments