|
@@ -1,383 +1,1164 @@
|
|
|
-@extends('app.stat-tree.stat-trees.single')
|
|
|
-@section('page')
|
|
|
+@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" />
|
|
|
-
|
|
|
- <div id="statTreeEdit">
|
|
|
- <div id="statTreeView" class="row">
|
|
|
- <div class="col-3 pr-0">
|
|
|
- @include('app.stat-tree.clauses-edit')
|
|
|
- </div>
|
|
|
- <div class="col-5 pr-0 pl-3 border-left tree-column">
|
|
|
- @include('app.stat-tree.tree-edit-v2', ['slug' => $statTree->slug])
|
|
|
- </div>
|
|
|
- <div class="col-4 pl-3 border-left setup-column">
|
|
|
- <div class="d-flex align-items-baseline mb-2">
|
|
|
- <h6 class="font-weight-bold m-0">Report Columns</h6>
|
|
|
- </div>
|
|
|
- <div id="report-column" class="d-none">
|
|
|
- @include('app.stat-tree.stat-tree-lines.report-columns')
|
|
|
+ <script src="/jstree/jstree.min.js"></script>
|
|
|
+ <div class="mcp-theme-1">
|
|
|
+ <div class="card border-0 rounded-0 d-flex flex-column body-height">
|
|
|
+ <div class="card-header px-2 py-3 bg-aliceblue">
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <a href="{{route('practice-management.statTrees.list')}}" class="small text-decoration-none mr-3">
|
|
|
+ <i class="fa fa-chevron-left"></i>
|
|
|
+ </a>
|
|
|
+ <div class="mr-3">
|
|
|
+ <span>Name:</span>
|
|
|
+ <span class="font-weight-bold" title="Slug: {{ $statTree->slug }}">{{ $statTree->name }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="mr-3 d-inline-flex">
|
|
|
+ <span class="mr-1">Model:</span>
|
|
|
+ <span class="font-weight-bold max-width-200px overflow-hidden text-ellipsis" title="{{ $statTree->model }}">{{ $statTree->model }}</span>
|
|
|
+ </div>
|
|
|
+ @if($statTree->pro_id)
|
|
|
+ <div class="mr-3">
|
|
|
+ <span>Pro:</span>
|
|
|
+ <span class="font-weight-bold" title="Clause: {{ $statTree->pro_scope_clause }}">{{ $statTree->pro->displayName() }}</span>
|
|
|
+ </div>
|
|
|
+ @endif
|
|
|
+ <div moe relative wide class="">
|
|
|
+ <a href="#" start show class=""><i class="fa fa-edit on-hover-opaque"></i></a>
|
|
|
+ <form url="{{ route("practice-management.api.statTree.updateBasic") }}">
|
|
|
+ @csrf
|
|
|
+ <input type="hidden" name="uid" value="{{$statTree->uid}}">
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Name *</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="name" value="{{$statTree->name}}" autofocus required>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Model *</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" data-option-list="model-options" autocomplete="off" name="model" value="{{$statTree->model}}" required>
|
|
|
+ <div id="model-options" class="data-option-list">
|
|
|
+ <?php $models = \Illuminate\Support\Facades\DB::select('SELECT distinct(model) as m FROM clause order by model'); ?>
|
|
|
+ @foreach($models as $m)
|
|
|
+ <div>{!! $m->m !!}</div>
|
|
|
+ @endforeach
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Slug *</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="slug" value="{{$statTree->slug}}" required>
|
|
|
+ </div>
|
|
|
+ <label class="my-3 d-flex align-items-center">
|
|
|
+ <span class="mr-2">Is Template?</span>
|
|
|
+ <input type="checkbox" name="isTemplate" {{@$statTree->is_template ? 'checked' : ''}}>
|
|
|
+ </label>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Pro</label>
|
|
|
+ <select name="proUid" class="form-control input-sm" provider-search provider-type="hcp" data-pro-uid="{{ @$statTree->pro->uid }}">
|
|
|
+ <option value="">--select--</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Pro Scope Clause</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="proScopeClause" value="{{@$statTree->pro_scope_clause}}">
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ @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>
|
|
|
+ <div class="card-body p-0 flex-grow-1">
|
|
|
+ <div id="statTreeEdit-{{$statTree->id}}" class="row m-0 h-100 stat-tree {{$multiProView ? 'multi-pro-view' : ''}}">
|
|
|
|
|
|
- </div>
|
|
|
- <script src="/jstree/jstree.min.js"></script>
|
|
|
- <script>
|
|
|
- (function() {
|
|
|
- function init() {
|
|
|
- $(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() {
|
|
|
- let form = $(this).closest('.frm-clause-add-edit');
|
|
|
- let label = $.trim(form.find('input[name="question"]').val()) + ' ' +
|
|
|
- $.trim(form.find('input[name="answer"]').val());
|
|
|
- form.find('input[name="label"]').val(label);
|
|
|
- });
|
|
|
-
|
|
|
- let treePayload = '';
|
|
|
-
|
|
|
- function selectedNode() {
|
|
|
- let selected = $('#stat-tree-view-{{$statTree->id}}>ul').jstree('get_selected', false);
|
|
|
- if(selected && selected.length) {
|
|
|
- selected = $('#' + selected[0]);
|
|
|
- }
|
|
|
- if(!selected || !selected.length) return;
|
|
|
- return selected.find('>a.jstree-anchor>.st-node').first();
|
|
|
- }
|
|
|
-
|
|
|
- function getSelectedNodeColumns() {
|
|
|
- let selected = selectedNode();
|
|
|
- let columnsField = selected.find('>[data-name="columns"]').first();
|
|
|
- let columns = columnsField.val();
|
|
|
- if(!!columns) return JSON.parse(columns);
|
|
|
- return [];
|
|
|
- }
|
|
|
-
|
|
|
- function setSelectedNodeColumns(columns) {
|
|
|
- let selected = selectedNode();
|
|
|
- let columnsField = selected.find('>[data-name="columns"]').first();
|
|
|
- columnsField.val(JSON.stringify(columns));
|
|
|
- }
|
|
|
-
|
|
|
- function getNodes(_ul, _indent, _lines) {
|
|
|
- _ul.find('>li').each(function() {
|
|
|
- let node = $(this).find('>a.jstree-anchor>.st-node');
|
|
|
- let line = _indent + node.find('>span').first().text();
|
|
|
- let columnsElem = node.find('>[data-name="columns"]').first(), columns = [];
|
|
|
- if(columnsElem && columnsElem.length && !!columnsElem.val()) {
|
|
|
- let columnsParsed = JSON.parse(columnsElem.val());
|
|
|
- for (let i = 0; i < columnsParsed.length; i++) {
|
|
|
- columns.push(columnsParsed[i].display_key+'|'+columnsParsed[i].label);
|
|
|
- }
|
|
|
- columns = columns.join(',');
|
|
|
- }
|
|
|
- line = line + '==>' + columns;
|
|
|
- _lines.push(line);
|
|
|
- $(this).find('>ul.jstree-children').each(function() {
|
|
|
- getNodes($(this), _indent + "\t", _lines);
|
|
|
- });
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- function generateTextRepresentation(_e, _data) {
|
|
|
-
|
|
|
- $('#stat-tree-view-{{$statTree->id}}').jstree('open_all');
|
|
|
- $('#stat-tree-view-{{$statTree->id}} [data-type="meta"]').remove();
|
|
|
-
|
|
|
- let nodes = [];
|
|
|
- getNodes($('#stat-tree-view-{{$statTree->id}}>ul').first(), '', nodes);
|
|
|
-
|
|
|
- let converted = tsvToArray.getAutoFilledTabContent(nodes.join("\n"));
|
|
|
-
|
|
|
- let maxColumn = 0, columns = [];
|
|
|
- try {
|
|
|
- let rows = converted.split("\n");
|
|
|
- rows.map((row, index) => {
|
|
|
- columns[index] = row.split("\t");
|
|
|
- const length = columns[index].length;
|
|
|
- if (length > maxColumn) {
|
|
|
- maxColumn = length
|
|
|
- }
|
|
|
- const emptyFields = maxColumn - length;
|
|
|
- for (ii = 0; ii < emptyFields; ii++) {
|
|
|
- columns[index].push('');
|
|
|
+ <!-- clauses -->
|
|
|
+ <div class="col-3 p-0 h-100 clauses-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">Available Clauses</h6>
|
|
|
+ <div moe relative wide class="ml-3">
|
|
|
+ <a href="#" start show>+ Add</a>
|
|
|
+ <form url="{{ route("practice-management.api.clause.create") }}" class="frm-clause-add-edit" hook="reloadClausesTree">
|
|
|
+ @csrf
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Model</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="model" readonly value="{{$statTree->model}}">
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Question</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="question" autofocus>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Answer</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="answer">
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Label</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="label" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Clause Text</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="clauseText">
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ <a href="#" class="clause-expand-all ml-3" title="Expand All"><i class="fa fa-angle-double-down text-secondary"></i></a>
|
|
|
+ <a href="#" class="clause-collapse-all ml-2" title="Collapse All"><i class="fa fa-angle-double-up text-secondary"></i></a>
|
|
|
+ </div>
|
|
|
+ <div class="flex-grow-1 overflow-overlay-on-hover pl-1">
|
|
|
+ <div class="overflow-auto clauses-view pb-5" id="clauses-view-{{$statTree->id}}"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- hidden moes invoked due to context actions -->
|
|
|
+ <div class="border mb-3 p-2 position-absolute" style="left: -10000px; top: -10000px;">
|
|
|
+ <div class="d-inline-flex align-items-baseline">
|
|
|
+
|
|
|
+ <!-- edit clause -->
|
|
|
+ <div moe center relative wide class="ml-3 mr-2" id="edit-clause-moe">
|
|
|
+ <a href="#" start show><i class="text-sm fa fa-edit on-hover-opaque"></i></a>
|
|
|
+ <form url="{{ route("practice-management.api.clause.update") }}" class="frm-clause-add-edit" center hook="reloadClausesTree">
|
|
|
+ @csrf
|
|
|
+ <input type="hidden" name="uid">
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Model</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="model" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Question</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="question">
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Answer</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="answer">
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Label</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="label" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Clause Text</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="clauseText">
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- remove clause -->
|
|
|
+ <div moe relative center id="remove-clause-moe">
|
|
|
+ <a href="#" start show><i class="text-sm fa fa-trash-alt on-hover-opaque text-danger"></i></a>
|
|
|
+ <form url="{{ route("practice-management.api.clause.remove") }}" center hook="reloadClausesTree">
|
|
|
+ @csrf
|
|
|
+ <input type="hidden" name="uid">
|
|
|
+ <p>Are you sure?</p>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-danger mr-2" type="button" submit>Remove</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- add clause arg -->
|
|
|
+ <div moe relative center id="add-clause-arg-moe">
|
|
|
+ <a href="#" start show><i class="text-sm fa fa-trash-alt on-hover-opaque text-danger"></i></a>
|
|
|
+ <form url="{{ route("practice-management.api.clauseArg.create") }}" center hook="reloadClausesTree">
|
|
|
+ @csrf
|
|
|
+ <input type="hidden" name="clauseId">
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Arg Text</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="argText" required>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <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="numeric">Number</option>
|
|
|
+ <option value="date">Date</option>
|
|
|
+ <option value="text">String</option>
|
|
|
+ <option value="bool">Boolean</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- edit clause arg -->
|
|
|
+ <div moe relative center id="edit-clause-arg-moe">
|
|
|
+ <a href="#" start show><i class="text-sm fa fa-trash-alt on-hover-opaque text-danger"></i></a>
|
|
|
+ <form url="{{ route("practice-management.api.clauseArg.update") }}" center hook="reloadClausesTree">
|
|
|
+ @csrf
|
|
|
+ <input type="hidden" name="id">
|
|
|
+ <div class="mb-2">
|
|
|
+ <label class="text-secondary text-sm mb-1">Arg Text</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" name="argText" required>
|
|
|
+ </div>
|
|
|
+ <div class="mb-2">
|
|
|
+ <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="numeric">Number</option>
|
|
|
+ <option value="date">Date</option>
|
|
|
+ <option value="text">String</option>
|
|
|
+ <option value="bool">Boolean</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- remove clause arg -->
|
|
|
+ <div moe relative center id="remove-clause-arg-moe">
|
|
|
+ <a href="#" start show><i class="text-sm fa fa-trash-alt on-hover-opaque text-danger"></i></a>
|
|
|
+ <form url="{{ route("practice-management.api.clauseArg.remove") }}" center hook="reloadClausesTree">
|
|
|
+ @csrf
|
|
|
+ <input type="hidden" name="id">
|
|
|
+ <p>Are you sure?</p>
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-danger mr-2" type="button" submit>Remove</button>
|
|
|
+ <button class="btn btn-sm btn-default mr-2 border" type="button" cancel>Cancel</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- tree -->
|
|
|
+ <div class="col-9 p-0 h-100 border-left tree-column">
|
|
|
+ <div class="row m-0 h-100">
|
|
|
+ <div class="{{$multiProView ? 'col-12' : 'col-6'}} tree-lhs-column border-right h-100 p-0">
|
|
|
+ <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>
|
|
|
+ <div class="ml-auto mr-2 d-none if-changed">
|
|
|
+ <a href="#" class="btn btn-sm btn-primary text-white" id="btn-save-tree">Save</a>
|
|
|
+ <a href="#" class="ml-2 btn btn-sm btn-default border text-dark" onclick="return fastReload()">Reset</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="flex-grow-1 overflow-overlay-on-hover">
|
|
|
+ @if(!$multiProView)
|
|
|
+ <div class="stat-tree-view overflow-auto min-height-300px" id="stat-tree-edit-{{$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-edit-{{$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>
|
|
|
+ @if(!$multiProView)
|
|
|
+ <!-- selected line properties -->
|
|
|
+ <div class="col-6 tree-rhs-column h-100 p-0">
|
|
|
+ <div class="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>-->
|
|
|
+ </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>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <script>
|
|
|
+ (function() {
|
|
|
+ function init() {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ moe.find('input[name], select[name]').each(function() {
|
|
|
+ let name = $(this).attr('name');
|
|
|
+ if(!!_node.data[name]) {
|
|
|
+ $(this).val(!!_node.data[name] ? _node.data[name] : '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ moe.find('a[start]').trigger('click');
|
|
|
}
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- this.rows = [];
|
|
|
- }
|
|
|
-
|
|
|
- treePayload = JSON.stringify(columns);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- function autoSaveChanges() {
|
|
|
- setTimeout(() => {
|
|
|
- saveStatTree();
|
|
|
- }, 0);
|
|
|
- }
|
|
|
-
|
|
|
- function saveStatTree() {
|
|
|
- generateTextRepresentation();
|
|
|
- $.post('{{ route("practice-management.api.statTree.replaceAllLines") }}', {
|
|
|
- statTreeID: "{{ $statTree->id }}",
|
|
|
- data: treePayload
|
|
|
- }, function (response) {
|
|
|
- if(!hasResponseError(response)) {
|
|
|
- //fastReload();
|
|
|
- // need to fix this!
|
|
|
- showMask();
|
|
|
- window.top.location.reload();
|
|
|
- }
|
|
|
- }, 'json');
|
|
|
- }
|
|
|
-
|
|
|
- function onDeselected(_e, _data) {
|
|
|
- let rptColumn = $('#report-column').addClass('d-none');
|
|
|
- }
|
|
|
-
|
|
|
- function onSelected(_e, _data) {
|
|
|
- let selected = selectedNode();
|
|
|
-
|
|
|
- let rptColumn = $('#report-column').removeClass('d-none');
|
|
|
- rptColumn.find('[line-label]').text(selected.find('>span').first().text());
|
|
|
-
|
|
|
- let tbody = rptColumn.find('[line-columns]');
|
|
|
-
|
|
|
- let columns = getSelectedNodeColumns();
|
|
|
-
|
|
|
- tbody.empty();
|
|
|
-
|
|
|
- if(columns && columns.length) {
|
|
|
- for (let i = 0; i < columns.length; i++) {
|
|
|
- $('<tr/>')
|
|
|
- .append($('<td/>').text(i + 1))
|
|
|
- .append($('<td/>').text(columns[i].label))
|
|
|
- .append($('<td/>').text(columns[i].display_key))
|
|
|
- .append(
|
|
|
- $('<td/>')
|
|
|
- .addClass('text-right')
|
|
|
- .append(i > 0 ? '<a href="#" class="move-column-up mr-2" data-index="' + i + '"><i class="fa fa-arrow-up text-primary on-hover-opaque"></i></a>': '')
|
|
|
- .append(i < columns.length - 1 ? '<a href="#" class="move-column-down mr-2" data-index="' + i + '"><i class="fa fa-arrow-down text-primary on-hover-opaque"></i></a>': '')
|
|
|
- .append('<a href="#" class="remove-column" data-index="' + i + '"><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>')
|
|
|
- )
|
|
|
- .appendTo(tbody);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- $('#stat-tree-view-{{$statTree->id}}')
|
|
|
- //.on('changed.jstree', autoSaveChanges)
|
|
|
- .on('move_node.jstree', autoSaveChanges)
|
|
|
- .on('copy_node.jstree', autoSaveChanges)
|
|
|
- .on('select_node.jstree', onSelected)
|
|
|
- .on('deselect_node.jstree', onDeselected)
|
|
|
- .jstree({
|
|
|
- "core": {
|
|
|
- "check_callback": true,
|
|
|
- "multiple": false,
|
|
|
- "animation": 0
|
|
|
- },
|
|
|
- "contextmenu": {
|
|
|
- show_at_node: false,
|
|
|
- items: function ($node) {
|
|
|
- return {
|
|
|
- "data": {
|
|
|
- "label": "<span class='text-sm'>View Data</span>",
|
|
|
- "action": function (obj) {
|
|
|
- let uid = $(obj.reference).find('>div.stat-tree-line').attr('data-line-uid');
|
|
|
- openDynamicStagPopup('/practice-management/stat-tree-lines/view-data/' + uid,
|
|
|
- null,
|
|
|
- $(obj.reference).find('>div.stat-tree-line>span').first().text(),
|
|
|
- false,
|
|
|
- 'medium');
|
|
|
- },
|
|
|
- },
|
|
|
- "remove": {
|
|
|
- "label": "<span class='text-sm'>Remove Node</span>",
|
|
|
- "action": function (obj) {
|
|
|
- let id = $(obj.reference).find('>div.stat-tree-line').attr('data-line-id');
|
|
|
- $('.remove-line-moe-' + id).find('a[start]').trigger('click');
|
|
|
- }
|
|
|
+
|
|
|
+ // clauses tree
|
|
|
+ let ClausesTree = {
|
|
|
+ el: $('#clauses-view-{{$statTree->id}}'),
|
|
|
+ load: function() {
|
|
|
+
|
|
|
+ // destroy if existing
|
|
|
+ try {
|
|
|
+ this.el.jstree('destroy');
|
|
|
}
|
|
|
+ catch (e) {}
|
|
|
+
|
|
|
+ // get data
|
|
|
+ $.get('{{ route('practice-management.statTrees.view.clausesJSON', $statTree) }}', _data => {
|
|
|
+
|
|
|
+ // init tree with data
|
|
|
+ this.el
|
|
|
+ .jstree({
|
|
|
+ "core": {
|
|
|
+ "multiple": false,
|
|
|
+ "animation": 0,
|
|
|
+ 'data': _data
|
|
|
+ },
|
|
|
+ "dnd": {
|
|
|
+ "is_draggable": function(_node, _e) {
|
|
|
+ return _node[0].data.type === 'clause';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "contextmenu": {
|
|
|
+ show_at_node: false,
|
|
|
+ items: function (node) {
|
|
|
+ if(node.data.type === 'clause') { // clause
|
|
|
+ return {
|
|
|
+ "edit": {
|
|
|
+ "label": "<span class='text-sm'>Edit Clause</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ fillAndInvokeMoe('#edit-clause-moe', node);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "remove": {
|
|
|
+ "label": "<span class='text-sm'>Remove Clause</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ fillAndInvokeMoe('#remove-clause-moe', node);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "add_arg": {
|
|
|
+ "label": "<span class='text-sm'>Add Clause Arg</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ fillAndInvokeMoe('#add-clause-arg-moe', node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(node.data.type === 'clause_arg') { // clause
|
|
|
+ return {
|
|
|
+ "edit": {
|
|
|
+ "label": "<span class='text-sm'>Edit Arg</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ fillAndInvokeMoe('#edit-clause-arg-moe', node);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "remove": {
|
|
|
+ "label": "<span class='text-sm'>Remove Arg</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ fillAndInvokeMoe('#remove-clause-arg-moe', node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "plugins": [
|
|
|
+ "wholerow",
|
|
|
+ "dnd",
|
|
|
+ "contextmenu",
|
|
|
+ "state"
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ }, 'json');
|
|
|
}
|
|
|
- },
|
|
|
- },
|
|
|
- "plugins": [
|
|
|
- "wholerow",
|
|
|
- "dnd",
|
|
|
- "contextmenu",
|
|
|
- "state"
|
|
|
- ]
|
|
|
- });
|
|
|
-
|
|
|
- $('#clauses-view-{{$statTree->id}}')
|
|
|
- /*.on('changed.jstree', generateTextRepresentation)
|
|
|
- .on('move_node.jstree', generateTextRepresentation)
|
|
|
- .on('copy_node.jstree', generateTextRepresentation)*/
|
|
|
- .jstree({
|
|
|
- "core": {
|
|
|
- "multiple": false,
|
|
|
- "animation": 0
|
|
|
- },
|
|
|
- "dnd": {
|
|
|
- "is_draggable": function(_node, _e) {
|
|
|
- return $('#' + _node[0].id).find('>a.jstree-anchor>.clause').length === 1;
|
|
|
- }
|
|
|
- },
|
|
|
- "contextmenu": {
|
|
|
- show_at_node: false,
|
|
|
- items: function ($node) {
|
|
|
- console.log($node);
|
|
|
- if($('#' + $node.id).find('>a.jstree-anchor>.clause').length === 1) { // clause
|
|
|
- return {
|
|
|
- "edit": {
|
|
|
- "label": "<span class='text-sm'>Edit Clause</span>",
|
|
|
- "action": function (obj) {
|
|
|
- let id = $(obj.reference).find('>div.clause').attr('data-clause-id');
|
|
|
- $('.edit-clause-moe-' + id).find('a[start]').trigger('click');
|
|
|
+ };
|
|
|
+
|
|
|
+ @if($multiProView)
|
|
|
+ (function ($, undefined) {
|
|
|
+ "use strict";
|
|
|
+ $.jstree.plugins.noclose = function () {
|
|
|
+ this.close_node = $.noop;
|
|
|
+ };
|
|
|
+ })(jQuery);
|
|
|
+ @endif
|
|
|
+
|
|
|
+ // stat tree
|
|
|
+ let StatTree = {
|
|
|
+ el: $('#stat-tree-edit-{{$statTree->id}}'),
|
|
|
+ changed: false,
|
|
|
+
|
|
|
+ setDirty: function(_changed = true) {
|
|
|
+ this.changed = _changed;
|
|
|
+ if(_changed) {
|
|
|
+ $('.if-changed').removeClass('d-none');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('.if-changed').addClass('d-none');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ load: function() {
|
|
|
+
|
|
|
+ // destroy if existing
|
|
|
+ try {
|
|
|
+ this.el.jstree('destroy');
|
|
|
+ }
|
|
|
+ catch (e) {}
|
|
|
+
|
|
|
+ this.el = $('#stat-tree-edit-{{$statTree->id}}');
|
|
|
+
|
|
|
+ // get data
|
|
|
+ showMask();
|
|
|
+ $.get('{{ route('practice-management.statTrees.view.linesJSON', $statTree) }}', _data => {
|
|
|
+
|
|
|
+ // init tree with data
|
|
|
+ this.el
|
|
|
+ .on('move_node.jstree', (_e, _data) => { StatTree.dropped(_e, _data); })
|
|
|
+ .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';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "contextmenu": {
|
|
|
+ show_at_node: false,
|
|
|
+ items: function (node) {
|
|
|
+ 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) {
|
|
|
+ openDynamicStagPopup('/practice-management/stat-tree-lines/view-data/' + node.data.uid,
|
|
|
+ null,
|
|
|
+ node.data.displayLabel,
|
|
|
+ false,
|
|
|
+ 'medium');
|
|
|
+ },
|
|
|
+ separator_after: true,
|
|
|
+ },
|
|
|
+ @endif
|
|
|
+
|
|
|
+ "cut": {
|
|
|
+ "label": "<span class='text-sm'>Cut</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ let selected = StatTree.selectedNode();
|
|
|
+ if(selected) {
|
|
|
+ StatTree.el.jstree(true).cut(selected.id);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "copy": {
|
|
|
+ "label": "<span class='text-sm'>Copy</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ let selected = StatTree.selectedNode();
|
|
|
+ if(selected) {
|
|
|
+ StatTree.el.jstree(true).copy(selected.id);
|
|
|
+
|
|
|
+ // put into localStorage for paste_ext
|
|
|
+ let node = StatTree.el.jstree(true).get_json(selected.id);
|
|
|
+ localStorage.stPasteBuffer = JSON.stringify(StatTree.getPasteBufferForNode(node));
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "paste": {
|
|
|
+ "label": "<span class='text-sm'>Paste</span>",
|
|
|
+ "_disabled": !StatTree.el.jstree(true).can_paste(),
|
|
|
+ "action": function (obj) {
|
|
|
+ let selected = StatTree.selectedNode();
|
|
|
+ if(selected && StatTree.el.jstree(true).can_paste()) {
|
|
|
+ StatTree.el.jstree(true).paste(selected.id, 'last');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "paste_ext": {
|
|
|
+ "label": "<span class='text-sm'>Paste (external)</span>",
|
|
|
+ "_disabled": !localStorage.stPasteBuffer,
|
|
|
+ "action": function (obj) {
|
|
|
+ let selected = StatTree.selectedNode();
|
|
|
+ if(selected && !!localStorage.stPasteBuffer) {
|
|
|
+ try {
|
|
|
+ let parsed = JSON.parse(localStorage.stPasteBuffer);
|
|
|
+ StatTree.el.jstree(true).create_node(selected.id, parsed);
|
|
|
+ StatTree.el.jstree(true).open_node(selected.id);
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ console.error('Unable to paste. Invalid buffer.')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ separator_after: true,
|
|
|
+ },
|
|
|
+ "remove": {
|
|
|
+ "label": "<span class='text-sm'>Remove</span>",
|
|
|
+ "action": function (obj) {
|
|
|
+ let selected = StatTree.selectedNode();
|
|
|
+ if(selected) {
|
|
|
+ StatTree.el.jstree(true).delete_node(selected.id);
|
|
|
+ StatTree.setDirty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ @endif
|
|
|
+ "plugins": [
|
|
|
+ "wholerow",
|
|
|
+ @if(!$multiProView)
|
|
|
+ "dnd",
|
|
|
+ "contextmenu",
|
|
|
+ @else
|
|
|
+ "noclose",
|
|
|
+ @endif
|
|
|
+ "state"
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ }, 'json').then(hideMask);
|
|
|
+ },
|
|
|
+
|
|
|
+ dropVisualize: function() {
|
|
|
+ console.log('redrawn')
|
|
|
+ function calculateDropPercent(node, parent = null) {
|
|
|
+ let realNode = StatTree.el.jstree(true).get_node(node.id);
|
|
|
+ if(!realNode.data) return;
|
|
|
+ if(parent && parent.data.lastRefreshCount !== null) {
|
|
|
+ if(node.data.lastRefreshCount !== null) {
|
|
|
+ realNode.data.dropPercent = (((parent.data.lastRefreshCount - node.data.lastRefreshCount) / parent.data.lastRefreshCount) * 100);
|
|
|
+ if(realNode.data.dropPercent) {
|
|
|
+ let element = StatTree.el.jstree(true).get_node(node.id, true), cssClass = '';
|
|
|
+ if(realNode.data.dropPercent > 75) {
|
|
|
+ cssClass = 'drop-76-100';
|
|
|
+ }
|
|
|
+ else if(realNode.data.dropPercent > 50 && realNode.data.dropPercent <= 75) {
|
|
|
+ cssClass = 'drop-51-75';
|
|
|
+ }
|
|
|
+ else if(realNode.data.dropPercent > 25 && realNode.data.dropPercent <= 50) {
|
|
|
+ cssClass = 'drop-26-50';
|
|
|
+ }
|
|
|
+ else if(realNode.data.dropPercent > 0 && realNode.data.dropPercent <= 25) {
|
|
|
+ cssClass = 'drop-0-25';
|
|
|
+ }
|
|
|
+ element.find('>a.jstree-anchor')
|
|
|
+ .addClass('has-drop-visualization')
|
|
|
+ .addClass(cssClass)
|
|
|
+ .attr('data-drop-percent', (realNode.data.dropPercent.toFixed(1)) + '% ⤵');
|
|
|
+ }
|
|
|
}
|
|
|
- },
|
|
|
- "remove": {
|
|
|
- "label": "<span class='text-sm'>Remove Clause</span>",
|
|
|
- "action": function (obj) {
|
|
|
- let id = $(obj.reference).find('>div.clause').attr('data-clause-id');
|
|
|
- $('.remove-clause-moe-' + id).find('a[start]').trigger('click');
|
|
|
+ }
|
|
|
+ for (let i = 0; i < node.children.length; i++) {
|
|
|
+ calculateDropPercent(node.children[i], node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let raw = this.el.jstree('get_json');
|
|
|
+ for (let i = 0; i < raw.length; i++) {
|
|
|
+ calculateDropPercent(raw[i]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ dropped: function(_e, _data) {
|
|
|
+
|
|
|
+ if(_data.original && _data.original.data &&
|
|
|
+ _data.original.data.type === 'clause') {
|
|
|
+ _data.node.data = {
|
|
|
+ type: "stat_tree_line",
|
|
|
+ displayLabel: _data.original.data.label,
|
|
|
+ columns: [],
|
|
|
+ clause: {
|
|
|
+ clause_id: _data.original.data.clauseId,
|
|
|
+ clause_label: _data.original.data.label,
|
|
|
+ args: _data.original.data.args
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // delete args and query children (from the clauses tree)
|
|
|
+ this.el.jstree(true).delete_node(_data.node.children);
|
|
|
+
|
|
|
+ // open new parent to reveal dropped node
|
|
|
+ this.el.jstree(true).open_node(_data.parent);
|
|
|
+
|
|
|
+ // select the new node
|
|
|
+ this.el.jstree(true).deselect_all();
|
|
|
+ this.el.jstree(true).select_node(_data.node.id);
|
|
|
+ }
|
|
|
+ else if(_e.type === 'copy_node' && _data.original && _data.original.data &&
|
|
|
+ _data.original.data.type === 'stat_tree_line') {
|
|
|
+
|
|
|
+ function recursiveCopyData(src, target) {
|
|
|
+ src = StatTree.el.jstree(true).get_node(src);
|
|
|
+ target = StatTree.el.jstree(true).get_node(target);
|
|
|
+ target.data = JSON.parse(JSON.stringify(src.data));
|
|
|
+ if(src.children.length === target.children.length) {
|
|
|
+ for (let i = 0; i < target.children.length; i++) {
|
|
|
+ recursiveCopyData(src.children[i], target.children[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log('Child count not the same!', src.text, target.text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ recursiveCopyData(_data.original.id, _data.node.id);
|
|
|
+
|
|
|
+ // open new parent to reveal dropped node
|
|
|
+ this.el.jstree(true).open_node(_data.parent);
|
|
|
+
|
|
|
+ // select the new node
|
|
|
+ this.el.jstree(true).deselect_all();
|
|
|
+ this.el.jstree(true).select_node(_data.node.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setDirty();
|
|
|
+ },
|
|
|
+
|
|
|
+ save: function() {
|
|
|
+ setTimeout(() => {
|
|
|
+ $.post('{{ route("practice-management.api.statTree.replaceAllLinesJSON") }}', {
|
|
|
+ uid: "{{ $statTree->uid }}",
|
|
|
+ data: StatTree.payload()
|
|
|
+ }, function (response) {
|
|
|
+ if(!hasResponseError(response)) {
|
|
|
+ toastr.success('All changes saved!');
|
|
|
+ /*StatTree.setDirty(false);
|
|
|
+ StatTree.load();*/
|
|
|
+ fastReload();
|
|
|
}
|
|
|
+ }, 'json');
|
|
|
+ }, 0);
|
|
|
+ },
|
|
|
+
|
|
|
+ log: function() {
|
|
|
+ let raw = this.el.jstree('get_json');
|
|
|
+ for (let i = 0; i < raw.length; i++) {
|
|
|
+ this.logNode(raw[i].id, "");
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ logNode: function(_id, _indent) {
|
|
|
+ let node = this.el.jstree('get_node', _id);
|
|
|
+ let s = [], css = false;
|
|
|
+ if(!node.data) css = true;
|
|
|
+ s.push($('<div/>').html(node.text).text().substr(0, 10) + '...');
|
|
|
+ s.push(node.data ? 'data:' + node.data.type: '%cdata:X');
|
|
|
+ console.log("ALIX: " + _indent + s.join(' '), css ? 'color:red' : '');
|
|
|
+ for (let i = 0; i < node.children.length; i++) {
|
|
|
+ this.logNode(node.children[i], _indent + "\t");
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ getPasteBufferForNode(_node) {
|
|
|
+ let children = [];
|
|
|
+ for (let i = 0; i < _node.children.length; i++) {
|
|
|
+ children.push(this.getPasteBufferForNode(_node.children[i]));
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ "text": _node.text,
|
|
|
+ "state": {
|
|
|
+ "opened": true,
|
|
|
+ "disabled": false,
|
|
|
+ "selected": false,
|
|
|
},
|
|
|
- "add_arg": {
|
|
|
- "label": "<span class='text-sm'>Add Clause Arg</span>",
|
|
|
- "action": function (obj) {
|
|
|
- let id = $(obj.reference).find('>div.clause').attr('data-clause-id');
|
|
|
- $('.add-clause-arg-moe-' + id).find('a[start]').trigger('click');
|
|
|
+ "children": children,
|
|
|
+ "data": _node.data
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ payload: function() {
|
|
|
+ let raw = this.el.jstree('get_json');
|
|
|
+ let nodes = [];
|
|
|
+ for (let i = 0; i < raw.length; i++) {
|
|
|
+ nodes.push(this.nodePayload(raw[i].id));
|
|
|
+ }
|
|
|
+ return JSON.stringify(nodes);
|
|
|
+ },
|
|
|
+
|
|
|
+ nodePayload: function(_id) {
|
|
|
+ let node = this.el.jstree('get_node', _id);
|
|
|
+ let payload = {};
|
|
|
+ if(node.data.type === 'stat_tree_line') {
|
|
|
+ payload = {
|
|
|
+ displayLabel: node.data.displayLabel,
|
|
|
+ clause: node.data.clause,
|
|
|
+ columns: node.data.columns,
|
|
|
+ };
|
|
|
+ let children = [];
|
|
|
+ for (let i = 0; i < node.children.length; i++) {
|
|
|
+ children.push(this.nodePayload(node.children[i]));
|
|
|
+ }
|
|
|
+ payload.children = children;
|
|
|
+ }
|
|
|
+ return payload;
|
|
|
+ },
|
|
|
+
|
|
|
+ selectedNode: function() {
|
|
|
+ let selected = this.el.jstree('get_selected', true);
|
|
|
+ if(selected && selected.length) {
|
|
|
+ return selected[0];
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+
|
|
|
+ getSelectedNodeClauseArgs: function() {
|
|
|
+ let selected = this.selectedNode();
|
|
|
+ if(selected) {
|
|
|
+ return selected.data.clause.args;
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ },
|
|
|
+
|
|
|
+ getSelectedNodeColumns: function() {
|
|
|
+ let selected = this.selectedNode();
|
|
|
+ if(selected) {
|
|
|
+ return selected.data.columns;
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ },
|
|
|
+
|
|
|
+ setSelectedNodeColumns: function(columns) {
|
|
|
+ let selected = this.selectedNode();
|
|
|
+ if(selected) {
|
|
|
+ selected.data.columns = columns;
|
|
|
+ this.setDirty();
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ },
|
|
|
+
|
|
|
+ onDeselected: function(_e, _data) {
|
|
|
+ linePropsColumn.addClass('d-none');
|
|
|
+ },
|
|
|
+
|
|
|
+ onSelected: function(_e, _data) {
|
|
|
+
|
|
|
+ @if($multiProView)
|
|
|
+ return;
|
|
|
+ @endif
|
|
|
+
|
|
|
+ let selected = this.selectedNode();
|
|
|
+
|
|
|
+ if(selected) console.log(selected.data)
|
|
|
+
|
|
|
+ if(!(selected && selected.data && selected.data.type === 'stat_tree_line')) return;
|
|
|
+
|
|
|
+ linePropsColumn.removeClass('d-none');
|
|
|
+ linePropsColumn.find('[line-label]').text(selected.data.displayLabel);
|
|
|
+
|
|
|
+ // fill args
|
|
|
+ let tbody = linePropsColumn.find('[line-args]');
|
|
|
+ let clause = selected.data.clause;
|
|
|
+ tbody.empty();
|
|
|
+ if(clause) {
|
|
|
+ let edit = true;
|
|
|
+ let args = clause.args ? clause.args : [];
|
|
|
+ // $('<tr/>').addClass(edit ? '' : 'opacity-60 parent-arg').append($('<td/>').attr('colspan', 3).addClass('font-weight-bold text-sm ' + (edit ? '' : 'text-secondary')).text(clause.clause_label)).appendTo(tbody);
|
|
|
+ if(!args.length) {
|
|
|
+ $('<tr/>').addClass(edit ? '' : 'opacity-60 parent-arg').append($('<td/>').attr('colspan', 3).addClass('pl-3 text-secondary text-sm').text('No args')).appendTo(tbody);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ for (let i = 0; i < args.length; i++) {
|
|
|
+ $('<tr/>')
|
|
|
+ .addClass(edit ? '' : 'opacity-60 parent-arg')
|
|
|
+ .append(
|
|
|
+ $('<td/>')
|
|
|
+ .addClass('pl-3')
|
|
|
+ .html(args[i].arg_text + ' <span class="text-secondary text-sm">(' + args[i].field_type + ')</span>')
|
|
|
+ )
|
|
|
+ .append(
|
|
|
+ $('<td/>')
|
|
|
+ .text(args[i].default_value)
|
|
|
+ .append(edit ? '<a href="#" class="edit-arg-value ml-2" data-index="' + i + '"><i class="fa fa-edit text-primary text-sm on-hover-opaque"></i></a>': '')
|
|
|
+ )
|
|
|
+ .append(
|
|
|
+ $('<td/>')
|
|
|
+ .text(args[i].access_level)
|
|
|
+ .append(edit ? '<a href="#" class="edit-arg-access-level ml-2" data-index="' + i + '"><i class="fa fa-edit text-primary text-sm on-hover-opaque"></i></a>': '')
|
|
|
+ )
|
|
|
+ .appendTo(tbody);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
- "plugins": [
|
|
|
- "wholerow",
|
|
|
- "dnd",
|
|
|
- "contextmenu"
|
|
|
- ]
|
|
|
- });
|
|
|
-
|
|
|
- $('#report-column').find('input[stag-suggest][name="displayKey"]')
|
|
|
- .off('stag-suggest-selected')
|
|
|
- .on('stag-suggest-selected', (_e, _input, _data) => {
|
|
|
- let columns = getSelectedNodeColumns();
|
|
|
- columns.push({
|
|
|
- label: _data.label,
|
|
|
- display_key: _data.text
|
|
|
- });
|
|
|
- setSelectedNodeColumns(columns);
|
|
|
- onSelected();
|
|
|
- autoSaveChanges();
|
|
|
- $(_input).val('').focus();
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $('#btn-save-tree')
|
|
|
- .off('click')
|
|
|
- .on('click', function() {
|
|
|
- saveStatTree();
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $('#refresh-counts')
|
|
|
- .off('click')
|
|
|
- .on('click', function() {
|
|
|
- showMask();
|
|
|
- $.post("{{ route('practice-management.api.statTree.refreshTreeCountQueries') }}", {
|
|
|
- statTreeID: "{{ $statTree->id }}"
|
|
|
- }, function (response) {
|
|
|
- if(!hasResponseError(response)) {
|
|
|
- // fastLoad("{{ route('practice-management.statTrees.view.edit', $statTree) }}");
|
|
|
- // need to fix this!
|
|
|
- showMask();
|
|
|
- window.top.location.reload();
|
|
|
- }
|
|
|
- }, 'json');
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $(document)
|
|
|
- .off('click', '.move-column-up')
|
|
|
- .on('click', '.move-column-up', function() {
|
|
|
- let columns = getSelectedNodeColumns();
|
|
|
- let index = +($(this).attr('data-index'));
|
|
|
- if(index > 0) {
|
|
|
- let x = columns[index - 1];
|
|
|
- columns[index - 1] = columns[index];
|
|
|
- columns[index] = x;
|
|
|
- }
|
|
|
- setSelectedNodeColumns(columns);
|
|
|
- onSelected();
|
|
|
- autoSaveChanges();
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $(document)
|
|
|
- .off('click', '.move-column-down')
|
|
|
- .on('click', '.move-column-down', function() {
|
|
|
- let columns = getSelectedNodeColumns();
|
|
|
- let index = +($(this).attr('data-index'));
|
|
|
- if(index < columns.length - 1) {
|
|
|
- let x = columns[index + 1];
|
|
|
- columns[index + 1] = columns[index];
|
|
|
- columns[index] = x;
|
|
|
- }
|
|
|
- setSelectedNodeColumns(columns);
|
|
|
- onSelected();
|
|
|
- autoSaveChanges();
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $(document)
|
|
|
- .off('click', '.remove-column')
|
|
|
- .on('click', '.remove-column', function() {
|
|
|
- let columns = getSelectedNodeColumns();
|
|
|
- columns.splice(+($(this).attr('data-index')), 1);
|
|
|
- setSelectedNodeColumns(columns);
|
|
|
- onSelected();
|
|
|
- autoSaveChanges();
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $(document)
|
|
|
- .off('click', '.clause-expand-all')
|
|
|
- .on('click', '.clause-expand-all', function() {
|
|
|
- $('#clauses-view-{{$statTree->id}}').jstree('open_all');
|
|
|
- return false;
|
|
|
- });
|
|
|
- $(document)
|
|
|
- .off('click', '.clause-collapse-all')
|
|
|
- .on('click', '.clause-collapse-all', function() {
|
|
|
- $('#clauses-view-{{$statTree->id}}').jstree('close_all');
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $(document)
|
|
|
- .off('click', '.tree-expand-all')
|
|
|
- .on('click', '.tree-expand-all', function() {
|
|
|
- $('#stat-tree-view-{{$statTree->id}}').jstree('open_all');
|
|
|
- return false;
|
|
|
- });
|
|
|
- $(document)
|
|
|
- .off('click', '.tree-collapse-all')
|
|
|
- .on('click', '.tree-collapse-all', function() {
|
|
|
- $('#stat-tree-view-{{$statTree->id}}').jstree('close_all');
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- initMoes();
|
|
|
|
|
|
- }
|
|
|
- addMCInitializer('stat-tree-edit-page', init, '#statTreeEdit')
|
|
|
- }).call(window);
|
|
|
- </script>
|
|
|
+ // fill columns
|
|
|
+ tbody = linePropsColumn.find('[line-columns]');
|
|
|
+ let columns = StatTree.getSelectedNodeColumns();
|
|
|
+ tbody.empty();
|
|
|
+ if(columns && columns.length) {
|
|
|
+ for (let i = 0; i < columns.length; i++) {
|
|
|
+ $('<tr/>')
|
|
|
+ .append($('<td/>').text(i + 1))
|
|
|
+ .append($('<td/>').text(columns[i].label))
|
|
|
+ .append($('<td/>').text(columns[i].display_key))
|
|
|
+ .append(
|
|
|
+ $('<td/>')
|
|
|
+ .addClass('text-right text-nowrap')
|
|
|
+ .append(i > 0 ? '<a href="#" class="move-column-up mr-2" data-index="' + i + '"><i class="fa fa-arrow-up text-primary on-hover-opaque"></i></a>': '')
|
|
|
+ .append(i < columns.length - 1 ? '<a href="#" class="move-column-down mr-2" data-index="' + i + '"><i class="fa fa-arrow-down text-primary on-hover-opaque"></i></a>': '')
|
|
|
+ .append('<a href="#" class="remove-column" data-index="' + i + '"><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>')
|
|
|
+ )
|
|
|
+ .appendTo(tbody);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ initMoes();
|
|
|
+
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ linePropsColumn.find('input[stag-suggest][name="displayKey"]')
|
|
|
+ .off('stag-suggest-selected')
|
|
|
+ .on('stag-suggest-selected', (_e, _input, _data) => {
|
|
|
+ let columns = StatTree.getSelectedNodeColumns();
|
|
|
+ columns.push({
|
|
|
+ label: _data.label,
|
|
|
+ display_key: _data.text
|
|
|
+ });
|
|
|
+ $(_input).val('').focus();
|
|
|
+ StatTree.setSelectedNodeColumns(columns);
|
|
|
+ StatTree.onSelected();
|
|
|
+ StatTree.setDirty();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.move-column-up')
|
|
|
+ .on('click', '.move-column-up', function() {
|
|
|
+ let columns = StatTree.getSelectedNodeColumns();
|
|
|
+ let index = +($(this).attr('data-index'));
|
|
|
+ if(index > 0) {
|
|
|
+ let x = columns[index - 1];
|
|
|
+ columns[index - 1] = columns[index];
|
|
|
+ columns[index] = x;
|
|
|
+ }
|
|
|
+ StatTree.setSelectedNodeColumns(columns);
|
|
|
+ StatTree.onSelected();
|
|
|
+ StatTree.setDirty();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.move-column-down')
|
|
|
+ .on('click', '.move-column-down', function() {
|
|
|
+ let columns = StatTree.getSelectedNodeColumns();
|
|
|
+ let index = +($(this).attr('data-index'));
|
|
|
+ if(index < columns.length - 1) {
|
|
|
+ let x = columns[index + 1];
|
|
|
+ columns[index + 1] = columns[index];
|
|
|
+ columns[index] = x;
|
|
|
+ }
|
|
|
+ StatTree.setSelectedNodeColumns(columns);
|
|
|
+ StatTree.onSelected();
|
|
|
+ StatTree.setDirty();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.remove-column')
|
|
|
+ .on('click', '.remove-column', function() {
|
|
|
+ let columns = StatTree.getSelectedNodeColumns();
|
|
|
+ columns.splice(+($(this).attr('data-index')), 1);
|
|
|
+ StatTree.setSelectedNodeColumns(columns);
|
|
|
+ StatTree.onSelected();
|
|
|
+ StatTree.setDirty();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.edit-arg-value')
|
|
|
+ .on('click', '.edit-arg-value', function() {
|
|
|
+ let args = StatTree.getSelectedNodeClauseArgs();
|
|
|
+ let value = window.prompt('New value:', args[+($(this).attr('data-index'))].default_value || '');
|
|
|
+ if(value !== null) {
|
|
|
+ args[+($(this).attr('data-index'))].default_value = value;
|
|
|
+ StatTree.onSelected();
|
|
|
+ StatTree.setDirty();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.edit-arg-access-level')
|
|
|
+ .on('click', '.edit-arg-access-level', function() {
|
|
|
+ let args = StatTree.getSelectedNodeClauseArgs();
|
|
|
+ let accessLevel = window.prompt('New access level (USER, PRO or ADMIN):', args[+($(this).attr('data-index'))].access_level || '');
|
|
|
+ if(accessLevel !== null) {
|
|
|
+ args[+($(this).attr('data-index'))].access_level = accessLevel;
|
|
|
+ StatTree.onSelected();
|
|
|
+ StatTree.setDirty();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
|
|
|
+ $(document)
|
|
|
+ .off('click', '.clause-expand-all')
|
|
|
+ .on('click', '.clause-expand-all', function() {
|
|
|
+ $('#clauses-view-{{$statTree->id}}').jstree('open_all');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ $(document)
|
|
|
+ .off('click', '.clause-collapse-all')
|
|
|
+ .on('click', '.clause-collapse-all', function() {
|
|
|
+ $('#clauses-view-{{$statTree->id}}').jstree('close_all');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.tree-expand-all')
|
|
|
+ .on('click', '.tree-expand-all', function() {
|
|
|
+ $('#stat-tree-edit-{{$statTree->id}}').jstree('open_all');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ $(document)
|
|
|
+ .off('click', '.tree-collapse-all')
|
|
|
+ .on('click', '.tree-collapse-all', function() {
|
|
|
+ $('#stat-tree-edit-{{$statTree->id}}').jstree('close_all');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '#btn-save-tree')
|
|
|
+ .on('click', '#btn-save-tree', function() {
|
|
|
+ StatTree.save();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click', '.log-tree')
|
|
|
+ .on('click', '.log-tree', function() {
|
|
|
+ StatTree.log();
|
|
|
+ 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() {
|
|
|
+ let form = $(this).closest('.frm-clause-add-edit');
|
|
|
+ let label = $.trim(form.find('input[name="question"]').val()) + ' ' +
|
|
|
+ $.trim(form.find('input[name="answer"]').val());
|
|
|
+ form.find('input[name="label"]').val(label);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#refresh-counts')
|
|
|
+ .off('click')
|
|
|
+ .on('click', function() {
|
|
|
+ if(StatTree.changed) {
|
|
|
+ window.alert('Cannot refresh counts while the tree has unsaved changes.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ showMask();
|
|
|
+ $.post("{{ route('practice-management.api.statTree.refreshTreeCountQueries') }}", {
|
|
|
+ statTreeID: "{{ $statTree->id }}"
|
|
|
+ }, function (response) {
|
|
|
+ if(!hasResponseError(response)) {
|
|
|
+ fastReload();
|
|
|
+ }
|
|
|
+ }, 'json').then(hideMask);
|
|
|
+ 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();
|
|
|
+
|
|
|
+ addMCHook('reloadClausesTree', function() {
|
|
|
+ ClausesTree.load();
|
|
|
+ });
|
|
|
+
|
|
|
+ initVSplitter('stat-tree-edit-1', $('.clauses-column'), $('.tree-column'));
|
|
|
+ @if(!$multiProView)
|
|
|
+ initVSplitter('stat-tree-edit-2', $('.tree-lhs-column'), $('.tree-rhs-column'));
|
|
|
+ @endif
|
|
|
+
|
|
|
+ }
|
|
|
+ addMCInitializer('stat-tree-edit-page', init, '#statTreeEdit-{{$statTree->id}}');
|
|
|
+ }).call(window);
|
|
|
+ </script>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
@endsection
|