Skip to content

Commit

Permalink
Flows charge bar, update axis x and y
Browse files Browse the repository at this point in the history
  • Loading branch information
francinii committed Jun 11, 2020
1 parent 721d078 commit 0ac1826
Show file tree
Hide file tree
Showing 21 changed files with 537 additions and 213 deletions.
69 changes: 41 additions & 28 deletions app/Http/Controllers/FlowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,33 @@ public function show(Request $request)
// $step_step = $steps->steps;
//$action_step_user = $flow->steps;
//$steps = $flow->steps;
$step_step = StepStep::where('prev_flow_id', '=', $id_flow)->get();
$step_step = StepStep::where('prev_flow_id', '=', $id_flow)
->join('actions', 'actions.id', '=', 'step_step.id_action')
->get();
//$step_user = StepUser::where('flow_id', '=', $flow)->get();
$action_step_user = ActionStepUser::where('flow_id', '=', $id_flow)->get();
$action_step_user =
ActionStepUser::where('flow_id', '=', $id_flow)
->join('users', 'users.username', '=', 'action_step_user.username')
->join('actions', 'actions.id', '=', 'action_step_user.action_id')
->get();

// return view('flows.table',compact('flow', 'steps', 'step_step','step_user', 'action_step_user'));
// $usuario = Auth::user()->id;
// $flows =Flow::where('username', '=', $usuario)->get();
// $users = User::all();
// $usuario = Auth::user()->id;
// $flows =Flow::where('username', '=', $usuario)->get();
$users = User::all();
// $departments = Department::all();
// $actions = Action::all();
// return view('flows.table',compact('flows', 'users','departments','actions','flow','steps','step_step', 'step_user', 'action_step_user'));
// return FlowController::refresh();
//return response()->json(compact('flows', 'users','departments','actions','flow','steps','step_step', 'step_user', 'action_step_user'));
$steps = json_encode( $steps);
// $steps = json_encode( $steps);

// $steps = json_decode(json_encode($steps), true);
// $steps = json_encode($steps, JSON_FORCE_OBJECT);
// $step_step = json_encode($step_step);

// $action_step_user = json_encode($action_step_user);
return compact('flow','steps','step_step', 'action_step_user');
// $action_step_user = json_encode($action_step_user);
return compact('flow','step_step','users', 'action_step_user');
// return compact('flow','steps','step_step', 'action_step_user');

}
Expand All @@ -138,12 +144,23 @@ public function edit(Flow $flow)
*/
public function update(Request $request, $id)
{
$dato = request()->except(['_token', '_method', 'flows']);
$flows = request('flows');
$id = $dato['id'];
Flow::where('id', '=', $id)->update($dato);

$data = request()->except(['_token', '_method']);
//$res = $this->insertFlow($data);
// $idFlow = $res[0]['id_flow'] ;
$this->destroy($id);
$res= $this->insertFlow( $data);
$idFlow = $res[0]['id_flow'] ;
$this->insert( $data, $idFlow);

return $this->refresh();

// $dato = request()->except(['_token', '_method', 'flows']);
// $flows = request('flows');
// $id = $dato['id'];
// Flow::where('id', '=', $id)->update($dato);

return FlowController::refresh();
// return FlowController::refresh();
}

/**
Expand All @@ -158,23 +175,21 @@ public function destroy($id)
return FlowController::refresh();
}




/**
* Refresh the table on the view.
*
* @return \Illuminate\Http\Response
*/
private function refresh()
{
$usuario = Auth::user()->id;
$usuario = Auth::user()->username;
$flows =Flow::where('username', '=', $usuario)->get();
//$flows = Flow::all();
$users = User::all();
$departments = Department::all();
//$actions = Action::where('type', '=', 1)->get();
$actions = Action::all();
//return view('Flows.index',compact('flows', 'users','departments','actions'));
return view('flows.table',compact('flows', 'users','departments','actions'));
}

