Prechádzať zdrojové kódy

Stat tree edit - replicate for all US states

Vijayakrishnan 3 rokov pred
rodič
commit
7c39918a6c

+ 4 - 0
app/Http/Controllers/StatTreeController.php

@@ -472,6 +472,7 @@ class StatTreeController extends Controller
         // clause
         $lineClause = $line->displayLineClause();
         $args = [];
+        $argsLabel = [];
         foreach($lineClause->lineClauseArgs as $stlcArg) {
             if($stlcArg->clauseArg) {
                 $args[] = [
@@ -480,6 +481,7 @@ class StatTreeController extends Controller
                     "default_value" => $stlcArg->default_value,
                     "access_level" => $stlcArg->access_level
                 ];
+                $argsLabel[] = $stlcArg->clauseArg->arg_text . ': ' . $stlcArg->default_value;
             }
         }
         $clause = [
@@ -495,6 +497,7 @@ class StatTreeController extends Controller
         }
         return [
             "text" => '<span class="stat-tree-anchor">' . $line->displayLabel() . '</span>' .
+                (count($argsLabel) ? '<span class="text-info text-sm ml-2">[' . implode(', ', $argsLabel) . ']</span>' : '') .
                 '<span class="ml-2 text-secondary line-count-label">(' .
                 (is_null($line->last_refresh_count) ? '…' :
                     ($line->last_refresh_count === -1 ?
@@ -512,6 +515,7 @@ class StatTreeController extends Controller
                 "id" => $line->id,
                 "uid" => $line->uid,
                 "displayLabel" => $line->displayLabel(),
+                "extendedLabel" => $line->displayLabel() . (count($argsLabel) ? ' [' . implode(', ', $argsLabel) . ']' : ''),
                 "lastRefreshCount" => $line->last_refresh_count,
                 "treeOrderPositionIndex" => $line->tree_order_position_index,
                 "columns" => $columns,

+ 14 - 0
public/css/style.css

@@ -2916,6 +2916,20 @@ body .vakata-context .vakata-context-separator>a {
     margin: 0;
 }
 
+.clause-label-part:not(:last-child)::after {
+    content: 'and';
+    position: absolute;
+    color: #299ab3;
+    font-size: 90%;
+    left: 100%;
+    width: 35px;
+    text-align: center;
+}
+.clause-label-part:not(:last-child) {
+    position: relative;
+    margin-right: 35px !important;
+}
+
 .phq .btn-select {
     padding: 5px 13px;
     border-radius: 100%;

+ 3 - 3
resources/views/app/stat-tree/stat-tree-lines/view-data.blade.php

@@ -11,9 +11,9 @@
                 Report columns not configured for this report!
             </div>
         @else
-            <div class="mb-2 d-flex flex-wrap">
+            <div class="mb-3 d-flex flex-wrap">
                 @foreach($line->lineClauses as $lineClause)
-                    <div class="border rounded px-2 py-1 mr-2 bg-light">{{$lineClause->clause_label}}
+                    <div class="border rounded px-2 py-1 mr-2 bg-light clause-label-part">{{$lineClause->clause_label}}
                         @if(count($lineClause->lineClauseArgs))
                             <?php
                             $argsLabel = [];
@@ -22,7 +22,7 @@
                                 $argsLabel[] = $argLabel;
                             }
                             ?>
-                            ({{implode(', ', $argsLabel)}})
+                            [{{implode(', ', $argsLabel)}}]
                         @endif
                     </div>
                 @endforeach

+ 45 - 1
resources/views/app/stat-tree/stat-trees/sub/edit.blade.php

@@ -595,7 +595,7 @@
                                                                     "action": function (obj) {
                                                                         openDynamicStagPopup('/practice-management/stat-tree-lines/view-data/' + node.data.uid,
                                                                             null,
-                                                                            node.data.displayLabel,
+                                                                            node.data.extendedLabel,
                                                                             false,
                                                                             'medium');
                                                                     },
@@ -709,6 +709,16 @@
                                                                             StatTree.createChildTreePermutations(selected);
                                                                         }
                                                                     }
+                                                                },
+                                                                "generate_all_us_states": {
+                                                                    "label": "<span class='text-sm'>Replicate for all US states</span>",
+                                                                    "_disabled": !StatTree.hasStateArg(node),
+                                                                    "action": function (obj) {
+                                                                        let selected = StatTree.selectedNode();
+                                                                        if(selected) {
+                                                                            StatTree.replicateForAllUSStates(selected);
+                                                                        }
+                                                                    }
                                                                 }
                                                             }
                                                         }
@@ -729,6 +739,40 @@
                                     }, 'json').then(hideMask);
                                 },
 
+                                hasStateArg: function(_node) {
+                                    if(_node.data.clause && _node.data.clause.args && _node.data.clause.args.length) {
+                                        let matched = _node.data.clause.args.filter(_x => _x.arg_text === 'state' && _x.field_type === 'text');
+                                        return !!(matched.length);
+                                    }
+                                    return false;
+                                },
+
+                                replicateForAllUSStates: function(_node) {
+                                    let node = this.el.jstree(true).get_json(_node), parent = this.el.jstree(true).get_node(_node.parent);
+                                    let states = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'];
+
+                                    node = this.getPasteBufferForNode(node);
+
+                                    // delete node
+                                    this.el.jstree(true).delete_node(_node);
+
+                                    // create new for each state
+                                    for (let i = 0; i < states.length; i++) {
+                                        let stateNode = JSON.parse(JSON.stringify(node));
+                                        for (let j = 0; j < stateNode.data.clause.args.length; j++) {
+                                            if(stateNode.data.clause.args[j].arg_text === 'state' && stateNode.data.clause.args[j].field_type === 'text') {
+                                                stateNode.data.clause.args[j].default_value = states[i];
+                                            }
+                                        }
+                                        stateNode.text = stateNode.text.replace(/state:\s[A-Z]{2}/g, 'state: ' + states[i]);
+                                        stateNode.text = stateNode.text.replace(/\([0-9]+\)/g, '(…)');
+                                        this.el.jstree(true).create_node(parent, stateNode, 'last');
+                                    }
+
+                                    this.setDirty();
+
+                                },
+
                                 createChildTreePermutations: function(_node) {
 
                                     // permute: thanks: https://stackoverflow.com/a/37580979/921204