"src/git@labs.maarch.org:maarch/MaarchCourrier.git" did not exist on "f238d9262317b16fb1b647eef76f61606226e920"
Newer
Older
import { Component, OnInit, ViewChild, ViewContainerRef, TemplateRef, OnDestroy } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { NotificationService } from '@service/notification/notification.service';
import { MatDialog } from '@angular/material/dialog';
import { MatSidenav } from '@angular/material/sidenav';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';
import { HeaderService } from '@service/header.service';
import { FiltersListService } from '@service/filtersList.service';
import { Overlay } from '@angular/cdk/overlay';
import { AppService } from '@service/app.service';
import { ActionsService } from '../actions/actions.service';

Alex ORLUC
committed
import { tap, catchError, map, finalize, filter } from 'rxjs/operators';
import { DocumentViewerComponent } from '../viewer/document-viewer.component';

Alex ORLUC
committed
import { IndexingFormComponent } from '../indexation/indexing-form/indexing-form.component';
import { ConfirmComponent } from '../../plugins/modal/confirm.component';
import { ContactResourceModalComponent } from '../contact/contact-resource/modal/contact-resource-modal.component';

Alex ORLUC
committed
import { DiffusionsListComponent } from '../diffusions/diffusions-list.component';
import { ContactService } from '@service/contact.service';
import { VisaWorkflowComponent } from '../visa/visa-workflow.component';
import { PrivilegeService } from '@service/privileges.service';
import { AvisWorkflowComponent } from '../avis/avis-workflow.component';
import { FunctionsService } from '@service/functions.service';
import { PrintedFolderModalComponent } from '../printedFolder/printed-folder-modal.component';
import { of, Subscription } from 'rxjs';
import { TechnicalInformationComponent } from '@appRoot/indexation/technical-information/technical-information.component';
import { NotesListComponent } from '@appRoot/notes/notes-list.component';

