Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer

This commit is contained in:
Peter Maquiran
2021-05-28 16:39:35 +01:00
2 changed files with 146 additions and 69 deletions
@@ -18,6 +18,7 @@ import { SearchDocument } from 'src/app/models/search-document';
import { SearchPage } from 'src/app/pages/search/search.page';
import { BadRequestComponent } from 'src/app/shared/popover/bad-request/bad-request.component';
import { SuccessMessageComponent } from 'src/app/shared/popover/success-message/success-message.component';
import { User } from 'src/app/models/user.model';
@Component({
selector: 'app-create-process',
@@ -58,6 +59,8 @@ export class CreateProcessPage implements OnInit {
showEmptyContainer = true;
documents:SearchDocument[] = [];
loggeduser: User;
constructor(
private modalController: ModalController,
@@ -66,7 +69,10 @@ export class CreateProcessPage implements OnInit {
private attachmentsService: AttachmentsService,
private navParams: NavParams,
private alertController: AlertService,
private authService: AuthService) {
private authService: AuthService,
private userAuth: AuthService,
) {
this.loggeduser = userAuth.ValidatedUser;
this.user = environment.defaultuser +'@'+ environment.domain;
this.task = this.navParams.get('task');
@@ -80,9 +86,9 @@ export class CreateProcessPage implements OnInit {
Nad: 30,
Subject: '',
Message: '',
SourceSecFsId: this.task.workflowInstanceDataFields.FsId, //361
SourceSecFsId: this.task.workflowInstanceDataFields.SourceSecFsID, //361
SourceType: 'DOC', //FOLDER
SourceId: this.task.workflowInstanceDataFields.DocIdD, //FolderId
SourceId: this.task.workflowInstanceDataFields.SourceID, //FolderId
DeadlineType: '',
SubjectTypes: ['99999844'],
NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber,
@@ -153,74 +159,145 @@ export class CreateProcessPage implements OnInit {
});
this.dispatchFolder.SubjectTypes = this.selectedTypes;
if(this.taskParticipants.length > 0) {
switch (this.taskType) {
case '0':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log('this.postData', this.postData, this.taskType);
try {
await this.processes.postDespatcho(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
case '1':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log(this.postData);
await this.processes.postParecer(this.postData).toPromise()
try {
await this.processes.postParecer(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
case '2':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log(this.postData);
switch (this.loggeduser.Profile) {
case 'MDGPR':
if(this.taskParticipants.length > 0) {
switch (this.taskType) {
case '0':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log('this.postData', this.postData, this.taskType);
try {
await this.processes.postDespatcho(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
case '1':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log(this.postData);
await this.processes.postParecer(this.postData).toPromise()
try {
await this.processes.postParecer(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
case '2':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log(this.postData);
try {
await this.processes.postDeferimento(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
}
this.executado();
this.modalController.dismiss();
}
else {
this.alertController.presentAlert("Lista de intervenientes vazia. Por favor, adicione 1 ou mais intervenientes.");
}
try {
await this.processes.postDeferimento(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
break;
case 'PR':
switch (this.taskType) {
case '0':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log('this.postData', this.postData, this.taskType);
try {
await this.processes.postDespatcho(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
case '1':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log(this.postData);
await this.processes.postParecer(this.postData).toPromise()
try {
await this.processes.postParecer(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
case '2':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.user,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
}
console.log(this.postData);
try {
await this.processes.postDeferimento(this.postData).toPromise()
this.successMessage()
} catch (error) {
this.badRequest()
}
break;
}
this.executado();
this.modalController.dismiss();
break;
}
break;
}
this.executado();
this.modalController.dismiss();
}
else {
this.alertController.presentAlert("Lista de intervenientes vazia. Por favor, adicione 1 ou mais intervenientes.");
}
}
async executado(){