Update survey entity interaction inside list
This commit is contained in:
parent
be97c9f4bc
commit
559210768c
|
@ -5,9 +5,10 @@ import { EncuestaDetailComponent } from './detail/encuesta-detail.component';
|
||||||
import { EncuestaUpdateComponent } from './update/encuesta-update.component';
|
import { EncuestaUpdateComponent } from './update/encuesta-update.component';
|
||||||
import { EncuestaDeleteDialogComponent } from './delete/encuesta-delete-dialog.component';
|
import { EncuestaDeleteDialogComponent } from './delete/encuesta-delete-dialog.component';
|
||||||
import { EncuestaRoutingModule } from './route/encuesta-routing.module';
|
import { EncuestaRoutingModule } from './route/encuesta-routing.module';
|
||||||
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [SharedModule, EncuestaRoutingModule],
|
imports: [SharedModule, EncuestaRoutingModule, FontAwesomeModule],
|
||||||
declarations: [EncuestaComponent, EncuestaDetailComponent, EncuestaUpdateComponent, EncuestaDeleteDialogComponent],
|
declarations: [EncuestaComponent, EncuestaDetailComponent, EncuestaUpdateComponent, EncuestaDeleteDialogComponent],
|
||||||
entryComponents: [EncuestaDeleteDialogComponent],
|
entryComponents: [EncuestaDeleteDialogComponent],
|
||||||
})
|
})
|
||||||
|
|
|
@ -36,14 +36,23 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Lista de Encuestas del Usuario -->
|
<!-- Lista de Encuestas del Usuario -->
|
||||||
<div class="ds-list">
|
<div class="ds-list" oncontextmenu="return false;">
|
||||||
<div
|
<div
|
||||||
class="ds-list--entity"
|
class="ds-list--entity"
|
||||||
*ngFor="let encuesta of encuestas; trackBy: trackId"
|
*ngFor="let encuesta of encuestas; trackBy: trackId"
|
||||||
(dblclick)="openSurvey($event)"
|
(dblclick)="openSurvey($event)"
|
||||||
|
(click)="selectSurvey($event)"
|
||||||
[attr.data-id]="encuesta.id"
|
[attr.data-id]="encuesta.id"
|
||||||
>
|
>
|
||||||
<span>{{ encuesta.nombre }}</span>
|
<span>{{ encuesta.nombre }}</span>
|
||||||
|
<br />
|
||||||
|
<span>{{ encuesta.descripcion }}</span>
|
||||||
|
<br />
|
||||||
|
<span>{{ encuesta.fechaCreacion | formatMediumDatetime }}</span>
|
||||||
|
<br />
|
||||||
|
<span>{{ encuesta.calificacion }}</span>
|
||||||
|
<br />
|
||||||
|
<span><fa-icon [icon]="faShareAlt"></fa-icon></span>
|
||||||
|
|
||||||
<!-- <p>
|
<!-- <p>
|
||||||
<a [routerLink]="['/encuesta', encuesta.id, 'view']">{{ encuesta.id }}</a>
|
<a [routerLink]="['/encuesta', encuesta.id, 'view']">{{ encuesta.id }}</a>
|
||||||
|
|
|
@ -23,6 +23,8 @@ import { AccountService } from 'app/core/auth/account.service';
|
||||||
import { Account } from 'app/core/auth/account.model';
|
import { Account } from 'app/core/auth/account.model';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
import * as $ from 'jquery';
|
import * as $ from 'jquery';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -30,6 +32,9 @@ import * as $ from 'jquery';
|
||||||
templateUrl: './encuesta.component.html',
|
templateUrl: './encuesta.component.html',
|
||||||
})
|
})
|
||||||
export class EncuestaComponent implements OnInit, AfterViewInit {
|
export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
|
// Icons
|
||||||
|
faShareAlt = faShareAlt;
|
||||||
|
|
||||||
account: Account | null = null;
|
account: Account | null = null;
|
||||||
usuarioExtra: UsuarioExtra | null = null;
|
usuarioExtra: UsuarioExtra | null = null;
|
||||||
|
|
||||||
|
@ -80,7 +85,8 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
this.encuestaService.query().subscribe(
|
this.encuestaService.query().subscribe(
|
||||||
(res: HttpResponse<IEncuesta[]>) => {
|
(res: HttpResponse<IEncuesta[]>) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.encuestas = res.body ?? [];
|
const tmpEncuestas = res.body ?? [];
|
||||||
|
this.encuestas = tmpEncuestas.filter(e => e.usuarioExtra?.id === this.usuarioExtra?.id);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -89,12 +95,15 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loadAll();
|
document.body.addEventListener('click', e => {
|
||||||
|
if (e.target) {
|
||||||
// Call upon selecting a survey to edit
|
if (!(e.target as HTMLElement).classList.contains('ds-list--entity')) {
|
||||||
// this.updateForm(encuesta);
|
document.querySelectorAll('.ds-list--entity').forEach(e => {
|
||||||
|
e.classList.remove('active');
|
||||||
this.loadRelationshipsOptions();
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// this.activatedRoute.data.subscribe(({ encuesta }) => {
|
// this.activatedRoute.data.subscribe(({ encuesta }) => {
|
||||||
// if (encuesta.id === undefined) {
|
// if (encuesta.id === undefined) {
|
||||||
|
@ -114,6 +123,8 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
if (account !== null) {
|
if (account !== null) {
|
||||||
this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => {
|
this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => {
|
||||||
this.usuarioExtra = usuarioExtra.body;
|
this.usuarioExtra = usuarioExtra.body;
|
||||||
|
this.loadAll();
|
||||||
|
this.loadRelationshipsOptions();
|
||||||
if (this.usuarioExtra !== null) {
|
if (this.usuarioExtra !== null) {
|
||||||
if (this.usuarioExtra.id === undefined) {
|
if (this.usuarioExtra.id === undefined) {
|
||||||
const today = dayjs().startOf('day');
|
const today = dayjs().startOf('day');
|
||||||
|
@ -127,10 +138,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {}
|
||||||
let surveys = document.querySelectorAll('.ds-list--entity');
|
|
||||||
console.log(surveys);
|
|
||||||
}
|
|
||||||
|
|
||||||
trackId(index: number, item: IEncuesta): number {
|
trackId(index: number, item: IEncuesta): number {
|
||||||
return item.id!;
|
return item.id!;
|
||||||
|
@ -278,14 +286,12 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
openSurvey(event: any): void {
|
openSurvey(event: any): void {
|
||||||
const surveyId = event.target.getAttribute('data-id');
|
const surveyId = event.target.getAttribute('data-id');
|
||||||
this.router.navigate(['/encuesta', surveyId, 'edit']);
|
this.router.navigate(['/encuesta', surveyId, 'edit']);
|
||||||
|
}
|
||||||
|
|
||||||
// document.querySelectorAll(".ds-list--entity").forEach(ele => {
|
selectSurvey(event: any): void {
|
||||||
// console.log(ele);
|
document.querySelectorAll('.ds-list--entity').forEach(e => {
|
||||||
|
e.classList.remove('active');
|
||||||
// ele.addEventListener('dblclick', e => {
|
});
|
||||||
// console.log(e.target);
|
event.target.classList.add('active');
|
||||||
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,23 @@
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
grid-auto-rows: minmax(12.5rem, auto);
|
grid-auto-rows: minmax(12.5rem, auto);
|
||||||
border: 2px dashed #e6e6e6;
|
border: 2px dashed #f1f1f1;
|
||||||
border-radius: $border-radius-x-large;
|
border-radius: $border-radius-x-large;
|
||||||
padding: 1rem;
|
padding: 2rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
.ds-list--entity {
|
.ds-list--entity {
|
||||||
border: 2px solid #e6e6e6;
|
border: 1px solid #dadce0;
|
||||||
border-radius: $border-radius-small;
|
border-radius: $border-radius-small;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
margin: 1rem;
|
margin: 1rem;
|
||||||
transition: all 0.1s ease-in-out;
|
// transition: all 0.1s ease-in-out;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: #e8f0fe;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active {
|
||||||
|
background-color: #e8f0fe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
@media screen and (max-width: 1280px) {
|
||||||
|
.ds-list {
|
||||||
|
grid-template-columns: repeat(3, 1fr) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 880px) {
|
||||||
|
.ds-list {
|
||||||
|
grid-template-columns: repeat(2, 1fr) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 991px) {
|
@media screen and (max-width: 991px) {
|
||||||
.navbar {
|
.navbar {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -434,10 +446,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 767px) {
|
@media screen and (max-width: 767px) {
|
||||||
.ds-list {
|
|
||||||
grid-template-columns: repeat(3, 1fr) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tabs-navigation.vertical-navs {
|
.nav-tabs-navigation.vertical-navs {
|
||||||
padding: 0 28px;
|
padding: 0 28px;
|
||||||
}
|
}
|
||||||
|
@ -511,7 +519,7 @@
|
||||||
|
|
||||||
@media screen and (max-width: 576px) {
|
@media screen and (max-width: 576px) {
|
||||||
.ds-list {
|
.ds-list {
|
||||||
grid-template-columns: repeat(2, 1fr) !important;
|
grid-template-columns: repeat(1, 1fr) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar[class*='navbar-toggleable-'] .container {
|
.navbar[class*='navbar-toggleable-'] .container {
|
||||||
|
|
Loading…
Reference in New Issue