Explorar o código

Stat tree edit (wip)

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
2f1a651acd

+ 98 - 12
app/Http/Controllers/StatTreeController.php

@@ -80,8 +80,21 @@ class StatTreeController extends Controller
         return $this->pass();
     }
 
+    private function traverseLines($_lines, &$result) {
+        foreach ($_lines as $line) {
+            $result[] = $line;
+            if(count($line->children)) {
+                $this->traverseLines($line->children, $result);
+            }
+        }
+    }
+
     public function edit(Request $request, StatTree $statTree) {
-        return view('app.stat-tree.stat-trees.sub.edit', compact('statTree'));
+        $linesFlat = [];
+        if($request->input('multi-pro')) {
+            $this->traverseLines($statTree->rootLines, $linesFlat);
+        }
+        return view('app.stat-tree.stat-trees.sub.edit', compact('statTree', 'linesFlat'));
     }
 
     public function delete(Request $request){
@@ -244,6 +257,9 @@ class StatTreeController extends Controller
                 "li_attr" => [
                     "type" => "clause_text"
                 ],
+                "a_attr" => [
+                    "title" => $clause->clause_text,
+                ],
                 "data" => [
                     "type" => "clause_text"
                 ]
@@ -296,7 +312,10 @@ class StatTreeController extends Controller
                     "clauseText" => $clause->clause_text,
                     "clauseId" => $clause->id,
                     "args" => $argsSystem
-                ]
+                ],
+                "a_attr" => [
+                    "title" => $clause->clause_text,
+                ],
             ];
         }
 
@@ -312,12 +331,31 @@ class StatTreeController extends Controller
         return $content;
     }
 
