Phase 5: Configuration Form
Historical design/implementation plan. It is retained as background, not a statement that every proposed feature is available. Use the current component/project guides and the deployed editor before following its recipes.
Estimated Effort: 4-5 hours Dependencies: Phase 4 complete Jira: EZ-2206
Overview
Implement the configuration form that allows users to customize app installation settings including name, dependencies, portal navigation, shortcuts, and dashboard tiles. This phase focuses on the frontend form only - backend integration comes in Phase 6.
Objectives
- Build AppStoreConfig.vue component
- Implement dependency selectors with auto-create option
- Add portal navigation fields with conditional display
- Add shortcuts checkbox
- Build recommended tiles section with dashboard selector
- Implement form validation
- Wire up form submission (Phase 6 will handle backend)
Implementation Steps
Step 1: Build AppStoreConfig.vue
File: resources/js/Components/Mod/AppStoreModal/AppStoreConfig.vue
This is a large component - see full implementation below:
<template>
<div class="app-config-view">
<div class="row">
<!-- Left Column - App Info -->
<div class="col-md-3 border-end">
<div class="sticky-top pt-3">
<div
class="app-icon-large d-flex align-items-center justify-content-center rounded mx-auto mb-3"
:style="{
backgroundColor: app.background_color || '#3490dc',
width: '80px',
height: '80px'
}"
>
<FontAwesomeIcon
:icon="app.icon || 'cube'"
size="3x"
class="text-white"
/>
</div>
<h5 class="text-center">{{ app.name }}</h5>
</div>
</div>
<!-- Right Column - Configuration Form -->
<div class="col-md-9">
<form @submit.prevent="handleSubmit">
<!-- App Name -->
<div class="mb-3">
<label class="form-label">
Name <span class="text-danger">*</span>
</label>
<input
v-model="formData.name"
type="text"
class="form-control"
:class="{ 'is-invalid': errors.name }"
required
/>
<div v-if="errors.name" class="invalid-feedback">
{{ errors.name }}
</div>
</div>
<!-- Dependencies -->
<div
v-for="dep in dependencies"
:key="dep.identifier"
class="mb-3"
>
<label class="form-label">
{{ formatLabel(dep.model) }}
<span v-if="dep.required" class="text-danger">*</span>
</label>
<select
v-model="formData.dependencies[dep.identifier]"
class="form-select"
:class="{ 'is-invalid': errors[`dependencies.${dep.identifier}`] }"
>
<option value="">Select {{ formatLabel(dep.model) }}</option>
<option value="create_new">
Create new {{ formatLabel(dep.model) }}
</option>
<!-- Options will be loaded via async in Phase 6 -->
</select>
<div v-if="errors[`dependencies.${dep.identifier}`]" class="invalid-feedback">
{{ errors[`dependencies.${dep.identifier}`] }}
</div>
</div>
<!-- Add to Portal Navigation -->
<div class="mb-3">
<div class="form-check">
<input
id="add-to-portal-nav"
v-model="formData.addToPortalNav"
type="checkbox"
class="form-check-input"
/>
<label class="form-check-label" for="add-to-portal-nav">
Add to navigation on default portal
</label>
</div>
</div>
<!-- Portal Nav Fields (conditional) -->
<Transition name="slide-fade">
<div v-if="formData.addToPortalNav" class="ms-4 mb-3">
<div class="mb-3">
<label class="form-label">Page Title</label>
<input
v-model="formData.portalPageTitle"
type="text"
class="form-control"
:class="{ 'is-invalid': errors.portalPageTitle }"
/>
<div v-if="errors.portalPageTitle" class="invalid-feedback">
{{ errors.portalPageTitle }}
</div>
</div>
<div class="mb-3">
<label class="form-label">Page Path</label>
<input
v-model="formData.portalPagePath"
type="text"
class="form-control"
:class="{ 'is-invalid': errors.portalPagePath }"
/>
<div v-if="errors.portalPagePath" class="invalid-feedback">
{{ errors.portalPagePath }}
</div>
</div>
</div>
</Transition>
<!-- Add to Shortcuts Menu -->
<div class="mb-3">
<div class="form-check">
<input
id="add-to-shortcuts"
v-model="formData.addToShortcuts"
type="checkbox"
class="form-check-input"
/>
<label class="form-check-label" for="add-to-shortcuts">
Add to shortcuts menu
</label>
</div>
</div>
<!-- Recommended Dashboard Tiles (Collapsed Card) -->
<div v-if="recommendedTiles.length > 0" class="mb-3">
<div class="card">
<div
class="card-header bg-white cursor-pointer"
@click="tilesExpanded = !tilesExpanded"
>
<div class="d-flex justify-content-between align-items-center">
<h6 class="mb-0">Recommended Dashboard Tiles</h6>
<FontAwesomeIcon
:icon="tilesExpanded ? 'chevron-up' : 'chevron-down'"
/>
</div>
</div>
<Transition name="collapse">
<div v-if="tilesExpanded" class="card-body">
<!-- Dashboard Selector -->
<div class="mb-3">
<label class="form-label">Add tiles to:</label>
<select
v-model="formData.targetDashboard"
class="form-select"
>
<option value="new">Create new dashboard</option>
<option
v-for="dashboard in existingDashboards"
:key="dashboard.id"
:value="dashboard.id"
>
{{ dashboard.name }}
</option>
</select>
</div>
<!-- New Dashboard Name (conditional) -->
<Transition name="slide-fade">
<div v-if="formData.targetDashboard === 'new'" class="mb-3">
<label class="form-label">New Dashboard Name</label>
<input
v-model="formData.newDashboardName"
type="text"
class="form-control"
:class="{ 'is-invalid': errors.newDashboardName }"
/>
<div v-if="errors.newDashboardName" class="invalid-feedback">
{{ errors.newDashboardName }}
</div>
</div>
</Transition>
<!-- Tiles List -->
<div class="tiles-list">
<div
v-for="tile in recommendedTiles"
:key="tile.id"
class="form-check mb-2"
>
<input
:id="`tile-${tile.id}`"
v-model="formData.selectedTiles"
type="checkbox"
class="form-check-input"
:value="tile.id"
/>
<label class="form-check-label" :for="`tile-${tile.id}`">
{{ tile.name }}
</label>
</div>
</div>
</div>
</Transition>
</div>
</div>
<!-- Form Actions -->
<div class="d-flex justify-content-between pt-3 border-top">
<button type="button" class="btn btn-light" @click="$emit('back')">
Cancel
</button>
<button
type="submit"
class="btn btn-primary"
:disabled="submitting"
>
<span
v-if="submitting"
class="spinner-border spinner-border-sm me-2"
></span>
{{ submitting ? 'Adding...' : 'Add to Project' }}
</button>
</div>
</form>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed } from 'vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
const props = defineProps({
app: {
type: Object,
required: true
},
appDetails: {
type: Object,
required: true
},
project: {
type: Object,
required: true
},
existingAppNames: {
type: Array,
required: true
},
existingDashboards: {
type: Array,
default: () => []
},
recommendedTiles: {
type: Array,
default: () => []
}
})
const emit = defineEmits(['back', 'submit'])
const tilesExpanded = ref(false)
const submitting = ref(false)
const errors = ref({})
// Form data initialization
const formData = ref({
name: getDefaultName(),
dependencies: {},
addToPortalNav: false,
portalPageTitle: props.app.name,
portalPagePath: slugify(props.app.name),
addToShortcuts: false,
targetDashboard: 'new',
newDashboardName: props.app.name,
selectedTiles: []
})
function getDefaultName() {
let name = props.app.name
if (props.existingAppNames.includes(name)) {
name += ' Copy'
}
return name
}
const dependencies = computed(() => props.appDetails.dependencies || [])
function formatLabel(model) {
return model.replace(/([A-Z])/g, ' $1').trim()
}
function slugify(text) {
return text
.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w-]/g, '')
}
function validateForm() {
const newErrors = {}
if (!formData.value.name?.trim()) {
newErrors.name = 'Name is required'
}
if (formData.value.addToPortalNav) {
if (!formData.value.portalPageTitle?.trim()) {
newErrors.portalPageTitle = 'Page title is required'
}
if (!formData.value.portalPagePath?.trim()) {
newErrors.portalPagePath = 'Page path is required'
}
}
if (
formData.value.targetDashboard === 'new' &&
!formData.value.newDashboardName?.trim()
) {
newErrors.newDashboardName = 'Dashboard name is required'
}
// Validate dependencies
dependencies.value.forEach((dep) => {
if (dep.required && !formData.value.dependencies[dep.identifier]) {
newErrors[`dependencies.${dep.identifier}`] = `${formatLabel(dep.model)} is required`
}
})
errors.value = newErrors
return Object.keys(newErrors).length === 0
}
function handleSubmit() {
if (!validateForm()) {
return
}
submitting.value = true
// Emit to parent - actual submission will be in Phase 6
emit('submit', {
...formData.value,
plugin_page_id: props.app.id
})
// Reset submitting after a delay (will be handled by actual submission in Phase 6)
setTimeout(() => {
submitting.value = false
}, 1000)
}
</script>
<style scoped>
.slide-fade-enter-active,
.slide-fade-leave-active {
transition: all 0.3s ease;
}
.slide-fade-enter-from {
transform: translateY(-10px);
opacity: 0;
}
.slide-fade-leave-to {
opacity: 0;
}
.collapse-enter-active,
.collapse-leave-active {
transition: max-height 0.3s ease, opacity 0.3s ease;
overflow: hidden;
}
.collapse-enter-from,
.collapse-leave-to {
max-height: 0;
opacity: 0;
}
.collapse-enter-to,
.collapse-leave-from {
max-height: 1000px;
opacity: 1;
}
.cursor-pointer {
cursor: pointer;
}
</style>
Step 2: Update AppStoreModal.vue with Config View
Add import:
import AppStoreConfig from './AppStoreConfig.vue'
Add data refs:
const existingDashboards = ref([])
const recommendedTiles = ref([])
Update loadInitialData to fetch dashboards:
const loadInitialData = async () => {
loading.value = true
try {
const [appsRes, tagsRes, dashboardsRes] = await Promise.all([
http.get(route('dashboard.plugins.pages.index', {
app_store: true,
project: props.project.slug,
source: sourceFilter.value
})),
http.get(route('dashboard.system-tags.index', {
class: 'app-store'
})),
http.get(route('dashboard.project.dashboards.index', {
project: props.project.slug
}))
])
allApps.value = appsRes.data
availableTags.value = tagsRes.data
existingDashboards.value = dashboardsRes.data
} catch (err) {
toast.error('Failed to load app store data')
console.error(err)
} finally {
loading.value = false
}
}
Replace placeholder config section in template:
<!-- Configuration View -->
<div v-else-if="currentView === 'config'" class="p-4">
<AppStoreConfig
:app="selectedApp"
:app-details="appDetails"
:project="project"
:existing-app-names="existingAppNames"
:existing-dashboards="existingDashboards"
:recommended-tiles="recommendedTiles"
@back="backFromConfig"
@submit="handleConfigSubmit"
/>
</div>
Replace showConfig method:
const showConfig = async (app) => {
viewHistory.value.push(currentView.value)
selectedApp.value = app
// If details aren't loaded, load them first
if (!appDetails.value || appDetails.value.id !== app.id) {
await showDetails(app)
}
// Load recommended tiles
await loadRecommendedTiles(app)
currentView.value = 'config'
}
const loadRecommendedTiles = async (app) => {
// Filter tags for app-tiles class
const tileTags = app.tags.filter(tag => tag.includes('app-tiles'))
if (tileTags.length === 0) {
recommendedTiles.value = []
return
}
try {
const res = await http.get(route('dashboard.plugins.tiles.index', {
tags: tileTags
}))
recommendedTiles.value = res.data
} catch (err) {
console.error('Failed to load recommended tiles:', err)
recommendedTiles.value = []
}
}
Add backFromConfig method:
const backFromConfig = () => {
const previousView = viewHistory.value.pop()
if (previousView === 'details') {
currentView.value = 'details'
} else {
currentView.value = 'browse'
selectedApp.value = null
appDetails.value = null
}
}
Add handleConfigSubmit method (placeholder for Phase 6):
const handleConfigSubmit = (formData) => {
console.log('Form submitted:', formData)
toast.success('Form validation passed! Backend integration in Phase 6')
// Phase 6 will implement actual submission
}
Step 3: Manual Testing Checklist
Form Initialization:
- Click "Add" on an app
- Verify form loads with app icon and name in left column
- Check name field is prepopulated
- If app name exists, verify " Copy" is appended
Name Field:
- Clear name field and submit - should show error
- Fill name and submit - error should clear
Dependencies:
- Verify dependency selectors show for each dependency in app
- Check "Create new" option appears
- Select "Create new" - should accept
Portal Navigation:
- Check "Add to navigation" checkbox
- Verify Page Title and Page Path fields appear with slide animation
- Fields should be prepopulated
- Clear fields and submit - should show errors
- Uncheck - fields should hide
Shortcuts:
- Check "Add to shortcuts" checkbox
- Uncheck - should work
Dashboard Tiles:
- If app has recommended tiles, verify collapsed card shows
- Click header - card should expand with smooth animation
- Select "Create new dashboard"
- Verify dashboard name field appears
- Clear name and submit - should show error
- Select existing dashboard - name field should hide
- Check/uncheck tiles
Form Submission:
- Fill valid form data
- Submit - should show success toast (placeholder)
- Verify spinner shows in button during submission
- Button should be disabled while submitting
Form Validation:
- Submit empty form - should show multiple errors
- Fix errors one by one - errors should clear
- Submit valid form - no errors should show
Navigation:
- Click Cancel - should return to previous view
- From browse → config → cancel = browse
- From details → config → cancel = details
Acceptance Criteria
- Form displays with app info in left column
- Name field prepopulates and handles duplicates
- Dependencies show with create new option
- Portal nav fields show/hide conditionally
- Shortcuts checkbox works
- Dashboard tiles section expands/collapses
- Dashboard selector switches between new/existing
- Form validation works for all fields
- Validation errors display inline
- Submit button shows loading state
- Cancel navigation works correctly
- All transitions are smooth
Files Created
resources/js/Components/Mod/AppStoreModal/AppStoreConfig.vue
Files Modified
resources/js/Components/Mod/AppStoreModal/AppStoreModal.vue
Next Phase
After this phase is complete and manual testing passes, proceed to Phase 6: Backend Integration.