Commit fc5fd47b authored by Trino Parra's avatar Trino Parra

formulario

parent f0daaa3e
{"plugins":["cordova-plugin-whitelist","cordova-plugin-device","cordova-plugin-splashscreen","cordova-plugin-headercolor","call-number","cordova-plugin-statusbar","cordova-plugin-disable-ios11-statusbar","ionic-plugin-keyboard","cordova-sqlite-storage","cordova-plugin-fcm","phonegap-plugin-push","cordova-plugin-native-keyboard","cordova-plugin-console","cordova-plugin-actionsheet","cordova-plugin-camera","cordova-plugin-file","cordova-plugin-file-transfer","cordova-plugin-network-information","cordova-plugin-app-preferences","com-badrit-base64","cordova-plugin-filechooser","cordova-plugin-android-permissions","cordova.plugins.diagnostic","cordova-android-support-gradle-release","cordova-plugin-file-opener2"]}
\ No newline at end of file
// Type definitions for Cordova Keyboard plugin
// Project: https://github.com/driftyco/ionic-plugins-keyboard
// Definitions by: Hendrik Maus <https://github.com/hendrikmaus>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Ionic {
interface Keyboard {
/**
* Hide the keyboard accessory bar with the next, previous and done buttons.
*
* @param hide
*/
hideKeyboardAccessoryBar(hide:boolean): void;
/**
* Close the keyboard if it is open.
*/
close(): void;
/**
* Force keyboard to be shown on Android.
* This typically helps if autofocus on a text element does not pop up the keyboard automatically
*
* Supported Platforms: Android, Blackberry 10
*/
show(): void;
/**
* Disable native scrolling, useful if you are using JavaScript to scroll
*
* @param disbale
*/
disableScroll(disbale:boolean): void;
/**
* Whether or not the keyboard is currently visible.
*/
isVisible: boolean;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -11,6 +11,7 @@ import { Camera } from '@ionic-native/camera'; ...@@ -11,6 +11,7 @@ import { Camera } from '@ionic-native/camera';
import { MyApp } from './app.component'; import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home'; import { HomePage } from '../pages/home/home';
import { MenuPage } from '../pages/menu/menu'; import { MenuPage } from '../pages/menu/menu';
//import { FormularyPage } from '../pages/formulary/formulary';
import { InquiryPage } from '../pages/inquiry/inquiry'; import { InquiryPage } from '../pages/inquiry/inquiry';
import { PassportloginPage } from '../pages/passportlogin/passportlogin'; import { PassportloginPage } from '../pages/passportlogin/passportlogin';
import { PassportloginPageModule } from '../pages/passportlogin/passportlogin.module'; import { PassportloginPageModule } from '../pages/passportlogin/passportlogin.module';
......
<ion-header>
<ion-navbar>
</ion-navbar>
</ion-header>
<ion-content padding style="background-color: #F3F4F6">
<img src="assets/imgs/Marqueta/logo.png" class="center headerimg">
<br />
<h6 class="header6">En estos momentos nuestros ejecutivos se encuentran ocupados, por favor indiquenos su requerimiento y nuestro equipo se contactara con usted lo más pronto posible.</h6>
<br />
<form [formGroup]="messageForm" class="list center-form" *ngIf="isSchema()">
<ion-item>
<ion-label stacked>{{shema.formulario[0].nombre}}</ion-label>
<ion-select formControlName="request" *ngIf="isSchema()" placeholder="Seleccione una opcion">
<ion-option *ngFor="let req of shema.formulario[0].opciones" [value]="req">{{req}}</ion-option>
</ion-select>
</ion-item>
<br />
<ion-item>
<ion-label stacked>{{shema.formulario[1].nombre}}</ion-label>
<ion-textarea *ngIf="shema.formulario[1].tipo=='text'" class="mensajebox" formControlName="message" type="text" [maxlength]="shema.formulario[1].largo"></ion-textarea>
<!--<ion-textarea class="mensajebox" formControlName="message" type="text" maxlength="450"></ion-textarea>-->
</ion-item>
<br />
<div class="error-message">
{{error}}
</div>
<br />
<button ion-button type="button" [disabled]="!messageForm.valid" (click)="enviar()" class="center btn">enviar</button>
</form>
<ion-footer class="footer hideElementOnKeyboardShown hide-on-keyboard-open applyFooter">
<a href="http://gearlabs.cl/" onclick="window.open(this.href, '_blank', 'location=no'); return false;"><img
class="footerlogo" src="assets/imgs/Marqueta/paer.png"></a>
</ion-footer>
</ion-content>
\ No newline at end of file
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { FormularyPage } from './formulary';
@NgModule({
declarations: [
FormularyPage,
],
imports: [
IonicPageModule.forChild(FormularyPage),
],
})
export class FormularyPageModule {}
page-formulary {
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 40%!important;
}
.mensajebox {
height: 100px;
}
.headerimg{
margin-top: 10px;
}
.header6{
text-align: center;
color: #787879;
font-weight: 400;
}
.btn{
border-radius: 20px;
width: 50%;
overflow: hidden;
height: 3.6rem;
font-size: 16px;
font-weight: 400;
font-variant: small-caps;
color: #fff;
background-color: #CB0D12;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.btn:hover{
background-color: transparent !important;
}
.container .btn:hover{
background-color: #008B7D;
}
.itemclr{
background-color: #F2F2F2;
max-width: 96%;
}
.ion-input:hover{
background-color: #CB0D12;
}
.item-input .label-ios, .item-select .label-ios, .item-datetime .label-ios {
color: #424242;
}
.item-input .label-md, .item-select .label-md, .item-datetime .label-md {
color: #424242;
}
.item-input .label-wp, .item-select .label-wp, .item-datetime .label-wp {
color: #424242;
}
.button-md.activated{
background-color: #CB0D12;
}
.button-ios.activated{
background-color: #CB0D12;
}
.button-wp.activated{
background-color: #CB0D12;
}
.btn:hover{
background-color: #CB0D12 !important;
}
.label-md[stacked] {
font-size: 16px !important;
}
.label-ios[stacked] {
font-size: 16px !important;
}
.label-wp[stacked] {
font-size: 16px !important;
}
.footer{
position: fixed;
left: 0;
bottom: 0px;
width: 100%;
padding-left:15%;
padding-right:15%
}
$list-ios-activated-background-color: #CB0D12;
$list-md-activated-background-color: #CB0D12;
$list-wp-activated-background-color: #CB0D12;
}
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { RestProvider } from '../../providers/rest/rest';
import { Loader } from "../../providers/loader/loader";
import { Storage } from '@ionic/storage';
import { AlertController } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-formulary',
templateUrl: 'formulary.html',
})
export class FormularyPage {
public messageForm: FormGroup;
shema: any;
rut: any;
error: any = '';
constructor(public navCtrl: NavController, public navParams: NavParams,
private formBuilder: FormBuilder, public restProvider: RestProvider,
private alertCtrl: AlertController,
private loader: Loader, public storage: Storage) {
this.messageForm = formBuilder.group({
message: ['', Validators.compose([Validators.required])],
request: ['', Validators.compose([Validators.required])]
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad FormularyPage');
this.storage.get('rut').then((rut) => {
this.rut = rut;
});
this.restProvider.getCofiguration().then(msg => {
console.log(msg['formularioJson']);
this.shema = msg['formularioJson']['formularioJson'];
});
}
isSchema(){
return this.shema && this.shema.formulario && this.shema.formulario.length > 0;
//return this.shema && this.shema.formulario;
}
enviar() {
console.log("Enviando....");
this.error = '';
//this.loader.show('Please Wait');
let message: any = this.messageForm.value.message;
let request: any = this.messageForm.value.request;
if (!message || message == '' || message.length == 0) {
//this.loader.hide();
let alert = this.alertCtrl.create({
subTitle: 'Por favor ingrese un mensaje',
buttons: ['Aceptar']
});
alert.present();
} else if (!request || request == '' || request.length == 0 ){
this.loader.hide();
let alert = this.alertCtrl.create({
subTitle: 'Por favor indique el tipo de requerimiento',
buttons: ['Aceptar']
});
alert.present();
} else {
//console.log('pot data: ' + this.rut + " request: " + request + " message: " + message);
this.restProvider.save_form(this.rut, request, message).then(data => {
console.log('resp: ' + data);
//this.loader.hide();
let alert = this.alertCtrl.create({
subTitle: 'Su solicitud fue recibida, en breve lo atenderemos!',
buttons: ['Aceptar']
});
alert.present();
this.goback();
}).catch(error => {
this.loader.hide();
this.error = error.error['error'];
console.log("error2: " + this.error);
});
}
}
goback() {
this.navCtrl.pop();
}
}
<ion-content style="background-color: #F3F4F6"> <ion-content style="background-color: #F3F4F6">
<img src="assets/imgs/Marqueta/logo.png" class="center headerimg">
<br />
<br />
<h6 class="header6">Encuesta</h6> <h6 class="header6">Encuesta</h6>
<form novalidate class="list center-form"> <form novalidate class="list center-form">
<ion-grid> <ion-grid>
......
...@@ -5,6 +5,9 @@ page-inquiry { ...@@ -5,6 +5,9 @@ page-inquiry {
.maincontent{ .maincontent{
height: 95vh; height: 95vh;
padding: 30px!important; padding: 30px!important;
}
.headerimg{
margin-top: 50px;
} }
.center { .center {
display: block; display: block;
......
...@@ -4,7 +4,6 @@ import { MenuPage } from '../../pages/menu/menu'; ...@@ -4,7 +4,6 @@ import { MenuPage } from '../../pages/menu/menu';
import { RestProvider, UserInfo } from '../../providers/rest/rest'; import { RestProvider, UserInfo } from '../../providers/rest/rest';
import { AlertController } from 'ionic-angular'; import { AlertController } from 'ionic-angular';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { single } from 'rxjs/operators';
/** /**
* Generated class for the InquiryPage page. * Generated class for the InquiryPage page.
...@@ -55,24 +54,11 @@ export class InquiryPage { ...@@ -55,24 +54,11 @@ export class InquiryPage {
this.storage.get('companyLogo').then((getcompanyLogo) => { this.storage.get('companyLogo').then((getcompanyLogo) => {
this.getcompanyLogo = getcompanyLogo; this.getcompanyLogo = getcompanyLogo;
}); });
/*let parser = new DOMParser();
let parsedHtml = parser.parseFromString(this.inquiryTest, 'text/html');
let questions = parsedHtml.getElementsByTagName("span");
if (questions.length > 1) {
this.question1 = questions[0].innerHTML;
this.question2 = questions[1].innerHTML;
}*/
//this.N = parsedHtml.getElementsByClassName("rating__icon").length;
this.stars = new Array<string>(this.shema[0].opcionesPregunta.length - 1); this.stars = new Array<string>(this.shema[0].opcionesPregunta.length - 1);
for (var i = 0; i < this.shema[0].opcionesPregunta.length - 1; i++) { this.stars[i] = "star"; } for (var i = 0; i < this.shema[0].opcionesPregunta.length - 1; i++) { this.stars[i] = "star"; }
console.log('construct InquiryPage 2'); console.log('construct InquiryPage 2');
/*let inputs = parsedHtml.getElementsByClassName("rating__input");
this.options = new Array<string>(inputs.length);
for (var i = 0; i < this.options.length; i++) {
this.options[i] = inputs[i].getAttribute("data-op");
}*/
} }
inquiry() { inquiry() {
......
...@@ -107,46 +107,17 @@ export class MenuPage { ...@@ -107,46 +107,17 @@ export class MenuPage {
} }
}).catch(error => { }).catch(error => {
if (error && error.error && error.error.error) { /*if (error && error.error && error.error.error) {
let alert = this.alertCtrl.create({ let alert = this.alertCtrl.create({
subTitle: error.error.error, subTitle: error.error.error,
buttons: ['Dismiss'] buttons: ['Dismiss']
}); });
alert.present(); alert.present();
/*this.restProvider.getCofiguration().then(msg => { }*/
let optionsName = msg['formularioJson']['formulario']['opciones']; this.loader.show('Please Wait');
var optionsForm = new Array<any>(optionsName.length); this.loader.hide();
for (var i=0; i < optionsName.length; i++){ this.navCtrl.push("FormularyPage");
optionsForm[i] = {
label: optionsName[i],
value: optionsName[i],
type: 'radio'
};
console.log('opcion: ' + optionsName[i],);
}
let alert = this.alertCtrl.create({
title: msg['formularioJson']['formulario']['nombre'],
inputs: optionsForm,
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Enviar',
handler: data => {
console.log('data: ' + data);
}
}
]
});
alert.present();
});*/
}
}); });
} }
......
...@@ -5,7 +5,6 @@ import { RestProvider } from '../../providers/rest/rest'; ...@@ -5,7 +5,6 @@ import { RestProvider } from '../../providers/rest/rest';
import { Loader } from "../../providers/loader/loader"; import { Loader } from "../../providers/loader/loader";
import { MenuPage } from '../../pages/menu/menu'; import { MenuPage } from '../../pages/menu/menu';
import { SelectSearchableComponent } from 'ionic-select-searchable'; import { SelectSearchableComponent } from 'ionic-select-searchable';
import { InquiryPage } from '../../pages/inquiry/inquiry';
/** /**
* Generated class for the UsefulinfoPage page. * Generated class for the UsefulinfoPage page.
* *
...@@ -130,12 +129,6 @@ export class UsefulinfoPage { ...@@ -130,12 +129,6 @@ export class UsefulinfoPage {
this.getDatoUtils(); this.getDatoUtils();
} }
ionViewWillLeave(){
if (!this.inquiry){
this.navCtrl.push(InquiryPage);
this.inquiry = true;
}
}
goback(){ goback(){
//this.navCtrl.push(MenuPage); //this.navCtrl.push(MenuPage);
this.navCtrl.pop(); this.navCtrl.pop();
......
...@@ -328,4 +328,22 @@ export class RestProvider { ...@@ -328,4 +328,22 @@ export class RestProvider {
}); });
}); });
} }
save_form(rut, request, message) {
return new Promise((resolve, reject) => {
this.http.post('https://' + SERVERS.get() + '/api/registrar/solicitud/formulario ', {
"rut": rut,
"respuesta": {
"requerimiento": request,
"mensaje": message
}
} ,
httpOptions).subscribe(res => {
console.log('res: ' + res);
resolve(res);
}, (err) => {
console.log('err: ' + err);
reject(err);
});
});
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment