diff --git a/modules/basket/view_baskets.php b/modules/basket/view_baskets.php index 2df7c7388f2467f0524b289c1d9d95d9a0b5ef21..fec79dd7460de4cb6f78fb8bb870e9cfcf5b0d66 100755 --- a/modules/basket/view_baskets.php +++ b/modules/basket/view_baskets.php @@ -60,24 +60,25 @@ if (empty($_GET['resId'])) { $_GET['resId'] = "'none'"; } -if(empty($_GET['defaultAction'])) { +if (empty($_GET['defaultAction'])) { $_GET['defaultAction'] = $_SESSION['current_basket']['default_action']; } $_SESSION['urlV2Basket'] = $_GET; echo '<script language="javascript">'; - -if (!empty($_GET['signatureBookMode'])) { - echo 'islockForSignatureBook(\''.$_GET['resId'].'\', \''.$_GET['baskets'].'\', \'RESPONSABLE\');'; +if (!empty($_GET['backToBasket'])) { + echo 'triggerAngular(\'#/basketList/users/'.$_GET['userId'].'/groups/'.$_GET['groupIdSer'].'/baskets/'.$_GET['basketId'].'\');'; +} else if (!empty($_GET['signatureBookMode'])) { + echo 'triggerAngular(\'#/signatureBook/users/'.$_GET['userId'].'/groups/'.$_GET['groupIdSer'].'/baskets/'.$_GET['basketId'].'/resources/'.$_GET['resId'].'\');'; } else { - echo 'action_send_first_request(\'' - . $_SESSION['config']['businessappurl'] + echo 'action_send_first_request(\'' + . $_SESSION['config']['businessappurl'] . 'index.php?display=true&page=manage_action&module=core\'' . ', \'page\'' - . ',' . $_GET['defaultAction'] - . ',' . $_GET['resId'] + . ',' . $_GET['defaultAction'] + . ',' . $_GET['resId'] . ',\'' . $_SESSION['current_basket']['table'] . '\'' - . ',\'basket\'' + . ',\'basket\'' . ',\'' . $_SESSION['current_basket']['coll_id'] . '\');'; } echo '</script>'; diff --git a/src/frontend/app/app-routing.module.ts b/src/frontend/app/app-routing.module.ts index f3190503a21ccd734a76e9218b30612cf56c3566..e703b6dea05d52e47edc40ef838af518fc207dbc 100755 --- a/src/frontend/app/app-routing.module.ts +++ b/src/frontend/app/app-routing.module.ts @@ -20,7 +20,7 @@ import { SaveNumericPackageComponent } from './save-numeric-package.compone { path: 'home', component: HomeComponent }, { path: 'basketList/users/:userSerialId/groups/:groupSerialId/baskets/:basketId', component: BasketListComponent }, { path: 'saveNumericPackage', component: SaveNumericPackageComponent }, - { path: 'groups/:groupId/baskets/:basketId/signatureBook/:resId', component: SignatureBookComponent }, + { path: 'signatureBook/users/:userId/groups/:groupId/baskets/:basketId/resources/:resId', component: SignatureBookComponent }, { path: '**', redirectTo: 'home', pathMatch: 'full' }, ], { useHash: true }), ], diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts index bb4fbac28caf6b3dd7219586cec278afcf286fc6..8186dc9fbf81208ad7e1cf598ea5ffe9e3dd983f 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -12,6 +12,7 @@ declare function $j(selector: string) : any; declare function showAttachmentsForm(path: string) : void; declare function modifyAttachmentsForm(path: string, width: string, height: string) : void; declare function setSessionForSignatureBook(resId: any) : void; +declare function triggerAngular(route: string) : void; declare var angularGlobals : any; @@ -32,8 +33,9 @@ export class SignatureBookComponent implements OnInit { coreUrl : string; resId : number; - basketId : string; - groupId : string; + basketId : number; + groupId : number; + userId : number; lang : any = LANG; signatureBook: any = { @@ -106,11 +108,13 @@ export class SignatureBookComponent implements OnInit { this.resId = +params['resId']; this.basketId = params['basketId']; this.groupId = params['groupId']; + 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.http.get(this.coreUrl + "rest/groups/" + this.groupId + "/baskets/" + this.basketId + '/signatureBook/' + this.resId) + //this.http.get(this.coreUrl + "rest/groups/" + this.groupId + "/baskets/" + this.basketId + '/signatureBook/' + this.resId) + this.http.get("../../rest/signatureBook/users/" + this.userId + "/groups/" + this.groupId + "/baskets/" + this.basketId + "/resources/" + this.resId) .subscribe((data : any) => { if (data.error) { location.hash = ""; @@ -256,8 +260,7 @@ export class SignatureBookComponent implements OnInit { this.rightContentWidth = "44%"; this.leftContentWidth = "44%"; if (this.signatureBook.resList.length == 0 || typeof this.signatureBook.resList[0].creation_date === 'undefined') { - //TODO change route /signatureBook/users/{userId}/groups/{groupId}/baskets/{basketId}/resources - this.http.get(this.coreUrl + 'rest/' + this.basketId + '/signatureBook/resList/details') + this.http.get("../../rest/signatureBook/users/" + this.userId + "/groups/" + this.groupId + "/baskets/" + this.basketId + "/resources") .subscribe((data : any) => { this.signatureBook.resList = data.resources; this.signatureBook.resList.forEach((value: any, index: number) => { @@ -477,8 +480,10 @@ export class SignatureBookComponent implements OnInit { backToBasket() { unlockDocument(this.resId); - location.hash = ""; - location.reload(); + //location.hash = ""; + //location.reload(); + //this.router.navigate(['basketList/users/'+ this.userId+'/groups/'+ this.groupId+'/baskets/'+ this.basketId]); + window.location.href = 'index.php?page=view_baskets&module=basket&basketId='+this.basketId+'&userId='+this.userId+'&groupIdSer='+this.groupId+'&backToBasket=true'; } backToDetails() { @@ -488,22 +493,16 @@ export class SignatureBookComponent implements OnInit { } changeLocation(resId: number, origin: string) { - //TODO Refonte route isLock - this.http.put(this.coreUrl + 'rest/resources/lock', {resources : [resId]}) - .subscribe(() => { - let path = "/groups/" + this.groupId + "/baskets/" + this.basketId + '/signatureBook/' + resId; - this.router.navigate([path]); - }, (err) => { - if (err.error.lockBy) { - if (origin == "view") { - alert("Courrier verrouillé par " + err.error.lockBy[0]); - } else if (origin == "action") { - alert("Courrier suivant verrouillé par " + err.error.lockBy[0]); - this.backToBasket(); - } + this.http.put('../../rest/resourcesList/users/' + this.userId + '/groups/' + this.groupId + '/baskets/' + this.basketId + '/lock', { resources: [resId] }) + .subscribe((data: any) => { + if (data.lockedResources > 0) { + alert(data.lockedResources + ' ' + this.lang.warnLockRes + '.'); } else { - this.notify.error(err.error.errors); + let path = "signatureBook/users/" + this.userId + "/groups/" + this.groupId + "/baskets/" + this.basketId + "/resources/" + resId; + this.router.navigate([path]); } + }, (err: any) => { + this.notify.handleErrors(err); }); }