-    private function applyStatTreeLineQueryClauses(StatTreeLine $statTreeLine)
+    private function applyStatTreeLineQueryClauses(StatTreeLine $statTreeLine, $proUid = false)
     {
         $model = $statTreeLine->statTree->model;
         $clauses = [];
         foreach ($statTreeLine->lineClauses as $lineClause) {
             $clauseText = $lineClause->clause->clause_text;
+
+            // apply arg values
+            foreach ($lineClause->clause->clauseArgs as $clauseArg) {
+
+                $value = null;
+                foreach ($lineClause->statTreeLineClauseArgs as $lineClauseArg) {
+                    if($lineClauseArg->clause_arg_id === $clauseArg->id) {
+                        $value = $lineClauseArg->default_value;
+                    }
+                }
+
+                if(!is_null($value)) {
+                    $clauseText = str_replace(
+                        ':' . $clauseArg->arg_text,                         // search for :xxx
+                        "'" . $value . "'::" . $clauseArg->field_type,      // replace with '$value'::$field_type
+                        $clauseText);
+                }
+            }
+
             $isValid = $this->cleanupClause($clauseText);
             if ($isValid) {
                 array_push($clauses, $clauseText);
@@ -325,12 +363,27 @@ class StatTreeController extends Controller
         }
 
         // if stat tree bound to a pro, apply pro_scope_clause
-        if($statTreeLine->statTree->pro && $statTreeLine->statTree->pro_scope_clause) {
-            $clauses[] = str_replace('@PRO_ID', $statTreeLine->statTree->pro->id, $statTreeLine->statTree->pro_scope_clause);
+        if(!$proUid) {
+            if($statTreeLine->statTree->pro && $statTreeLine->statTree->pro_scope_clause) {
+                $clauses[] = str_replace('@PRO_ID', $statTreeLine->statTree->pro->id, $statTreeLine->statTree->pro_scope_clause);
+            }
+        }
+        else {
+            $mvPro = Pro::where('uid', $proUid)->first();
+            if($statTreeLine->statTree->pro_scope_clause) {
+                $clauses[] = str_replace('@PRO_ID', $mvPro->id, $statTreeLine->statTree->pro_scope_clause);
+            }
+            $query = 'SELECT COUNT(*) FROM '.$model.' WHERE '. implode(" AND ", $clauses);
         }
 
         $query = 'SELECT COUNT(*) FROM '.$model.' WHERE '. implode(" AND ", $clauses);
-        return DB::select($query);
+        try {
+            $result = DB::select($query);
+        }
+        catch (\Exception $ex) {
+            $result = 'error';
+        }
+        return $result;
     }
 
     public function linesJSON(Request $request, StatTree $statTree) {
@@ -339,10 +392,13 @@ class StatTreeController extends Controller
         $lines = $statTree->lines;
         foreach ($lines as $line) {
             $query = $this->applyStatTreeLineQueryClauses($line);
-            if ($query) {
+            if ($query && $query !== 'error') {
                 $line->last_refresh_count = $query[0]->count;
-                $line->save();
             }
+            else {
+                $line->last_refresh_count = -1;
+            }
+            $line->save();
         }
 
         $nodes = [];
@@ -352,6 +408,24 @@ class StatTreeController extends Controller
         return json_encode($nodes);
     }
 
+    public function getCountsForPro(Request $request) {
+        $statTreeUid = $request->get('uid');
+        if (!$statTreeUid) return $this->fail('No specified stat tree!');
+        $statTree = StatTree::where('uid',  $statTreeUid)->first();
+        $lines = $statTree->lines;
+        $result = [];
+        foreach ($lines as $line) {
+            $query = $this->applyStatTreeLineQueryClauses($line, $request->input('proUid'));
+            if ($query && $query !== 'error') {
+                $result[$line->uid] = $query[0]->count;
+            }
+            else {
+                $result[$line->uid] = -1;
+            }
+        }
+        return json_encode($result);
+    }
+
     private function lineObject(StatTreeLine  $line) {
 
         // columns
@@ -388,7 +462,13 @@ class StatTreeController extends Controller
             $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>',
+            "text" => $line->displayLabel() .
+                '<span class="ml-2 text-secondary line-count-label">(' .
+                (is_null($line->last_refresh_count) ? '…' :
+                    ($line->last_refresh_count === -1 ?
+                        '<span class="text-danger text-sm font-weight-bold"><i class="fa fa-exclamation-triangle"></i> Query Error</span>' :
+                        $line->last_refresh_count)) .
+                ')</span>',
             "state" => [
                 "opened" => true,
                 "disabled" => false,
@@ -404,6 +484,9 @@ class StatTreeController extends Controller
                 "treeOrderPositionIndex" => $line->tree_order_position_index,
                 "columns" => $columns,
                 "clause" => $clause
+            ],
+            "a_attr" => [
+                "title" => $line->displayLineClause()->clause->clause_text
             ]
         ];
     }
@@ -561,11 +644,14 @@ class StatTreeController extends Controller
         if (!$statTree) return $this->fail('Invalid stat tree!');
         $lines = $statTree->lines;
         foreach ($lines as $line) {
-            $query = $this->applyStatTreeLineQueryClauses($line);
-            if ($query) {
+            $query = $this->applyStatTreeLineQueryClauses($line, $request);
+            if ($query && $query !== 'error') {
                 $line->last_refresh_count = $query[0]->count;
-                $line->save();
             }
+            else {
+                $line->last_refresh_count = -1;
+            }
+            $line->save();
         }
 
         return $this->pass();

+ 63 - 2
public/css/style.css

@@ -2784,7 +2784,7 @@ table.stag-compact-grid>tbody>tr>td [if-grid-view] {
 .stat-tree-view .jstree-anchor.has-drop-visualization::after {
     content: attr(data-drop-percent);
     margin-left: 1rem;
-    font-size: 80%;
+    font-size: 70%;
 }
 .stat-tree-view .jstree-anchor.has-drop-visualization.drop-0-25::after {
     color: grey;
@@ -2798,6 +2798,67 @@ table.stag-compact-grid>tbody>tr>td [if-grid-view] {
 .stat-tree-view .jstree-anchor.has-drop-visualization.drop-76-100::after {
     color: red;
 }
+.multi-pro-view .line-count-label {
+    display: none;
+}
+.multi-pro-view .multi-pro-stats-table {
+    border: 0;
+}
+.multi-pro-view .multi-pro-stats-table tr th {
+    height: 22px;
+    background: #eee;
+    line-height: 22px;
+    padding: 0 5px;
+    font-weight: normal;
+    color: #777;
+    border: 0;
+    border-left: 1px solid #e1e1e1;
+    width: 100px;
+}
+.multi-pro-view .multi-pro-stats-table tr th .pro-label {
+    max-width: 100px;
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
+.multi-pro-view .multi-pro-stats-table tr td {
+    border-top: 0;
+    padding: 0 5px;
+    border-left: 1px solid #f1f1f1;
+    width: 100px;
+}
+.multi-pro-view .multi-pro-stats-table tr th:last-child,
+.multi-pro-view .multi-pro-stats-table tr td:last-child {
+    width: auto;
+}
+.multi-pro-view .count-label {
+    height: 24px;
+    line-height: 24px;
+    border-bottom: 1px solid #f1f1f1;
+    color: #666;
+    display: flex;
+    align-items: baseline;
+    padding-left: 4px;
+}
+.multi-pro-view .count-label .count {
+    min-width: 30px;
+    /*text-align: right;*/
+    margin-right: 5px;
+}
+.multi-pro-view .count-label .drop-percent {
+    width: 41px;
+    font-size: 80%;
+    opacity: 0.8;
+    text-align: right;
+}
+.multi-pro-view .multi-pro-view-stat-label {
+    height: 22px;
+    background: #eee;
+    line-height: 22px;
+    padding: 0 5px;
+    font-weight: bold;
+    color: #777;
+}
 body .vakata-context li>a {
     padding: 1px 5px;
     padding-right: 10px;
@@ -2820,4 +2881,4 @@ body #vakata-dnd {
 }
 body .vakata-context .vakata-context-separator>a {
     margin: 0;
-}
+}

+ 199 - 63
resources/views/app/stat-tree/stat-trees/sub/edit.blade.php

@@ -1,5 +1,18 @@
 @extends ('layouts/template')
 @section('content')
+    <?php
+    $multiProView = !!request()->input('multi-pro');
+    $multiPros = [];
+    if(request()->input('multi-pro-uids')) {
+        $uids = explode(',', request()->input('multi-pro-uids'));
+        foreach ($uids as $uid) {
+            $multiPro = \App\Models\Pro::where('uid', $uid)->first();
+            if($multiPro) {
+                $multiPros[] = $multiPro;
+            }
+        }
+    }
+    ?>
     <link rel="stylesheet" href="/jstree/themes/default/style.min.css" />
     <script src="/jstree/jstree.min.js"></script>
     <div class="mcp-theme-1">
@@ -62,16 +75,21 @@
                             </div>
                         </form>
                     </div>
-                    @if($statTree->pro_id)
-                        <a href="{{route('practice-management.statTrees.list')}}" class="text-decoration-none font-weight-bold text-primary ml-auto">
+                    @if(!$multiProView)
+                        <a href="{{ route('practice-management.statTrees.view.edit', $statTree) }}?multi-pro=1" class="text-decoration-none font-weight-bold text-primary ml-auto">
                             <i class="fa fa-users mr-1"></i>
                             Multi-Pro View
                         </a>
+                    @else
+                        <a href="{{ route('practice-management.statTrees.view.edit', $statTree) }}" class="text-decoration-none font-weight-bold text-primary ml-auto">
+                            <i class="fa fa-edit mr-1"></i>
+                            Edit View
+                        </a>
                     @endif
                 </div>
             </div>
             <div class="card-body p-0 flex-grow-1">
-                <div id="statTreeEdit-{{$statTree->id}}" class="row m-0 h-100">
+                <div id="statTreeEdit-{{$statTree->id}}" class="row m-0 h-100 {{$multiProView ? 'multi-pro-view' : ''}}">
 
                     <!-- clauses -->
                     <div class="col-3 p-0 h-100">
@@ -182,9 +200,9 @@
                                             <label class="text-secondary text-sm mb-1">Field Type</label>
                                             <select class="form-control form-control-sm" name="fieldType" required>
                                                 <option value="">-- select --</option>
-                                                <option value="number">Number</option>
+                                                <option value="numeric">Number</option>
                                                 <option value="date">Date</option>
-                                                <option value="string">String</option>
+                                                <option value="text">String</option>
                                                 <option value="bool">Boolean</option>
                                             </select>
                                         </div>
@@ -209,9 +227,9 @@
                                             <label class="text-secondary text-sm mb-1">Field Type</label>
                                             <select class="form-control form-control-sm" name="fieldType" required>
                                                 <option value="">-- select --</option>
-                                                <option value="number">Number</option>
+                                                <option value="numeric">Number</option>
                                                 <option value="date">Date</option>
-                                                <option value="string">String</option>
+                                                <option value="text">String</option>
                                                 <option value="bool">Boolean</option>
                                             </select>
                                         </div>
@@ -244,11 +262,27 @@
 
 
                     <!-- tree -->
-                    <div class="col-5 p-0 h-100 border-left border-right tree-column">
+                    <div class="{{ !$multiProView ? 'col-5' : 'col-9' }} p-0 h-100 border-left border-right tree-column">
                         <div class="d-flex flex-column h-100">
                             <div class="d-flex align-items-center pl-2 height-35px border-bottom bg-light">
                                 <h6 class="font-weight-bold m-0 text-secondary">{{$statTree->name}}</h6>
                                 <span class="text-danger d-none if-changed ml-2 text-sm">(modified *)</span>
+                                @if($multiProView)
+                                    <div moe class="ml-3">
+                                        <a href="#" start show>Add Pro</a>
+                                        <div url="/nop">
+                                            <div class="mb-2">
+                                                <select id="proUid" class="form-control input-sm" provider-search provider-type="hcp">
+                                                    <option value="">--select--</option>
+                                                </select>
+                                            </div>
+                                            <div class="d-flex align-items-center">
+                                                <button class="btn btn-sm btn-primary mr-2 btn-add-pro" type="button">Add</button>
+                                                <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
+                                            </div>
+                                        </div>
+                                    </div>
+                                @endif
                                 <a href="#" id="refresh-counts" class="ml-3">Refresh Counts</a>
                                 <a href="#" class="tree-expand-all ml-3" title="Expand All"><i class="fa fa-angle-double-down text-secondary"></i></a>
                                 <a href="#" class="tree-collapse-all ml-2" title="Collapse All"><i class="fa fa-angle-double-up text-secondary"></i></a>
@@ -258,79 +292,133 @@
                                 </div>
                             </div>
                             <div class="flex-grow-1 overflow-overlay-on-hover">
-                                <div class="stat-tree-view overflow-auto" id="stat-tree-view-{{$statTree->id}}"></div>
+                                @if(!$multiProView)
+                                    <div class="stat-tree-view overflow-auto" id="stat-tree-view-{{$statTree->id}}"></div>
+                                @else
+                                    <div class="d-flex align-items-start">
+                                        <div class="">
+                                            <div class="multi-pro-view-stat-label">Stat</div>
+                                            <div class="stat-tree-view overflow-auto" id="stat-tree-view-{{$statTree->id}}"></div>
+                                        </div>
+                                        <div class="flex-grow-1">
+                                            <table class="table table-sm multi-pro-stats-table">
+                                                <thead>
+                                                <tr>
+                                                    <th {{$statTree->pro ? 'data-pro-uid="' . $statTree->pro->uid . '"' : ''}}>
+                                                        <div class="pro-label" title="{{$statTree->pro ? $statTree->pro->name_display : 'Total'}}">{{$statTree->pro ? $statTree->pro->name_display : 'Total'}}</div>
+                                                    </th>
+                                                    @foreach($multiPros as $multiPro)
+                                                        <th data-pro-uid="{{$multiPro->uid}}" count-required>
+                                                            <div class="pro-label" title="{{$multiPro->name_display}}">{{$multiPro->name_display}}</div>
+                                                        </th>
+                                                    @endforeach
+                                                    <th></th>
+                                                </tr>
+                                                </thead>
+                                                <tbody>
+                                                @foreach($linesFlat as $line)
+                                                <tr data-line-uid="{{$line->uid}}">
+                                                    <td class="p-0">
+                                                        <div class="count-label">
+                                                            <div class="count">{{$line->last_refresh_count}}</div>
+                                                            <div class="drop-percent">50%  ⤵</div>
+                                                        </div>
+                                                    </td>
+                                                    @foreach($multiPros as $multiPro)
+                                                        <td class="p-0" data-pro-uid="{{$multiPro->uid}}">
+                                                            <div class="count-label">
+                                                                <div class="count">0</div>
+                                                                <div class="drop-percent">0%  ⤵</div>
+                                                            </div>
+                                                        </td>
+                                                    @endforeach
+                                                    <td></td>
+                                                </tr>
+                                                @endforeach
+                                                </tbody>
+                                            </table>
+                                        </div>
+                                    </div>
+                                @endif
                             </div>
                         </div>
                     </div>
 
 
                     <!-- selected line properties -->
-                    <div class="col-4 p-0 h-100 setup-column d-none" id="line-properties-column">
-                        <div class="d-flex flex-column h-100">
-                            <div class="d-flex align-items-center pl-2 height-35px border-bottom bg-light">
-                                <h6 class="font-weight-bold m-0 text-secondary">Selected Line Properties</h6>
-                            </div>
-                            <div class="flex-grow-1 overflow-overlay-on-hover">
-                                <div class="mb-3 d-flex align-items-baseline p-2 border-bottom font-weight-bold">
-                                    <span line-label></span>
-                                </div>
-                                <div class="d-flex align-items-baseline mb-2 px-2">
-                                    <h6 class="font-weight-bold m-0 text-secondary">Argument Values</h6>
-                                    <!--<a href="#" class="ml-3 text-sm" onclick="$('.parent-arg').toggle(); return false;">Toggle Parent Clause Args</a>-->
+                    @if(!$multiProView)
+                        <div class="col-4 p-0 h-100 setup-column d-none" id="line-properties-column">
+                            <div class="d-flex flex-column h-100">
+                                <div class="d-flex align-items-center pl-2 height-35px border-bottom bg-light">
+                                    <h6 class="font-weight-bold m-0 text-secondary">Selected Line Properties</h6>
                                 </div>
-                                <div class="px-2">
-                                    <table class="table table-sm table-bordered table-striped">
-                                        <thead>
-                                        <tr>
-                                            <th class="border-bottom-0 w-35">Arg</th>
-                                            <th class="border-bottom-0 w-35">Value</th>
-                                            <th class="border-bottom-0">Access</th>
-                                        </tr>
-                                        </thead>
-                                        <tbody line-args>
-                                        </tbody>
-                                    </table>
-                                </div>
-                                <div class="d-flex align-items-baseline mb-2 border-top pt-3 px-2">
-                                    <h6 class="font-weight-bold m-0 text-secondary">Report Columns</h6>
-                                </div>
-                                <div class="px-2">
-                                    <div class="mb-2 d-flex align-items-baseline">
-                                        <span class="text-secondary mr-1 text-nowrap">Quick Add:</span>
-                                        <div class="flex-grow-1 position-relative">
-                                            <input type="text"
-                                                   name="displayKey"
-                                                   class="form-control form-control-sm"
-                                                   placeholder="Column name"
-                                                   stag-suggest stag-suggest-left
-                                                   stag-suggest-ep="/column-suggest"
-                                                   stag-suggest-extra="table={{$statTree->model}}"
-                                                   autocomplete="off">
+                                <div class="flex-grow-1 overflow-overlay-on-hover">
+                                    <div class="mb-3 d-flex align-items-baseline p-2 border-bottom font-weight-bold">
+                                        <span line-label></span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-2 px-2">
+                                        <h6 class="font-weight-bold m-0 text-secondary">Argument Values</h6>
+                                        <!--<a href="#" class="ml-3 text-sm" onclick="$('.parent-arg').toggle(); return false;">Toggle Parent Clause Args</a>-->
+                                    </div>
+                                    <div class="px-2">
+                                        <table class="table table-sm table-bordered table-striped">
+                                            <thead>
+                                            <tr>
+                                                <th class="border-bottom-0 w-35">Arg</th>
+                                                <th class="border-bottom-0 w-35">Value</th>
+                                                <th class="border-bottom-0">Access</th>
+                                            </tr>
+                                            </thead>
+                                            <tbody line-args>
+                                            </tbody>
+                                        </table>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-2 border-top pt-3 px-2">
+                                        <h6 class="font-weight-bold m-0 text-secondary">Report Columns</h6>
+                                    </div>
+                                    <div class="px-2">
+                                        <div class="mb-2 d-flex align-items-baseline">
+                                            <span class="text-secondary mr-1 text-nowrap">Quick Add:</span>
+                                            <div class="flex-grow-1 position-relative">
+                                                <input type="text"
+                                                       name="displayKey"
+                                                       class="form-control form-control-sm"
+                                                       placeholder="Column name"
+                                                       stag-suggest stag-suggest-left
+                                                       stag-suggest-ep="/column-suggest"
+                                                       stag-suggest-extra="table={{$statTree->model}}"
+                                                       autocomplete="off">
+                                            </div>
                                         </div>
+                                        <table class="table table-sm table-bordered table-striped">
+                                            <thead>
+                                            <tr>
+                                                <th class="border-bottom-0 width-30px">#</th>
+                                                <th class="border-bottom-0 w-35">Label</th>
+                                                <th class="border-bottom-0">Column</th>
+                                                <th class="border-bottom-0 width-60px"></th>
+                                            </tr>
+                                            </thead>
+                                            <tbody line-columns>
+                                            </tbody>
+                                        </table>
                                     </div>
-                                    <table class="table table-sm table-bordered table-striped">
-                                        <thead>
-                                        <tr>
-                                            <th class="border-bottom-0 width-30px">#</th>
-                                            <th class="border-bottom-0 w-35">Label</th>
-                                            <th class="border-bottom-0">Column</th>
-                                            <th class="border-bottom-0 width-60px"></th>
-                                        </tr>
-                                        </thead>
-                                        <tbody line-columns>
-                                        </tbody>
-                                    </table>
                                 </div>
                             </div>
                         </div>
-                    </div>
+                    @endif
 
                 </div>
                 <script>
                     (function() {
                         function init() {
 
-                            let linePropsColumn = $('#line-properties-column');
+                            let linePropsColumn = $('#line-properties-column'),
+                                multiViewPros = [];
+
+                            @if(request()->input('multi-pro-uids'))
+                                multiViewPros = '{{request()->input('multi-pro-uids')}}'.split(',');
+                            @endif
 
                             function fillAndInvokeMoe(_id, _node) {
                                 let moe = $(_id);
@@ -424,6 +512,15 @@
                                 }
                             };
 
+                            @if($multiProView)
+                            (function ($, undefined) {
+                                "use strict";
+                                $.jstree.plugins.noclose = function () {
+                                    this.close_node = $.noop;
+                                };
+                            })(jQuery);
+                            @endif
+
                             // stat tree
                             let StatTree = {
                                 el: $('#stat-tree-view-{{$statTree->id}}'),
@@ -459,14 +556,19 @@
                                             .on('copy_node.jstree', (_e, _data) => { StatTree.dropped(_e, _data); })
                                             .on('select_node.jstree', () => { StatTree.onSelected(); })
                                             .on('deselect_node.jstree', () => { StatTree.onDeselected(); })
+                                            @if(!$multiProView)
                                             .on('redraw.jstree', () => { StatTree.dropVisualize(); })
+                                            @endif
                                             .jstree({
                                                 "core": {
+                                                    @if(!$multiProView)
                                                     "check_callback": true,
+                                                    @endif
                                                     "multiple": false,
                                                     "animation": 0,
                                                     'data': _data
                                                 },
+                                                @if(!$multiProView)
                                                 "dnd": {
                                                     "is_draggable": function(_node, _e) {
                                                         return _node[0].data && _node[0].data.type === 'stat_tree_line';
@@ -478,6 +580,7 @@
                                                         if(node.data.type === 'stat_tree_line') { // stat_tree_line
                                                             return {
 
+                                                                @if(!$multiProView)
                                                                 "data": {
                                                                     "label": "<span class='text-sm'>View Data</span>",
                                                                     "action": function (obj) {
@@ -489,6 +592,8 @@
                                                                     },
                                                                     separator_after: true,
                                                                 },
+                                                                @endif
+
                                                                 "cut": {
                                                                     "label": "<span class='text-sm'>Cut</span>",
                                                                     "action": function (obj) {
@@ -555,10 +660,15 @@
                                                         }
                                                     },
                                                 },
+                                                @endif
                                                 "plugins": [
                                                     "wholerow",
+                                                    @if(!$multiProView)
                                                     "dnd",
                                                     "contextmenu",
+                                                    @else
+                                                    "noclose",
+                                                    @endif
                                                     "state"
                                                 ]
                                             });
@@ -775,6 +885,11 @@
                                 },
 
                                 onSelected: function(_e, _data) {
+
+                                    @if($multiProView)
+                                    return;
+                                    @endif
+
                                     let selected = this.selectedNode();
 
                                     if(selected) console.log(selected.data)
@@ -967,6 +1082,14 @@
                                     return false;
                                 });
 
+                            $(document)
+                                .off('click', '.btn-add-pro')
+                                .on('click', '.btn-add-pro', function() {
+                                    multiViewPros.push($(this).closest('[moe]').find('#proUid').val());
+                                    fastLoad('{{ route('practice-management.statTrees.view.edit', $statTree) }}?multi-pro=1&multi-pro-uids=' + multiViewPros.join(','));
+                                    return false;
+                                });
+
                             $(document)
                                 .off('input change paste', '.frm-clause-add-edit input[name="question"], .frm-clause-add-edit input[name="answer"]')
                                 .on('input change paste', '.frm-clause-add-edit input[name="question"], .frm-clause-add-edit input[name="answer"]', function() {
@@ -994,6 +1117,19 @@
                                     return false;
                                 });
 
+                            @if($multiProView)
+                            $('[count-required]').each(function() {
+                                $.post('{{route('practice-management.api.statTree.getCountsForPro')}}', {
+                                    uid: '{{$statTree->uid}}',
+                                    proUid: $(this).attr('data-pro-uid')
+                                }, _data => {
+                                    for(let x in _data) {
+                                        $('.multi-pro-stats-table tr[data-line-uid="' + x + '"] td[data-pro-uid="' + $(this).attr('data-pro-uid') + '"] .count').text(_data[x]);
+                                    }
+                                }, 'json');
+                            });
+                            @endif
+
                             ClausesTree.load();
                             StatTree.load();
                             initMoes();

+ 1 - 0
routes/web.php

@@ -360,6 +360,7 @@ Route::middleware('pro.auth')->group(function () {
                 Route::post('replace-all-lines', 'StatTreeController@replaceAllLines')->name('replaceAllLines');
                 Route::post('replace-all-lines-json', 'StatTreeController@replaceAllLinesJSON')->name('replaceAllLinesJSON');
                 Route::post('refresh-tree-count-queries', 'StatTreeController@refreshTreeCountQueries')->name('refreshTreeCountQueries');
+                Route::post('get-counts-for-pro', 'StatTreeController@getCountsForPro')->name('getCountsForPro');
             });
 
             //Stat Tree Line