Untitled

 avatar
unknown
javascript
a year ago
1.6 kB
6
Indexable
// WATCH
    switchUniao(newValue, oldValue) {
      let item = this.defaultValue[0]
      if(item) {

        if (item.ministerio === "TODOS") {
          item.ministerio = "Todos os ministérios da União"
        }
  
        
        if(newValue === false) {
          this.selectedMinisterios = []
          this.editTags.ministerio = []
        } else {
          this.selectedMinisterios = item?.ministerio.split(", ")
          this.editTags.ministerio = item?.ministerio.split(", ")
        }
      }
    },
    selectedMinisterios(newValue, oldValue) {
      const arrayDefaultValue = this.defaultValue[0]?.ministerio.split(', ')

      if(arrayDefaultValue === "Todos os ministérios da União") {
          arrayDefaultValue = "TODOS"
        }

        const hasArrayDefaultValue = arrayDefaultValue?.includes('TODOS')
        const hasElementNewValue = newValue?.includes('Todos os ministérios da União')

        if(hasArrayDefaultValue && hasElementNewValue) {
          this.hideButtonSave = true
        } else if(newValue.length === 0) {
          this.hideButtonSave = true
        } else {
          this.hideButtonSave = false
        }
    },


// METHODS
// enableButtonSave(element)
if (element.value === 'selectMinisterios') {        

    const arrayDefaultValue = this.defaultValue[0]?.ministerio.split(', ')
    
    if(JSON.stringify(element.newValue) !== JSON.stringify(arrayDefaultValue) && element.newValue.length !== 0) {
      this.hideButtonSave = false
    } else {
      this.hideButtonSave = true
    }

}
Editor is loading...
Leave a Comment