@@ -50,37 +50,19 @@ export const jsSchema = (intl, taskPropertyKeys) => {
5050 type : "object" ,
5151 properties : {
5252 valueType : {
53- title : "Property Type " ,
53+ title : "" ,
5454 type : "string" ,
55- enum : [ "string" , "number" , "compound rule" ] ,
55+ enum : [ "string" , "number" ] ,
5656 enumNames : [
5757 intl . formatMessage ( messages . stringType ) ,
5858 intl . formatMessage ( messages . numberType ) ,
59- intl . formatMessage ( messages . compoundRuleType ) ,
6059 ] ,
6160 } ,
6261 } ,
6362 dependencies : {
6463 // Show operators appropriate to value type
6564 valueType : {
6665 oneOf : [
67- {
68- // nested rules
69- properties : {
70- valueType : {
71- enum : [ "compound rule" ] ,
72- } ,
73- left : { $ref : "#/definitions/tagRule" } ,
74- condition : {
75- title : " " , // empty title
76- type : "string" ,
77- enum : _values ( TaskPropertyOperationType ) ,
78- enumNames : operationTypeMessages ,
79- default : _values ( TaskPropertyOperationType ) [ 0 ] ,
80- } ,
81- right : { $ref : "#/definitions/tagRule" } ,
82- } ,
83- } ,
8466 {
8567 // string values
8668 properties : {
@@ -152,28 +134,23 @@ export const jsSchema = (intl, taskPropertyKeys) => {
152134 } ,
153135 ] ,
154136 } ,
155- value : {
156- oneOf : [
157- {
158- properties : {
159- value : {
160- minItems : 2 ,
161- } ,
162- } ,
163- } ,
164- {
165- properties : {
166- value : {
167- maxItems : 1 ,
168- } ,
169- commaSeparate : {
170- title : intl . formatMessage ( messages . commaSeparateValues ) ,
171- type : "boolean" ,
172- default : false ,
173- } ,
174- } ,
175- } ,
176- ] ,
137+ } ,
138+ } ,
139+ ruleGroup : {
140+ title : " " , // empty title for compact UI
141+ type : "object" ,
142+ properties : {
143+ condition : {
144+ title : intl . formatMessage ( messages . conditionLabel ) ,
145+ type : "string" ,
146+ enum : _values ( TaskPropertyOperationType ) ,
147+ enumNames : operationTypeMessages ,
148+ default : _values ( TaskPropertyOperationType ) [ 0 ] ,
149+ } ,
150+ rules : {
151+ title : "" ,
152+ type : "array" ,
153+ items : { $ref : "#/definitions/tagRule" } ,
177154 } ,
178155 } ,
179156 } ,
@@ -183,7 +160,7 @@ export const jsSchema = (intl, taskPropertyKeys) => {
183160 title : "" ,
184161 type : "object" ,
185162 properties : {
186- rootRule : { $ref : "#/definitions/tagRule " } ,
163+ rootRule : { $ref : "#/definitions/ruleGroup " } ,
187164 } ,
188165 } ,
189166 } ,
@@ -198,11 +175,7 @@ export const jsSchema = (intl, taskPropertyKeys) => {
198175 *
199176 * @private
200177 */
201- function buildUISchema ( deepness , taskPropertyKeys ) {
202- if ( deepness === 0 ) {
203- return { } ;
204- }
205-
178+ function buildUISchema ( taskPropertyKeys ) {
206179 let keyType = {
207180 classNames : "inline-selector mr-inline" ,
208181 "ui:widget" : "select" ,
@@ -218,15 +191,9 @@ function buildUISchema(deepness, taskPropertyKeys) {
218191 }
219192
220193 return {
221- classNames :
222- "property-rule mr-border-2 mr-border-white-10 mr-pt-2 mr-pb-3 mr-m-1 mr-pl-4 mr-flex" ,
194+ classNames : "property-rule-content mr-pt-1 mr-pb-0 mr-pl-1 mr-flex" ,
223195 valueType : {
224- classNames : "mr-text-green mr-w-48" ,
225- "ui:widget" : "select" ,
226- "ui:options" : { inline : true , label : true } ,
227- } ,
228- condition : {
229- classNames : "mr-ml-4 mr-w-24" ,
196+ classNames : "mr-text-green mr-w-40" ,
230197 "ui:widget" : "select" ,
231198 "ui:options" : { inline : true , label : false } ,
232199 } ,
@@ -240,12 +207,6 @@ function buildUISchema(deepness, taskPropertyKeys) {
240207 classNames : "inline-selector mr-inline" ,
241208 "ui:options" : { inline : true , label : false , orderable : false } ,
242209 } ,
243- commaSeparate : {
244- classNames : "inline-selector mr-inline" ,
245- "ui:options" : { inline : true } ,
246- } ,
247- left : buildUISchema ( deepness - 1 ) ,
248- right : buildUISchema ( deepness - 1 ) ,
249210 } ;
250211}
251212
@@ -259,11 +220,11 @@ export function ArrayFieldTemplate(props) {
259220 < div key = { index } >
260221 < div className = "mr-flex" >
261222 { element . children }
262- { props . items . length > 1 && (
223+ { props . items . length > 1 && props . schema ?. title === "Value" && (
263224 < Fragment >
264225 < button
265226 type = "button"
266- className = "mr-text-red-light mr-pb-4 mr-pl-2 "
227+ className = "mr-text-red-light mr-pb-4"
267228 onClick = { ( event ) => element . onDropIndexClick ( index ) ( event ) }
268229 >
269230 < SvgSymbol
@@ -278,7 +239,18 @@ export function ArrayFieldTemplate(props) {
278239 </ Fragment >
279240 ) }
280241 </ div >
281- { props . canAdd && props . items . length === index + 1 && (
242+ { props . schema ?. title !== "Value" && element . hasRemove && (
243+ < div className = "mr-border-b mr-border-grey mr-pb-2" >
244+ < button
245+ type = "button"
246+ className = "mr-text-red-light"
247+ onClick = { ( event ) => element . onDropIndexClick ( index ) ( event ) }
248+ >
249+ < FormattedMessage { ...messages . removeRuleButton } />
250+ </ button >
251+ </ div >
252+ ) }
253+ { props . schema ?. title === "Value" && props . canAdd && props . items . length === index + 1 && (
282254 < button
283255 type = "button"
284256 className = "mr-text-green-lighter mr-mt-1"
@@ -289,6 +261,13 @@ export function ArrayFieldTemplate(props) {
289261 ) }
290262 </ div >
291263 ) ) }
264+ { props . schema ?. title !== "Value" && props . canAdd && (
265+ < div className = "mr-mt-2" >
266+ < button type = "button" className = "mr-text-green-lighter" onClick = { props . onAddClick } >
267+ < FormattedMessage { ...messages . addRuleButton } />
268+ </ button >
269+ </ div >
270+ ) }
292271 </ div >
293272 ) ;
294273}
@@ -305,6 +284,17 @@ export function ArrayFieldTemplate(props) {
305284 */
306285export const uiSchema = ( intl , taskPropertyKeys ) => ( {
307286 propertyRules : {
308- rootRule : buildUISchema ( 7 , taskPropertyKeys ) ,
287+ rootRule : {
288+ classNames : "property-rule-group mr-m-1 " ,
289+ condition : {
290+ classNames : "mr-ml-1 mr-w-48" ,
291+ "ui:widget" : "select" ,
292+ "ui:options" : { inline : true , label : true , labelText : "__conditionLabel__" } ,
293+ } ,
294+ rules : {
295+ classNames : "mr-mt-2" ,
296+ items : buildUISchema ( taskPropertyKeys ) ,
297+ } ,
298+ } ,
309299 } ,
310300} ) ;
0 commit comments