Expand All @@ -186,7 +201,6 @@ private function refresh()
*/
protected function insert(array $datos, $id_Flow)
{

$idFlow = "'". $id_Flow."'";
$steps = json_decode(json_encode( $datos['data']), true);
if($steps != null){
Expand Down Expand Up @@ -248,8 +262,7 @@ protected function insertStep(array $steps, $id_flow)
$axisX =($step['axisX']== null)? 0 : $step['axisX'] ;
DB::select("call insert_step($identifier, $id_flow, $description, $axisX, $axisY, @res)");
$res=DB::select("SELECT @res as res;");
}

}
}
return json_decode(json_encode($res), true);
}
Expand All @@ -267,20 +280,20 @@ protected function insertStepStep(array $step, $id_flow)
$actionid = $actions[0]['id'];
$res = -1;
//Falta validar los datos que esten que no este vacio etc
$pasos = array_key_exists('steps', $step) ? $step['steps']: null;
if($pasos != null)
foreach ($pasos as $paso) {
if($paso !=null){
$idInicial = "'".$paso['begin']."'";
$idFinal = "'".$paso['end']."'";
$action = $paso['begin'] == self::DRAGGABLE_INICIO? $actionid : $paso['action'];
$steps = array_key_exists('steps', $step) ? $step['steps']: null;
if($steps != null)
foreach ($steps as $paso) {
if($paso !=null && array_key_exists('begin', $paso) && array_key_exists('end', $paso) && array_key_exists('action', $paso)){
$idInicial = "'".$paso['begin']."'";
$idFinal = "'".$paso['end']."'";
$action = $paso['begin'] == self::DRAGGABLE_INICIO? $actionid : $paso['action'];
// $action = $paso['action'] != ''? "'".$paso['action']."'" : "'1'"; //Validar que action exista cuando se pasa
if( $action != null){
DB::select("call insert_step_step($idInicial, $idFinal, $id_flow, $action, @res)");
$res=DB::select("SELECT @res as res;");
//$res = json_decode(json_encode($res), true);
//if($res[0]['res'] != 0)
return json_decode(json_encode($res), true);
// return json_decode(json_encode($res), true);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class Step extends Model
/**
* One step belongs to a flow
*/

//Esto es necesario cuando un id no es de tipo int
public $incrementing = false;
//protected $primaryKey = ['id','flow_id'];

public function flow() {
return $this->belongsTo('App\Flow');
}
Expand Down
2 changes: 1 addition & 1 deletion laravel notas.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Las tablas pivote deben:
LLamarse en orden alfabetico con las dos tablas que se unen ejemplo: permiso_rol Además deben ir en singular.

Comando para compilar el sass y que se observen los cambios que se realizan a la hoja de estilos
sass --watch resources/sass/app.scss:public/css/estilos.css

sass --watch resources\sass\app.scss:resources\css\app.css

Convenciones para ATRIBUTOS
1. nombre minuscula segunda palabra en mayuscula (lowel camel case).
Expand Down
11 changes: 0 additions & 11 deletions public/css/estilos.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/estilos.css.map

This file was deleted.

1 change: 0 additions & 1 deletion resources/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/css/app.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions resources/js/departments.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ function ajaxCreate() {
_token: $("input[name=_token]").val(),
description: description,
},
beforeSend: function (xhr) {
$("#cargandoDiv").css('display', 'block')
},
success: function(result) {
$("#table").html(result);
$("#table")
Expand All @@ -48,11 +51,13 @@ function ajaxCreate() {
createDataTable("table");
$("#create").modal("hide");
alerts("El departamento "+name+" ha sido agregado satisfactoriamente", "alert-success");
$("#cargandoDiv").css('display', 'none')
},
error: function(request, status, error) {

alerts("Ha ocurrido un error inesperado.", "alert-danger");
alert(request.responseText);
$("#cargandoDiv").css('display', 'none')

}
});
Expand Down Expand Up @@ -115,6 +120,9 @@ function ajaxUpdate() {
description: description,

},
beforeSend: function (xhr) {
$("#cargandoDiv").css('display', 'block')
},
success: function(result) {
$("#table").html(result);
$("#table")
Expand All @@ -123,10 +131,12 @@ function ajaxUpdate() {
createDataTable("table");
$("#edit").modal("hide");
alerts("El departamento "+description+" ha sido actualizado satisfactoriamente", "alert-success");
$("#cargandoDiv").css('display', 'none')
},
error: function(request, status, error) {
alerts("Ha ocurrido un error inesperado.", "alert-danger");
alert(request.responseText);
$("#cargandoDiv").css('display', 'none')
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions resources/js/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ function ajaxCreate(user) {
user_id: user
},

beforeSend: function (xhr) {
$("#cargandoDiv").css('display', 'block')
},
success: function(result) {
$("#table").html(result);
$("#table")
Expand All @@ -55,11 +58,13 @@ function ajaxCreate(user) {
" ha sido creaado satisfactoriamente",
"alert-success"
);
$("#cargandoDiv").css('display', 'none')
},

error: function(request, status, error) {
alert(request.responseText);
alerts("Ha ocurrido un error inesperado.", "alert-danger");
$("#cargandoDiv").css('display', 'none')
}
});
}
Expand Down Expand Up @@ -126,6 +131,9 @@ function ajaxUpdate() {
flow_id: flow,

},
beforeSend: function (xhr) {
$("#cargandoDiv").css('display', 'block')
},
success: function(result) {
$("#table").html(result);
$("#table")
Expand All @@ -134,10 +142,12 @@ function ajaxUpdate() {
createDataTable("table");
$("#edit").modal("hide");
alerts("El departamento "+name+" ha sido actualizado satisfactoriamente", "alert-success");
$("#cargandoDiv").css('display', 'none')
},
error: function(request, status, error) {
alerts("Ha ocurrido un error inesperado.", "alert-danger");
alert(request.responseText);
$("#cargandoDiv").css('display', 'none')
}
});
}
Expand Down
Loading

0 comments on commit 0ac1826

Please sign in to comment.