Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 13068 Rev 13069
Línea 47... Línea 47...
47
	range: '0',
47
	range: '0',
48
	options: [],
48
	options: [],
49
	answer: ''
49
	answer: ''
50
}
50
}
Línea 51... Línea -...
51
 
-
 
52
 
51
 
Línea 53... Línea 52...
53
const FormView = ({ actionLink }) => {
52
const FormView = ({ actionLink }) => {
54
 
53
 
55
	// Hooks
54
	// Hooks
Línea 77... Línea 76...
77
	const [status, setStatus] = useState('A')
76
	const [status, setStatus] = useState('A')
78
	const [showDeleteModal, setShowDeleteModal] = useState(false)
77
	const [showDeleteModal, setShowDeleteModal] = useState(false)
79
	const [deleteType, setDeleteType] = useState('section')
78
	const [deleteType, setDeleteType] = useState('section')
80
	const deleteSlugsOptions = {
79
	const deleteSlugsOptions = {
81
		section: sectionSelected.slug_section,
80
		section: sectionSelected.slug_section,
82
		question: questionSelected.slug_question
81
		question: questionSelected.slug_question,
-
 
82
		option: optionSelected.slug_option
83
	}
83
	}
Línea 84... Línea 84...
84
 
84
 
85
	// Section methods
85
	// Section methods
86
	const showSectionModal = (section = INITIAL_SECTION, type = 'add') => {
86
	const showSectionModal = (section = INITIAL_SECTION, type = 'add') => {
Línea 218... Línea 218...
218
 
218
 
219
		setContent(current =>
219
		setContent(current =>
220
			current.map(currentSection => {
220
			current.map(currentSection => {
Línea -... Línea 221...
-
 
221
				if (currentSection.slug_section === sectionSelected.slug_section) {
-
 
222
 
221
				if (currentSection.slug_section === sectionSelected.slug_section) {
223
					return {
222
 
224
						...currentSection,
-
 
225
						questions: currentSection.questions.map(currentQuestion => {
223
					currentSection.questions.map(currentQuestion => {
226
							if (currentQuestion.slug_question === questionSelected.slug_question) {
224
						if (currentQuestion.slug_question === questionSelected.slug_question) {
227
 
225
							return {
228
								return {
226
								...currentQuestion,
229
									...currentQuestion,
227
								options: [
230
									options: [
228
									...currentQuestion.options,
231
										...currentQuestion.options,
229
									{
232
										{
230
										...option,
233
											...option,
231
										slug_question: questionSelected.slug_question,
234
											slug_question: questionSelected.slug_question,
232
										slug_section: sectionSelected.slug_section,
235
											slug_section: sectionSelected.slug_section,
233
										slug_option: `option${uuid}`
236
											slug_option: `option${uuid}`
-
 
237
										}
234
									}
238
									]
235
								]
-
 
Línea 236... Línea 239...
236
							}
239
								}
237
						}
240
							}
-
 
241
 
238
 
242
							return currentQuestion
239
						return currentQuestion
-
 
240
					})
243
						})
241
				}
244
					}
242
 
245
				}
243
				return currentSection
246
				return currentSection
Línea 244... Línea 247...
244
			})
247
			})
245
		)
248
		)
246
	}
249
	}
247
 
250
 
Línea -... Línea 251...
-
 
251
	const deleteOption = (slug) => {
-
 
252
		setContent(current =>
248
	const deleteOption = (slug) => {
253
			current.map(currentSection => {
Línea 249... Línea 254...
249
		setContent(current =>
254
				if (currentSection.slug_section === sectionSelected.slug_section) {
250
			current.map(currentSection => {
255
 
251
				if (currentSection.slug_section === sectionSelected.slug_section) {
256
					return {
252
 
257
						...currentSection,
-
 
258
						questions: currentSection.questions.map(question => {
253
					currentSection.questions.map(question => {
259
 
254
 
-
 
Línea 255... Línea 260...
255
						if (question.slug_question === questionSelected.slug_question) {
260
							if (question.slug_question === questionSelected.slug_question) {
256
							return {
261
								return {
-
 
262
									...question,
257
								...question,
263
									options: question.options.filter(option => option.slug_option !== slug)
Línea 258... Línea 264...
258
								options: question.options.filter(option => option.slug_option !== slug)
264
								}
259
							}
265
							}
260
						}
266
 
Línea 485... Línea 491...
485
																										</td>
491
																										</td>
486
																									</tr>
492
																									</tr>
487
																									{
493
																									{
488
																										question.options.map(option => (
494
																										question.options.map(option => (
489
																											<tr key={option.slug_question} className="tr-option">
495
																											<tr key={option.slug_question} className="tr-option">
490
																												<td className="text-left">Pregunta</td>
496
																												<td className="text-left">Opción</td>
491
																												<td className="text-left">
497
																												<td className="text-left">
492
																													{parse(option.text)}
498
																													{parse(option.text)}
493
																												</td>
499
																												</td>
494
																												<td />
500
																												<td />
495
																												<td>
501
																												<td>