Explorar el Código

Links to TL single in sub-entity listing

Vijayakrishnan Krishnan hace 5 años
padre
commit
760a2b64e5

+ 25 - 1
app/Console/Commands/GenerateTreeCommand.php

@@ -66,6 +66,13 @@ class GenerateTreeCommand extends Command
                 $ls = $this->numLS($line);
                 $line = trim($line);
 
+                $exitURL = false;
+                if(strpos($line, "=>") !== FALSE) {
+                    $parts = explode("=>", $line);
+                    $exitURL = str_replace("UID", "{{ \$subRecord->uid }}", $parts[1]);
+                    $line = $parts[0];
+                }
+
                 $tokens = explode("|", $line);
                 $line = $tokens[0];
                 $dbTable = null;
@@ -194,6 +201,14 @@ class GenerateTreeCommand extends Command
                     case 16: // data for actions and subs
                         if(!empty($currentMethod)) {
                             $currentMethod->data[] = $line;
+                            if($exitURL) {
+                                if(strpos("=", $line) !== FALSE) {
+                                    $currentMethod->viewURL = $exitURL;
+                                }
+                                else {
+                                    $currentMethod->exitURL = $exitURL;
+                                }
+                            }
                         }
                         break;
 
@@ -297,6 +312,7 @@ class GenController {
                 }
                 $newMethod->parentSub = $this->name . '-' . $method->name;
                 $newMethod->table = explode(":", $method->data[1])[1];
+                $newMethod->exitURL = $method->exitURL;
                 $newMethods[] = $newMethod;
                 $method->childAddRoute = $this->name . '-' . $methodName;
             }
@@ -541,7 +557,11 @@ class GenController {
         $tds = [];
         foreach ($columns as $column) {
             $ths[] = "<th>{$this->snakeToTitleCase($column)}</th>";
-            $tds[] = "<td><?= \$subRecord->$column ?></td>";
+            $tds[] = "<td>" .
+                ($method->exitURL && $column === 'uid' ? '<a href="' . $method->exitURL . '">' : '') .
+                "<?= \$subRecord->$column ?>" .
+                ($method->exitURL && $column === 'uid' ? '</a>' : '') .
+                "</td>";
         }
         $text = str_replace("<!-- __SCAFFOLD_THS__ -->", implode("\n", $ths), $text);
         $text = str_replace("<!-- __SCAFFOLD_TDS__ -->", implode("\n", $tds), $text);
@@ -602,6 +622,8 @@ class GenController {
             $this->w('Rout: ' . $method->route, 1);
             $this->w('Meth: ' . $method->name . '($request' . ($method->hasUID ? ', $uid' : '') . ')', 1);
             if(!empty($method->data)) $this->w('Data: ' . implode(", ", $method->data), 1);
+            $this->w('Exit: ' . $method->exitURL, 1);
+            $this->w('View: ' . $method->viewURL, 1);
             if(!$method->redirect) {
                 $this->w('View: ' . resource_path("views/{$this->root}/{$this->name}/{$method->name}.blade.php"), 1);
             }
@@ -725,6 +747,8 @@ class GenControllerMethod {
     public $table = false;
     public $api = 'create';
     public $show = null;
+    public $viewURL = false;
+    public $exitURL = false;
     public function __construct($name, $route)
     {
         $this->name = $name;

+ 4 - 6
generatecv/tree.txt

@@ -158,18 +158,16 @@ PRO
             med_profile
             med_profile_log
             pro_access
-# :: also link to TL pro-access single
-                id=client_pro_access.client_id
-                add_new:client_pro_access
+                id=client_pro_access.client_id=>/pro_access/view/UID
+                add_new:client_pro_access=>/pro_access/view/UID
                     clientUid:hidden=uid
                     proUid:record:pro:uid,name_display
                     reasonCategory
                     reasonMemo
                     reasonDetail
             notes
-                id=note.client_id
-# :: exit to notes/view/{uid} - 207
-                add_new:note
+                id=note.client_id=>/notes/view/UID
+                add_new:note=>/notes/view/UID
                     clientUid:hidden=uid
                     hcpProUid:record:pro:uid,name_display
                     allyProUid:record:pro:uid,name_display

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_notes.blade.php

@@ -53,7 +53,7 @@
                         <td><?= $subRecord->id ?></td>
 <td><?= $subRecord->created_at ?></td>
 <td><?= $subRecord->type ?></td>
-<td><?= $subRecord->uid ?></td>
+<td><a href="/notes/view/{{ $subRecord->uid }}"><?= $subRecord->uid ?></a></td>
 <td><?= $subRecord->deactivated_at ?></td>
 <td><?= $subRecord->deactivation_memo ?></td>
 <td><?= $subRecord->is_active ?></td>

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_pro_access.blade.php

@@ -38,7 +38,7 @@
                         <td><?= $subRecord->id ?></td>
 <td><?= $subRecord->created_at ?></td>
 <td><?= $subRecord->type ?></td>
-<td><?= $subRecord->uid ?></td>
+<td><a href="/pro_access/view/{{ $subRecord->uid }}"><?= $subRecord->uid ?></a></td>
 <td><?= $subRecord->deactivated_at ?></td>
 <td><?= $subRecord->deactivation_memo ?></td>
 <td><?= $subRecord->is_active ?></td>