improve project dialog system
- project model : refactor getSteps() method - create dialog store - create DialogWrapper component that open the dialog corresponding to the URL query param
This commit is contained in:
parent
4e8c876dac
commit
26369ad71b
228 changed files with 451 additions and 525 deletions
|
|
@ -5,34 +5,57 @@ class ProjectPage extends Page {
|
|||
$steps = [];
|
||||
|
||||
foreach ($this->children() as $child) {
|
||||
$files = [];
|
||||
|
||||
if ($child->stepName() == 'clientBrief') {
|
||||
foreach ($child->moodboard()->toFiles() as $file) {
|
||||
$files[] = getFileData($file);
|
||||
}
|
||||
foreach ($child->pdf()->toFiles() as $file) {
|
||||
$files[] = getFileData($file);
|
||||
}
|
||||
}
|
||||
|
||||
$steps[] = [
|
||||
'text' => $child->title()->value(),
|
||||
'value' => $child->stepName()->value(),
|
||||
'index' => $child->stepIndex()->value(),
|
||||
'modified' => $child->modified('Y-MM-dd'),
|
||||
'uri' => $child->uri(),
|
||||
'files' => $files
|
||||
];
|
||||
$steps[] = $this->createStep($child);
|
||||
}
|
||||
|
||||
usort($steps, function ($a, $b) {
|
||||
return $a['index'] <=> $b['index'];
|
||||
});
|
||||
usort($steps, fn($a, $b) => $a['index'] <=> $b['index']);
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
private function createStep($child) {
|
||||
$files = [];
|
||||
$uri = null;
|
||||
|
||||
if ($child->stepName() == 'clientBrief') {
|
||||
$this->handleClientBriefStep($child, $files, $uri);
|
||||
}
|
||||
|
||||
if ($child->stepName() == 'virtualSample') {
|
||||
$this->handleVirtualSampleStep($child, $files, $uri);
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $child->title()->value(),
|
||||
'id' => $child->stepName()->value(),
|
||||
'index' => intval($child->stepIndex()->value()),
|
||||
'modified' => $child->modified('Y-MM-dd'),
|
||||
'uri' => $uri,
|
||||
'files' => $files,
|
||||
];
|
||||
}
|
||||
|
||||
private function handleClientBriefStep($child, &$files, &$uri) {
|
||||
if ($child->moodboard()->isNotEmpty()) {
|
||||
$uri = $child->uri();
|
||||
foreach ($child->moodboard()->toFiles() as $file) {
|
||||
$files[] = getFileData($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($child->pdf()->isNotEmpty()) {
|
||||
$uri = $child->parent()->uri() . '?dialog=' . $child->stepName()->value();
|
||||
$files[] = getFileData($child->pdf()->toFile());
|
||||
}
|
||||
}
|
||||
|
||||
private function handleVirtualSampleStep($child, &$files, &$uri) {
|
||||
$uri = $child->parent()->uri() . '?dialog=' . $child->stepName()->value();
|
||||
foreach ($child->views()->toFiles() as $file) {
|
||||
$files[] = getFileData($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function getStepLabel() {
|
||||
$stepsLabel = [
|
||||
"clientBrief" => "brief",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue