From 7bdd54deb18a12bbed66fbd1fa5b31b5e8ec528f Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Tue, 26 Feb 2019 18:22:05 +0100 Subject: [PATCH] 9686 begin launch default action --- apps/maarch_entreprise/actions/process.php | 25 ++++++++----------- apps/maarch_entreprise/js/functions.js | 14 ++++++++--- .../app/actions/actions-list.component.ts | 25 ++++++++++++++++++- .../process-action.component.html | 12 +++++++++ .../process-action.component.scss | 24 ++++++++++++++++++ .../process-action.component.ts | 22 ++++++++++++++++ src/frontend/app/app.module.ts | 3 +++ .../app/list/basket-list.component.html | 2 +- .../app/list/basket-list.component.ts | 22 ++++++++++++++++ 9 files changed, 129 insertions(+), 20 deletions(-) create mode 100644 src/frontend/app/actions/process-action/process-action.component.html create mode 100644 src/frontend/app/actions/process-action/process-action.component.scss create mode 100644 src/frontend/app/actions/process-action/process-action.component.ts diff --git a/apps/maarch_entreprise/actions/process.php b/apps/maarch_entreprise/actions/process.php index 902eaae25ee..a979ddd58a3 100755 --- a/apps/maarch_entreprise/actions/process.php +++ b/apps/maarch_entreprise/actions/process.php @@ -236,10 +236,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $frm_str .= '<input type="button" name="send" id="send" value="' ._VALIDATE - // . '" class="button" onclick="new Ajax.Request(\'' .'" class="button" onclick="$j.ajax({url :\'index.php?display=true&dir=actions&page=docLocker\', type : \'POST\',data : {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': '.$res_id.'}, success: function (response) { }});valid_action_form(\'process\', \'' - // . $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': ' . $res_id . '} });valid_action_form(\'process\', \'' - //. $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': ' . $res_id . '} });valid_action_form(\'process\', \'' .$path_manage_action.'\', \''.$id_action.'\', \'' .$res_id.'\', \''.$table.'\', \''.$module.'\', \'' @@ -247,18 +244,16 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $frm_str .= '</div>'; $frm_str .= '</div>'; - $frm_str .= '<i onmouseover="this.style.cursor=\'pointer\';" ' - .'onclick="$j.ajax({url :\'index.php?display=true&dir=actions&page=docLocker\', type : \'POST\',data : {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': '.$res_id.'}, success: function (answer) { '; -// .'onclick="new Ajax.Request(\'' . $_SESSION['config']['businessappurl'] - // . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': ' - $frm_str .= 'window.location.href=window.location.href.replace(\'&directLinkToAction\', \'\');} });var tmp_bask=$(\'baskets\');'; - $frm_str .= 'if (tmp_bask){tmp_bask.style.visibility=\'visible\';}var tmp_ent =$(\'entity\');'; - $frm_str .= 'if (tmp_ent){tmp_ent.style.visibility=\'visible\';} var tmp_cat =$(\'category\');'; - $frm_str .= 'if (tmp_cat){tmp_cat.style.visibility=\'visible\';}destroyModal(\'modal_' - .$id_action.'\');reinit();"'; - $frm_str .= ' }};' - - .' class="fa fa-times-circle fa-2x closeModale" title="'._CLOSE.'"/>'; + $frm_str .= '<i onmouseover="this.style.cursor=\'pointer\';" '; + $frm_str .= 'onclick="$j.ajax({url :\'index.php?display=true&dir=actions&page=docLocker\', type : \'POST\',data : {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': '.$res_id.'}, success: function (answer) { '; + $frm_str .= 'destroyModal(\'modal_'.$id_action.'\');triggerAngular(\'#/basketList/users/21/groups/2/baskets/9\');'; + //$frm_str .= 'window.location.href=window.location.href.replace(\'&directLinkToAction\', \'\');} });var tmp_bask=$(\'baskets\');'; + //$frm_str .= 'if (tmp_bask){tmp_bask.style.visibility=\'visible\';}var tmp_ent =$(\'entity\');'; + //$frm_str .= 'if (tmp_ent){tmp_ent.style.visibility=\'visible\';} var tmp_cat =$(\'category\');'; + //$frm_str .= 'if (tmp_cat){tmp_cat.style.visibility=\'visible\';}destroyModal(\'modal_'.$id_action.'\');reinit();"'; + $frm_str .= ' }});"'; + + $frm_str .= ' class="fa fa-times-circle fa-2x closeModale" title="'._CLOSE.'"/>'; $frm_str .= '</i>'; /********************************* LEFT PART **************************************/ $frm_str .= '<div style="height:90vh;overflow:auto;">'; diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index 56fec8b2130..49954fcb415 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -1096,20 +1096,24 @@ function close_action(id_action, page, path_manage_script, mode_req, res_id_valu if (pile_actions.values.length == 0) { if (actions_status.values.length > 0) { var status = actions_status.values[actions_status.values.length - 1]; + console.log('toto'); action_done = action_change_status(path_manage_script, mode_req, res_id_values, tablename, id_coll, status, page); } else { if (page != '' && page != NaN && page && page != null) { if (typeof window['angularSignatureBookComponent'] != "undefined") { window.angularSignatureBookComponent.componentAfterAction(); } else { + console.log('tutu'); do_nothing = false; - window.top.location.href = page; + triggerAngular('#/basketList/users/21/groups/2/baskets/9'); + //window.top.location.href = page; } } else if (do_nothing == false) { if (typeof window['angularSignatureBookComponent'] != "undefined") { window.angularSignatureBookComponent.componentAfterAction(); } else { + console.log('tata'); window.top.location.hash = ""; window.top.location.reload(); } @@ -1542,8 +1546,12 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table if (typeof window['angularSignatureBookComponent'] != "undefined") { window.angularSignatureBookComponent.componentAfterAction(); } else { - window.top.location.hash = ""; - window.top.location.reload(); + //window.top.location.hash = ""; + //window.top.location.reload(); + var arr = window.top.location.href.split('&'); + arr = arr.unshift(); + console.log(arr); + triggerAngular('#/basketList/users/21/groups/2/baskets/9'); } } } diff --git a/src/frontend/app/actions/actions-list.component.ts b/src/frontend/app/actions/actions-list.component.ts index c20202544fc..3047be5f78b 100644 --- a/src/frontend/app/actions/actions-list.component.ts +++ b/src/frontend/app/actions/actions-list.component.ts @@ -7,6 +7,7 @@ import { MatDialog, MatMenuTrigger } from '@angular/material'; import { ConfirmActionComponent } from './confirm-action/confirm-action.component'; import { CloseMailActionComponent } from './close-mail-action/close-mail-action.component'; import { UpdateDepartureDateActionComponent } from './update-departure-date-action/update-departure-date-action.component'; +import { ProcessActionComponent } from './process-action/process-action.component'; @Component({ selector: 'app-actions-list', @@ -62,6 +63,7 @@ export class ActionsListComponent implements OnInit { this.arrRes = []; this.currentAction = action; + console.log(action); if (this.contextMode && this.selectedRes.length == 0) { this.arrRes = [this.contextResId]; } else { @@ -77,7 +79,8 @@ export class ActionsListComponent implements OnInit { this[action.component](); } catch (error) { - alert(this.lang.actionNotExist); + console.log(error); + alert(this.lang.actionNotExist); } this.loading = false; }, (err: any) => { @@ -145,6 +148,26 @@ export class ActionsListComponent implements OnInit { } }); } + + processAction() { + console.log(this.currentBasketInfo); + console.log(this.currentAction); + console.log(this.arrRes); + + this.currentBasketInfo.basket_id = 'MyBasket'; + window.location.href = 'index.php?page=view_baskets&module=basket&baskets='+this.currentBasketInfo.basket_id+'&resId='+this.arrRes[0]+'&defaultAction='+this.currentAction.id; + // WHEN V2 + /*this.dialog.open(ProcessActionComponent, { + width: '500px', + data: { + contextMode: this.contextMode, + contextChrono: this.contextMenuTitle, + selectedRes: this.selectedRes, + action: this.currentAction, + currentBasketInfo: this.currentBasketInfo + } + });*/ + } //// endAction() { diff --git a/src/frontend/app/actions/process-action/process-action.component.html b/src/frontend/app/actions/process-action/process-action.component.html new file mode 100644 index 00000000000..1252c6a10e8 --- /dev/null +++ b/src/frontend/app/actions/process-action/process-action.component.html @@ -0,0 +1,12 @@ +<h1 mat-dialog-title></h1> +<div mat-dialog-content> + <div *ngIf="loading" class="loading" style="display:flex;height:100%;"> + <mat-spinner style="margin:auto;"></mat-spinner> + </div> + <div class="row"> + </div> +</div> +<div mat-dialog-actions class="actions"> + <button mat-raised-button mat-button color="primary" [disabled]="loading" (click)="onSubmit()">{{lang.validate}}</button> + <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{lang.cancel}}</button> +</div> diff --git a/src/frontend/app/actions/process-action/process-action.component.scss b/src/frontend/app/actions/process-action/process-action.component.scss new file mode 100644 index 00000000000..6de958ac477 --- /dev/null +++ b/src/frontend/app/actions/process-action/process-action.component.scss @@ -0,0 +1,24 @@ +.mat-dialog-content { + position: relative; +} + +.mat-dialog-actions, .mat-dialog-title { + justify-content: center; + text-align: center; +} + +.highlight { + font-size: 110%; +} + +.loading { + display:flex; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: #ffffffb3; + z-index: 1; + overflow: hidden; +} diff --git a/src/frontend/app/actions/process-action/process-action.component.ts b/src/frontend/app/actions/process-action/process-action.component.ts new file mode 100644 index 00000000000..55da5338fc6 --- /dev/null +++ b/src/frontend/app/actions/process-action/process-action.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit, Inject } from '@angular/core'; +import { LANG } from '../../translate.component'; +import { NotificationService } from '../../notification.service'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { HttpClient } from '@angular/common/http'; + +@Component({ + templateUrl: "process-action.component.html", + styleUrls: ['process-action.component.scss'], + providers: [NotificationService], +}) +export class ProcessActionComponent implements OnInit { + + lang: any = LANG; + loading: boolean = false; + + constructor(public http: HttpClient, private notify: NotificationService, public dialogRef: MatDialogRef<ProcessActionComponent>, @Inject(MAT_DIALOG_DATA) public data: any) { } + + ngOnInit(): void { + window.location.href = 'index.php?page=view_baskets&module=basket&baskets=MyBasket&resId=105&defaultAction=19'; + } +} diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index 5e20152fbca..28645d447fd 100755 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -26,6 +26,7 @@ import { ActionsListComponent } from './actions/actions-list.com import { ConfirmActionComponent } from './actions/confirm-action/confirm-action.component'; import { CloseMailActionComponent } from './actions/close-mail-action/close-mail-action.component'; import { UpdateDepartureDateActionComponent } from './actions/update-departure-date-action/update-departure-date-action.component'; +import { ProcessActionComponent } from './actions/process-action/process-action.component'; import { FiltersListComponent } from './list/filters/filters-list.component'; import { FiltersToolComponent } from './list/filters/filters-tool.component'; @@ -70,6 +71,7 @@ import { DiffusionsListComponent } from './diffusions/diffusions-lis ConfirmActionComponent, CloseMailActionComponent, UpdateDepartureDateActionComponent, + ProcessActionComponent, ActionsListComponent, ], entryComponents: [ @@ -84,6 +86,7 @@ import { DiffusionsListComponent } from './diffusions/diffusions-lis ConfirmActionComponent, CloseMailActionComponent, UpdateDepartureDateActionComponent, + ProcessActionComponent, ], providers: [ ShortcutMenuService, HeaderService, FiltersListService ], bootstrap: [ AppComponent ] diff --git a/src/frontend/app/list/basket-list.component.html b/src/frontend/app/list/basket-list.component.html index be1c1269063..f9df9fa3db1 100644 --- a/src/frontend/app/list/basket-list.component.html +++ b/src/frontend/app/list/basket-list.component.html @@ -76,7 +76,7 @@ (click)="$event.stopPropagation();"></mat-checkbox> </div> <div class="resultCol" [class]="data.cssClasses.join(' ')" *ngFor="let data of displayedMainData" - style="cursor: pointer;"> + style="cursor: pointer;" (click)="$event.stopPropagation();launch(defaultAction,row)"> <span *ngIf="data.value == 'alt_identifier'"> <mat-icon [ngStyle]="{'color': row.priorityColor}" color="primary" class="{{row.statusImage.charAt(0)}}{{row.statusImage.charAt(1)}} {{row.statusImage}} {{row.statusImage.charAt(0)}}{{row.statusImage.charAt(1)}}-2x" title="{{row.statusLabel}}" style="cursor: crosshair;" (click)="$event.stopPropagation();filterThis(row.statusLabel)"></mat-icon><br /> diff --git a/src/frontend/app/list/basket-list.component.ts b/src/frontend/app/list/basket-list.component.ts index 72109f32509..968690da10a 100755 --- a/src/frontend/app/list/basket-list.component.ts +++ b/src/frontend/app/list/basket-list.component.ts @@ -71,6 +71,10 @@ export class BasketListComponent implements OnInit { listProperties: any = {}; currentBasketInfo: any = {}; currentChrono: string = ''; + defaultAction = { + id: 19, + component : 'processAction' + }; thumbnailUrl: string = ''; selectedRes: number[] = []; @@ -112,6 +116,7 @@ export class BasketListComponent implements OnInit { this.initResultList(); this.route.params.subscribe(params => { + console.log(params); this.basketUrl = '../../rest/resourcesList/users/' + params['userSerialId'] + '/groups/' + params['groupSerialId'] + '/baskets/' + params['basketId']; this.currentBasketInfo = { @@ -155,6 +160,8 @@ export class BasketListComponent implements OnInit { data = this.processPostData(data); this.resultsLength = data.count; this.allResInBasket = data.allResources; + this.currentBasketInfo.basket_id = data.basket_id; + this.defaultAction = data.defaultAction; this.headerService.setHeader(data.basketLabel, this.resultsLength + ' ' + this.lang.entries); return data.resources; }), @@ -378,11 +385,26 @@ export class BasketListComponent implements OnInit { // prevents default return false; } + + launch(action: any, row: any) { + let thisSelect = { checked : true }; + let thisDeselect = { checked : false }; + row.checked = true; + this.toggleAllRes(thisDeselect); + this.toggleRes(thisSelect, row); + + setTimeout(() => { + this.actionsList.launchEvent(action); + }, 200); + + } } export interface BasketList { resources: any[]; count: number; basketLabel: string, + basket_id: string, + defaultAction: any; allResources: number[] } -- GitLab