Add children flag in parent field data response

This commit is contained in:
Andy Miller
2020-03-06 12:37:01 -07:00
parent 559e2adbf2
commit f127d28bcd

View File

@@ -2366,7 +2366,8 @@ class AdminController extends AdminBaseController
'extension' => '', 'extension' => '',
'type' => 'root', 'type' => 'root',
'modified' => $fileInfo->getMTime(), 'modified' => $fileInfo->getMTime(),
'size' => 0 'size' => 0,
'children' => false
]; ];
} else { } else {
continue; continue;
@@ -2376,6 +2377,9 @@ class AdminController extends AdminBaseController
$file_path = Utils::replaceFirstOccurrence(GRAV_ROOT, '', $filePath); $file_path = Utils::replaceFirstOccurrence(GRAV_ROOT, '', $filePath);
$type = $fileInfo->getType(); $type = $fileInfo->getType();
$child_path = $file_page ? GRAV_ROOT . $file_page->path() : $filePath;
$has_children = Folder::hasChildren($child_path);
$payload = [ $payload = [
'name' => $file_page ? $file_page->title() : $fileName, 'name' => $file_page ? $file_page->title() : $fileName,
'value' => $file_page ? $file_page->rawRoute() : $file_path, 'value' => $file_page ? $file_page->rawRoute() : $file_path,
@@ -2385,7 +2389,8 @@ class AdminController extends AdminBaseController
'type' => $type, 'type' => $type,
'modified' => $fileInfo->getMTime(), 'modified' => $fileInfo->getMTime(),
'size' => $fileInfo->getSize(), 'size' => $fileInfo->getSize(),
'symlink' => false 'symlink' => false,
'children' => $has_children
]; ];
} }