@@ -54,7 +54,12 @@ class Body extends Component {
5454 deltaUpdateString : '{}' ,
5555 globalUpdateString : '{}' ,
5656 textareaRef : null ,
57+ readOnlyBooleanRef : null ,
58+ readOnlyFunctionRef : null ,
5759 readOnlyRef : null ,
60+ readOnlyEnable : false ,
61+ readOnlyFunctionEnable : false ,
62+ readOnlyBooleanEnable : false ,
5863 readOnly : false ,
5964 customInputRef : null ,
6065 customInput : false ,
@@ -66,8 +71,12 @@ class Body extends Component {
6671 this . onDeltaUpdate = this . onDeltaUpdate . bind ( this ) ;
6772 this . refTextarea = this . refTextarea . bind ( this ) ;
6873 this . refReadOnlyCheckbox = this . refReadOnlyCheckbox . bind ( this ) ;
74+ this . refReadOnlyFunctionCheckbox = this . refReadOnlyFunctionCheckbox . bind ( this ) ;
75+ this . refReadOnlyBooleanCheckbox = this . refReadOnlyBooleanCheckbox . bind ( this ) ;
6976 this . handleSubmit = this . handleSubmit . bind ( this ) ;
7077 this . handleResetToDefault = this . handleResetToDefault . bind ( this ) ;
78+ this . handleChangeReadOnlyBoolean = this . handleChangeReadOnlyBoolean . bind ( this ) ;
79+ this . handleChangeReadOnlyFunction = this . handleChangeReadOnlyFunction . bind ( this ) ;
7180 this . handleChangeReadOnly = this . handleChangeReadOnly . bind ( this ) ;
7281 this . handleClearGlobalUpdateString = this . handleClearGlobalUpdateString . bind ( this ) ;
7382 this . handleClearDeltaUpdateString = this . handleClearDeltaUpdateString . bind ( this ) ;
@@ -93,6 +102,16 @@ class Body extends Component {
93102 this . state . textareaRef = node ;
94103 }
95104
105+ refReadOnlyFunctionCheckbox ( node ) {
106+ this . state . readOnlyFunctionRef = node ;
107+ this . state . readOnlyFunctionRef . disabled = true ;
108+ }
109+
110+ refReadOnlyBooleanCheckbox ( node ) {
111+ this . state . readOnlyBooleanRef = node ;
112+ this . state . readOnlyBooleanRef . disabled = true ;
113+ }
114+
96115 refReadOnlyCheckbox ( node ) {
97116 this . state . readOnlyRef = node ;
98117 }
@@ -146,10 +165,53 @@ class Body extends Component {
146165 }
147166
148167 handleChangeReadOnly ( ) {
149- const { readOnlyRef } = this . state ;
168+ const { readOnlyRef, readOnlyBooleanRef, readOnlyFunctionRef } = this . state ;
169+
170+ this . setState ( {
171+ readOnlyEnable : readOnlyRef . checked ,
172+ } ) ;
173+
174+ if ( readOnlyRef . checked ) {
175+ readOnlyBooleanRef . disabled = false ;
176+ readOnlyFunctionRef . disabled = false ;
177+ if ( readOnlyBooleanRef . checked ) {
178+ this . handleChangeReadOnlyBoolean ( ) ;
179+ } else if ( readOnlyFunctionRef . checked ) {
180+ this . handleChangeReadOnlyFunction ( ) ;
181+ }
182+ } else {
183+ readOnlyBooleanRef . disabled = true ;
184+ readOnlyFunctionRef . disabled = true ;
185+ this . setState ( {
186+ readOnly : false ,
187+ } ) ;
188+ }
189+ }
190+
191+ handleChangeReadOnlyBoolean ( ) {
192+ const { readOnlyBooleanRef, readOnlyFunctionRef } = this . state ;
193+
194+ readOnlyFunctionRef . disabled = readOnlyBooleanRef . checked ;
195+
196+ this . setState ( {
197+ readOnly : readOnlyBooleanRef . checked ,
198+ } ) ;
199+ }
200+
201+ handleChangeReadOnlyFunction ( ) {
202+ const { readOnlyFunctionRef, readOnlyBooleanRef } = this . state ;
203+
204+ readOnlyBooleanRef . disabled = readOnlyFunctionRef . checked ;
205+
206+ let result = null ;
207+ if ( readOnlyFunctionRef . checked ) {
208+ result = ( name , value , keyPath ) => ( keyPath [ keyPath . length - 1 ] === 'text' ) ;
209+ } else {
210+ result = ( ) => false ;
211+ }
150212
151213 this . setState ( {
152- readOnly : readOnlyRef . checked ,
214+ readOnly : result ,
153215 } ) ;
154216 }
155217
@@ -200,6 +262,20 @@ class Body extends Component {
200262 onChange = { this . handleChangeReadOnly }
201263 /> Read Only
202264 </ span >
265+ < span >
266+ < input
267+ type = "checkbox"
268+ ref = { this . refReadOnlyBooleanCheckbox }
269+ onChange = { this . handleChangeReadOnlyBoolean }
270+ /> Read Only Boolean
271+ </ span >
272+ < span >
273+ < input
274+ type = "checkbox"
275+ ref = { this . refReadOnlyFunctionCheckbox }
276+ onChange = { this . handleChangeReadOnlyFunction }
277+ /> Read Only Function (read only for all 'text' key)
278+ </ span >
203279 < span >
204280 < input
205281 type = "checkbox"
0 commit comments