Selaa lähdekoodia

ClientTag - create & cancel UI

Vijayakrishnan 4 vuotta sitten
vanhempi
commit
30979f011c

+ 7 - 0
app/Models/Client.php

@@ -508,4 +508,11 @@ class Client extends Model
         return $this->hasOne(Pro::class, 'id', 'shadow_pro_id');
     }
 
+    public function clientTags()
+    {
+        return $this->hasMany(ClientTag::class, 'client_id', 'id')
+            ->where('is_cancelled', false)
+            ->orderBy('tag', 'asc');
+    }
+
 }

+ 14 - 0
app/Models/ClientTag.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasOne;
+use Illuminate\Support\Collection;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class ClientTag extends Model
+{
+    protected $table = 'client_tag';
+
+}

+ 13 - 0
resources/views/app/patients.blade.php

@@ -56,6 +56,7 @@
                     {{--<th class="border-0">RMM</th>--}}
                     <th class="border-0">Appointments</th>
                     <th class="border-0">Account</th>
+                    <th class="border-0">Tags</th>
                 </tr>
                 </thead>
                 <tbody>
@@ -188,6 +189,18 @@
                                 <span class="text-secondary">-</span>
                             @endif
                         </td>
+                        <td>
+                            @if($patient->tags)
+                                <?php
+                                $tags = explode("|", $patient->tags);
+                                $tags = array_filter($tags, function($_x) {
+                                    return !empty($_x);
+                                });
+                                $tags = implode(", ", $tags);
+                                ?>
+                                {{ $tags }}
+                            @endif
+                        </td>
                     </tr>
                 @endforeach
                 </tbody>

+ 35 - 0
resources/views/layouts/patient.blade.php

@@ -939,6 +939,41 @@
                             </div>
                         </div> <!-- z -->
                     </div>
+                    <div class="card-header py-1 d-flex align-items-center mcp-theme-1 bg-white">
+                        <b class="">Tags ({{count($patient->clientTags)}}):</b>
+                        @foreach($patient->clientTags as $tag)
+                            <div class="d-inline-flex align-items-center ml-2 py-1 px-2 rounded bg-aliceblue text-info">
+                                <span class="text-sm">{{$tag->tag}}</span>
+                                <div moe relative class="ml-2">
+                                    <a href="" start show><i class="fa fa-times text-danger"></i></a>
+                                    <form url="/api/clientTag/cancel" class="mcp-theme-1 min-width-200px">
+                                        <input type="hidden" name="uid" value="{{$tag->uid}}">
+                                        <p class="text-nowrap text-dark">Cancel this tag?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            </div>
+                        @endforeach
+                        <div moe relative class="ml-2">
+                            <a href="" start show class="btn btn-sm btn-primary py-1 text-sm text-white">+ Add</a>
+                            <form url="/api/clientTag/create" class="mcp-theme-1">
+                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                <div class="mb-2">
+                                    <label class="text-secondary text-sm">Tag</label>
+                                    <input type="text" class="form-control form-control-sm"
+                                           name="tag"
+                                           placeholder="Tag" required>
+                                </div>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    </div>
                     {{--<div class="text-container border-bottom d-flex align-items-center mcp-theme-1 px-3">
 
                         @if($patient->mcp_pro_id !== $pro->id && $patient->active_mcp_request_id)