New Attachmentes Page with Skeleton. EventAttachments Model revised. Compatibility with v2. Get Attachments revised.

This commit is contained in:
Paulo Pinto
2020-08-24 23:41:15 +01:00
parent 91147ef6b9
commit 751b8dd7c5
23 changed files with 494 additions and 74 deletions
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AttachmentsPage } from './attachments.page';
const routes: Routes = [
{
path: '',
component: AttachmentsPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AttachmentsPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { AttachmentsPageRoutingModule } from './attachments-routing.module';
import { AttachmentsPage } from './attachments.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
AttachmentsPageRoutingModule
],
declarations: [AttachmentsPage]
})
export class AttachmentsPageModule {}
@@ -0,0 +1,102 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button routerDirection="back">Voltar</ion-back-button>
</ion-buttons>
<ion-title>Anexos do evento</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div *ngIf="loadedEventAttachments">
<ion-list>
<ion-item-sliding>
<ion-item lines="none" *ngFor="let att of loadedEventAttachments" [routerLink]="['/home/viewer', att.SourceId]">
<div class="div-item">
<div class="div-up">
<div class="div-icon">
<ion-icon class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
</div>
<div class="div-content-attachment">
<h3>{{ att.SourceName }}</h3>
<p>{{ att.CreateDate }}</p>
<p>{{ att.Description }}</p>
</div>
</div>
<div class="div-botton">
<div class="div-botton-left">
<ion-icon class="ion-icon-location" slot="start" name="location"></ion-icon>
</div>
<div class="div-botton-middle">
<p class="item-list-small">{{ att.Stakeholders }}</p>
</div>
</div>
</div>
</ion-item>
</ion-item-sliding>
</ion-list>
</div>
<!-- Skeleton screen -->
<div *ngIf="!loadedEventAttachments">
<div class="ion-padding custom-skeleton">
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
<ion-skeleton-text animated></ion-skeleton-text>
<ion-skeleton-text animated style="width: 88%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 70%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</div>
<ion-list>
<ion-list-header>
<ion-label>
<ion-skeleton-text animated style="width: 20%"></ion-skeleton-text>
</ion-label>
</ion-list-header>
<ion-item>
<ion-avatar slot="start">
<ion-skeleton-text animated></ion-skeleton-text>
</ion-avatar>
<ion-label>
<h3>
<ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
</h3>
<p>
<ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
</p>
<p>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</p>
</ion-label>
</ion-item>
<ion-item>
<ion-thumbnail slot="start">
<ion-skeleton-text animated></ion-skeleton-text>
</ion-thumbnail>
<ion-label>
<h3>
<ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
</h3>
<p>
<ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
</p>
<p>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</p>
</ion-label>
</ion-item>
<ion-item>
<ion-skeleton-text animated style="width: 27px; height: 27px" slot="start"></ion-skeleton-text>
<ion-label>
<h3>
<ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
</h3>
<p>
<ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
</p>
<p>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</p>
</ion-label>
</ion-item>
</ion-list>
</div>
</ion-content>
@@ -0,0 +1,102 @@
/* CONTENT */
.item-list-small{
font-size: 14px;
overflow: auto;
}
.ion-item-class{
padding: 0;
}
.label-text{
width: 100%;
padding: 0;
margin: 0;
}
//DIV
.div-item{
width: 100%;
overflow: auto;
border-bottom: 1px solid #ccc;
margin: 10px 0 5px 0;
}
.div-up{
width: 100%;
overflow: auto;
}
.div-up h3{
margin: 0;
padding: 0;
font-size: 17px;
width: 100%;
}
.div-icon{
width: 10%;
font-size: 22px;
float: left;
color: #808080;
}
.div-icon ion-icon{
display: block;
margin: 0 auto;
}
.div-content-attachment{
width: 85%;
float: left;
padding: 0 0 0 12px;
}
.div-content-oficial h3, .div-content-pessoal h3{
font-size: 16pt;
/* border: 1px solid red; */
}
.div-content-oficial p, .div-content-pessoal p{
font-size: 14pt;
color: rgb(94, 92, 92);
padding: 0 !important;
margin: 0 !important;
}
.div-botton{
width: 100%;
overflow: auto;
margin: 10px 0 5px 0;
}
.div-botton-left{
width: 10%;
float: left;
}
.ion-icon-location{
text-align: center;
display: block;
color: #000;
font-size: 16px;
margin: 0 auto;
}
.div-botton-middle{
width: 75%;
float: left;
margin-top: 0.5px;
}
.div-botton-middle p{
padding: 0;
margin: 0;
}
.div-botton-right{
width: 10%;
float: left;
margin: 0;
padding: 0;
}
.ion-icon-attach{
color: #666666;
font-size: 20px;
}
/* Custom Skeleton Line Height and Margin */
.custom-skeleton ion-skeleton-text {
line-height: 13px;
}
.custom-skeleton ion-skeleton-text:last-child {
margin-bottom: 5px;
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { AttachmentsPage } from './attachments.page';
describe('AttachmentsPage', () => {
let component: AttachmentsPage;
let fixture: ComponentFixture<AttachmentsPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AttachmentsPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(AttachmentsPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,35 @@
import { Component, OnInit } from '@angular/core';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Attachment } from 'src/app/models/attachment.model';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-attachments',
templateUrl: './attachments.page.html',
styleUrls: ['./attachments.page.scss'],
})
export class AttachmentsPage implements OnInit {
loadedEventAttachments: Attachment[];
constructor(private attachamentsService: AttachmentsService, private activatedRoute: ActivatedRoute) { }
ngOnInit() {
/* Emit new data when something changes */
this.activatedRoute.paramMap.subscribe(paramMap =>{
if(!paramMap.has('eventId')){
//Redirect
return;
}
this.loadAttachments(paramMap.get('eventId'));
});
}
loadAttachments(eventid:string)
{
this.attachamentsService.getEventAttachments(eventid).subscribe(attachments => {
this.loadedEventAttachments = attachments;
});
}
}
@@ -6,12 +6,11 @@
<ion-title>Visualizar Evento</ion-title>
</ion-toolbar>
</ion-header>
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<ion-content padding>
<ion-item-group>
<ion-item>
<ion-label position="stacked">Assunto</ion-label>
<!-- <ion-input value='{{event.Subject}}'></ion-input> -->
<ion-input [(ngModel)]="loadedEvent.Subject"></ion-input>
</ion-item>
<ion-item>
@@ -31,27 +30,48 @@
</ion-list>
</ion-item>
<ion-item>
<ion-label position="stacked">Calendário</ion-label>
<ion-input [(ngModel)]='loadedEvent.CalendarName'></ion-input>
<ion-label position="stacked">Agenda</ion-label>
<ion-select [(ngModel)]="loadedEvent.CalendarName" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
<ion-select-option Pessoal="Reunião">Pessoal</ion-select-option>
<ion-select-option Oficial="Viagem">Oficial</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="stacked">Tipo do evento</ion-label>
<ion-input [(ngModel)]='loadedEvent.EventType'></ion-input>
<ion-label position="stacked">Selecione o tipo de evento</ion-label>
<ion-select [(ngModel)]="loadedEvent.EventType" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
<ion-select-option value="Reunião">Reunião</ion-select-option>
<ion-select-option value="Viagem">Viagem</ion-select-option>
<ion-select-option value="Conferência">Conferência</ion-select-option>
<ion-select-option value="Encontro">Encontro</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="stacked">Data Início: </ion-label>
<ion-input [(ngModel)]='loadedEvent.StartDate'></ion-input>
<ion-label position="stacked">Data Início</ion-label>
<ion-datetime [(ngModel)]="loadedEvent.StartDate" min="2020" max="2100"
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
<ion-item>
<ion-label position="stacked">Data Fim</ion-label>
<ion-input [(ngModel)]='loadedEvent.EndDate'></ion-input>
<ion-datetime [(ngModel)]="loadedEvent.EndDate" min="2020" max="2100"
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
<ion-list>
<ion-list-header>Anexos</ion-list-header>
<ion-item>
<ion-icon name="attach" slot="start"></ion-icon>
<ion-label>Lei do orçamento geral do Estado</ion-label>
</ion-item>
<ion-item-sliding>
<ion-item lines="none" [routerLink]="['/home/attachments', loadedEvent.EventId]">
<div class="div-item">
<div class="div-up">
<div class="div-icon">
<ion-icon class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
</div>
<div class="div-content-attachment">
<h3>Ver anexos</h3>
</div>
</div>
</div>
</ion-item>
</ion-item-sliding>
</ion-list>
</ion-item-group>
<div class="event-detail-buttons">
@@ -11,4 +11,40 @@
}
.ion-button-right{
float: right;
}
}
.div-item{
width: 100%;
overflow: auto;
border-bottom: 1px solid #ccc;
margin: 10px 0 5px 0;
}
.div-up{
width: 100%;
overflow: auto;
}
.div-up h3{
margin: 0;
padding: 0;
font-size: 17px;
width: 100%;
}
.div-icon{
width: 10%;
font-size: 22px;
float: left;
color: #808080;
}
.div-icon ion-icon{
display: block;
margin: 0 auto;
}
.div-content-attachment{
width: 85%;
float: left;
padding: 0 0 0 12px;
}
.ion-icon-attach{
color: #666666;
font-size: 20px;
}
@@ -1,11 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { EventsService } from 'src/app/services/events.service';
import { Router } from '@angular/router';
import { Event } from '../../../models/event.model';
import { Observable } from 'rxjs';
import { EventBody } from 'src/app/models/eventbody.model';
import { AlertController } from '@ionic/angular';
import { Attachment } from 'src/app/models/attachment.model';
import { ActionSheetController } from '@ionic/angular';
@Component({
selector: 'app-event-detail',
@@ -15,9 +17,11 @@ import { AlertController } from '@ionic/angular';
export class EventDetailPage implements OnInit {
loadedEvent: Event;
eventItem: Observable<Event>;
loadedEventAttachments: Attachment[];
showLoader: boolean = true;
constructor(public alertController: AlertController, private router: Router, private activatedRoute: ActivatedRoute, private eventsService: EventsService) {
constructor(public actionSheetController: ActionSheetController, public alertController: AlertController, private router: Router, private activatedRoute: ActivatedRoute,
private eventsService: EventsService) {
this.loadedEvent = new Event();
this.loadedEvent.Body = new EventBody();
}
@@ -29,19 +33,17 @@ export class EventDetailPage implements OnInit {
//Redirect
return;
}
const eventId = paramMap.get('eventId');
this.loadEvent(paramMap.get('eventId'));
});
}
console.log(eventId);
/* Load my event detail */
/* this.loadedEvent = this.eventsService.getEvent(eventId); */
this.eventItem = this.eventsService.getEvent(eventId);
/* console.log(this.eventItem); */
this.eventsService.getEvent(eventId).subscribe(response =>
{
this.loadedEvent = response;
});
loadEvent(eventid:string)
{
this.showLoader = true;
this.eventsService.getEvent(eventid).subscribe(event => {
this.loadedEvent = event;
this.showLoader = false;
});
}
@@ -56,7 +58,7 @@ export class EventDetailPage implements OnInit {
text: 'Não',
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => { }
handler: () => { }
}, {
text: 'Sim',
handler: () => {
@@ -71,7 +73,7 @@ export class EventDetailPage implements OnInit {
Delete()
{
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async response =>
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () =>
{
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
@@ -87,7 +89,7 @@ export class EventDetailPage implements OnInit {
Save()
{
this.eventsService.putEvent(this.loadedEvent, 2, 3).subscribe(async response =>
this.eventsService.putEvent(this.loadedEvent, 2, 3).subscribe(async () =>
{
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
@@ -100,5 +102,4 @@ export class EventDetailPage implements OnInit {
this.router.navigate(['/home/events']);
});
}
}
@@ -11,6 +11,10 @@ const routes: Routes = [
{
path: 'event-detail',
loadChildren: () => import('./event-detail/event-detail.module').then( m => m.EventDetailPageModule)
},
{
path: 'attachments',
loadChildren: () => import('./attachments/attachments.module').then( m => m.AttachmentsPageModule)
}
];
+1 -1
View File
@@ -106,7 +106,7 @@
<p class="item-list-small">{{event.Location}}</p>
</div>
<div class="div-botton-right">
<ion-icon class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
<ion-icon *ngIf="event.HasAttachments" class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
</div>
</div>
</div>