@@ -12,21 +12,17 @@ export abstract class EditComponentController {
1212 $translate : any ;
1313 allowedConnectedComponentTypes : any [ ] ;
1414 authoringComponentContent : any ;
15- authoringComponentContentJSONString : string ;
16- authoringValidComponentContentJSONString : string ;
1715 componentChangedSubscription : Subscription ;
1816 componentContent : any ;
1917 componentId : string ;
2018 idToOrder : any ;
2119 isDirty : boolean = false ;
22- isJSONStringChanged : boolean = false ;
2320 isPromptVisible : boolean = true ;
2421 isSaveButtonVisible : boolean ;
2522 isSubmitButtonVisible : boolean ;
2623 isSubmitDirty : boolean = false ;
2724 nodeId : string ;
2825 showAdvancedAuthoring : boolean = false ;
29- showJSONAuthoring : boolean = false ;
3026 submitCounter : number = 0 ;
3127 starterStateResponseSubscription : Subscription ;
3228 showAdvancedAuthoringSubscription : Subscription ;
@@ -46,7 +42,6 @@ export abstract class EditComponentController {
4642 this . resetUI ( ) ;
4743 this . idToOrder = this . ProjectService . idToOrder ;
4844 this . $translate = this . $filter ( 'translate' ) ;
49- this . updateAdvancedAuthoringView ( ) ;
5045 this . componentChangedSubscription = this . ProjectService . componentChanged$ . subscribe ( ( ) => {
5146 this . authoringViewComponentChanged ( ) ;
5247 } ) ;
@@ -71,74 +66,8 @@ export abstract class EditComponentController {
7166 this . showAdvancedAuthoringSubscription . unsubscribe ( ) ;
7267 }
7368
74- showJSONButtonClicked ( ) : void {
75- if ( this . showJSONAuthoring ) {
76- if ( this . isJSONValid ( ) ) {
77- this . saveJSONAuthoringViewChanges ( ) ;
78- this . toggleJSONAuthoringView ( ) ;
79- this . NotificationService . hideJSONValidMessage ( ) ;
80- } else {
81- let isRollback = confirm ( this . $translate ( 'jsonInvalidErrorMessage' ) ) ;
82- if ( isRollback ) {
83- this . toggleJSONAuthoringView ( ) ;
84- this . NotificationService . hideJSONValidMessage ( ) ;
85- this . isJSONStringChanged = false ;
86- this . rollbackToRecentValidJSON ( ) ;
87- this . saveJSONAuthoringViewChanges ( ) ;
88- }
89- }
90- } else {
91- this . toggleJSONAuthoringView ( ) ;
92- this . rememberRecentValidJSON ( ) ;
93- }
94- }
95-
96- isJSONValid ( ) : boolean {
97- try {
98- angular . fromJson ( this . authoringComponentContentJSONString ) ;
99- return true ;
100- } catch ( e ) {
101- return false ;
102- }
103- }
104-
105- saveJSONAuthoringViewChanges ( ) : void {
106- try {
107- const editedComponentContent = angular . fromJson ( this . authoringComponentContentJSONString ) ;
108- this . ProjectService . replaceComponent ( this . nodeId , this . componentId , editedComponentContent ) ;
109- this . componentContent = editedComponentContent ;
110- this . ProjectService . nodeChanged ( ) ;
111- this . isJSONStringChanged = false ;
112- } catch ( e ) {
113- alert ( this . $translate ( 'saveErrorAdvancedAuthoring' ) ) ;
114- }
115- }
116-
117- toggleJSONAuthoringView ( ) : void {
118- this . showJSONAuthoring = ! this . showJSONAuthoring ;
119- }
120-
121- authoringJSONChanged ( ) : void {
122- this . isJSONStringChanged = true ;
123- if ( this . isJSONValid ( ) ) {
124- this . NotificationService . showJSONValidMessage ( ) ;
125- this . rememberRecentValidJSON ( ) ;
126- } else {
127- this . NotificationService . showJSONInvalidMessage ( ) ;
128- }
129- }
130-
131- rememberRecentValidJSON ( ) : void {
132- this . authoringValidComponentContentJSONString = this . authoringComponentContentJSONString ;
133- }
134-
135- rollbackToRecentValidJSON ( ) : void {
136- this . authoringComponentContentJSONString = this . authoringValidComponentContentJSONString ;
137- }
138-
13969 authoringViewComponentChanged ( ) : void {
14070 this . resetUI ( ) ;
141- this . updateAdvancedAuthoringView ( ) ;
14271 this . ProjectService . nodeChanged ( ) ;
14372 }
14473
@@ -152,10 +81,6 @@ export abstract class EditComponentController {
15281 this . submitCounter = 0 ;
15382 }
15483
155- updateAdvancedAuthoringView ( ) : void {
156- this . authoringComponentContentJSONString = angular . toJson ( this . authoringComponentContent , 4 ) ;
157- }
158-
15984 openAssetChooser ( params : any ) : any {
16085 return this . ProjectAssetService . openAssetChooser ( params ) . then (
16186 ( data : any ) => { return this . assetSelected ( data ) }
0 commit comments