add element pdf path
This commit is contained in:
parent
6c6b3ad257
commit
cc1735ee7b
13 changed files with 76 additions and 0 deletions
|
|
@ -47,6 +47,7 @@ class ElementController
|
|||
'title' => $element->getTitle(),
|
||||
'description' => $element->getDescription(),
|
||||
'richText' => $element->getRichText(),
|
||||
'pdfPath' => $element->getPdfPath(),
|
||||
],
|
||||
], 200);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class CreateElementDto
|
|||
public string $title,
|
||||
public string $description,
|
||||
public string $richText,
|
||||
public ?string $pdfPath,
|
||||
public ?Element $parentElement,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class Element
|
|||
private string $title,
|
||||
private string $description,
|
||||
private string $richText,
|
||||
private ?string $pdfPath,
|
||||
private Set $set,
|
||||
private ?Element $parentElement,
|
||||
) {
|
||||
|
|
@ -36,6 +37,11 @@ class Element
|
|||
return $this->richText;
|
||||
}
|
||||
|
||||
public function getPdfPath(): ?string
|
||||
{
|
||||
return $this->pdfPath;
|
||||
}
|
||||
|
||||
public function getSet(): Set
|
||||
{
|
||||
return $this->set;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property string $title
|
||||
* @property string $description
|
||||
* @property string $rich_text
|
||||
* @property string|null $pdf_path
|
||||
* @property int|null $parent_element_id
|
||||
*
|
||||
* @method static Builder<static>|ElementModel newModelQuery()
|
||||
|
|
@ -22,6 +23,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static Builder<static>|ElementModel whereTitle($value)
|
||||
* @method static Builder<static>|ElementModel whereDescription($value)
|
||||
* @method static Builder<static>|ElementModel whereRichText($value)
|
||||
* @method static Builder<static>|ElementModel wherePdfPath($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
|
@ -36,6 +38,7 @@ class ElementModel extends Model
|
|||
'title',
|
||||
'description',
|
||||
'rich_text',
|
||||
'pdf_path',
|
||||
'parent_element_id',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
'title' => $dto->title,
|
||||
'description' => $dto->description,
|
||||
'rich_text' => $dto->richText,
|
||||
'pdf_path' => $dto->pdfPath,
|
||||
'parent_element_id' => $dto->parentElement?->getId(),
|
||||
]);
|
||||
|
||||
|
|
@ -27,6 +28,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
title: $dto->title,
|
||||
description: $dto->description,
|
||||
richText: $dto->richText,
|
||||
pdfPath: $dto->pdfPath,
|
||||
set: $dto->set,
|
||||
parentElement: $dto->parentElement,
|
||||
);
|
||||
|
|
@ -108,6 +110,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
title: $model->title,
|
||||
description: $model->description,
|
||||
richText: $model->rich_text,
|
||||
pdfPath: $model->pdf_path,
|
||||
set: $set,
|
||||
parentElement: $parentElement,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class CreateElement
|
|||
}
|
||||
$description = $request->description ?? '';
|
||||
$richText = $request->richText ?? '';
|
||||
$pdfPath = $request->pdfPath === '' ? null : $request->pdfPath;
|
||||
|
||||
$set = $this->setRepo->find($request->setId);
|
||||
if ($set === null) {
|
||||
|
|
@ -48,6 +49,7 @@ class CreateElement
|
|||
title: $request->title,
|
||||
description: $description,
|
||||
richText: $richText,
|
||||
pdfPath: $pdfPath,
|
||||
parentElement: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -71,6 +73,7 @@ class CreateElement
|
|||
title: $request->title,
|
||||
description: $description,
|
||||
richText: $richText,
|
||||
pdfPath: $pdfPath,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class CreateElementRequest
|
|||
public ?string $title,
|
||||
public ?string $description,
|
||||
public ?string $richText,
|
||||
public ?string $pdfPath,
|
||||
public ?int $parentElementId,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ return new class extends Migration
|
|||
$table->string('title');
|
||||
$table->text('description')->default('');
|
||||
$table->text('rich_text')->default('');
|
||||
$table->string('pdf_path')->nullable();
|
||||
$table->foreignId('parent_element_id')
|
||||
->nullable()
|
||||
->constrained('elements');
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class ElementSeeder extends Seeder
|
|||
richText: '<p>Begin with a clear map for avodah growth.</p>'
|
||||
. '<p><strong>Move steadily</strong> from awareness '
|
||||
. 'to practice.</p>',
|
||||
pdfPath: '/assets/pdfs/baderech.pdf',
|
||||
parentElement: null,
|
||||
));
|
||||
$elementRepository->create(new CreateElementDto(
|
||||
|
|
@ -30,6 +31,7 @@ class ElementSeeder extends Seeder
|
|||
. 'avodah practice.',
|
||||
richText: '<p>Avodah foundations begin with honest awareness '
|
||||
. 'and small repeatable steps.</p>',
|
||||
pdfPath: null,
|
||||
parentElement: $rootElement,
|
||||
));
|
||||
$elementRepository->create(new CreateElementDto(
|
||||
|
|
@ -38,6 +40,7 @@ class ElementSeeder extends Seeder
|
|||
description: 'Practical steps for consistent daily growth.',
|
||||
richText: '<p>Daily practice turns inspiration into a '
|
||||
. 'dependable rhythm.</p>',
|
||||
pdfPath: null,
|
||||
parentElement: $rootElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class FakeElementRepository implements ElementRepository
|
|||
title: $dto->title,
|
||||
description: $dto->description,
|
||||
richText: $dto->richText,
|
||||
pdfPath: $dto->pdfPath,
|
||||
set: $dto->set,
|
||||
parentElement: $dto->parentElement,
|
||||
);
|
||||
|
|
@ -99,6 +100,7 @@ class FakeElementRepository implements ElementRepository
|
|||
title: $element->getTitle(),
|
||||
description: $element->getDescription(),
|
||||
richText: $element->getRichText(),
|
||||
pdfPath: $element->getPdfPath(),
|
||||
set: $element->getSet(),
|
||||
parentElement: $parentElement,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SetsEndpointTest extends TestCase
|
|||
title: $baderechSet->getName(),
|
||||
description: $baderechSet->getDescription(),
|
||||
richText: '',
|
||||
pdfPath: null,
|
||||
parentElement: null,
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export interface ChildElement {
|
|||
|
||||
export interface Element extends ChildElement {
|
||||
richText: string
|
||||
pdfPath: string | null
|
||||
}
|
||||
|
||||
interface ElementResponse {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,18 @@ watch(
|
|||
v-html="element.richText"
|
||||
/>
|
||||
|
||||
<div v-if="element.pdfPath !== null" class="element-page__actions">
|
||||
<a
|
||||
:href="element.pdfPath"
|
||||
class="element-page__pdf-link"
|
||||
data-cy="element-pdf-link"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
View PDF
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<nav
|
||||
v-if="childElements.length > 0"
|
||||
class="element-page__children"
|
||||
|
|
@ -137,6 +149,44 @@ watch(
|
|||
font-weight: 700;
|
||||
}
|
||||
|
||||
.element-page__actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 1.75rem;
|
||||
}
|
||||
|
||||
.element-page__pdf-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 2.75rem;
|
||||
padding: 0.7rem 1.15rem;
|
||||
color: var(--color-white);
|
||||
background: var(--color-olive);
|
||||
border-radius: 8px;
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
text-decoration: none;
|
||||
transition:
|
||||
background-color 180ms ease,
|
||||
box-shadow 180ms ease,
|
||||
transform 180ms ease;
|
||||
}
|
||||
|
||||
.element-page__pdf-link:hover,
|
||||
.element-page__pdf-link:focus-visible {
|
||||
background: #4d5b3c;
|
||||
box-shadow: 0 10px 24px rgb(44 44 44 / 12%);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.element-page__pdf-link:focus-visible {
|
||||
outline: 3px solid rgb(94 107 76 / 38%);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
.element-page__children {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue