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 @@