Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/API/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,30 @@ public function get( $request ) {
$id = $request->get_param( 'id' );
$task = get_post( $id );

// Get stage
$stages = wp_get_post_terms( $task->ID, 'task_stage', array( 'fields' => 'names' ));
$stage = is_wp_error( $stages ) || empty( $stages ) ? '-' : implode(',', $stages );

// Get products
$products = wp_get_post_terms( $task->ID, 'task_product', array( 'fields' => 'names' ));
$product = is_wp_error( $products ) || empty( $products ) ? '-' : implode(',', $products );

// Get tags
$tags = wp_get_post_terms( $task->ID, 'task_tags', array( 'fields' => 'names' ) );
$tag = is_wp_error( $tags ) || empty( $tags ) ? '-' : implode( ',', $tags );

$this->response_success(
array(
'message' => __( 'Task found', 'easyroadmap' ),
'task' => array(
'title' => $task->post_title,
'description' => wpautop( $task->post_content ),
'stage' => $stage,
'products' => $product,
'tags' => $tag,
'upvotes' => get_post_meta( $task->ID, 'upvote', true ),
'downvotes' => get_post_meta( $task->ID, 'downvote', true ),
'link' => get_permalink( $task->ID ),
),
)
);
Expand Down
19 changes: 19 additions & 0 deletions assets/public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.er-flex {
display: flex;
}
.er-items-center {
align-items: baseline;
}
.er-space-x-2 {
gap: 8px;
}
Expand Down Expand Up @@ -87,6 +90,9 @@
position: relative;
max-height: 600px;
}
#er-modal-content > *:not(:last-child) {
margin-bottom: 1rem;
}
.er-close-modal {
position: absolute;
top: 10px;
Expand All @@ -110,6 +116,19 @@
margin-bottom: 1rem;
margin-top: 1.5rem;
}
#er-modal-link:before {
display: inline-block;
width: 20px;
height: 20px;
--svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23000' d='M9 3h8v8l-2-1V6.92l-5.6 5.59l-1.41-1.41L14.08 5H10zm3 12v-3l2-2v7H3V6h8L9 8H5v7z'/%3E%3C/svg%3E");
background-color: currentColor;
-webkit-mask-image: var(--svg);
mask-image: var(--svg);
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-size: 100% 100%;
mask-size: 100% 100%;
}
.er-vote-btn {
align-items: center;
gap: 4px;
Expand Down
11 changes: 11 additions & 0 deletions assets/public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,19 @@ jQuery(
success: function (response) {
$( "#er-modal-title" ).text( response.data.task.title );
$( "#er-modal-description" ).html( response.data.task.description );
$( "#er-modal-stage" ).html( response.data.task.stage );
$( "#er-modal-products" ).html( response.data.task.products );
$( "#er-modal-tags" ).html( response.data.task.tags );
$( "#er-upvote-count" ).text( response.data.task.upvotes || 0 );
$( "#er-downvote-count" ).text( response.data.task.downvotes || 0 );

if(response.data.task.link) {
$( "#er-modal-link" )
.attr('href', response.data.task.link )
.attr('target', '_blank');
} else {
$( "#er-modal-link" ).hide();
}
},
error: function () {
console.error( "Error fetching task data." );
Expand Down
15 changes: 13 additions & 2 deletions views/shortcodes/roadmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@

<div id="er-modal-content" class="er-text-gray-700">
<input type="hidden" id="er-modal-id">
<h2 id="er-modal-title" class="er-text-2xl er-font-bold er-mb-4">Task Title</h2>

<div class="er-flex er-space-x-2 er-items-center">
<h2 id="er-modal-title" class="er-text-2xl er-font-bold er-mb-4">Task Title</h2>
<a href="#" id="er-modal-link">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path fill="currentColor" d="M9 3h8v8l-2-1V6.92l-5.6 5.59l-1.41-1.41L14.08 5H10zm3 12v-3l2-2v7H3V6h8L9 8H5v7z"/></svg>
</a>
</div>

<div class="er-flex er-items-center er-space-x-2 er-mb-4">
<span id="er-upvote" data-type="upvote" class="er-vote-btn er-flex er-items-center er-space-x-2">
👍 <?php esc_html_e( 'Upvote', 'easyroadmap' ); ?>
Expand All @@ -39,6 +44,12 @@
</span>
</div>

<div class="er-flex er-items-center er-space-x-2 er-mb-4">
Stage:<span id="er-modal-stage"></span>
| Products:<span id="er-modal-products"></span>
| Tags:<span id="er-modal-tags"></span>
</div>

<div id="er-modal-description" class="er-mb-4">Loading...</div>
</div>
</div>
Expand Down