feat(03-02): integrate edit form into provider dashboard

- Add edit mode detection via URL parameters (action=edit_job&job_id=X)
- Display edit form when in edit mode, hide listings table
- Update edit links in table to point to dashboard edit form
- Add back navigation link to return to dashboard overview
- Style edit section with card layout and back link
- Form pre-populates with existing job data via id_param
- Dashboard shows either edit form OR listings, not both

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-14 19:45:09 +09:00
parent 943544e72b
commit 491c4fb535

View File

@@ -26,6 +26,27 @@ if ( ! in_array( 'ddhh_provider', $current_user->roles, true ) ) {
return; return;
} }
// Check if we're in edit mode
$is_edit_mode = isset( $_GET['action'] ) && $_GET['action'] === 'edit_job' && isset( $_GET['job_id'] );
if ( $is_edit_mode ) {
$job_id = absint( $_GET['job_id'] );
$form_id = DDHH_JM_Formidable::get_job_edit_form_id();
if ( $form_id ) {
?>
<div class="ddhh-provider-dashboard">
<div class="ddhh-job-edit-section">
<h2>Stellenangebot bearbeiten</h2>
<p><a href="<?php echo esc_url( get_permalink() ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
<?php echo do_shortcode( "[formidable id={$form_id} id_param={$job_id}]" ); ?>
</div>
</div>
<?php
return;
}
}
// Query current user's job_offer posts // Query current user's job_offer posts
$args = array( $args = array(
'post_type' => 'job_offer', 'post_type' => 'job_offer',
@@ -93,9 +114,16 @@ $job_query = new WP_Query( $args );
<td class="job-type"><?php echo esc_html( $job_type ? $job_type : '-' ); ?></td> <td class="job-type"><?php echo esc_html( $job_type ? $job_type : '-' ); ?></td>
<td class="job-actions"> <td class="job-actions">
<?php <?php
// Edit link - uses WordPress capabilities to determine if user can edit // Edit link - points to edit form on dashboard
if ( current_user_can( 'edit_job_offer', $post_id ) ) { if ( current_user_can( 'edit_job_offer', $post_id ) ) {
edit_post_link( 'Bearbeiten', '', '', $post_id, 'button edit-link' ); $edit_url = add_query_arg(
array(
'action' => 'edit_job',
'job_id' => $post_id,
),
get_permalink()
);
echo '<a href="' . esc_url( $edit_url ) . '" class="button edit-link">Bearbeiten</a>';
} }
// View link - only for published posts // View link - only for published posts
@@ -139,6 +167,33 @@ $job_query = new WP_Query( $args );
color: #333; color: #333;
} }
.ddhh-job-edit-section {
padding: 2rem;
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.ddhh-job-edit-section h2 {
margin-top: 0;
margin-bottom: 1rem;
font-size: 1.5rem;
color: #333;
}
.back-to-dashboard {
display: inline-block;
margin-bottom: 1.5rem;
color: #3b82f6;
text-decoration: none;
font-weight: 500;
}
.back-to-dashboard:hover {
color: #2563eb;
text-decoration: underline;
}
.ddhh-job-listings-section { .ddhh-job-listings-section {
margin-top: 3rem; margin-top: 3rem;
} }