-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Catalog Item with Tag Control element cannot be ordered #278
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,11 @@ export default class DialogDataService { | |
if (field.type === 'DialogFieldCheckBox' && fieldValue === 'f') { | ||
validation.isValid = false; | ||
validation.message = __('This field is required'); | ||
} else if (field.type === 'DialogFieldTagControl') { | ||
if (this.isInvalidTagControl(field.options.force_single_value, fieldValue)) { | ||
validation.isValid = false; | ||
validation.message = __('This field is required'); | ||
} | ||
} else if (_.isEmpty(fieldValue)) { | ||
validation.isValid = false; | ||
validation.message = __('This field is required'); | ||
|
@@ -143,4 +148,31 @@ export default class DialogDataService { | |
|
||
return validation; | ||
} | ||
|
||
/** | ||
* Determines if a value is a tag control and whether or not that value is valid | ||
* @memberof DialogDataService | ||
* @function isInvalidTagControl | ||
* @param forceSingleValue {boolean} Whether or not the field allows multiple selections | ||
* @param fieldValue {any} This is the value of the field in question to be validated | ||
**/ | ||
private isInvalidTagControl(forceSingleValue, fieldValue) { | ||
let invalid = false; | ||
|
||
if (forceSingleValue) { | ||
if (_.isNumber(fieldValue)) { | ||
if (fieldValue === 0) { | ||
invalid = true; | ||
} | ||
} else if (_.isEmpty(fieldValue)) { | ||
invalid = true; | ||
} | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the else but keep the if statement that is inside this. Same logic, just cuts down on a few lines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not the same logic though, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, gotcha. Sorry I misinterpreted it. Looks good to me. |
||
if (_.isEmpty(fieldValue)) { | ||
invalid = true; | ||
} | ||
} | ||
|
||
return invalid; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be made a little more concise by removing it from here and removing the else below and just changing the else to an if.