Compare commits
No commits in common. "2e87add96c61c82db9c7c74bc137ef97bef9b004" and "070722e01358e92264dda055a89982a2890452bd" have entirely different histories.
2e87add96c
...
070722e013
12 changed files with 25 additions and 202 deletions
|
|
@ -20,13 +20,6 @@ guides (`backend-context.md`, `frontend-context.md`) extend these.
|
||||||
batch multiple behaviors into one failing-test commit and one
|
batch multiple behaviors into one failing-test commit and one
|
||||||
implementation commit when they can be reviewed separately.
|
implementation commit when they can be reviewed separately.
|
||||||
|
|
||||||
## Runtime assumptions
|
|
||||||
|
|
||||||
- Assume every process defined in `process-compose.yml` is already running
|
|
||||||
for local development and verification unless a command proves otherwise.
|
|
||||||
Do not start duplicate PostgreSQL, backend, or frontend processes just to
|
|
||||||
run checks.
|
|
||||||
|
|
||||||
## Code style
|
## Code style
|
||||||
|
|
||||||
- Lines should not exceed 80 columns, but should use up to 80 columns when
|
- Lines should not exceed 80 columns, but should use up to 80 columns when
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,14 @@
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Element\ElementRepository;
|
|
||||||
use App\Set\Set as DomainSet;
|
use App\Set\Set as DomainSet;
|
||||||
use App\Set\SetRepository;
|
use App\Set\SetRepository;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
class SetController
|
class SetController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(private SetRepository $setRepository)
|
||||||
private SetRepository $setRepository,
|
{
|
||||||
private ElementRepository $elementRepository,
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(): JsonResponse
|
public function index(): JsonResponse
|
||||||
|
|
@ -32,20 +29,16 @@ class SetController
|
||||||
* id: int,
|
* id: int,
|
||||||
* name: string,
|
* name: string,
|
||||||
* description: string,
|
* description: string,
|
||||||
* iconImageUrl: string,
|
* iconImageUrl: string
|
||||||
* rootElementId: int|null
|
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
private function buildSetPayload(DomainSet $set): array
|
private function buildSetPayload(DomainSet $set): array
|
||||||
{
|
{
|
||||||
$rootElement = $this->elementRepository->findRootBySet($set);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $set->getId(),
|
'id' => $set->getId(),
|
||||||
'name' => $set->getName(),
|
'name' => $set->getName(),
|
||||||
'description' => $set->getDescription(),
|
'description' => $set->getDescription(),
|
||||||
'iconImageUrl' => $set->getIconImageUrl(),
|
'iconImageUrl' => $set->getIconImageUrl(),
|
||||||
'rootElementId' => $rootElement?->getId(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ interface ElementRepository
|
||||||
|
|
||||||
public function find(int $id): ?Element;
|
public function find(int $id): ?Element;
|
||||||
|
|
||||||
public function findRootBySet(DomainSet $set): ?Element;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Element[]
|
* @return Element[]
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -35,16 +35,6 @@ class EloquentElementRepository implements ElementRepository
|
||||||
return $model === null ? null : $this->toDomain($model);
|
return $model === null ? null : $this->toDomain($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findRootBySet(DomainSet $set): ?Element
|
|
||||||
{
|
|
||||||
$model = ElementModel::where('set_id', $set->getId())
|
|
||||||
->whereNull('parent_element_id')
|
|
||||||
->orderBy('id')
|
|
||||||
->first();
|
|
||||||
|
|
||||||
return $model === null ? null : $this->toDomain($model);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Element[]
|
* @return Element[]
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,14 @@ class SetSeeder extends Seeder
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$setRepository = app(SetRepository::class);
|
$setRepository = app(SetRepository::class);
|
||||||
$baderechTitle = 'Baderech HaAvodah';
|
$title = 'Baderech HaAvodah';
|
||||||
|
|
||||||
$setRepository->create(new CreateSetDto(
|
$set = $setRepository->create(new CreateSetDto(
|
||||||
name: $baderechTitle,
|
name: $title,
|
||||||
description: 'Baderech HaAvodah is a way of living - '
|
description: 'Baderech HaAvodah is a way of living - '
|
||||||
. 'a structured path for inner and outer growth, '
|
. 'a structured path for inner and outer growth, '
|
||||||
. 'spiritual refinement, and personal development.',
|
. 'spiritual refinement, and personal development.',
|
||||||
iconImageUrl: '/assets/baderech-haavodah-icon.png',
|
iconImageUrl: '/assets/baderech-haavodah-icon.png',
|
||||||
));
|
));
|
||||||
$setRepository->create(new CreateSetDto(
|
|
||||||
name: 'Daily Learning',
|
|
||||||
description: 'Daily learning for steady growth',
|
|
||||||
iconImageUrl: '/assets/daily-learning-icon.svg',
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,20 +37,6 @@ class FakeElementRepository implements ElementRepository
|
||||||
return $this->cloneElement($this->elementsById[$id]);
|
return $this->cloneElement($this->elementsById[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findRootBySet(DomainSet $set): ?Element
|
|
||||||
{
|
|
||||||
foreach ($this->elementsById as $element) {
|
|
||||||
if (
|
|
||||||
$element->getSet()->getId() === $set->getId()
|
|
||||||
&& $element->getParentElement() === null
|
|
||||||
) {
|
|
||||||
return $this->cloneElement($element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Element[]
|
* @return Element[]
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Element\CreateElementDto;
|
|
||||||
use App\Element\ElementRepository;
|
|
||||||
use App\Set\CreateSetDto;
|
use App\Set\CreateSetDto;
|
||||||
use App\Set\SetRepository;
|
use App\Set\SetRepository;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
@ -16,7 +14,6 @@ class SetsEndpointTest extends TestCase
|
||||||
public function testReturnsAllSets(): void
|
public function testReturnsAllSets(): void
|
||||||
{
|
{
|
||||||
$setRepository = app(SetRepository::class);
|
$setRepository = app(SetRepository::class);
|
||||||
$elementRepository = app(ElementRepository::class);
|
|
||||||
$baderechSet = $setRepository->create(new CreateSetDto(
|
$baderechSet = $setRepository->create(new CreateSetDto(
|
||||||
name: 'Baderech HaAvodah',
|
name: 'Baderech HaAvodah',
|
||||||
description: 'Baderech HaAvodah is a way of living',
|
description: 'Baderech HaAvodah is a way of living',
|
||||||
|
|
@ -27,13 +24,6 @@ class SetsEndpointTest extends TestCase
|
||||||
description: 'Daily learning for steady growth',
|
description: 'Daily learning for steady growth',
|
||||||
iconImageUrl: '/assets/daily-learning-icon.svg',
|
iconImageUrl: '/assets/daily-learning-icon.svg',
|
||||||
));
|
));
|
||||||
$baderechRootElement = $elementRepository->create(
|
|
||||||
new CreateElementDto(
|
|
||||||
set: $baderechSet,
|
|
||||||
title: $baderechSet->getName(),
|
|
||||||
parentElement: null,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$response = $this->getJson('/api/sets');
|
$response = $this->getJson('/api/sets');
|
||||||
|
|
||||||
|
|
@ -45,14 +35,12 @@ class SetsEndpointTest extends TestCase
|
||||||
'name' => $baderechSet->getName(),
|
'name' => $baderechSet->getName(),
|
||||||
'description' => $baderechSet->getDescription(),
|
'description' => $baderechSet->getDescription(),
|
||||||
'iconImageUrl' => $baderechSet->getIconImageUrl(),
|
'iconImageUrl' => $baderechSet->getIconImageUrl(),
|
||||||
'rootElementId' => $baderechRootElement->getId(),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => $dailyLearningSet->getId(),
|
'id' => $dailyLearningSet->getId(),
|
||||||
'name' => $dailyLearningSet->getName(),
|
'name' => $dailyLearningSet->getName(),
|
||||||
'description' => $dailyLearningSet->getDescription(),
|
'description' => $dailyLearningSet->getDescription(),
|
||||||
'iconImageUrl' => $dailyLearningSet->getIconImageUrl(),
|
'iconImageUrl' => $dailyLearningSet->getIconImageUrl(),
|
||||||
'rootElementId' => null,
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,8 @@ describe('media page sets', () => {
|
||||||
cy.contains('h1', 'Torah Media').should('be.visible')
|
cy.contains('h1', 'Torah Media').should('be.visible')
|
||||||
cy.get('[data-cy="media-set-grid"]').should('be.visible')
|
cy.get('[data-cy="media-set-grid"]').should('be.visible')
|
||||||
cy.get('[data-cy="media-set-card"]', { timeout: 10000 })
|
cy.get('[data-cy="media-set-card"]', { timeout: 10000 })
|
||||||
.should('have.length', 2)
|
.should('have.length', 1)
|
||||||
|
.first()
|
||||||
cy.contains('[data-cy="media-set-card"]', 'Baderech HaAvodah')
|
|
||||||
.as('baderechCard')
|
|
||||||
.should('have.attr', 'href', '/element/1')
|
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.get('img[data-cy="media-set-icon"]')
|
cy.get('img[data-cy="media-set-icon"]')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
|
|
@ -25,21 +22,5 @@ describe('media page sets', () => {
|
||||||
cy.contains('a structured path for inner and outer growth')
|
cy.contains('a structured path for inner and outer growth')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
})
|
})
|
||||||
|
|
||||||
cy.contains('[data-cy="media-set-card"]', 'Daily Learning')
|
|
||||||
.as('dailyLearningCard')
|
|
||||||
.should('match', 'article')
|
|
||||||
.and('not.have.attr', 'href')
|
|
||||||
|
|
||||||
cy.get('@dailyLearningCard')
|
|
||||||
.within(() => {
|
|
||||||
cy.contains('h2', 'Daily Learning').should('be.visible')
|
|
||||||
cy.contains('Daily learning for steady growth').should('be.visible')
|
|
||||||
})
|
|
||||||
|
|
||||||
cy.get('@baderechCard').click()
|
|
||||||
cy.location('pathname').should('eq', '/element/1')
|
|
||||||
cy.get('[data-cy="element-page"]').should('be.visible')
|
|
||||||
cy.contains('h1', 'Element 1').should('be.visible')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import HomePage from '@/views/HomePage.vue'
|
import HomePage from '@/views/HomePage.vue'
|
||||||
import LoginPage from '@/views/LoginPage.vue'
|
import LoginPage from '@/views/LoginPage.vue'
|
||||||
import MediaPage from '@/views/MediaPage.vue'
|
import MediaPage from '@/views/MediaPage.vue'
|
||||||
import ElementPage from '@/views/ElementPage.vue'
|
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
|
|
@ -22,11 +21,6 @@ const router = createRouter({
|
||||||
name: 'media',
|
name: 'media',
|
||||||
component: MediaPage,
|
component: MediaPage,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/element/:id',
|
|
||||||
name: 'element',
|
|
||||||
component: ElementPage,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ export interface MediaSet {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
iconImageUrl: string
|
iconImageUrl: string
|
||||||
rootElementId: number | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SetsResponse {
|
interface SetsResponse {
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed } from 'vue'
|
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import SiteHeader from '@/components/SiteHeader.vue'
|
|
||||||
|
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
const elementId = computed(() => {
|
|
||||||
const routeElementId = route.params.id
|
|
||||||
|
|
||||||
if (Array.isArray(routeElementId)) {
|
|
||||||
return routeElementId.join('/')
|
|
||||||
}
|
|
||||||
|
|
||||||
return routeElementId
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="element-page">
|
|
||||||
<SiteHeader />
|
|
||||||
<main class="element-page__main" data-cy="element-page">
|
|
||||||
<h1 class="element-page__heading">Element {{ elementId }}</h1>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.element-page {
|
|
||||||
min-height: 100vh;
|
|
||||||
background: var(--color-white);
|
|
||||||
}
|
|
||||||
|
|
||||||
.element-page__main {
|
|
||||||
min-height: 100vh;
|
|
||||||
padding: 5.1rem 4.15rem 5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.element-page__heading {
|
|
||||||
margin: 0;
|
|
||||||
color: #2c2c2c;
|
|
||||||
font-family: var(--font-serif);
|
|
||||||
font-size: clamp(2.6rem, 4.8vw, 3.2rem);
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 1.1;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.element-page__main {
|
|
||||||
padding: 3rem 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -33,41 +33,23 @@ onMounted(() => {
|
||||||
No media sets are available yet.
|
No media sets are available yet.
|
||||||
</p>
|
</p>
|
||||||
<div v-else class="media-page__grid" data-cy="media-set-grid">
|
<div v-else class="media-page__grid" data-cy="media-set-grid">
|
||||||
<template v-for="mediaSet in sets" :key="mediaSet.id">
|
<article
|
||||||
<RouterLink
|
v-for="mediaSet in sets"
|
||||||
v-if="mediaSet.rootElementId !== null"
|
:key="mediaSet.id"
|
||||||
:to="{ name: 'element', params: { id: mediaSet.rootElementId } }"
|
class="media-page__card"
|
||||||
class="media-page__card"
|
data-cy="media-set-card"
|
||||||
data-cy="media-set-card"
|
>
|
||||||
>
|
<img
|
||||||
<img
|
:src="mediaSet.iconImageUrl"
|
||||||
:src="mediaSet.iconImageUrl"
|
:alt="`${mediaSet.name} icon`"
|
||||||
:alt="`${mediaSet.name} icon`"
|
class="media-page__card-icon"
|
||||||
class="media-page__card-icon"
|
data-cy="media-set-icon"
|
||||||
data-cy="media-set-icon"
|
/>
|
||||||
/>
|
<h2 class="media-page__card-title">{{ mediaSet.name }}</h2>
|
||||||
<h2 class="media-page__card-title">{{ mediaSet.name }}</h2>
|
<p class="media-page__card-description">
|
||||||
<p class="media-page__card-description">
|
{{ mediaSet.description }}
|
||||||
{{ mediaSet.description }}
|
</p>
|
||||||
</p>
|
</article>
|
||||||
</RouterLink>
|
|
||||||
<article
|
|
||||||
v-else
|
|
||||||
class="media-page__card media-page__card--disabled"
|
|
||||||
data-cy="media-set-card"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
:src="mediaSet.iconImageUrl"
|
|
||||||
:alt="`${mediaSet.name} icon`"
|
|
||||||
class="media-page__card-icon"
|
|
||||||
data-cy="media-set-icon"
|
|
||||||
/>
|
|
||||||
<h2 class="media-page__card-title">{{ mediaSet.name }}</h2>
|
|
||||||
<p class="media-page__card-description">
|
|
||||||
{{ mediaSet.description }}
|
|
||||||
</p>
|
|
||||||
</article>
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
@ -132,29 +114,7 @@ onMounted(() => {
|
||||||
background: var(--color-white);
|
background: var(--color-white);
|
||||||
border: 1px solid #e5cf9f;
|
border: 1px solid #e5cf9f;
|
||||||
border-radius: 17px;
|
border-radius: 17px;
|
||||||
color: inherit;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
text-decoration: none;
|
|
||||||
transition:
|
|
||||||
border-color 180ms ease,
|
|
||||||
box-shadow 180ms ease,
|
|
||||||
transform 180ms ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.media-page__card:hover,
|
|
||||||
a.media-page__card:focus-visible {
|
|
||||||
border-color: #d4ad5f;
|
|
||||||
box-shadow: 0 14px 35px rgb(44 44 44 / 10%);
|
|
||||||
transform: translateY(-2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
a.media-page__card:focus-visible {
|
|
||||||
outline: 3px solid rgb(212 173 95 / 45%);
|
|
||||||
outline-offset: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.media-page__card--disabled {
|
|
||||||
opacity: 0.72;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-page__card-icon {
|
.media-page__card-icon {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue