Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15079 | Rev 15082 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 15079 Rev 15081
Línea 3... Línea 3...
3
import { CKEditor } from 'ckeditor4-react'
3
import { CKEditor } from 'ckeditor4-react'
4
import React, { useEffect, useState } from 'react'
4
import React, { useEffect, useState } from 'react'
5
import { useRef } from 'react'
5
import { useRef } from 'react'
6
import { useForm } from 'react-hook-form'
6
import { useForm } from 'react-hook-form'
7
import { useDispatch } from 'react-redux'
7
import { useDispatch } from 'react-redux'
8
import { useHistory, useParams } from 'react-router-dom'
-
 
9
import { addNotification } from '../../redux/notification/notification.actions'
8
import { addNotification } from '../../redux/notification/notification.actions'
10
import { config } from '../../shared/helpers/ckeditor_config'
9
import { config } from '../../shared/helpers/ckeditor_config'
11
import ToggleComponent from '../../shared/ToggleComponent'
10
import ToggleComponent from '../../shared/ToggleComponent'
12
import ConductModal from '../component/ConductModal'
11
import ConductModal from '../component/ConductModal'
Línea 19... Línea 18...
19
	4: 'Cuatro'
18
	4: 'Cuatro'
20
}
19
}
Línea 21... Línea 20...
21
 
20
 
22
const FormView = ({
21
const FormView = ({
23
	actionLink = '',
22
	actionLink = '',
-
 
23
	setActionLink = function () { },
-
 
24
	action = '',
24
	setActionLink = function () { }
25
	setAction = function () { }
Línea 25... Línea 26...
25
}) => {
26
}) => {
26
 
27
 
27
	// Hooks
-
 
28
	const dispatch = useDispatch()
28
	// Hooks
29
	const history = useHistory()
29
	const dispatch = useDispatch()
30
	const selectInput = useRef(null)
-
 
-
 
30
	const selectInput = useRef(null)
31
	const selectInput2 = useRef(null)
31
	const selectInput2 = useRef(null)
32
	const { action } = useParams()
32
 
33
	const {
33
	const {
34
		setValue,
34
		setValue,
35
		register,
35
		register,
Línea 48... Línea 48...
48
	const [isShowModal, setIsShowModal] = useState(false)
48
	const [isShowModal, setIsShowModal] = useState(false)
49
	const [isActive, setIsActive] = useState(false)
49
	const [isActive, setIsActive] = useState(false)
Línea 50... Línea 50...
50
 
50
 
51
 
-
 
52
	const onSubmit = (data) => {
51
 
53
 
52
	const onSubmit = (data) => {
54
		const submitData = new FormData()
53
		const submitData = new FormData()
55
		submitData.append('subordinates_selected', JSON.stringify(subordinatesSelected))
54
		submitData.append('subordinates_selected', JSON.stringify(subordinatesSelected))
56
		submitData.append('competencies_selected', JSON.stringify(competenciesSelected))
55
		submitData.append('competencies_selected', JSON.stringify(competenciesSelected))
Línea 78... Línea 77...
78
							)
77
							)
79
						)
78
						)
80
					return
79
					return
81
				}
80
				}
Línea 82... Línea -...
82
 
-
 
83
				history.goBack()
81
 
-
 
82
				setActionLink('')
84
				setActionLink('')
83
				setAction('')
85
				dispatch(addNotification({
84
				dispatch(addNotification({
86
					style: 'success',
85
					style: 'success',
87
					msg: `Registro ${action === 'edit' ? 'actualizado' : 'añadido'}`
86
					msg: `Registro ${action === 'edit' ? 'actualizado' : 'añadido'}`
88
				}))
87
				}))
Línea 112... Línea 111...
112
	const deleteSubordinate = (id) => {
111
	const deleteSubordinate = (id) => {
113
		setSubordinatesSelected(prev => prev.filter(subordinate => subordinate.job_description_id !== id))
112
		setSubordinatesSelected(prev => prev.filter(subordinate => subordinate.job_description_id !== id))
114
	}
113
	}
Línea 115... Línea 114...
115
 
114
 
116
	const editLevel = (val) => {
-
 
117
		
-
 
118
		//console.log("val = " + val)
-
 
119
		console.log('competenciesSelected')
115
	const editLevel = (val) => {
120
		console.log(competenciesSelected)
-
 
121
		console.log('lenght = ' + competenciesSelected.length)
-
 
122
		
116
		setCompetenciesSelected(prev => {
123
		var i = 0;
117
			var i = 0
-
 
118
			var j = 0
124
		var j = 0;
119
 
125
		for (i = 0; i <competenciesSelected.length; i++) {
120
			for (i = 0; i < prev.length; i++) {
126
		   	if(competenciesSelected[i].competency_id === selectBehavior.competency_id) {
121
				if (prev[i].competency_id === selectBehavior.competency_id) {
127
				for(j = 0 ; j < competenciesSelected[i].behaviors.length; j++) {
122
					for (j = 0; j < prev[i].behaviors.length; j++) {
128
					if ( competenciesSelected[i].behaviors[j] .behavior_id === selectBehavior.behavior_id ) {
123
						if (prev[i].behaviors[j].behavior_id === selectBehavior.behavior_id) {
129
						
124
 
130
						competenciesSelected[i].behaviors[j].level = val
125
							prev[i].behaviors[j].level = val
-
 
126
							break
-
 
127
						}
131
						break;
128
 
132
					}
-
 
133
				
-
 
134
				}
129
					}
135
				break;
-
 
136
 			}
-
 
137
		} 
-
 
138
				
-
 
139
				
-
 
140
		setCompetenciesSelected(competenciesSelected)
-
 
141
		setSelectBehavior({})
-
 
142
				
-
 
143
		
-
 
144
		/*
-
 
145
		setCompetenciesSelected(prev => prev.map(competency => {
-
 
146
			if (competency.competency_id === selectBehavior.competency_id) {
-
 
147
				return {
-
 
148
					...competency,
-
 
149
					behaviors: competency.behaviors.map(cual => cual.behavior_id === selectBehavior.behavior_id && { ...cual, level: val })
130
					break
150
				}
131
				}
151
			}
132
			}
152
		}))
-
 
-
 
133
		})
153
		console.log(competenciesSelected)
134
 
154
		setSelectBehavior({})*/
135
		setSelectBehavior({})
155
		setIsShowModal(false)
136
		setIsShowModal(false)
Línea 156... Línea 137...
156
	}
137
	}
157
 
138