-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
layer design resource routes created and selecting a layer will displ…
…ay its designs which can be updated
- Loading branch information
Showing
21 changed files
with
467 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type IntentActionArgs } from '#app/definitions/intent-action-args' | ||
import { NewLayerDesignSchema } from '#app/schema/design-layer' | ||
import { ValidateLayerParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' | ||
import { validateEntitySubmission } from '#app/utils/conform-utils' | ||
|
||
export const validateLayerNewDesignSubmission = async ({ | ||
userId, | ||
formData, | ||
}: IntentActionArgs) => { | ||
const strategy = new ValidateLayerParentSubmissionStrategy() | ||
|
||
return await validateEntitySubmission({ | ||
userId, | ||
formData, | ||
schema: NewLayerDesignSchema, | ||
strategy, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type IntentActionArgs } from '#app/definitions/intent-action-args' | ||
import { DeleteLayerDesignSchema } from '#app/schema/design-layer' | ||
import { ValidateLayerParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' | ||
import { validateEntitySubmission } from '#app/utils/conform-utils' | ||
|
||
export const validateLayerDeleteDesignSubmission = async ({ | ||
userId, | ||
formData, | ||
}: IntentActionArgs) => { | ||
const strategy = new ValidateLayerParentSubmissionStrategy() | ||
|
||
return await validateEntitySubmission({ | ||
userId, | ||
formData, | ||
schema: DeleteLayerDesignSchema, | ||
strategy, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { type IntentActionArgs } from '#app/definitions/intent-action-args' | ||
import { | ||
ReorderLayerDesignSchema, | ||
ToggleVisibleLayerDesignSchema, | ||
} from '#app/schema/design-layer' | ||
import { ValidateLayerParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' | ||
import { validateEntitySubmission } from '#app/utils/conform-utils' | ||
|
||
export const validateLayerToggleVisibeDesignSubmission = async ({ | ||
userId, | ||
formData, | ||
}: IntentActionArgs) => { | ||
const strategy = new ValidateLayerParentSubmissionStrategy() | ||
|
||
return await validateEntitySubmission({ | ||
userId, | ||
formData, | ||
schema: ToggleVisibleLayerDesignSchema, | ||
strategy, | ||
}) | ||
} | ||
|
||
export const validateLayerReorderDesignSubmission = async ({ | ||
userId, | ||
formData, | ||
}: IntentActionArgs) => { | ||
const strategy = new ValidateLayerParentSubmissionStrategy() | ||
|
||
return await validateEntitySubmission({ | ||
userId, | ||
formData, | ||
schema: ReorderLayerDesignSchema, | ||
strategy, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
type LoaderFunctionArgs, | ||
json, | ||
type DataFunctionArgs, | ||
} from '@remix-run/node' | ||
import { redirectBack } from 'remix-utils/redirect-back' | ||
import { validateLayerNewDesignSubmission } from '#app/models/design-layer/design-layer.create.server' | ||
import { validateNoJS } from '#app/schema/form-data' | ||
import { layerDesignCreateService } from '#app/services/layer/design/create.service' | ||
import { requireUserId } from '#app/utils/auth.server' | ||
|
||
// https://www.epicweb.dev/full-stack-components | ||
|
||
export async function loader({ request }: LoaderFunctionArgs) { | ||
await requireUserId(request) | ||
return json({}) | ||
} | ||
|
||
export async function action({ request }: DataFunctionArgs) { | ||
const userId = await requireUserId(request) | ||
const formData = await request.formData() | ||
const noJS = validateNoJS({ formData }) | ||
|
||
let createSuccess = false | ||
const { status, submission } = await validateLayerNewDesignSubmission({ | ||
userId, | ||
formData, | ||
}) | ||
|
||
if (status === 'success') { | ||
const { success } = await layerDesignCreateService({ | ||
userId, | ||
...submission.value, | ||
}) | ||
createSuccess = success | ||
} | ||
|
||
if (noJS) { | ||
throw redirectBack(request, { | ||
fallback: '/', | ||
}) | ||
} | ||
|
||
return json( | ||
{ status, submission }, | ||
{ | ||
status: status === 'error' || !createSuccess ? 422 : 201, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
type LoaderFunctionArgs, | ||
json, | ||
type DataFunctionArgs, | ||
} from '@remix-run/node' | ||
import { redirectBack } from 'remix-utils/redirect-back' | ||
import { validateLayerDeleteDesignSubmission } from '#app/models/design-layer/design-layer.delete.server' | ||
import { validateNoJS } from '#app/schema/form-data' | ||
import { layerDesignDeleteService } from '#app/services/layer/design/delete.service' | ||
import { requireUserId } from '#app/utils/auth.server' | ||
|
||
// https://www.epicweb.dev/full-stack-components | ||
|
||
export async function loader({ request }: LoaderFunctionArgs) { | ||
await requireUserId(request) | ||
return json({}) | ||
} | ||
|
||
export async function action({ request }: DataFunctionArgs) { | ||
const userId = await requireUserId(request) | ||
const formData = await request.formData() | ||
const noJS = validateNoJS({ formData }) | ||
|
||
let deleteSuccess = false | ||
const { status, submission } = await validateLayerDeleteDesignSubmission({ | ||
userId, | ||
formData, | ||
}) | ||
|
||
if (status === 'success') { | ||
const { success } = await layerDesignDeleteService({ | ||
userId, | ||
...submission.value, | ||
}) | ||
deleteSuccess = success | ||
} | ||
|
||
if (noJS) { | ||
throw redirectBack(request, { | ||
fallback: '/', | ||
}) | ||
} | ||
|
||
return json( | ||
{ status, submission }, | ||
{ | ||
status: status === 'error' || !deleteSuccess ? 404 : 200, | ||
}, | ||
) | ||
} |
58 changes: 58 additions & 0 deletions
58
app/routes/resources+/api.v1+/layer.design.update.order.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
type LoaderFunctionArgs, | ||
json, | ||
type DataFunctionArgs, | ||
} from '@remix-run/node' | ||
import { redirectBack } from 'remix-utils/redirect-back' | ||
import { validateLayerReorderDesignSubmission } from '#app/models/design-layer/design-layer.update.server' | ||
import { validateNoJS } from '#app/schema/form-data' | ||
import { layerDesignMoveDownService } from '#app/services/layer/design/move-down.service' | ||
import { layerDesignMoveUpService } from '#app/services/layer/design/move-up.service' | ||
import { requireUserId } from '#app/utils/auth.server' | ||
|
||
// https://www.epicweb.dev/full-stack-components | ||
|
||
export async function loader({ request }: LoaderFunctionArgs) { | ||
await requireUserId(request) | ||
return json({}) | ||
} | ||
|
||
export async function action({ request }: DataFunctionArgs) { | ||
const userId = await requireUserId(request) | ||
const formData = await request.formData() | ||
const noJS = validateNoJS({ formData }) | ||
|
||
let updateSuccess = false | ||
const { status, submission } = await validateLayerReorderDesignSubmission({ | ||
userId, | ||
formData, | ||
}) | ||
|
||
if (status === 'success') { | ||
const { direction } = submission.value | ||
const { success } = | ||
direction === 'up' | ||
? await layerDesignMoveUpService({ | ||
userId, | ||
...submission.value, | ||
}) | ||
: await layerDesignMoveDownService({ | ||
userId, | ||
...submission.value, | ||
}) | ||
updateSuccess = success | ||
} | ||
|
||
if (noJS) { | ||
throw redirectBack(request, { | ||
fallback: '/', | ||
}) | ||
} | ||
|
||
return json( | ||
{ status, submission }, | ||
{ | ||
status: status === 'error' || !updateSuccess ? 404 : 200, | ||
}, | ||
) | ||
} |
51 changes: 51 additions & 0 deletions
51
app/routes/resources+/api.v1+/layer.design.update.visible.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
type LoaderFunctionArgs, | ||
json, | ||
type DataFunctionArgs, | ||
} from '@remix-run/node' | ||
import { redirectBack } from 'remix-utils/redirect-back' | ||
import { validateLayerToggleVisibeDesignSubmission } from '#app/models/design-layer/design-layer.update.server' | ||
import { validateNoJS } from '#app/schema/form-data' | ||
import { layerDesignToggleVisibleService } from '#app/services/layer/design/toggle-visible.service' | ||
import { requireUserId } from '#app/utils/auth.server' | ||
|
||
// https://www.epicweb.dev/full-stack-components | ||
|
||
export async function loader({ request }: LoaderFunctionArgs) { | ||
await requireUserId(request) | ||
return json({}) | ||
} | ||
|
||
export async function action({ request }: DataFunctionArgs) { | ||
const userId = await requireUserId(request) | ||
const formData = await request.formData() | ||
const noJS = validateNoJS({ formData }) | ||
|
||
let updateSuccess = false | ||
const { status, submission } = | ||
await validateLayerToggleVisibeDesignSubmission({ | ||
userId, | ||
formData, | ||
}) | ||
|
||
if (status === 'success') { | ||
const { success } = await layerDesignToggleVisibleService({ | ||
userId, | ||
...submission.value, | ||
}) | ||
updateSuccess = success | ||
} | ||
|
||
if (noJS) { | ||
throw redirectBack(request, { | ||
fallback: '/', | ||
}) | ||
} | ||
|
||
return json( | ||
{ status, submission }, | ||
{ | ||
status: status === 'error' || !updateSuccess ? 404 : 200, | ||
}, | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
...$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
...s+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.layer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type ILayerWithDesigns } from '#app/models/layer.server' | ||
import { DashboardPanelCreateLayerDesignTypeStrategy } from '#app/strategies/component/dashboard-panel/create-entity.strategy' | ||
import { DashboardPanelLayerDesignActionStrategy } from '#app/strategies/component/dashboard-panel/entity-action/entity-action' | ||
import { DashboardPanelUpdateLayerDesignTypeOrderStrategy } from '#app/strategies/component/dashboard-panel/update-entity-order.strategy' | ||
import { PanelDesigns } from './sidebars.panel.designs' | ||
|
||
export const PanelLayerDesigns = ({ layer }: { layer: ILayerWithDesigns }) => { | ||
const strategyEntityNew = new DashboardPanelCreateLayerDesignTypeStrategy() | ||
const strategyReorder = new DashboardPanelUpdateLayerDesignTypeOrderStrategy() | ||
const strategyActions = new DashboardPanelLayerDesignActionStrategy() | ||
|
||
return ( | ||
<PanelDesigns | ||
parent={layer} | ||
strategyEntityNew={strategyEntityNew} | ||
strategyReorder={strategyReorder} | ||
strategyActions={strategyActions} | ||
/> | ||
) | ||
} |
10 changes: 10 additions & 0 deletions
10
.../projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.layer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { type ILayerWithDesigns } from '#app/models/layer.server' | ||
import { PanelLayerDesigns } from './sidebars.panel.designs.layer' | ||
|
||
export const PanelLayer = ({ layer }: { layer: ILayerWithDesigns }) => { | ||
return ( | ||
<div> | ||
<PanelLayerDesigns layer={layer} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.