FEAT #12982 TIME 2:15 make action in signatureBook

parent b359fe49
<?php
$_SESSION['doc_id'] = $_REQUEST['resId'];
......@@ -67,41 +67,6 @@ function changeLocationToAngular(locationToGo) {
location.href = locationToGo;
}
function lockDocument(resId) {
$j.ajax({
url: 'index.php?display=true&dir=actions&page=docLocker',
type: 'POST',
data: {
AJAX_CALL: true,
lock: true,
res_id: resId
},
success: function (result) {}
});
}
function intervalLockDocument(resId){
lockInterval = setInterval(function() {lockDocument(resId);}, 50000);
}
function unlockDocument(resId) {
$j.ajax({
url: 'index.php?display=true&dir=actions&page=docLocker',
type: 'POST',
data: {
AJAX_CALL: true,
unlock: true,
res_id: resId
},
success: function (result) {}
});
}
function intervalUnlockDocument(resId){
clearInterval(lockInterval);
unlockDocument(resId);
}
function islockForSignatureBook(resId, basketId, groupId) {
$j.ajax({
url: 'index.php?display=true&dir=actions&page=docLocker',
......@@ -144,7 +109,7 @@ function setAttachmentInSignatureBook(id) {
},
success: function (answer) {
if (typeof window.parent['angularSignatureBookComponent'] !== "undefined") {
window.parent.angularSignatureBookComponent.componentAfterAttach("left");
// window.parent.angularSignatureBookComponent.componentAfterAttach("left");
}
},
error: function (err) {
......@@ -153,17 +118,6 @@ function setAttachmentInSignatureBook(id) {
});
}
function setSessionForSignatureBook(resId) {
$j.ajax({
url: 'index.php?display=true&dir=actions&page=setSession',
type: 'POST',
data: {
resId: resId
},
success: function (result) {}
});
}
function displayThumbnail(resId) {
$j('#thumb_' + resId).html('<img src="../../rest/resources/' + resId + '/thumbnail">');
}
......
......@@ -847,7 +847,7 @@ function close_action(id_action, page, path_manage_script, mode_req, res_id_valu
} else {
if (page != '' && page != NaN && page && page != null) {
if (typeof window['angularSignatureBookComponent'] != "undefined") {
window.angularSignatureBookComponent.componentAfterAction();
// window.angularSignatureBookComponent.componentAfterAction();
} else {
do_nothing = false;
window.top.location.href = page;
......@@ -855,7 +855,7 @@ function close_action(id_action, page, path_manage_script, mode_req, res_id_valu
} else if (do_nothing == false) {
if (typeof window['angularSignatureBookComponent'] != "undefined") {
window.angularSignatureBookComponent.componentAfterAction();
// window.angularSignatureBookComponent.componentAfterAction();
} else {
window.top.location.hash = "";
window.top.location.reload();
......@@ -1281,13 +1281,13 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table
var cur_url = window.top.location.href;
if (cur_url.indexOf("&directLinkToAction") != -1) {
if (typeof window['angularSignatureBookComponent'] != "undefined") {
window.angularSignatureBookComponent.componentAfterAction();
// window.angularSignatureBookComponent.componentAfterAction();
} else {
window.top.location = cur_url.replace("&directLinkToAction", "");
}
} else {
if (typeof window['angularSignatureBookComponent'] != "undefined") {
window.angularSignatureBookComponent.componentAfterAction();
// window.angularSignatureBookComponent.componentAfterAction();
} else {
var arr = window.top.location.href.split('&');
......@@ -1779,7 +1779,7 @@ function addLinks(path_manage_script, child, parent, action, tableHist) {
eval("response = " + answer.responseText);
if (response.status == 0 || response.status == 1) {
if (typeof window.parent['angularSignatureBookComponent'] != "undefined") {
window.parent.angularSignatureBookComponent.componentAfterLinks();
// window.parent.angularSignatureBookComponent.componentAfterLinks();
}
if (response.status == 0) {
$(divName).innerHTML = response.links;
......@@ -2842,7 +2842,7 @@ function setSendAttachment(id) {
},
success: function (answer) {
if (typeof window.parent['angularSignatureBookComponent'] !== "undefined") {
window.parent.angularSignatureBookComponent.componentAfterAttach("left");
// window.parent.angularSignatureBookComponent.componentAfterAttach("left");
}
},
error: function (err) {
......
......@@ -40,7 +40,7 @@ function validNotesForm(path, form_id) {
eval("response = "+answer.responseText);
if(response.status == 0){
if (typeof window.parent['angularSignatureBookComponent'] != "undefined") {
window.parent.angularSignatureBookComponent.componentAfterNotes();
// window.parent.angularSignatureBookComponent.componentAfterNotes();
}
destroyModal('form_notes');
var modInfo = $j('<div class="info" id="main_info" onclick="this.remove();">'+response.msg_result+'</div>');
......
......@@ -26,7 +26,7 @@
"jstree-bootstrap-theme": "^1.0.1",
"ng2-pdf-viewer": "^5.3.4",
"ngx-cookie-service": "^2.1.0",
"ngx-pipes": "^2.6.0",
"ngx-pipes": "^2.7.3",
"pdfjs-dist": "2.2.228",
"photoswipe": "^4.1.3",
"tinymce": "^5.1.6",
......
......@@ -194,7 +194,6 @@ export class ProcessComponent implements OnInit {
} else {
this.initProcessPage(params);
}
console.log(params);
}, (err: any) => {
this.notify.handleErrors(err);
});
......
......@@ -5,19 +5,16 @@ import { Router, ActivatedRoute } from '@angular/router';
import { LANG } from './translate.component';
import { NotificationService } from './notification.service';
import { tap, catchError, filter } from 'rxjs/operators';
import { of } from 'rxjs';
import { of, Subscription } from 'rxjs';
import { PrivilegeService } from '../service/privileges.service';
import { MatDialogRef, MatDialog } from '@angular/material';
import { AttachmentCreateComponent } from './attachments/attachment-create/attachment-create.component';
import { FunctionsService } from '../service/functions.service';
import { AttachmentPageComponent } from './attachments/attachments-page/attachment-page.component';
import { VisaWorkflowComponent } from './visa/visa-workflow.component';
import { ActionsService } from './actions/actions.service';
declare function lockDocument(resId: number) : void;
declare function unlockDocument(resId: number) : void;
declare function valid_action_form(a1: string, a2: string, a3: string, a4: number, a5: string, a6: string, a7: string, a8: string, a9: boolean, a10: any) : void;
declare function $j(selector: string) : any;
declare function setSessionForSignatureBook(resId: any) : void;
declare var angularGlobals : any;
......@@ -68,6 +65,9 @@ export class SignatureBookComponent implements OnInit {
loading : boolean = false;
loadingSign : boolean = false;
subscription: Subscription;
currentResourceLock: any = null;
leftContentWidth : string = "44%";
rightContentWidth : string = "44%";
dialogRef: MatDialogRef<any>;
......@@ -109,13 +109,16 @@ export class SignatureBookComponent implements OnInit {
private notify: NotificationService,
public privilegeService: PrivilegeService,
public dialog: MatDialog,
public functions: FunctionsService
public functions: FunctionsService,
public actionService: ActionsService
) {
window['angularSignatureBookComponent'] = {
componentAfterAttach: (value: string) => this.processAfterAttach(value),
componentAfterAction: () => this.processAfterAction()
};
(<any>window).pdfWorkerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.min.js';
// Event after process action
this.subscription = this.actionService.catchAction().subscribe(message => {
clearInterval(this.currentResourceLock);
this.processAfterAction();
});
}
ngOnInit() : void {
......@@ -130,8 +133,7 @@ export class SignatureBookComponent implements OnInit {
this.userId = params['userId'];
this.signatureBook.resList = []; // This line is added because of manage action behaviour (processAfterAction is called twice)
lockDocument(this.resId);
setInterval(() => {lockDocument(this.resId)}, 50000);
this.lockResource();
this.http.get("../../rest/signatureBook/users/" + this.userId + "/groups/" + this.groupId + "/baskets/" + this.basketId + "/resources/" + this.resId)
.subscribe((data : any) => {
if (data.error) {
......@@ -189,6 +191,35 @@ export class SignatureBookComponent implements OnInit {
});
});
}
lockResource() {
this.http.put(`../../rest/resourcesList/users/${this.userId}/groups/${this.groupId}/baskets/${this.basketId}/lock`, { resources: [this.resId] }).pipe(
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
this.currentResourceLock = setInterval(() => {
this.http.put(`../../rest/resourcesList/users/${this.userId}/groups/${this.groupId}/baskets/${this.basketId}/lock`, { resources: [this.resId] }).pipe(
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}, 50000);
}
unlockResource() {
clearInterval(this.currentResourceLock);
this.http.put(`../../rest/resourcesList/users/${this.userId}/groups/${this.groupId}/baskets/${this.basketId}/unlock`, { resources: [this.resId] }).pipe(
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
loadActions() {
this.http.get("../../rest/resourcesList/users/" + this.userId + "/groups/" + this.groupId + "/baskets/" + this.basketId + "/actions?resId=" + this.resId)
......@@ -199,10 +230,6 @@ export class SignatureBookComponent implements OnInit {
});
}
ngOnDestroy() : void {
delete window['angularSignatureBookComponent'];
}
processAfterAttach(mode: string) {
this.zone.run(() => this.refreshAttachments(mode));
}
......@@ -461,28 +488,24 @@ export class SignatureBookComponent implements OnInit {
validForm() {
if ($j("#signatureBookActions option:selected")[0].value != "") {
this.sendActionForm();
this.processAction();
} else {
alert("Aucune action choisie");
}
}
sendActionForm() {
unlockDocument(this.resId);
setSessionForSignatureBook(this.resId);
valid_action_form(
'empty',
'index.php?display=true&page=manage_action&module=core',
this.signatureBook.currentAction.id,
this.resId,
'res_letterbox',
'null',
'letterbox_coll',
'page',
false,
[$j("#signatureBookActions option:selected")[0].value]
);
processAction() {
this.http.get(`../../rest/resources/${this.resId}?light=true`).pipe(
tap((data: any) => {
let actionId = $j("#signatureBookActions option:selected")[0].value;
let selectedAction = this.signatureBook.actions.filter((action: any) => action.id == actionId)[0];
this.actionService.launchAction(selectedAction, this.userId, this.groupId, this.basketId, [this.resId], data, false);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
refreshBadge(nbRres: any, id: string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment