|
@@ -76,145 +76,13 @@ class StatTreeController extends Controller
|
|
|
return view('app.stat-tree.stat-trees.sub.edit', compact('statTree'));
|
|
|
}
|
|
|
|
|
|
- public function clausesJSON(Request $request, StatTree $statTree) {
|
|
|
- $clauses = Clause::where('model', $statTree->model)->orderBy('position_index')->get();
|
|
|
- $nodes = [];
|
|
|
- foreach ($clauses as $clause) {
|
|
|
-
|
|
|
- $children = [];
|
|
|
-
|
|
|
- // clause text child
|
|
|
- $children[] = [
|
|
|
- "text" => $clause->clause_text,
|
|
|
- "icon" => "fa fa-laptop-code text-primary text-sm",
|
|
|
- "state" => [
|
|
|
- "opened" => false,
|
|
|
- "disabled" => false,
|
|
|
- "selected" => false,
|
|
|
- ],
|
|
|
- "li_attr" => [
|
|
|
- "type" => "clause_text"
|
|
|
- ],
|
|
|
- "system" => [
|
|
|
- "type" => "clause_text"
|
|
|
- ]
|
|
|
- ];
|
|
|
-
|
|
|
- // clause arg children
|
|
|
- foreach ($clause->clauseArgs as $clauseArg) {
|
|
|
- $children[] = [
|
|
|
- "text" => $clauseArg->arg_text . '<span class="text-secondary text-sm ml-2">' . $clauseArg->field_type . '</span>',
|
|
|
- "icon" => "fa fa-cubes text-info",
|
|
|
- "state" => [
|
|
|
- "opened" => false,
|
|
|
- "disabled" => false,
|
|
|
- "selected" => false,
|
|
|
- ],
|
|
|
- "system" => [
|
|
|
- "type" => "clause_arg",
|
|
|
- "id" => $clauseArg->id,
|
|
|
- "uid" => $clauseArg->uid,
|
|
|
- "argText" => $clauseArg->arg_text,
|
|
|
- "fieldType" => $clauseArg->field_type,
|
|
|
- "clauseId" => $clause->id
|
|
|
- ]
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $nodes[] = [
|
|
|
- "text" => $clause->label,
|
|
|
- "state" => [
|
|
|
- "opened" => false,
|
|
|
- "disabled" => false,
|
|
|
- "selected" => false,
|
|
|
- ],
|
|
|
- "children" => $children,
|
|
|
- "system" => [
|
|
|
- "type" => "clause",
|
|
|
- "id" => $clause->id,
|
|
|
- "uid" => $clause->uid,
|
|
|
- "model" => $clause->model,
|
|
|
- "question" => $clause->question,
|
|
|
- "answer" => $clause->answer,
|
|
|
- "label" => $clause->label,
|
|
|
- "clauseText" => $clause->clause_text,
|
|
|
- "clauseId" => $clause->id
|
|
|
- ]
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- return json_encode($nodes);
|
|
|
- }
|
|
|
-
|
|
|
- public function linesJSON(Request $request, StatTree $statTree) {
|
|
|
- $nodes = [];
|
|
|
- foreach ($statTree->rootLines as $rootLine) {
|
|
|
- $nodes[] = $this->lineObject($rootLine);
|
|
|
- }
|
|
|
- return json_encode($nodes);
|
|
|
- }
|
|
|
-
|
|
|
- private function lineObject(StatTreeLine $line) {
|
|
|
- $columns = [];
|
|
|
- foreach ($line->reportColumns as $column) {
|
|
|
- $columns[] = [
|
|
|
- "label" => $column->label,
|
|
|
- "display_key" => $column->display_key,
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $clauses = [];
|
|
|
- foreach($line->lineClauses as $lineClause) {
|
|
|
- $args = [];
|
|
|
- foreach($lineClause->statTreeLineClauseArgs as $stlcArg) {
|
|
|
- if($stlcArg->clauseArg) {
|
|
|
- $args[] = [
|
|
|
- "arg_text" => $stlcArg->clauseArg->arg_text,
|
|
|
- "field_type" => $stlcArg->clauseArg->field_type,
|
|
|
- "default_value" => $stlcArg->default_value,
|
|
|
- "access_level" => $stlcArg->access_level,
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- $clauses[] = [
|
|
|
- "clause_id" => $lineClause->clause_id,
|
|
|
- "clause_label" => $lineClause->clause_label,
|
|
|
- "position_index" => $lineClause->position_index,
|
|
|
- "args" => $args
|
|
|
- ];
|
|
|
- }
|
|
|
- $children = [];
|
|
|
- foreach ($line->children as $child) {
|
|
|
- $children[] = $this->lineObject($child);
|
|
|
- }
|
|
|
- return [
|
|
|
- "text" => $line->displayLabel() . '<span class="ml-2 text-secondary">(' . (is_null($line->last_refresh_count) ? '…' : $line->last_refresh_count) . ')</span>',
|
|
|
- "state" => [
|
|
|
- "opened" => true,
|
|
|
- "disabled" => false,
|
|
|
- "selected" => false,
|
|
|
- ],
|
|
|
- "children" => $children,
|
|
|
- "system" => [
|
|
|
- "type" => "stat_tree_line",
|
|
|
- "id" => $line->id,
|
|
|
- "uid" => $line->uid,
|
|
|
- "displayLabel" => $line->displayLabel(),
|
|
|
- "lastRefreshCount" => $line->last_refresh_count,
|
|
|
- "treeOrderPositionIndex" => $line->tree_order_position_index,
|
|
|
- "columns" => $columns,
|
|
|
- "clauses" => $clauses
|
|
|
- ]
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
public function delete(Request $request){
|
|
|
$request->validate([
|
|
|
'id' => 'required'
|
|
|
]);
|
|
|
$id = $request->get('id');
|
|
|
$statTree = StatTree::where('id', $id)->first();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function replaceAllLines(Request $request){
|
|
@@ -349,6 +217,137 @@ class StatTreeController extends Controller
|
|
|
return $this->pass();
|
|
|
}
|
|
|
|
|
|
+ public function clausesJSON(Request $request, StatTree $statTree) {
|
|
|
+ $clauses = Clause::where('model', $statTree->model)->orderBy('position_index')->get();
|
|
|
+ $nodes = [];
|
|
|
+ foreach ($clauses as $clause) {
|
|
|
+
|
|
|
+ $children = [];
|
|
|
+
|
|
|
+ // clause text child
|
|
|
+ $children[] = [
|
|
|
+ "text" => $clause->clause_text,
|
|
|
+ "icon" => "fa fa-laptop-code text-primary text-sm",
|
|
|
+ "state" => [
|
|
|
+ "opened" => false,
|
|
|
+ "disabled" => false,
|
|
|
+ "selected" => false,
|
|
|
+ ],
|
|
|
+ "li_attr" => [
|
|
|
+ "type" => "clause_text"
|
|
|
+ ],
|
|
|
+ "system" => [
|
|
|
+ "type" => "clause_text"
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ // clause arg children
|
|
|
+ foreach ($clause->clauseArgs as $clauseArg) {
|
|
|
+ $children[] = [
|
|
|
+ "text" => $clauseArg->arg_text . '<span class="text-secondary text-sm ml-2">' . $clauseArg->field_type . '</span>',
|
|
|
+ "icon" => "fa fa-cubes text-info",
|
|
|
+ "state" => [
|
|
|
+ "opened" => false,
|
|
|
+ "disabled" => false,
|
|
|
+ "selected" => false,
|
|
|
+ ],
|
|
|
+ "system" => [
|
|
|
+ "type" => "clause_arg",
|
|
|
+ "id" => $clauseArg->id,
|
|
|
+ "uid" => $clauseArg->uid,
|
|
|
+ "argText" => $clauseArg->arg_text,
|
|
|
+ "fieldType" => $clauseArg->field_type,
|
|
|
+ "clauseId" => $clause->id
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $nodes[] = [
|
|
|
+ "text" => $clause->label,
|
|
|
+ "state" => [
|
|
|
+ "opened" => false,
|
|
|
+ "disabled" => false,
|
|
|
+ "selected" => false,
|
|
|
+ ],
|
|
|
+ "children" => $children,
|
|
|
+ "system" => [
|
|
|
+ "type" => "clause",
|
|
|
+ "id" => $clause->id,
|
|
|
+ "uid" => $clause->uid,
|
|
|
+ "model" => $clause->model,
|
|
|
+ "question" => $clause->question,
|
|
|
+ "answer" => $clause->answer,
|
|
|
+ "label" => $clause->label,
|
|
|
+ "clauseText" => $clause->clause_text,
|
|
|
+ "clauseId" => $clause->id
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return json_encode($nodes);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function linesJSON(Request $request, StatTree $statTree) {
|
|
|
+ $nodes = [];
|
|
|
+ foreach ($statTree->rootLines as $rootLine) {
|
|
|
+ $nodes[] = $this->lineObject($rootLine);
|
|
|
+ }
|
|
|
+ return json_encode($nodes);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function lineObject(StatTreeLine $line) {
|
|
|
+ $columns = [];
|
|
|
+ foreach ($line->reportColumns as $column) {
|
|
|
+ $columns[] = [
|
|
|
+ "label" => $column->label,
|
|
|
+ "display_key" => $column->display_key
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $clauses = [];
|
|
|
+ foreach($line->lineClauses as $lineClause) {
|
|
|
+ $args = [];
|
|
|
+ foreach($lineClause->statTreeLineClauseArgs as $stlcArg) {
|
|
|
+ if($stlcArg->clauseArg) {
|
|
|
+ $args[] = [
|
|
|
+ "arg_text" => $stlcArg->clauseArg->arg_text,
|
|
|
+ "field_type" => $stlcArg->clauseArg->field_type,
|
|
|
+ "default_value" => $stlcArg->default_value,
|
|
|
+ "access_level" => $stlcArg->access_level
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $clauses[] = [
|
|
|
+ "clause_id" => $lineClause->clause_id,
|
|
|
+ "clause_label" => $lineClause->clause_label,
|
|
|
+ "position_index" => $lineClause->position_index,
|
|
|
+ "args" => $args
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $children = [];
|
|
|
+ foreach ($line->children as $child) {
|
|
|
+ $children[] = $this->lineObject($child);
|
|
|
+ }
|
|
|
+ return [
|
|
|
+ "text" => $line->displayLabel() . '<span class="ml-2 text-secondary">(' . (is_null($line->last_refresh_count) ? '…' : $line->last_refresh_count) . ')</span>',
|
|
|
+ "state" => [
|
|
|
+ "opened" => true,
|
|
|
+ "disabled" => false,
|
|
|
+ "selected" => false,
|
|
|
+ ],
|
|
|
+ "children" => $children,
|
|
|
+ "system" => [
|
|
|
+ "type" => "stat_tree_line",
|
|
|
+ "id" => $line->id,
|
|
|
+ "uid" => $line->uid,
|
|
|
+ "displayLabel" => $line->displayLabel(),
|
|
|
+ "lastRefreshCount" => $line->last_refresh_count,
|
|
|
+ "treeOrderPositionIndex" => $line->tree_order_position_index,
|
|
|
+ "columns" => $columns,
|
|
|
+ "clauses" => $clauses
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
|
|
|
public function replaceAllLinesJSON(Request $request) {
|
|
|
|