Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12791 Rev 12836
Línea 67... Línea 67...
67
	const closeSectionModal = () => {
67
	const closeSectionModal = () => {
68
		setIsShowSectionModal(false)
68
		setIsShowSectionModal(false)
69
		setSectionSelected(INITIAL_SECTION)
69
		setSectionSelected(INITIAL_SECTION)
70
	}
70
	}
Línea 71... Línea 71...
71
 
71
 
-
 
72
	const addSection = ({ name, text }) => {
-
 
73
		const uuid = new Date().getTime()
-
 
74
		let position = 0
-
 
75
 
-
 
76
		content.forEach((section) => {
-
 
77
			if (position < section.position) {
-
 
78
				position = section.position
-
 
79
			}
-
 
80
			position++
-
 
81
		})
-
 
82
 
-
 
83
		const newSection = {
-
 
84
			slug_section: `section${uuid}`,
-
 
85
			name: name,
-
 
86
			text: text,
-
 
87
			position: position,
-
 
88
			questions: [],
-
 
89
			status: 0
-
 
90
		}
72
	const addSection = (section) => {
91
 
73
		setContent(prev => [...prev, section])
92
		setContent(prev => [...prev, newSection])
Línea 74... Línea 93...
74
	}
93
	}
75
 
94
 
76
	const editSection = (section) => {
95
	const editSection = ({ name, text, slug }) => {
77
		setContent(prev => prev.map(contentSection => {
96
		setContent(prev => prev.map(contentSection => {
78
			if (contentSection.slug_section === section.slug_section) {
97
			if (contentSection.slug_section === slug.slug_section) {
79
				return section
98
				return { ...contentSection, name: name, text: text }
80
			}
99
			}
Línea 81... Línea 100...
81
		}))
100
		}))
Línea 198... Línea 217...
198
										<div className="row">
217
										<div className="row">
199
											<div className="col-xs-12 col-md-12">
218
											<div className="col-xs-12 col-md-12">
200
												<hr />
219
												<hr />
201
												<h4 style={{ fontSize: 18, fontWeight: 'bold' }}>Competencias asociadas al cargo:</h4>
220
												<h4 style={{ fontSize: 18, fontWeight: 'bold' }}>Competencias asociadas al cargo:</h4>
202
												<button className='btn btn-primary' onClick={() => showSectionModal()}>
221
												<button className='btn btn-primary' onClick={() => showSectionModal()}>
203
                                                    Agregar sección
222
													Agregar sección
204
												</button>
223
												</button>
205
												<br />
224
												<br />
206
												<div className="panel-group" id="rows-job-competencies" >
225
												<div className="panel-group" id="rows-job-competencies" >
207
													{
226
													{
208
														content.length > 0
227
														content.length > 0
209
                                                        &&
228
														&&
210
                                                        content.map((section) => {
229
														content.map((section) => {
Línea 211... Línea 230...
211
 
230
 
212
                                                        	return (
231
															return (
213
                                                        		<div className="panel panel-default" key={section.slug_section}>
232
																<div className="panel panel-default" key={section.slug_section}>
214
                                                        			<div className="panel-heading">
233
																	<div className="panel-heading">
215
                                                        				<h4 className="panel-title">
234
																		<h4 className="panel-title">
216
                                                        					<a className="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent={`panel-${section.slug_section}`} href={`#collapse-${section.slug_section}`}>
235
																			<a className="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent={`panel-${section.slug_section}`} href={`#collapse-${section.slug_section}`}>
217
                                                        						<span className={`section-name${section.slug_section}`}>
236
																				<span className={`section-name${section.slug_section}`}>
218
                                                        							{section.name}
237
																					{section.name}
219
                                                        						</span>
238
																				</span>
220
                                                        					</a>
239
																			</a>
221
                                                        				</h4>
240
																		</h4>
222
                                                        			</div>
241
																	</div>
223
                                                        			<div id="collapse-section1661528423935" className="panel-collapse in collapse show">
242
																	<div id="collapse-section1661528423935" className="panel-collapse in collapse show">
224
                                                        				<div className="panel-body">
243
																		<div className="panel-body">
225
                                                        					<div className="table-responsive">
244
																			<div className="table-responsive">
226
                                                        						<table className="table table-bordered">
245
																				<table className="table table-bordered">
227
                                                        							<thead>
246
																					<thead>
228
                                                        								<tr>
247
																						<tr>
229
                                                        									<th style={{ width: '10%' }}>Elemento</th>
248
																							<th style={{ width: '10%' }}>Elemento</th>
230
                                                        									<th style={{ width: '50%' }}>Texto</th>
249
																							<th style={{ width: '50%' }}>Texto</th>
231
                                                        									<th style={{ width: '10%' }}>Tipo</th>
250
																							<th style={{ width: '10%' }}>Tipo</th>
232
                                                        									<th style={{ width: '20%' }}>Acciones</th>
251
																							<th style={{ width: '20%' }}>Acciones</th>
233
                                                        								</tr>
252
																						</tr>
234
                                                        							</thead>
253
																					</thead>
235
                                                        							<tbody>
254
																					<tbody>
236
                                                        								<tr className="tr-section">
255
																						<tr className="tr-section">
237
                                                        									<td className="text-left">Sección</td>
256
																							<td className="text-left">Sección</td>
238
                                                        									<td className="text-left">{section.name}</td>
257
																							<td className="text-left">{section.name}</td>
239
                                                        									<td />
258
																							<td />
240
                                                        									<td>
259
																							<td>
241
                                                        										<button className="btn btn-default" onClick={() => showSectionModal(section, 'edit')}>
260
																								<button className="btn btn-default" onClick={() => showSectionModal(section, 'edit')}>
242
                                                        											<i className="fa fa-edit" />
261
																									<i className="fa fa-edit" />
243
                                                                                                    Editar Sección
262
																									Editar Sección
244
                                                        										</button>
263
																								</button>
245
                                                        										<button className="btn btn-default" >
264
																								<button className="btn btn-default" >
246
                                                        											<i className="fa fa-ban" />
265
																									<i className="fa fa-ban" />
247
                                                                                                    Borrar Sección
266
																									Borrar Sección
248
                                                        										</button>
267
																								</button>
249
                                                        										<button className="btn btn-default btn-add-question" >
268
																								<button className="btn btn-default btn-add-question" >
250
                                                        											<i className="fa fa-plus" />
269
																									<i className="fa fa-plus" />
251
                                                                                                    Agregar  Pregunta
270
																									Agregar  Pregunta
252
                                                        										</button>
271
																								</button>
253
                                                        									</td>
272
																							</td>
254
                                                        								</tr>
273
																						</tr>
255
                                                        								{
274
																						{
256
                                                        									section.questions.map((question) => (
275
																							section.questions.map((question) => (
257
                                                        										<tr key={question.slug_question} className="tr-question">
276
																								<tr key={question.slug_question} className="tr-question">
258
                                                        											<td className="text-left">Pregunta</td>
277
																									<td className="text-left">Pregunta</td>
259
                                                        											<td className="text-left">
278
																									<td className="text-left">
260
                                                        												{parse(question.text)}
279
																										{parse(question.text)}
261
                                                        											</td>
280
																									</td>
262
                                                        											<td className="text-capitalize">
281
																									<td className="text-capitalize">
263
                                                        												{sectionTypeOptions[question.type]}
282
																										{sectionTypeOptions[question.type]}
264
                                                        											</td>
283
																									</td>
265
                                                        											<td>
284
																									<td>
266
                                                        												<button className="btn btn-default btn-edit-question">
285
																										<button className="btn btn-default btn-edit-question">
267
                                                        													<i className="fa fa-edit" /> Editar Pregunta
286
																											<i className="fa fa-edit" /> Editar Pregunta
268
                                                        												</button>
287
																										</button>
269
                                                        												<button className="btn btn-default btn-delete-question">
288
																										<button className="btn btn-default btn-delete-question">
270
                                                        													<i className="fa fa-ban" /> Borrar Pregunta
289
																											<i className="fa fa-ban" /> Borrar Pregunta
271
                                                        												</button>
290
																										</button>
272
                                                        											</td>
291
																									</td>
273
                                                        										</tr>
292
																								</tr>
274
                                                        									))
293
																							))
275
                                                        								}
294
																						}
276
                                                        							</tbody>
295
																					</tbody>
277
                                                        						</table>
296
																				</table>
278
                                                        					</div>
297
																			</div>
279
                                                        				</div>
298
																		</div>
280
                                                        			</div>
299
																	</div>
281
                                                        		</div>
300
																</div>
282
                                                        	)
301
															)
283
                                                        })
302
														})
284
													}
303
													}
285
												</div>
304
												</div>
286
											</div>
305
											</div>
287
										</div>
306
										</div>
Línea 297... Línea 316...
297
					</div>
316
					</div>
298
				</div >
317
				</div >
299
			</section >
318
			</section >
300
			<SectionModal
319
			<SectionModal
301
				show={isShowSection}
320
				show={isShowSection}
-
 
321
				sectionType={sectionType}
302
				section={sectionSelected}
322
				section={sectionSelected}
303
				closeModal={closeSectionModal}
323
				closeModal={closeSectionModal}
304
				onSubmit={sectionType === 'add' ? addSection : editSection}
324
				onSubmit={sectionType === 'add' ? addSection : editSection}
305
			/>
325
			/>
306
		</>
326
		</>