diff --git a/app/API/Task.php b/app/API/Task.php index 50222fe..08014ce 100644 --- a/app/API/Task.php +++ b/app/API/Task.php @@ -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 ), ), ) ); diff --git a/assets/public/css/style.css b/assets/public/css/style.css index dde8c86..36d52a5 100644 --- a/assets/public/css/style.css +++ b/assets/public/css/style.css @@ -1,6 +1,9 @@ .er-flex { display: flex; } +.er-items-center { + align-items: baseline; +} .er-space-x-2 { gap: 8px; } @@ -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; @@ -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; diff --git a/assets/public/js/script.js b/assets/public/js/script.js index 52813d5..6d0adff 100644 --- a/assets/public/js/script.js +++ b/assets/public/js/script.js @@ -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." ); diff --git a/views/shortcodes/roadmap.php b/views/shortcodes/roadmap.php index 2bc3f69..e03b0a0 100644 --- a/views/shortcodes/roadmap.php +++ b/views/shortcodes/roadmap.php @@ -26,8 +26,13 @@