Take out all special characters in string

This commit is contained in:
tiago.kayaya
2021-12-10 11:41:24 +01:00
parent e5edac65af
commit d7300080c3
3 changed files with 37 additions and 42 deletions
+16 -27
View File
@@ -8,8 +8,6 @@ import {
ComponentRef,
ComponentFactory,
Output,
AfterViewChecked,
AfterViewInit
} from '@angular/core';
import { ModalController, Platform } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
@@ -40,7 +38,7 @@ import { SqliteService } from 'src/app/services/sqlite.service';
templateUrl: './chat.page.html',
styleUrls: ['./chat.page.scss'],
})
export class ChatPage implements OnInit, AfterViewInit {
export class ChatPage implements OnInit {
showLoader: boolean;
@@ -164,42 +162,25 @@ export class ChatPage implements OnInit, AfterViewInit {
this.openNewGroupPage();
} */
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
alert('Aqui' + this.dataService.get("newGroup"))
if (this.dataService.get("newGroup")) {
this.openNewGroupPage();
}
/* if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) {
alert(this.dataService.get("newGroup"))
else{
this.closeAllDesktopComponents();
this.showEmptyComponent = true;
}
else {
if (this.dataService.get("newGroup")) {
this.openNewGroupPage();
}
} */
}
else{
this.dataService.set("newGroup", false);
}
});
if (this.dataService.get("newGroup")) {
this.openNewGroupPage();
}
}
ngAfterViewInit() {
alert(this.dataService.get("newGroup"))
}
ngAfterViewChecked(){
//alert(this.dataService.get("newGroup"))
}
ngOnDestroy() {
this.setStatus('offline');
this.dataService.set("newGroup", false);
console.log('On Destroy')
}
@@ -513,6 +494,13 @@ export class ChatPage implements OnInit, AfterViewInit {
console.log('Chat list', res);
if (res != 200) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.userDirectMessages = res.ims.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
});
}
//console.log(res.ims);
/* this.userDirectMessages = res.ims.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
@@ -557,9 +545,10 @@ export class ChatPage implements OnInit, AfterViewInit {
this.chatService.getAllUsers().subscribe(res => {
console.log('chatusers', res);
this.transformDataUserList(res['users'])
//this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
//console.log(this.dmUsers);
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
console.log(this.dmUsers);
}
});
}
@@ -634,13 +634,8 @@ export class ExpedienteDetailPage implements OnInit {
}
openNewGroupPage() {
console.log(this.fulltask);
this.dataService.set("newGroup", true);
this.router.navigate(['/home/chat']);
this.dataService.set("newGroup", true);
if (window.innerWidth < 801) {
this.router.navigate(['/home/chat']);
this.newGroup();
}
else {
@@ -648,6 +643,7 @@ export class ExpedienteDetailPage implements OnInit {
this.dataService.set("task", this.task);
this.dataService.set("newGroupName", this.task.Folio);
this.dataService.set("documents", this.fulltask.Documents);
this.router.navigate(['/home/chat']);
}
}
@@ -1,5 +1,6 @@
import { analyzeAndValidateNgModules } from '@angular/compiler';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service';
import { DataService } from 'src/app/services/data.service';
@@ -35,22 +36,29 @@ export class NewGroupPage implements OnInit{
private chatService: ChatService,
private dataService:DataService,
private processesService: ProcessesService,
private router: Router,
)
{
this.isGroupCreated = false;
//this.groupName = this.navParams.get('name');
alert('New group '+this.dataService.get("newGroup"))
}
ngOnInit() {
//alert(this.dataService.get("newGroup"))
setTimeout(() => {
//alert(this.dataService.get("newGroup"))
}, 100)
if(this.dataService.get("newGroup") == true){
this.task = this.dataService.get("task");
this.groupName = this.task.Folio;
this.documents = this.dataService.get("documents");
}
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
alert('New group '+this.dataService.get("newGroup"))
if (this.dataService.get("newGroup")) {
this.task = this.dataService.get("task");
this.groupName = this.task.Folio;
this.documents = this.dataService.get("documents");
}
}
else{
this.dataService.set("newGroup", false);
}
});
console.log(this.task);
}
@@ -82,6 +90,8 @@ export class NewGroupPage implements OnInit{
createGroup(){
let name = this.groupName.split(' ').join('-');
//Take out all special characters in string
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');