|
|
@@ -93,14 +93,12 @@ export class TareasComponent {
|
|
|
|
|
|
}
|
|
|
|
|
|
- openDialog(tarea?: any) {
|
|
|
- let dialogRef;
|
|
|
-
|
|
|
- dialogRef = this.dialog.open(ModalTarea, {
|
|
|
- autoFocus: false,
|
|
|
- data: tarea ?? null // <--- paso la tarea si existe
|
|
|
- });
|
|
|
- }
|
|
|
+ openDialog(tarea?: any) {
|
|
|
+ this.dialog.open(ModalTarea, {
|
|
|
+ autoFocus: false,
|
|
|
+ data: tarea ? tarea : null
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -312,7 +310,7 @@ export class TareasComponent {
|
|
|
],
|
|
|
})
|
|
|
export class ModalTarea {
|
|
|
- constructor(
|
|
|
+ constructor(
|
|
|
public dialog: MatDialog,
|
|
|
private circularService: CircularService,
|
|
|
private _enviarInfoService: EnviarInfoService,
|
|
|
@@ -323,17 +321,6 @@ export class ModalTarea {
|
|
|
private tareaService: TareasService,
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
|
) {
|
|
|
- try {
|
|
|
- if (this.data && typeof this.data === 'string' && this.data.trim() !== '') {
|
|
|
- this.data = JSON.parse(this.data);
|
|
|
- } else if (!this.data) {
|
|
|
- this.data = {};
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- console.warn('Error al parsear data:', e);
|
|
|
- this.data = {};
|
|
|
- }
|
|
|
-
|
|
|
this.getTipoTareas();
|
|
|
this.getMaterias();
|
|
|
}
|
|
|
@@ -377,35 +364,34 @@ export class ModalTarea {
|
|
|
];
|
|
|
|
|
|
|
|
|
- ngOnInit(): void {
|
|
|
- this.editor = new Editor();
|
|
|
-
|
|
|
- if (this.data) {
|
|
|
- this.modoEdicion = true;
|
|
|
-
|
|
|
- // Rellenar el formulario con la info de la tarea
|
|
|
- this.form.patchValue({
|
|
|
- tituloTarea: this.data.tituloTarea,
|
|
|
- idMateriaTarea: this.data.idMateriaTarea,
|
|
|
- idTipoTarea: this.data.idTipoTarea,
|
|
|
- descripcionTarea: this.data.descripcionTarea,
|
|
|
- fechaPublicacion: moment(this.data.fechaPublicacion).toDate(),
|
|
|
- horaPublicacion: moment(this.data.fechaPublicacion).format("HH:mm:ss"),
|
|
|
- fechaEntrega: moment(this.data.fechaEntrega).toDate(),
|
|
|
- horaEntrega: moment(this.data.fechaEntrega).format("HH:mm:ss"),
|
|
|
- });
|
|
|
+ngOnInit(): void {
|
|
|
+ this.editor = new Editor();
|
|
|
|
|
|
- // URLs
|
|
|
- if (this.data.vinculoTarea) {
|
|
|
- this.urls = this.data.vinculoTarea.split("||");
|
|
|
- }
|
|
|
+ if (this.data && this.data.idTarea) { // Solo si trae idTarea
|
|
|
+ this.modoEdicion = true;
|
|
|
|
|
|
- // Archivos (si existen en la tarea)
|
|
|
- if (this.data.adjuntoTarea) {
|
|
|
- this.archivosData = this.data.adjuntoTarea;
|
|
|
- }
|
|
|
+ this.form.patchValue({
|
|
|
+ tituloTarea: this.data.tituloTarea,
|
|
|
+ idMateriaTarea: this.data.idMateriaTarea,
|
|
|
+ idTipoTarea: this.data.idTipoTarea,
|
|
|
+ descripcionTarea: this.data.descripcionTarea,
|
|
|
+ fechaPublicacion: moment(this.data.fechaPublicacion).toDate(),
|
|
|
+ horaPublicacion: moment(this.data.fechaPublicacion).format("HH:mm:ss"),
|
|
|
+ fechaEntrega: moment(this.data.fechaEntrega).toDate(),
|
|
|
+ horaEntrega: moment(this.data.fechaEntrega).format("HH:mm:ss"),
|
|
|
+ });
|
|
|
+
|
|
|
+ if (this.data.vinculoTarea) {
|
|
|
+ this.urls = this.data.vinculoTarea.split("||");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.data.adjuntoTarea) {
|
|
|
+ this.archivosData = this.data.adjuntoTarea;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ this.modoEdicion = false; // fuerza modo creación
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
ngOnDestroy(): void {
|
|
|
this.editor.destroy();
|