Alex ORLUC
committed
templateUrl: 'process.component.html',
styleUrls: [
'process.component.scss',
'../indexation/indexing-form/indexing-form.component.scss'
providers: [ActionsService, ContactService],
export class ProcessComponent implements OnInit, OnDestroy {

Alex ORLUC
committed
isMailing: boolean = false;
actionsList: any[] = [];
currentUserId: number = null;
currentBasketId: number = null;
currentGroupId: number = null;
selectedAction: any = {
id: 0,
label: '',
component: '',
default: false,
categoryUse: []
};
currentResourceInformations: any = {};
processTool: any[] = [
{
id: 'dashboard',
label: this.translate.instant('lang.newsFeed'),
label: this.translate.instant('lang.history'),
label: this.translate.instant('lang.notesAlt'),
label: this.translate.instant('lang.attachments'),
label: this.translate.instant('lang.links'),
{
id: 'emails',
icon: 'fas fa-envelope',
label: this.translate.instant('lang.mailsSentAlt'),
count: 0
},
label: this.translate.instant('lang.diffusionList'),

Alex ORLUC
committed
editMode: false,
label: this.translate.instant('lang.visaWorkflow'),
label: this.translate.instant('lang.avis'),
label: this.translate.instant('lang.informations'),
currentTool: string ;
subscription: Subscription;
actionEnded: boolean = false;
canEditData: boolean = false;

Alex ORLUC
committed
canChangeModel: boolean = false;
autoAction: boolean = false;
integrationsInfo: any = {
inSignatureBook: {
icon: 'fas fa-file-signature',

Alex ORLUC
committed
}
@ViewChild('snav2', { static: true }) sidenavRight: MatSidenav;

Alex ORLUC
committed
@ViewChild('adminMenuTemplate', { static: true }) adminMenuTemplate: TemplateRef<any>;
@ViewChild('appDocumentViewer', { static: false }) appDocumentViewer: DocumentViewerComponent;

Alex ORLUC
committed
@ViewChild('indexingForm', { static: false }) indexingForm: IndexingFormComponent;

Alex ORLUC
committed
@ViewChild('appDiffusionsList', { static: false }) appDiffusionsList: DiffusionsListComponent;
@ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent;
@ViewChild('appAvisWorkflow', { static: false }) appAvisWorkflow: AvisWorkflowComponent;
@ViewChild('appNotesList', { static: false }) appNotesList: NotesListComponent;

Alex ORLUC
committed
senderLightInfo: any = { 'displayName': null, 'fillingRate': null };
hasContact: boolean = false;
resourceFollowed: boolean = false;

Hamza HRAMCHI
committed
resourceFreezed: boolean = false;
resourceBinded: boolean = false;
public translate: TranslateService,
private route: ActivatedRoute,
private _activatedRoute: ActivatedRoute,
public http: HttpClient,
public dialog: MatDialog,
private headerService: HeaderService,
public filtersListService: FiltersListService,
private notify: NotificationService,
public overlay: Overlay,
public viewContainerRef: ViewContainerRef,
public appService: AppService,
public actionService: ActionsService,
private contactService: ContactService,
private router: Router,
public privilegeService: PrivilegeService,
public functions: FunctionsService

Alex ORLUC
committed
// ngOnInit does not call if navigate in the same component route : must be in constructor for this case
this.route.params.subscribe(params => {
this.loading = true;
this.headerService.sideBarForm = true;
this.headerService.showhHeaderPanel = true;
this.headerService.showMenuShortcut = false;
this.headerService.showMenuNav = false;
this.headerService.sideBarAdmin = true;

Alex ORLUC
committed
if (typeof params['detailResId'] !== 'undefined') {

Alex ORLUC
committed
this.initDetailPage(params);
} else {
this.initProcessPage(params);
}
}, (err: any) => {
this.notify.handleErrors(err);
});

Alex ORLUC
committed
// Event after process action
this.subscription = this.actionService.catchAction().subscribe(message => {
this.actionEnded = true;
this.router.navigate([`/basketList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}`]);
});

Alex ORLUC
committed
this.headerService.injectInSideBarLeft(this.adminMenuTemplate, this.viewContainerRef, 'adminMenu', 'form');
this.headerService.setHeader(this.translate.instant('lang.eventProcessDoc'));

Alex ORLUC
committed
checkAccesDocument(resId: number) {
return new Promise((resolve, reject) => {
this.http.get(`../rest/resources/${resId}/isAllowed`).pipe(
tap((data: any) => {
if (data.isAllowed) {
resolve(true);
} else {
this.notify.error(this.translate.instant('lang.documentOutOfPerimeter'));
this.router.navigate([`/home`]);
}
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
this.router.navigate([`/home`]);
return of(false);
})
)

Alex ORLUC
committed
.subscribe();
});
}
async initProcessPage(params: any) {

Alex ORLUC
committed
this.currentUserId = params['userSerialId'];
this.currentGroupId = params['groupSerialId'];
this.currentBasketId = params['basketId'];
this.currentResourceInformations = {
resId: params['resId'],

Hamza HRAMCHI
committed
mailtracking: false,

Alex ORLUC
committed
this.headerService.sideBarButton = {
icon: 'fa fa-inbox',
label: this.translate.instant('lang.backBasket'),
route: `/basketList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}`

Alex ORLUC
committed
};
await this.checkAccesDocument(this.currentResourceInformations.resId);
this.actionService.lockResource(this.currentUserId, this.currentGroupId, this.currentBasketId, [this.currentResourceInformations.resId]);
this.loadBadges();
this.loadResource();
if (this.appService.getViewMode()) {
setTimeout(() => {

Alex ORLUC
committed
this.headerService.sideNavLeft.open();
this.http.get(`../rest/resourcesList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}/actions?resId=${this.currentResourceInformations.resId}`).pipe(
map((data: any) => {
data.actions = data.actions.map((action: any, index: number) => {
return {
id: action.id,
label: action.label,
component: action.component,
categoryUse: action.categories

Alex ORLUC
committed
};
});
return data;
}),
tap((data: any) => {
this.selectedAction = data.actions[0];
this.actionsList = data.actions;
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
async initDetailPage(params: any) {

Alex ORLUC
committed
this._activatedRoute.queryParamMap.subscribe((paramMap: ParamMap) => {

Alex ORLUC
committed
this.isMailing = !this.functions.empty(paramMap.get('isMailing'));
Guillaume Heurtier
committed
if (this.isMailing) {
this.currentTool = 'attachments';
}

Alex ORLUC
committed
});

Alex ORLUC
committed
this.detailMode = true;
this.currentResourceInformations = {
resId: params['detailResId'],

Hamza HRAMCHI
committed
mailtracking: false,
retentionFrozen : false

Alex ORLUC
committed
this.headerService.sideBarButton = {
icon: 'fas fa-arrow-left',
label: this.translate.instant('lang.back'),

Alex ORLUC
committed
};
await this.checkAccesDocument(this.currentResourceInformations.resId);
Guillaume Heurtier
committed
this.loadResource(!this.isMailing);
if (this.appService.getViewMode()) {
setTimeout(() => {

Alex ORLUC
committed
this.headerService.sideNavLeft.open();
isActionEnded() {
return this.actionEnded;
}

Alex ORLUC
committed
loadResource(redirectDefautlTool: boolean = true) {
this.http.get(`../rest/resources/${this.currentResourceInformations.resId}?light=true`).pipe(
tap((data: any) => {
this.currentResourceInformations = data;
this.resourceFollowed = data.followed;

Hamza HRAMCHI
committed
this.resourceBinded = data.binding;
this.resourceFreezed = data.retentionFrozen;
if (this.currentResourceInformations.categoryId !== 'outgoing') {
this.loadSenders();
} else {
this.loadRecipients();
}

Alex ORLUC
committed
if (redirectDefautlTool) {
this.setEditDataPrivilege();
}

Alex ORLUC
committed
this.loadAvaibleIntegrations(data.integrations);
this.headerService.setHeader(this.detailMode ? this.translate.instant('lang.detailDoc') : this.translate.instant('lang.eventProcessDoc'), this.translate.instant('lang.' + this.currentResourceInformations.categoryId));
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
setEditDataPrivilege() {
if (this.detailMode) {
this.http.get('../rest/search/configuration').pipe(
tap((myData: any) => {
if (myData.configuration.listEvent.defaultTab == null) {
this.currentTool = 'dashboard';
} else {
this.currentTool = myData.configuration.listEvent.defaultTab;
}
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();

Florian Azizian
committed
this.canEditData = this.privilegeService.hasCurrentUserPrivilege('edit_resource') && this.currentResourceInformations.statusAlterable && this.functions.empty(this.currentResourceInformations.registeredMail_deposit_id);

Alex ORLUC
committed
if (this.isMailing && this.isToolEnabled('attachments')) {
this.currentTool = 'attachments';
// Avoid auto open if the user click one more time on tab attachments
setTimeout(() => {
this.isMailing = false;
}, 200);

Alex ORLUC
committed
}
this.http.get(`../rest/resources/${this.currentResourceInformations.resId}/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}/processingData`).pipe(
tap((data: any) => {
if (data.listEventData !== null) {
if (this.isToolEnabled(data.listEventData.defaultTab)) {
this.currentTool = data.listEventData.defaultTab;

Florian Azizian
committed
this.canEditData = data.listEventData.canUpdateData && this.functions.empty(this.currentResourceInformations.registeredMail_deposit_id);

Alex ORLUC
committed
this.canChangeModel = data.listEventData.canUpdateModel;
}
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
}

Alex ORLUC
committed
loadAvaibleIntegrations(integrationsData: any) {
this.integrationsInfo['inSignatureBook'].enable = !this.functions.empty(integrationsData['inSignatureBook']) ? integrationsData['inSignatureBook'] : false;
this.http.get(`../rest/externalConnectionsEnabled`).pipe(

Alex ORLUC
committed
tap((data: any) => {
Object.keys(data.connection).filter(connectionId => connectionId !== 'maarchParapheur').forEach(connectionId => {
if (connectionId === 'maileva') {
this.integrationsInfo['inShipping'] = {

Alex ORLUC
committed
};

Alex ORLUC
committed
}
});
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
toggleIntegration(integrationId: string) {
this.http.put(`../rest/resourcesList/integrations`, { resources: [this.currentResourceInformations.resId], integrations: { [integrationId]: !this.currentResourceInformations.integrations[integrationId] } }).pipe(

Alex ORLUC
committed
tap(() => {
this.currentResourceInformations.integrations[integrationId] = !this.currentResourceInformations.integrations[integrationId];
this.notify.success(this.translate.instant('lang.actionDone'));

Alex ORLUC
committed
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
this.http.get(`../rest/resources/${this.currentResourceInformations.resId}/items`).pipe(
tap((data: any) => {
this.processTool.forEach(element => {
element.count = data[element.id] !== undefined ? data[element.id] : 0;

Alex ORLUC
committed
});
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
loadSenders() {

Alex ORLUC
committed
if (this.currentResourceInformations.senders === undefined || this.currentResourceInformations.senders.length === 0) {
this.senderLightInfo = { 'displayName': this.translate.instant('lang.noSelectedContact'), 'filling': null };

Alex ORLUC
committed
} else if (this.currentResourceInformations.senders.length === 1) {
this.hasContact = true;
if (this.currentResourceInformations.senders[0].type === 'contact') {
this.http.get('../rest/contacts/' + this.currentResourceInformations.senders[0].id).pipe(
tap((data: any) => {
if (this.empty(data.firstname) && this.empty(data.lastname)) {
if (!this.functions.empty(data.fillingRate)) {
this.senderLightInfo = { 'displayName': data.company, 'filling': this.contactService.getFillingColor(data.fillingRate.thresholdLevel) };
} else {
this.senderLightInfo = { 'displayName': data.company };
}

Alex ORLUC
committed
arrInfo.push(data.firstname);
arrInfo.push(data.lastname);
if (!this.empty(data.company)) {
arrInfo.push('(' + data.company + ')');
if (!this.functions.empty(data.fillingRate)) {
this.senderLightInfo = { 'displayName': arrInfo.filter(info => info !== '').join(' '), 'filling': this.contactService.getFillingColor(data.fillingRate.thresholdLevel) };
} else {
this.senderLightInfo = { 'displayName': arrInfo.filter(info => info !== '').join(' ') };
}

Alex ORLUC
committed
}
})
).subscribe();

Alex ORLUC
committed
} else if (this.currentResourceInformations.senders[0].type === 'entity') {
this.http.get('../rest/entities/' + this.currentResourceInformations.senders[0].id).pipe(
tap((data: any) => {

Alex ORLUC
committed
this.senderLightInfo = { 'displayName': data.entity_label, 'filling': null };
})
).subscribe();

Alex ORLUC
committed
} else if (this.currentResourceInformations.senders[0].type === 'user') {
this.http.get('../rest/users/' + this.currentResourceInformations.senders[0].id).pipe(
tap((data: any) => {

Alex ORLUC
committed
this.senderLightInfo = { 'displayName': data.firstname + ' ' + data.lastname, 'filling': null };
})
).subscribe();
}
} else if (this.currentResourceInformations.senders.length > 1) {
this.hasContact = true;
this.senderLightInfo = { 'displayName': this.currentResourceInformations.senders.length + ' ' + this.translate.instant('lang.senders'), 'filling': null };
}
}
loadRecipients() {
if (this.currentResourceInformations.recipients === undefined || this.currentResourceInformations.recipients.length === 0) {
this.hasContact = false;
this.senderLightInfo = { 'displayName': this.translate.instant('lang.noSelectedContact'), 'filling': null };

Alex ORLUC
committed
} else if (this.currentResourceInformations.recipients.length === 1) {
this.hasContact = true;
if (this.currentResourceInformations.recipients[0].type === 'contact') {
this.http.get('../rest/contacts/' + this.currentResourceInformations.recipients[0].id).pipe(
tap((data: any) => {
const arrInfo = [];
if (this.empty(data.firstname) && this.empty(data.lastname)) {
if (!this.functions.empty(data.fillingRate)) {
this.senderLightInfo = { 'displayName': data.company, 'filling': this.contactService.getFillingColor(data.fillingRate.thresholdLevel) };
} else {
this.senderLightInfo = { 'displayName': data.company };
}
} else {
arrInfo.push(data.firstname);
arrInfo.push(data.lastname);
if (!this.empty(data.company)) {
arrInfo.push('(' + data.company + ')');
}
if (!this.functions.empty(data.fillingRate)) {
this.senderLightInfo = { 'displayName': arrInfo.filter(info => info !== '').join(' '), 'filling': this.contactService.getFillingColor(data.fillingRate.thresholdLevel) };
} else {
this.senderLightInfo = { 'displayName': arrInfo.filter(info => info !== '').join(' ') };
}
}
})
).subscribe();

Alex ORLUC
committed
} else if (this.currentResourceInformations.recipients[0].type === 'entity') {
this.http.get('../rest/entities/' + this.currentResourceInformations.recipients[0].id).pipe(
tap((data: any) => {
this.senderLightInfo = { 'displayName': data.entity_label, 'filling': null };
})
).subscribe();

Alex ORLUC
committed
} else if (this.currentResourceInformations.recipients[0].type === 'user') {
this.http.get('../rest/users/' + this.currentResourceInformations.recipients[0].id).pipe(
tap((data: any) => {
this.senderLightInfo = { 'displayName': data.firstname + ' ' + data.lastname, 'filling': null };
})
).subscribe();
}
} else if (this.currentResourceInformations.recipients.length > 1) {
this.hasContact = true;
this.senderLightInfo = { 'displayName': this.currentResourceInformations.recipients.length + ' ' + this.translate.instant('lang.recipients'), 'filling': null };
if (this.currentTool === 'info' || this.isModalOpen('info')) {
this.processAction();
} else {
if (this.isToolModified()) {
const dialogRef = this.openConfirmModification();
dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
tap(() => {
this.saveTool();
}),
finalize(() => {
this.autoAction = true;
this.currentTool = 'info';
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
} else {
this.autoAction = true;
this.currentTool = 'info';
}
}
}
triggerProcessAction() {
if (this.autoAction) {
this.processAction();
this.autoAction = !this.autoAction;
}
}
async processAction() {
if (this.indexingForm.isValidForm()) {
this.actionService.loading = true;
if (this.isToolModified()) {
const dialogRef = this.openConfirmModification();
dialogRef.afterClosed().pipe(
tap((data: string) => {
if (data !== 'ok') {
this.refreshTool();
this.actionService.loading = false;
}
}),
tap(async (data: string) => {
if (data === 'ok') {
await this.saveTool();
}
if (this.appDocumentViewer.isEditingTemplate()) {
await this.appDocumentViewer.saveMainDocument();
}
Guillaume Heurtier
committed

Alex ORLUC
committed
this.actionService.launchAction(this.selectedAction, this.currentUserId, this.currentGroupId, this.currentBasketId, [this.currentResourceInformations.resId], this.currentResourceInformations, false);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
this.actionService.loading = false;
return of(false);
})
).subscribe();
} else {
if (this.appDocumentViewer.isEditingTemplate()) {
await this.appDocumentViewer.saveMainDocument();
}
this.actionService.launchAction(this.selectedAction, this.currentUserId, this.currentGroupId, this.currentBasketId, [this.currentResourceInformations.resId], this.currentResourceInformations, false);
}

Alex ORLUC
committed
} else {
this.notify.error(this.translate.instant('lang.mustFixErrors'));

Alex ORLUC
committed
}
}
showActionInCurrentCategory(action: any) {
if (this.selectedAction.categoryUse.indexOf(this.currentResourceInformations.categoryId) === -1) {

Alex ORLUC
committed
const newAction = this.actionsList.filter(actionItem => actionItem.categoryUse.indexOf(this.currentResourceInformations.categoryId) > -1)[0];

Alex ORLUC
committed
this.selectedAction = this.actionsList.filter(actionItem => actionItem.categoryUse.indexOf(this.currentResourceInformations.categoryId) > -1)[0];
} else {
this.selectedAction = {
id: 0,
label: '',
component: '',
default: false,
categoryUse: []
};
}
}
return action.categoryUse.indexOf(this.currentResourceInformations.categoryId) > -1;
selectAction(action: any) {
this.selectedAction = action;
}
createModal() {
this.modalModule.push(this.processTool.filter(module => module.id === this.currentTool)[0]);
}
openTechnicalInfo() {
this.dialog.open(TechnicalInformationComponent, { panelClass: 'maarch-modal', autoFocus: false, data: { resId : this.currentResourceInformations.resId} });
}
if (this.modalModule[index].id === 'info' && this.indexingForm.isResourceModified()) {
const dialogRef = this.openConfirmModification();
dialogRef.afterClosed().pipe(
tap((data: string) => {
if (data !== 'ok') {
this.modalModule.splice(index, 1);
}
}),
filter((data: string) => data === 'ok'),
tap(() => {
this.indexingForm.saveData();

Alex ORLUC
committed
this.loadResource(false);
}, 400);
this.modalModule.splice(index, 1);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
} else {
this.modalModule.splice(index, 1);
}
isModalOpen(tool = this.currentTool) {
return this.modalModule.map(module => module.id).indexOf(tool) > -1;
if (!this.detailMode) {
this.actionService.stopRefreshResourceLock();
if (!this.actionService.actionEnded) {
this.actionService.unlockResource(this.currentUserId, this.currentGroupId, this.currentBasketId, [this.currentResourceInformations.resId]);
}
// unsubscribe to ensure no memory leaks
this.subscription.unsubscribe();
}

Alex ORLUC
committed
changeTab(tabId: string) {
if (this.isToolModified() && !this.isModalOpen()) {
const dialogRef = this.openConfirmModification();

Alex ORLUC
committed
dialogRef.afterClosed().pipe(
tap((data: string) => {
if (data !== 'ok') {

Alex ORLUC
committed
this.currentTool = tabId;
}
}),
filter((data: string) => data === 'ok'),
tap(() => {
this.saveTool();

Alex ORLUC
committed
this.loadResource(false);
}, 400);
this.currentTool = tabId;
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();

Alex ORLUC
committed
} else {
this.currentTool = tabId;
}
}
return this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.translate.instant('lang.confirm'), msg: this.translate.instant('lang.saveModifiedData'), buttonValidate: this.translate.instant('lang.yes'), buttonCancel: this.translate.instant('lang.no') } });
}
confirmModification() {
this.indexingForm.saveData();
setTimeout(() => {

Alex ORLUC
committed
this.loadResource(false);
async saveModificationBeforeClose() {
if (this.isToolModified() && !this.isModalOpen()) {
await this.saveTool();
}
if (this.appDocumentViewer.isEditingTemplate()) {
await this.appDocumentViewer.saveMainDocument();
}
}
refreshData() {
this.appDocumentViewer.loadRessource(this.currentResourceInformations.resId);
}
refreshBadge(nbRres: any, id: string) {
this.processTool.filter(tool => tool.id === id)[0].count = nbRres;
openContact() {
if (this.hasContact) {
this.dialog.open(ContactResourceModalComponent, { panelClass: 'maarch-modal', data: { title: `${this.currentResourceInformations.chrono} - ${this.currentResourceInformations.subject}`, mode: this.currentResourceInformations.categoryId !== 'outgoing' ? 'senders' : 'recipients', resId: this.currentResourceInformations.resId } });

Alex ORLUC
committed
saveListinstance() {
this.appDiffusionsList.saveListinstance();
}
saveVisaWorkflow() {
this.appVisaWorkflow.saveVisaWorkflow();
}

Alex ORLUC
committed
isToolModified() {
if (this.currentTool === 'info' && this.indexingForm !== undefined && this.indexingForm.isResourceModified()) {

Alex ORLUC
committed
return true;
} else if (this.currentTool === 'diffusionList' && this.appDiffusionsList !== undefined && this.appDiffusionsList.isModified()) {

Alex ORLUC
committed
return true;
} else if (this.currentTool === 'visaCircuit' && this.appVisaWorkflow !== undefined && this.appVisaWorkflow.isModified()) {
} else if (this.currentTool === 'opinionCircuit' && this.appAvisWorkflow !== undefined && this.appAvisWorkflow.isModified()) {
} else if (this.currentTool === 'notes' && this.appNotesList !== undefined && this.appNotesList.isModified()) {
return true;

Alex ORLUC
committed
} else {
return false;
}
}
refreshTool() {
const tmpTool = this.currentTool;
this.currentTool = '';
setTimeout(() => {
this.currentTool = tmpTool;
}, 0);
}
if (this.currentTool === 'info' && this.indexingForm !== undefined) {
await this.indexingForm.saveData();

Alex ORLUC
committed
setTimeout(() => {
this.loadResource(false);
}, 400);
} else if (this.currentTool === 'diffusionList' && this.appDiffusionsList !== undefined) {
await this.appDiffusionsList.saveListinstance();
} else if (this.currentTool === 'visaCircuit' && this.appVisaWorkflow !== undefined) {
await this.appVisaWorkflow.saveVisaWorkflow();
} else if (this.currentTool === 'opinionCircuit' && this.appAvisWorkflow !== undefined) {
await this.appAvisWorkflow.saveAvisWorkflow();
} else if (this.currentTool === 'notes' && this.appNotesList !== undefined) {
this.appNotesList.addNote();

Alex ORLUC
committed
}
}
empty(value: string) {
if (value === null || value === undefined) {
return true;
} else if (Array.isArray(value)) {
if (value.length > 0) {
return false;
} else {
return true;
}
} else if (String(value) !== '') {
return false;
} else {
return true;
}
}
toggleFollow() {
this.resourceFollowed = !this.resourceFollowed;
if (this.resourceFollowed) {
this.http.post('../rest/resources/follow', { resources: [this.currentResourceInformations.resId] }).pipe(
tap(() => this.headerService.nbResourcesFollowed++),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
} else {
this.http.request('DELETE', '../rest/resources/unfollow', { body: { resources: [this.currentResourceInformations.resId] } }).pipe(
tap(() => this.headerService.nbResourcesFollowed--),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
}

Hamza HRAMCHI
committed
toggleFreezing() {

Hamza HRAMCHI
committed
this.resourceFreezed = !this.resourceFreezed;
this.http.put('../rest/archival/freezeRetentionRule', { resources: [this.currentResourceInformations.resId], freeze : this.resourceFreezed }).pipe(

Hamza HRAMCHI
committed
tap(() => {

Hamza HRAMCHI
committed
if (this.resourceFreezed) {

Hamza HRAMCHI
committed
this.notify.success(this.translate.instant('lang.retentionRuleFrozen'));
} else {
this.notify.success(this.translate.instant('lang.retentionRuleUnfrozen'));

Hamza HRAMCHI
committed
}
}
),
catchError((err: any) => {

Hamza HRAMCHI
committed
this.resourceFreezed = !this.resourceFreezed;
this.notify.handleSoftErrors(err);

Hamza HRAMCHI
committed
return of(false);
})
).subscribe();
}

Hamza HRAMCHI
committed
toggleBinding(value) {
this.resourceBinded = value;
this.http.put('../rest/archival/binding', { resources: [this.currentResourceInformations.resId], binding : value }).pipe(

Hamza HRAMCHI
committed
tap(() => {

Hamza HRAMCHI
committed
this.notify.success(this.translate.instant('lang.bindingMail'));

Hamza HRAMCHI
committed
} else if (value === false) {
this.notify.success(this.translate.instant('lang.noBindingMail'));

Hamza HRAMCHI
committed
this.notify.success(this.translate.instant('lang.bindingUndefined'));
}

Hamza HRAMCHI
committed
}
),
catchError((err: any) => {

Hamza HRAMCHI
committed
this.resourceBinded = !this.resourceBinded;
this.notify.handleSoftErrors(err);

Hamza HRAMCHI
committed
return of(false);
})
).subscribe();
}
isToolEnabled(id: string) {
if (id === 'history') {
if (!this.privilegeService.hasCurrentUserPrivilege('view_full_history') && !this.privilegeService.hasCurrentUserPrivilege('view_doc_history')) {

Alex ORLUC
committed
return false;
} else {
return true;
}
} else {
return true;
}
}
this.dialog.open(PrintedFolderModalComponent, { panelClass: 'maarch-modal', data: { resId: this.currentResourceInformations.resId } });