mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve publication forms
This commit is contained in:
@@ -8,12 +8,40 @@ import { NewActionPageRoutingModule } from './new-action-routing.module';
|
|||||||
|
|
||||||
import { NewActionPage } from './new-action.page';
|
import { NewActionPage } from './new-action.page';
|
||||||
|
|
||||||
|
|
||||||
|
import { MatNativeDateModule } from '@angular/material/core';
|
||||||
|
import {
|
||||||
|
NgxMatDatetimePickerModule,
|
||||||
|
NgxMatNativeDateModule,
|
||||||
|
NgxMatTimepickerModule
|
||||||
|
} from '@angular-material-components/datetime-picker';
|
||||||
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
|
import { NgxMatMomentModule } from '@angular-material-components/moment-adapter';
|
||||||
|
import { MAT_DATE_LOCALE } from '@angular/material/core';
|
||||||
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||||
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
IonicModule,
|
IonicModule,
|
||||||
NewActionPageRoutingModule
|
NewActionPageRoutingModule,
|
||||||
|
// Angular material
|
||||||
|
MatDatepickerModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatNativeDateModule,
|
||||||
|
NgxMatDatetimePickerModule,
|
||||||
|
NgxMatTimepickerModule,
|
||||||
|
NgxMatNativeDateModule,
|
||||||
|
NgxMatMomentModule,
|
||||||
|
MatSelectModule,
|
||||||
|
MatButtonModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
MatDialogModule,
|
||||||
],
|
],
|
||||||
exports: [NewActionPage],
|
exports: [NewActionPage],
|
||||||
declarations: [NewActionPage]
|
declarations: [NewActionPage]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<ion-content>
|
<ion-content>
|
||||||
<div class="content-container">
|
<div class="content-container">
|
||||||
|
|
||||||
<div class="ion-item-container">
|
<div class="ion-item-container" [class.input-error]="Form?.get('Subject')?.invalid && validateFrom ">
|
||||||
<ion-input [(ngModel)]="folder.Description" placeholder="Assunto" ></ion-input>
|
<ion-input [(ngModel)]="folder.Description" placeholder="Assunto" ></ion-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ion-input-class flex-grow-1">
|
<div class="ion-input-class flex-grow-1">
|
||||||
<ion-datetime
|
<ion-datetime
|
||||||
|
class="d-block d-md-none"
|
||||||
[(ngModel)]="folder.DateBegin"
|
[(ngModel)]="folder.DateBegin"
|
||||||
placeholder="Início"
|
placeholder="Início"
|
||||||
displayFormat="D MMM YYYY H:mm"
|
displayFormat="D MMM YYYY H:mm"
|
||||||
@@ -39,6 +40,25 @@
|
|||||||
min="2018"
|
min="2018"
|
||||||
max="2025">
|
max="2025">
|
||||||
</ion-datetime>
|
</ion-datetime>
|
||||||
|
|
||||||
|
|
||||||
|
<mat-form-field class="width-100 date-hour-picker d-md-block">
|
||||||
|
<input matInput [ngxMatDatetimePicker]="picker1"
|
||||||
|
placeholder="Choose a date*"
|
||||||
|
[formControl]="dateControlStart"
|
||||||
|
[min]="minDate"
|
||||||
|
[disabled]="disabled"
|
||||||
|
>
|
||||||
|
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
|
||||||
|
<ngx-mat-datetime-picker #picker1
|
||||||
|
[showSpinners]="showSpinners"
|
||||||
|
[showSeconds]="showSeconds"
|
||||||
|
[stepHour]="stepHour" [stepMinute]="stepMinute"
|
||||||
|
[stepSecond]="stepSecond"
|
||||||
|
[touchUi]="touchUi">
|
||||||
|
</ngx-mat-datetime-picker>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -50,7 +70,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ion-input-class d-flex flex-grow-1">
|
<div class="ion-input-class d-flex flex-grow-1">
|
||||||
<ion-datetime
|
<ion-datetime
|
||||||
class="flex-grow-1"
|
class="flex-grow-1 d-md-none"
|
||||||
[(ngModel)]="folder.DateEnd"
|
[(ngModel)]="folder.DateEnd"
|
||||||
placeholder="Fim"
|
placeholder="Fim"
|
||||||
displayFormat="D MMM YYYY H:mm"
|
displayFormat="D MMM YYYY H:mm"
|
||||||
@@ -59,6 +79,24 @@
|
|||||||
min="2018"
|
min="2018"
|
||||||
max="2025">
|
max="2025">
|
||||||
</ion-datetime>
|
</ion-datetime>
|
||||||
|
|
||||||
|
|
||||||
|
<mat-form-field class="width-100 date-hour-picker d-md-block">
|
||||||
|
<input matInput [ngxMatDatetimePicker]="picker1"
|
||||||
|
placeholder="Choose a date*"
|
||||||
|
[formControl]="dateControlEnd"
|
||||||
|
[min]="minDate"
|
||||||
|
[disabled]="disabled"
|
||||||
|
>
|
||||||
|
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
|
||||||
|
<ngx-mat-datetime-picker #picker1
|
||||||
|
[showSpinners]="showSpinners"
|
||||||
|
[showSeconds]="showSeconds"
|
||||||
|
[stepHour]="stepHour" [stepMinute]="stepMinute"
|
||||||
|
[stepSecond]="stepSecond"
|
||||||
|
[touchUi]="touchUi">
|
||||||
|
</ngx-mat-datetime-picker>
|
||||||
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { AnimationController, ModalController } from '@ionic/angular';
|
import { AnimationController, ModalController } from '@ionic/angular';
|
||||||
|
import * as moment from 'moment';
|
||||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||||
import { PublicationsService } from 'src/app/services/publications.service';
|
import { PublicationsService } from 'src/app/services/publications.service';
|
||||||
import { ToastService } from 'src/app/services/toast.service';
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
@@ -16,10 +17,15 @@ export class NewActionPage implements OnInit {
|
|||||||
|
|
||||||
folder: PublicationFolder;
|
folder: PublicationFolder;
|
||||||
segment:string;
|
segment:string;
|
||||||
|
public minDate = new Date();
|
||||||
|
public endMinDate = new Date(new Date().getTime() + 15 * 60000);
|
||||||
|
|
||||||
Form: FormGroup;
|
Form: FormGroup;
|
||||||
validateFrom = false
|
validateFrom = false
|
||||||
|
|
||||||
|
public dateControlStart = new FormControl(moment("DD MM YYYY hh"));
|
||||||
|
public dateControlEnd = new FormControl(moment("DD MM YYYY hh"));
|
||||||
|
|
||||||
|
|
||||||
@Output() closeDesktopComponent= new EventEmitter<any>();
|
@Output() closeDesktopComponent= new EventEmitter<any>();
|
||||||
|
|
||||||
@@ -28,6 +34,18 @@ export class NewActionPage implements OnInit {
|
|||||||
private toastService: ToastService
|
private toastService: ToastService
|
||||||
) {
|
) {
|
||||||
this.folder = new PublicationFolder();
|
this.folder = new PublicationFolder();
|
||||||
|
|
||||||
|
this.dateControlStart = new FormControl(moment(new Date()));
|
||||||
|
this.dateControlEnd = new FormControl(moment(new Date(new Date().getTime() + 15 * 60000)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
get dateStart () {
|
||||||
|
return this.dateControlStart.value
|
||||||
|
}
|
||||||
|
|
||||||
|
get dateEnd () {
|
||||||
|
return this.dateControlEnd.value
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -55,8 +73,13 @@ export class NewActionPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async save() {
|
async save() {
|
||||||
|
|
||||||
|
this.injectValidation()
|
||||||
|
this.runValidation()
|
||||||
|
|
||||||
|
if(this.Form.invalid) return false
|
||||||
|
|
||||||
this.folder = {
|
this.folder = {
|
||||||
ProcessId: null,
|
ProcessId: null,
|
||||||
Description: this.folder.Description,
|
Description: this.folder.Description,
|
||||||
|
|||||||
@@ -12,15 +12,13 @@
|
|||||||
<ion-content>
|
<ion-content>
|
||||||
<div class="content-container">
|
<div class="content-container">
|
||||||
|
|
||||||
<div *ngIf="publicationType!='1'" class="ion-item-container">
|
<div *ngIf="publicationType!='1'" class="ion-item-container" [class.input-error]="Form?.get('Subject')?.invalid && validateFrom ">
|
||||||
<ion-input [(ngModel)]="pub.Title" name="title" placeholder="Título" ></ion-input>
|
<ion-input [(ngModel)]="pub.Title" name="title" placeholder="Título" ></ion-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div *ngIf="publicationType!='1'" class="container-div pb-20">
|
<div *ngIf="publicationType!='1'" class="container-div pb-20">
|
||||||
<div class="ion-item-class-2 d-flex">
|
<div class="ion-item-class-2 d-flex">
|
||||||
<div class="ion-icon-class">
|
<div class="ion-icon-class" >
|
||||||
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
|
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="ion-textarea-class flex-grow-1">
|
<div class="ion-textarea-class flex-grow-1">
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { PhotoService } from 'src/app/services/photo.service';
|
|||||||
//Cordova
|
//Cordova
|
||||||
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||||
import { ToastService } from 'src/app/services/toast.service';
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new-publication',
|
selector: 'app-new-publication',
|
||||||
@@ -30,6 +31,8 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
Defaultimage:any = '';
|
Defaultimage:any = '';
|
||||||
|
|
||||||
|
Form: FormGroup;
|
||||||
|
validateFrom = false
|
||||||
|
|
||||||
photo: SafeResourceUrl;
|
photo: SafeResourceUrl;
|
||||||
|
|
||||||
@@ -134,7 +137,30 @@ export class NewPublicationPage implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
runValidation() {
|
||||||
|
this.validateFrom = true
|
||||||
|
}
|
||||||
|
|
||||||
|
injectValidation() {
|
||||||
|
|
||||||
|
this.Form = new FormGroup({
|
||||||
|
Subject: new FormControl(this.pub.Title, [
|
||||||
|
Validators.required,
|
||||||
|
// Validators.minLength(4)
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async save(){
|
async save(){
|
||||||
|
|
||||||
|
this.injectValidation()
|
||||||
|
this.runValidation()
|
||||||
|
|
||||||
|
if(this.Form.invalid) return false
|
||||||
|
|
||||||
if(this.publicationType == '3'){
|
if(this.publicationType == '3'){
|
||||||
|
|
||||||
if(this.capturedImage != '') {
|
if(this.capturedImage != '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user