Les actions sont "automatiques" , elles arrivent du back et sont gérées dans les composants de base( BaseComponent - doExecuteAction )
Certaines ne le sont pas et necessitent qu'on code l'action manuellement
public executeSYNCHRONISER() {
this.coreServicesProvider.minimalHttpService.doPost('/param/backoffice/catalogue/version/synchroniser', { httpParams: { doToastSuccess: true, noTimeOut: false, forcePost: false }}, undefined)
.subscribe();
}
public executeTESTER_GEN_LIST() : void {
let l_body : HttpPostContext = {};
this.coreServicesProvider.minimalHttpService.doPost<HttpPostResult<Flux>>('/flux/paramGenList/admin/getMeta/' + this.dataBean.id_ParamGenListR,l_body).subscribe(
resultMeta => {
if (resultMeta.data) {
let l_defaultParams : Array<MsReportParam> = [{
code: "ID_ENTITE_COURANTE",
valeur: this.coreServicesProvider.routerGlobals.params.idEntite
},
{
code: "ID_BEANS_COURANTS",
valeur: []
}
];
if (((resultMeta.data.paramList_FluxR)&&(resultMeta.data.paramList_FluxR.length>0)) || ((resultMeta.data.formatList_FluxR)&&(resultMeta.data.formatList_FluxR.length>1))) {
let l_reportModalParams : ReportParamsModalData = {
paramList:l_defaultParams,
flux:resultMeta.data,
action:{code:"test",libelle:this.dataBean.libelle_ParamGenListR}
};
this.modalService.showModal(ReportParamsModalComponent,{dataType:ViewDataType.UPDATE,hasApiParam:false},l_reportModalParams).subscribe(
resultModal => {
if (resultModal.modalResult!==MsModalResult.KO) {
this.doGetSql((<FluxStart>resultModal.data).paramList);
}
}
)
} else {
this.doGetSql(l_defaultParams);
}
}
}
)
}
public executeRELANCERSYNCHRO(): void {
let l_body: HttpPostContext = {};
this.coreServicesProvider.minimalHttpService.doPostWithResponse('/terminal/statut/relancerSynchro', l_body)
.subscribe(result => {
if (result && result.status === 200) this.actionCALLBACK();
})
}
public actionCALLBACK(): void {
this.terminalService.onSynchroReactivee.emit(true);
}
public executeTERMINER() {
let a_id = this.viewParams.dataParams.apiParam;
this.coreServicesProvider.minimalHttpService.doPost('/beneftraitement/terminer/'+a_id, {httpParams: {forcePost: false,noTimeOut: false,doToastSuccess: true}}, undefined)
.subscribe(()=> {this.bsModalRef.hide()});
}
// ici on rajoute /*ID* a la fin de l'api :
public doBeforeLoadData(): void {
this.coreServicesProvider.actionService.currentActions.subscribe(actions => {
if (actions && actions.length > 0) {
let l_actions: MsAction;
l_actions = actions.find(elt =>elt.code === "EXPORTER");
l_actions.api += '/'+this.coreServicesProvider.routerGlobals.params.idBeneficiaire;
}
})
}
// On ajoute l'id de la tournée à l'api de l'action ARCHIVERTOURNEE
public getParamsARCHIVERTOURNEE(a_data : any,a_action : MsAction) : MsActionParams {
return {url:a_action.api +'/'+ (<ParamTourneeModeleEvtModal>this.data).id_ParamTourModelR}
}
// On ajoute l'id de la tournée à l'api de l'action DESARCHIVERTOURNEE
public getParamsDESARCHIVERTOURNEE(a_data : any,a_action : MsAction) : MsActionParams {
return {url:a_action.api +'/'+ (<ParamTourneeModeleEvtModal>this.data).id_ParamTourModelR}
}
On veux ajouter des PARAMS a notre action VALIDER_VERSION :
// Params pour l'action Valider Version , on rajoute l'idVersion
getParamsVALIDER_VERSION(): MsAsyncActionParams {
return {trtParams:[{paramName:"idVersion",paramType:"LONG",paramValue:this.coreServicesProvider.routerGlobals.params.id_ParamPlanningVersionR}]};
}
// exemples C:\\DEV\\depot\\ng-emedisys\\projects\\currentapp\\src\\app\\modules\\planning-visites\\classes\\planning-visites-base.ts
executePLANIFIER(a_data : any,a_action : MsAction) {
...
.subscribe();
};
// dans le ts
executeREEVALUER() {
this.benefEvalServProv.beneficiaireEvaluationAggirService.reevaluer((<BeneficiaireEvaluationResume>this.data).id_EvalPersR).subscribe(
result => {
if (result) {
let l_params = {
id_EvalPersR: result.data.id,
idBeneficiaire_EvalPersR: this.coreServicesProvider.routerGlobals.params.idBeneficiaire_EvalPersR
};
this.coreServicesProvider.urlService.go(this.currentState.name, l_params);
}
}
);
}
// dans le service
public reevaluer(a_idEvalPers : number, a_postMetas?:PostMeta,a_httpParams :MsHttpParams ={noTimeOut:false,forcePost:false,doToastSuccess:true}) : Observable<HttpPostResult<any>> {
let ldata : HttpPostContext = {meta:a_postMetas,httpParams:a_httpParams};
return this.doPost<HttpPostResult<any>>(this.getConstants().getServer()+this.getServiceConfig().baseApi+'reevaluer/'+a_idEvalPers,ldata);
}
getParamsDESANNULER(a_data : PlanningVisitesVisiteTournee,a_action : MsAction) : MsActionParams|MsAsyncActionParams {
return this.getParamsACTIONVISITE(a_data,a_action);
};
callbackDESANNULER(a_result : HttpResponse<HttpPostResult<Array<PlanningVisitesTournees>>>,a_data : PlanningVisitesVisiteTournee) {
this.callbackACTIONVISITE(a_result,a_data);
}
// récupération des actions en ligne
public buildActions() : void {
if ((this.data)&&(this.actions)) {
this.newActions=this.actionUtils.getActionsLigne(this.data,this.actions);
}
}