Hide a specific page's Vue component button within a table

I have a component that displays a table on various pages. Within this table, there is a button to create goals. However, I want to control when this button appears on certain pages and exclude it from others. Below is the code for the table component and an example of a page where I do not want the button to be displayed.

employeePage

<template>
  <v-card class="mx-auto overflow-hidden" height="900" width="1800">
    <div class="content">
      <MetasTableComponent
        :title="'Global Goal'"
        :headers="headers"
        :items="globalGoals"
        :loading="loadingGobalGoals"
      />
      <MetasTableComponent
        :title="'Sectorial Goals'"
        :headers="headers"
        :items="sectorialGoals"
        :loading="loadingMetasSetoriais"
      />
      <MetasTableComponent
        :title="'Individual Goals'"
        :headers="headers"
        :items="individualGoals"
        :loading="loadingMetasIndividuais"
        @save-data="createIndividualGoal"
      />
    </div>
  </v-card>
</template>
<script>
import {
  findGlobalGoals,
  findSectorialGoals,
  findIndividualGoals,  
  createIndividualGoal,
} from "...";
import MetasTableComponent from "...";

export default {
  name: "IndividualViewPage",
  components: {
    MetasTableComponent,
  },
  data: function () {
    return {
      drawer: false,
      group: null,
      headers: [
        {
          text: "Name",
          value: "GoalName",
          align: "left",
          width: 50,
          caption: "title",
        },
        {
          text: "Min",
          value: "Min",
          align: "left",
          width: 50,
          caption: "title",
        },
        {
          text: "Target",
          value: "Target",
          align: "left",
          width: 50,
          caption: "title",
        },
        {
...

Table component

<template>
  <div id="table">
    <v-card class="mx-auto mb-3">
      <v-app-bar dark color="green">
        <v-toolbar-title>{{ title }}</v-toolbar-title>
      </v-app-bar>

      <v-data-table
        dense
        :headers="headers"
        :items="items"
        item-key="name"
        class="elevation-1"
        :loading="loading"
        loading-text="Loading..."
        no-data-text="No record found."
        :items-per-page="20"
        :footer-props="{
          itemsPerPageText: 'Items per page',
          itemsPerPageAllText: 'All',
        }"
      >
        <template v-slot:top>
          <v-toolbar flat color="white">
            <v-row dense>
              <v-col cols="1">
                <v-btn
                  class="mx-5 mt-2"
                  fab
                  x-small
                  dark
                  color="green"
                  @click="createData()" //This button creates goals
                >
                  <v-icon dark>mdi-plus</v-icon>
                </v-btn>
              </v-col>
            </v-row>
          </v-toolbar>
        </template>

        <template v-slot:[`item.actions`]="{ item }">
          <v-tooltip right>
            <template v-slot:activator="{ on, attrs }">
              <v-icon
                small
                class="ml-1"
                @click="readData(item)"
                v-bind="attrs"
                v-on="on"
                >mdi-eye</v-icon
              >
            </template>
            <span>View</span>
          </v-tooltip>

...

Answer №1

Add a new prop to the Table component named "EnableGoalAction" with a boolean value.

Set this value to true or false in your implemented component based on your requirements.

Make sure to include a conditional check in your button code as shown below:

     <v-btn
              class="mx-5 mt-2"
              fab
              x-small
              dark
              color="green"
             v-if="EnableGoalAction"
              @click="createData()" //This button adds a goal
            >
              <v-icon dark>mdi-plus</v-icon>
            </v-btn>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The controller's AngularJS function seems to be unresponsive

Issue with AngularJs ng-click Event I'm attempting to utilize the GitHub Search-API. When a user clicks the button, my Controller should trigger a search query on GitHub. Here is my code: HTML: <head> <script src="js/AngularJS/angula ...

Leverage JSON data and implement it in JavaScript

In my PHP page, I have a JavaScript function that includes a JSON method for retrieving data from the database. The code snippet looks like this: $this->registerJsFile('/js/restaurant-reserve.js', ['depends' => [JqueryAsset::class ...

Creating AngularJS variables with dependencies on integer values

Hello, I am a brand new developer and I am currently working on creating an expenses calculator. The goal is to have the sum of inputted integers from a table, each with a default value, become the integer value of another variable. However, I seem to be m ...

Nuxt3: sending a user's submitted value from a registration form

I'm facing an issue in my Nuxt3 application where I need to pass the input value from an email field in a child component (SignForm.vue) to the parent component (signup.vue) for user registration. signup.vue <script setup> const props = { ...

Is there a method to detect the presence of a bot in your discord server using another bot?

I am developing my own unique discord bot and I am looking to implement a feature that can determine if a specific bot is present in the server. Here's how I've been approaching it: if (!message.guild.args[0]) In this code, args[0] represents ...

AngularJS Interceptors for secure page management

I recently started working with AngularJS and I'm facing an issue with my interceptor that catches 401 errors from server responses. When a 401 status is detected, it triggers a "loginRequired" message broadcast and redirects to the login page. Howev ...

How to Trigger a Django View Using Ajax

I am working on integrating Ajax with Django to trigger an action upon button click. I have successfully invoked the JavaScript function, but I am facing issues in calling the Django view. Despite no errors being displayed, the print statement within my vi ...

How can I ensure that only the relevant form values are submitted in Vue2?

I currently have a form page that serves the purpose of both creating and updating data. The form fields are structured as follows; view image details here content: (...) i18n: (...) image: (...) name: (...) orderIndex: (...) position: (...) I am able t ...

What is the process for exporting all sub-module types into a custom namespace?

When we import all types from a module using a custom-namespace, it appears to work smoothly, for example: import * as MyCustomNamespace from './my-sub-module' We are also able to export all types from a module without creating a new namespace, ...

What could be the reason for the unexpected undefined value of my ajaxurl variable?

Seeking assistance with implementing code to track mp3 plays in a Wordpress plugin using ajax-counter.js jQuery(document).ready(function($) { console.log(ChurchAdminAjax.ajaxurl); $("audio").bind("play", function(){ console.log(ChurchAdmin ...

Calculate the total price from a combination of HTML and JavaScript options without altering the values

I'm currently facing an issue in my form where the final price needs to be updated when a different option is selected. I've searched extensively for the problem without success. I've used similar code before, just with different variables a ...

Tips for reducing image file size using ImageMinimizerWebpackPlugin in Next.js (webpack 5)

When attempting to use this plugin for image compression, I am encountering an issue where the build process completes successfully, but the images remain uncompressed. As a beginner with webpack, I'm unsure of what might be causing this problem. Cou ...

Issue encountered: Failure to locate module 'socket.io' while attempting to execute a basic server JavaScript file

Below is my server.js file that I am attempting to run using node server.js: var app = require('express')(); var http = require('http').createServer(app); var io = require('socket-io')(http); //also tried socket.io instead of ...

What is the process for creating static pages that can access local data within a NextJS 13 application?

I recently completed a blog tutorial and I must say, it works like a charm. It's able to generate dynamic pages from .md blog posts stored locally, creating a beautiful output. However, I've hit a roadblock while attempting what seems like a sim ...

What is the process for displaying a hidden div using a button?

I'm running into a problem with my project. Here is the code I've been using to hide my div element : @keyframes hideAnimation { to { visibility: hidden; } } To trigger the animation and hide the div after 6 seconds, I have implemented ...

Ensure that this regular expression is able to accurately match all numbers, even those without decimal points

Seeking help to create a script that can extract the negative percentage value between two numbers. One of the numbers is dynamic and includes different currencies, decimals, etc., so I believe a regex is needed for this task. The current script works, but ...

Operating on a duplicate of the array is necessary for mapping an array of objects to function properly

I'm starting to uncover a mysterious aspect of Javascript that has eluded me thus far. Recently, I've been pulling an array of objects from a database using Sequelize. This array is quite intricate, with several associations included. Here' ...

How can scripts be used to enable fullscreen in PhoneGap?

Can JavaScript in PhoneGap enable fullscreen mode and hide the status bar? While I know it can be pre-defined in config.xml, I'm unsure if it can be changed dynamically. I've come across resources suggesting that plug-ins are necessary here, but ...

How can I resolve a JavaScript issue that occurs when accessing a property within the same object?

Displayed below is a snippet from a much larger JavaScript object within my project. Thousands of lines have been omitted to focus solely on the area in question... Line 6 is specifically where the issue lies. Here's a concise example involving Java ...

Enhancing Element Generation and Data Association through jQuery

Currently, I am seeking a more streamlined approach to generate DOM alterations and update the object within .data(). At the moment, data is being supplied in an array of objects. I construct strings piecemeal, appending them to the table body, and affixi ...