diff --git a/package-lock.json b/package-lock.json index 129f078ff..d2768bfd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27168,9 +27168,9 @@ "dev": true }, "tar": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz", - "integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==", + "version": "6.1.6", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.6.tgz", + "integrity": "sha512-oaWyu5dQbHaYcyZCTfyPpC+VmI62/OM2RTUYavTk1MDr1cwW5Boi3baeYQKiZbY2uSQJGr+iMOzb/JFxLrft+g==", "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", diff --git a/package.json b/package.json index 3ec6745e2..6d9eef49f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "e2e": "ng e2e", "test": "jest --detectOpenHandles --runInBand", "test:prof": "ionic build --configuration production && npm run test", - "dev": "lite-server --baseDir=www" + "dev:share": "lite-server --baseDir=share" }, "private": true, "dependencies": { @@ -186,4 +186,4 @@ "url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git" }, "license": "ISC" -} +} \ No newline at end of file diff --git a/readme.md b/readme.md index 8dcb26007..277261e27 100644 --- a/readme.md +++ b/readme.md @@ -12,8 +12,12 @@ Use the package manager npm to install dependencies. npm ci npm install npm install -g @ionic/cli -npm install -g http-server +npm install -g lite-server npm install -g @angular/cli + +## Mobile first dependencies +cordova plugin add cordova-plugin-mfp-jsonstore +cordova plugin add cordova-plugin-mfp ``` ## Start the development server diff --git a/src/app/OtherService/permission.service.ts b/src/app/OtherService/permission.service.ts index a09dafb53..390fc0617 100644 --- a/src/app/OtherService/permission.service.ts +++ b/src/app/OtherService/permission.service.ts @@ -11,27 +11,23 @@ export class PermissionService { constructor() { } userRole(args) { - let data: string[] = [] - if(!Array.isArray(args) && typeof(args) == 'string') { - data = [args] - } else { - data = args + if(!Array.isArray(args)) { + args = [args] } - return data.includes(this.userStore.user.Profile) + return args.includes(this.userStore.user.Profile) } role(args: any) { - let UserRoleIsValid = this.userRole(args) return { permissionAnyOf(role) { - if(!Array.isArray(args) && typeof(args) == 'string') { - role = [args] + if(!Array.isArray(role)) { + role = [role] } if(!UserRoleIsValid) {return false } diff --git a/src/app/Rules/despacho.service.ts b/src/app/Rules/despacho.service.ts index 6f97c8ad4..c1c94ff93 100644 --- a/src/app/Rules/despacho.service.ts +++ b/src/app/Rules/despacho.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { PermissionService } from '../OtherService/permission.service'; import { ProcessesService } from '../services/processes.service'; @Injectable({ @@ -16,6 +17,7 @@ export class DespachoService { constructor( private processes: ProcessesService, + public p: PermissionService ) { } arquivar(note:string, documents:any, serialnumber) { @@ -63,8 +65,37 @@ export class DespachoService { return this.processes.CompleteTask(body) } - sendExpedienteToPending(serialnumber) { + CompleteTask({serialNumber}) { + const body = { + "serialNumber": serialNumber, + "action": "Despacho", + "ActionTypeId": 94, + "dataFields": { + "ReviewUserComment": '', + }, + "AttachmentList" :null, + } + + return this.processes.CompleteTask(body) + } + + sendExpedienteToPending(serialnumber) { return this.processes.SetTaskToPending(serialnumber) } + + /** + * + * @param body any + * @returns promise + * @description for both profile PR and MDGPR + */ + createDespacho(body: any) { + if(this.p.userRole(['PR'])) { + return this.processes.postDespatchoPr(body) + } else { + return this.processes.postDespatcho(body) + } + } + } diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts index e8ea53a8d..831efdec1 100644 --- a/src/app/modals/create-process/create-process.page.ts +++ b/src/app/modals/create-process/create-process.page.ts @@ -17,6 +17,8 @@ import { ToastService } from 'src/app/services/toast.service'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; +import { PermissionService } from 'src/app/OtherService/permission.service'; +import { DespachoService } from 'src/app/Rules/despacho.service'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { @@ -91,6 +93,8 @@ export class CreateProcessPage implements OnInit { private userAuth: AuthService, private animationController: AnimationController, private toastService: ToastService, + public p: PermissionService, + private despachoService: DespachoService ) { this.loggeduser = userAuth.ValidatedUser; this.task = this.navParams.get('task'); @@ -193,11 +197,13 @@ export class CreateProcessPage implements OnInit { async saveTask() { - this.injectValidation() - this.runValidation() - - if(this.Form.invalid) return false + if(!this.p.userRole(['PR'])) { + this.injectValidation() + this.runValidation() + if(this.Form.invalid) return false + } + if(this.postData.Priority=='99999861') { this.dispatchFolder.DeadlineType = 'Normal'; @@ -232,11 +238,12 @@ export class CreateProcessPage implements OnInit { this.dispatchFolder.SubjectTypes = this.selectedTypes; const loader = this.toastService.loading() + switch (this.loggeduser.Profile) { case 'MDGPR': switch (this.taskType) { - case '0': + case '0': // Despacho this.postData = { DistributionType: "Paralelo", CountryCode: 'AO', @@ -252,6 +259,7 @@ export class CreateProcessPage implements OnInit { await this.FinalizarDespacho(loader, 'Despacho criado'); } catch (error) { this.toastService.badRequest('Processo não efectuado'); + loader.remove() } break; @@ -272,6 +280,7 @@ export class CreateProcessPage implements OnInit { } catch (error) { this.toastService.badRequest('Processo não efectuado'); + loader.remove() } break; @@ -292,10 +301,10 @@ export class CreateProcessPage implements OnInit { } catch (error) { this.toastService.badRequest('Processo não efectuado'); + loader.remove() } break; } - this.modalController.dismiss(); break; @@ -313,10 +322,14 @@ export class CreateProcessPage implements OnInit { console.log('this.postData', this.postData, this.taskType); try { - await this.processes.postDespatcho(this.postData).toPromise(); - await this.executado(loader, 'Despacho criado'); + await this.despachoService.createDespacho(this.postData).toPromise(); + await this.despachoService.CompleteTask({serialNumber: this.task.serialNumber}).toPromise(); + this.modalController.dismiss(); + this.toastService.successMessage('Despacho criado'); } catch (error) { this.toastService.badRequest('Processo não efectuado'); + } finally { + loader.remove() } break; @@ -337,6 +350,7 @@ export class CreateProcessPage implements OnInit { this.toastService.successMessage('Pedido de Parecer criado'); } catch (error) { + loader.remove() this.toastService.badRequest('Processo não efectuado'); } @@ -358,12 +372,12 @@ export class CreateProcessPage implements OnInit { this.toastService.successMessage('Pedido de Deferimento criado'); } catch (error) { + loader.remove() this.toastService.badRequest('Processo não efectuado'); } break; } - this.modalController.dismiss(); break; } @@ -387,6 +401,16 @@ export class CreateProcessPage implements OnInit { } else if(this.task.activityInstanceName =='Concluir Despacho' || this.task.activityInstanceName == 'Concluir Parecer') { + body = { + "serialNumber": this.task.serialNumber, + "action": "Despacho", + "ActionTypeId": 94, + "dataFields": { + "ReviewUserComment": '', + }, + "AttachmentList" :null, + } + } else { body = { "serialNumber": this.task.serialNumber, "action": "Despacho", @@ -401,8 +425,11 @@ export class CreateProcessPage implements OnInit { try { await this.processes.CompleteTask(body).toPromise(); this.toastService.successMessage(message); + this.modalController.dismiss(); } catch (error) { this.toastService.badRequest('Processo não efectuado'); + } finally { + loader.remove() } } diff --git a/src/app/modals/document-detail/document-detail.page.html b/src/app/modals/document-detail/document-detail.page.html index 0d44315f1..df3087c99 100644 --- a/src/app/modals/document-detail/document-detail.page.html +++ b/src/app/modals/document-detail/document-detail.page.html @@ -53,10 +53,10 @@
- +
- +
diff --git a/src/app/modals/document-detail/document-detail.page.ts b/src/app/modals/document-detail/document-detail.page.ts index dd54dc350..5cf5dc07b 100644 --- a/src/app/modals/document-detail/document-detail.page.ts +++ b/src/app/modals/document-detail/document-detail.page.ts @@ -4,10 +4,10 @@ import { AlertService } from 'src/app/services/alert.service'; import { ProcessesService } from 'src/app/services/processes.service'; import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page'; -import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page'; import { DocumentSetUpMeetingPage } from '../document-set-up-meeting/document-set-up-meeting.page'; import { FromSearchDocument, SearchFolder } from 'src/app/models/search-document'; import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage'; +import { PermissionService } from 'src/app/OtherService/permission.service'; @Component({ selector: 'app-document-detail', @@ -35,6 +35,7 @@ export class DocumentDetailPage implements OnInit { private processes: ProcessesService, private menu: MenuController, private iab: InAppBrowser, + public p: PermissionService, ) { this.docId = this.navParams.get('docId'); this.applicationId = this.navParams.get('applicationId'); diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index dffb6ff99..fc7e786e0 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -111,16 +111,14 @@ export class ViewEventPage implements OnInit { if(this.isModal) { this.close() } else { - // this.activatedRoute.paramMap.subscribe(params => { - // if(params["params"].caller == 'expediente'){ - // window.history.back(); - // } - // else{ - // this.router.navigate(['/home',params["params"].caller]); - // } - // }); - - this.location.back(); + this.activatedRoute.paramMap.subscribe(params => { + if(params["params"].caller == 'expediente'){ + window.history.back(); + } + else{ + this.router.navigate(['/home',params["params"].caller]); + } + }); } } @@ -133,15 +131,15 @@ export class ViewEventPage implements OnInit { this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ loader.remove() }, (error)=>{ - + if(error.status == 0) { - this.toastService.badRequest('Não é possível visualizar este evento no modo offline') + this.toastService.badRequest('não é possível vizualizar este event no modo offline') } else { this.toastService.badRequest('Este evento já não existe na sua agenda') - } + } loader.remove() - this.modalController.dismiss('Eevento não Encontrado'); + this.modalController.dismiss('Eevent not Foud'); this.location.back(); }); } @@ -165,7 +163,7 @@ export class ViewEventPage implements OnInit { async OpenDeleteEventModal() { - + const modal = await this.modalController.create({ component: EliminateEventPage, componentProps: { diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts index ba65238dd..f8ec0f16b 100644 --- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts @@ -20,6 +20,7 @@ import { FormControl, FormGroup, Validators } from '@angular/forms'; import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; import { task } from 'src/app/models/ExpedientTaskModalPage'; +import { DespachoService } from 'src/app/Rules/despacho.service'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -101,11 +102,14 @@ export class ExpedientTaskModalPage implements OnInit { private userAuth: AuthService, private animationController: AnimationController, private toastService: ToastService, + private despachoService: DespachoService ) { this.loggeduser = userAuth.ValidatedUser; this.task = this.navParams.get('task'); + console.log(this.task) + this.taskType = this.navParams.get('taskAction'); this.selectedTypes = ['99999850']; @@ -371,7 +375,7 @@ export class ExpedientTaskModalPage implements OnInit { break; case 'PR': switch (this.taskType) { - case '0': + case '0': // despacho this.postData = { DistributionType: "Paralelo", CountryCode: 'AO', @@ -393,7 +397,7 @@ export class ExpedientTaskModalPage implements OnInit { } try { - this.taskResult = await this.processes.postDespatchoPr(this.postData).toPromise(); + this.taskResult = await this.despachoService.createDespacho(this.postData).toPromise(); await this.toastService.successMessage('Processo efetuado'); this.modalController.dismiss(action_despacho_pr); } catch (error) { @@ -437,7 +441,7 @@ export class ExpedientTaskModalPage implements OnInit { loader.remove() } break; - } + } break; } } diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html index 234927796..0d3bbfdef 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html @@ -79,7 +79,8 @@
- + + @@ -88,7 +89,8 @@
- + + @@ -97,7 +99,8 @@
- + + diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts index 17840b6ff..2bb7481ac 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts @@ -23,8 +23,10 @@ import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.p import { ToastService } from 'src/app/services/toast.service'; import { ForwardPage } from 'src/app/modals/forward/forward.page'; import { async } from '@angular/core/testing'; +import { PermissionService } from 'src/app/OtherService/permission.service'; import { Location } from '@angular/common'; + @Component({ selector: 'app-pedido', templateUrl: './pedido.page.html', @@ -60,7 +62,8 @@ export class PedidoPage implements OnInit { authService: AuthService, private animationController: AnimationController, private toastService: ToastService, - private location: Location, + public p: PermissionService, + private location: Location ) { this.loggeduser = authService.ValidatedUser; @@ -492,7 +495,7 @@ export class PedidoPage implements OnInit { goBack() { this.location.back(); - /* if(this.task.Status == "Pending" && this.caller == 'gabinete-digital'){ + if(this.task.Status == "Pending" && this.caller == 'gabinete-digital'){ if (window.innerWidth <= 700) { this.router.navigate(['/home/gabinete-digital/pendentes']); } @@ -525,7 +528,7 @@ export class PedidoPage implements OnInit { } this.router.navigate(['/home/gabinete-digital'], navigationExtras); } - } */ + } } }