@@ -107,40 +107,24 @@ const generateDependIds = (depend, settings) => {
107107}
108108
109109//this won't change as it is initalised with [ESP800] which is call at start
110- const connectionDepend = ( depend , settings ) => {
110+ const connectionDepend = ( depend , connectionsettings ) => {
111111 if ( Array . isArray ( depend ) ) {
112- return depend . reduce ( ( acc , d ) => {
113- if ( d . connection_id && settings [ d . connection_id ] ) {
114- const quote = d . value && d . value . trim ( ) . endsWith ( "'" ) ? "'" : ""
115- if ( d . value )
116- return (
117- acc &&
118- eval (
119- quote + settings [ d . connection_id ] + quote + d . value
120- )
121- )
122- else if ( d . contains ) {
123- return (
124- acc &&
125- eval (
126- "'" +
127- settings [ d . connection_id ] +
128- "'" +
129- ".indexOf('" +
130- d . contains +
131- "')!=-1"
132- )
133- )
112+ return depend . every ( d => {
113+ if ( d . connection_id && connectionsettings [ d . connection_id ] ) {
114+ const quote = d . value && d . value . trim ( ) . endsWith ( "'" ) ? "'" : "" ;
115+ if ( d . value ) {
116+ return eval ( quote + connectionsettings [ d . connection_id ] + quote + d . value ) ;
117+ } else if ( d . contains ) {
118+ return eval ( "'" + connectionsettings [ d . connection_id ] + "'" + ".indexOf('" + d . contains + "')!=-1" ) ;
134119 }
135120 }
136- return acc
137- } , true )
121+ return true ;
122+ } ) ;
138123 }
139- return true
124+ return true ;
140125}
141-
142126//this is dynamic as it is depending on the preferences settings
143- const settingsDepend = ( depend , settings ) => {
127+ const settingDepend = ( depend , settings , connectionsettings ) => {
144128 if ( Array . isArray ( depend ) ) {
145129 return depend . every ( d => {
146130 if ( d . id ) {
@@ -153,7 +137,27 @@ const settingsDepend = (depend, settings) => {
153137 }
154138 if ( d . orGroups ) {
155139 return d . orGroups . some ( group =>
156- settingsDepend ( group , settings )
140+ checkDependencies ( group , settings , connectionsettings )
141+ ) ;
142+ }
143+ return true ;
144+ } ) ;
145+ }
146+ return true ;
147+ }
148+
149+ const checkDependencies = ( depend , settings , connectionsettings ) => {
150+ if ( Array . isArray ( depend ) ) {
151+ return depend . every ( d => {
152+ if ( d . id ) {
153+ return settingDepend ( [ d ] , settings , connectionsettings ) ;
154+ }
155+ if ( d . connection_id ) {
156+ return connectionDepend ( [ d ] , connectionsettings ) ;
157+ }
158+ if ( d . orGroups ) {
159+ return d . orGroups . some ( group =>
160+ checkDependencies ( group , settings , connectionsettings )
157161 ) ;
158162 }
159163 return true ;
@@ -170,5 +174,5 @@ export {
170174 getColClasses ,
171175 generateDependIds ,
172176 connectionDepend ,
173- settingsDepend ,
177+ checkDependencies
174178}
0 commit comments