Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Functions:

Code Block
languagejs
this.allowSubmit(Boolean)

this.changeFormValue(field_name, new_value)

this.enableField(field_name, Boolean)

this.disableField(field_name)

this.mandatoryField(field_name, Boolean)

this.changeInputValue(field_name, value)

let value =  JSON.stringify(finalValues)
this.updateAnnotations(value)

let errorMsgs = []if(errorMsgs.length > 0) {
  this.displayErrors(errorMsgs)
  this.disAllowSubmit(true)
} else {  
  this.disAllowSubmit(false)
}

this.changeAnnotationClasses(newClass);

let inputText = inputValues[field_name]

let currentUserId = localStorage.getItem("userId")
if(currentUserLevel === 1) {  
  this.changeFormValue(field_name, `${currentUserId}`)
}

For NER: 
let entities = _.get(annotations, "[0].value.annotations.entities", _.get(annotations, "annotations.entities", []))

To access form values in On-Change/on-Validation/On-save(also console the values coming from values and formValues then use as required):
let fieldNameValue = formValues["field_name"]

Examples

  1. Audio transcription validation: No special characters allowed, tags validations, etc.

Code Block
let regexNotToMatch = {
  "Add at least one space before the normal start tag.": /[^ ]<[^\/]*[^\/]*>/g,
  "Add at least one space after the normal end tag.": /<\/\s*[^>]*>[^ ]/g,
  "Add at least one space before and after a single tag.": /[^ ]<[^>]*\/>[^ ]|[^ ]<[^>]*\/>|<[^>]*\/>[^ ]/g,
  "Numbers are not allowed.": /[0-9]/g,
  "Special character: ^ ( ) { } [ ] ; : $ % * = are not allowed.": /[\^(){}\[\];:$%*=]/g,
  "New line/Enter is not allowed.": /\n/g,
};
this.setState({ audioRegexNotToMatch: regexNotToMatch });

...

Code Block
languagejs
function getIdFromUrl(url) { return url.match(/[-\w]{25,}/); }

let inputUrl = getIdFromUrl(inputValues["image"])[0]
this.changeInputValue("image", "https://drive.google.com/uc?export=view&id="+inputUrl)

13. Excel view: Update all visible tasks based on changes in one task

Code Block
languagejs
function getDupProdIds(tId, selectedInputValues, that) {
  let dupProdIds = []

  let selectedItemId = selectedInputValues["CATLG_ITEM_ID"]
  
  for (let i = 0; i < allTasks.length; i++) {
    let currentTaskInput = that.getInputValueByID(allTasks[i].taskValues.taskId)
    let currentTaskItemId = currentTaskInput["CATLG_ITEM_ID"]
    if(currentTaskItemId == selectedItemId)
      dupProdIds.push(currentTaskInput["productID"])
  }
  return dupProdIds
}
      
let that = this
let tIdsInputValues = this.getInputValueByID(tID)
let val = values["Select Action"];
if(val == "Duplicate"){
        let dpValuIds = getDupProdIds(tID, tIdsInputValues, that)
        //dpValuIds()
        console.log("dup", dpValuIds)
        this.changeFormValue("dup_productID", dpValuIds.join(), tID) 
} else {
        this.changeFormValue("dup_productID", tIdsInputValues["productID"], tID)
}