Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify v-select not showing :items

I can't figure this out. I am using Vuetify to style my pages, and for some reason I can't get the data to show in my v-select select box. The data SHOULD be coming from the array marketplaces. I thought it might be a version issue, but I've upgraded everything and its still not working.. I can't get the friggin thing to show my data!

Here is the page:

<template>
    <v-container fluid grid-list-lg class="come_closer">
      <v-layout row wrap>
        <v-flex xs12>
          <v-card class="lightpurple">
            <v-card-title>
              <v-icon class="my_dark_purple_text">language</v-icon>
              <h1 class="title oswald my_dark_purple_text pl-2 pr-5">ENTER YOUR AMAZON CREDENTIALS BELOW</h1>
            </v-card-title>

         <v-form ref="form" v-model="valid">   
            <v-layout xs12 row wrap class="mx-auto">
              <v-flex xs12>
                <v-text-field
                  required
                  :error-messages="sellerIdErrors"
                  color="purple darken-3"
                  label="Amazon Seller Id"
                  v-model="seller_id"
                  prepend-icon="person"
                  @input="$v.seller_id.$touch()"
                  @blur="$v.seller_id.$touch()"
                ></v-text-field>
              </v-flex>

              <v-flex xs12>
                <v-select
                  required
                  :items="marketplaces"
                  label="Select your Amazon Marketplace"
                  :error-messages="marketplaceErrors"
                  v-model="selected_marketplace"
                  color="purple darken-3"
                  prepend-icon="map"
                  @input="$v.selected_marketplace.$touch()"
                  @blur="$v.selected_marketplace.$touch()"                  
                ></v-select>
              </v-flex>

              <v-flex xs12>
                <v-text-field
                  required
                  color="purple darken-3"
                  id="testing"
                  name="input-1"
                  label="Amazon Auth Token"
                  :error-messages="tokenErrors"
                  v-model="token"
                  prepend-icon="https"
                  @input="$v.token.$touch()"
                  @blur="$v.token.$touch()"                      
                ></v-text-field>
              </v-flex>

              <v-layout row wrap class="text-xs-center mx-auto" v-if="show_cancel_button">
                <v-flex xs6>
                  <v-btn block large color="purple darken-3" dark @click="formCheckAndSend()">Update Your Credentials</v-btn>
                </v-flex>
                <v-flex xs6>
                  <v-btn block outline large color="purple darken-3" dark @click="sendBackToSpeeds">Cancel</v-btn>
                </v-flex>
              </v-layout>

              <v-layout row wrap class="text-xs-center mx-auto" v-else>
                <v-flex xs12>
                  <v-btn block large color="purple darken-3" dark @click="formCheckAndSend()">Save Your Credentials</v-btn>
                </v-flex>
              </v-layout>  

              </v-layout>
            </v-form>
          </v-card>
        </v-flex>

        <div class="text-xs-center">
          <v-bottom-sheet inset v-model="error_sheet">
            <v-card dark color="red darken-1">
              <v-card-title>
                <h1 v-if="credentials_bad" key="bad_creds" class="headline pb-2 oswald mx-auto">{{bad_credentials}}</h1>
                <h1 v-if="credentials_bad" key="video" class="title oswald mx-auto">{{watch_video}}</h1>
              </v-card-title>
            </v-card>  
          </v-bottom-sheet>
        </div>

      </v-layout>
    </v-container>
  </template>
<script>
import {dataShare} from '../packs/application.js';
import axios from 'axios';
import { required } from 'vuelidate/lib/validators';

export default {
  validations: {
      seller_id: { required },
      selected_marketplace: { required },
      token: { required },
      selected_zones: { required }
    },
  data: function() {
    return {
      show_cancel_button: true,
      credentials_bad: false,
      bad_credentials: "Oh no! Your Amazon credentials aren't right. Can you try again?",
      watch_video: "Make sure to watch our video in the top right hand corner",
      valid: true,
      error_sheet: false,
      seller_id: '',
      token: "",
      selected_zones: [],
      selected_marketplace: null,
      counter: 1,
      subtractor: 1,
      wrapCounter: 1,
      marketplaces:[
          { text: 'Australia', value: "A39IBJ37TRP1C6" },
          { text: 'Canada', value: "A2EUQ1WTGCTBG2" },
          { text: 'France', value: "A13V1IB3VIYZZH" },
          { text: 'Germany', value: "A1PA6795UKMFR9" },
          { text: 'Italy', value: "APJ6JRA9NG5V4" },
          { text: 'Mexico', value: "A1AM78C64UM0Y8" },
          { text: 'Spain', value: "A1RKKUPIHCS9HS" },
          { text: 'United Kingdom', value: "A1F83G8C2ARO7P" },
          { text: 'United States', value: "ATVPDKIKX0DER" },          
        ],
    };
  },
  created() {
    let self = this;
    axios.get("https://shopify-ship-refactor-trimakas.c9users.io/return_amazon_credentials").then(response => {
      this.seller_id = response.data.seller_id;
      if(this.seller_id == ""){
        this.show_cancel_button = false;
      }
      this.show_cancel_button;
      this.selected_marketplace = response.data.marketplace;      
      this.token = response.data.auth_token;
    });
  },
  computed: {
    sellerIdErrors() {
      const errors = []
      if (!this.$v.seller_id.$dirty) return errors
      !this.$v.seller_id.required && errors.push('Please enter your Amazon Seller Id')
      return errors      
    },
    marketplaceErrors() {
      const errors = []
      if (!this.$v.selected_marketplace.$dirty) return errors
      !this.$v.selected_marketplace.required && errors.push('Please select your Amazon Marketplace')
      return errors      
    },
    tokenErrors() {
      const errors = []
      if (!this.$v.token.$dirty) return errors
      !this.$v.token.required && errors.push('Please enter your Amazon Auth Token')
      return errors      
    },
    zoneErrors() {
      const errors = []
      if (!this.$v.selected_zones.$dirty) return errors
      !this.$v.selected_zones.required && errors.push('Please choose atleast one shipping zone to add this rate too')
      return errors      
    },      
  },
  methods: {
    formCheckAndSend () {
      if(this.$refs.form.validate()) {
        this.sendAmazonCreds();
      }
    },
    sendBackToSpeeds() {
      dataShare.$emit('whereToGo', "speeds");
    },
    removeCounter() {
      dataShare.$emit('removeComponent', this.subtractor);
    },
    addCounter() {
      this.counter++;
      dataShare.$emit('addComponent', this.counter);
      var allWraps = document.getElementsByClassName("application--wrap");
      var classToRemove = allWraps[this.wrapCounter];
      classToRemove.classList.remove("application--wrap");
      this.wrapCounter++;
    },
    sendAmazonCreds() {
      const AmazonCreds = {
        seller_id: this.seller_id,
        marketplace: this.selected_marketplace,
        auth_token: this.token,
      };
      let self = this;
      axios.post("https://shopify-ship-refactor-trimakas.c9users.io/amazon_credentials_check", AmazonCreds).then(response => {
        var creds_status = response.data.are_the_amazon_creds_good;
        if(creds_status == true){
          dataShare.$emit('whereToGo', "speeds");
          this.sendZones();
        }
        if(creds_status == false){
          self.error_sheet = true;
          self.credentials_bad = true;
        }
      });
    },
    sendZones() {
        const SelectedZones = {
          zone_info: this.selected_zones
        };
        axios.post("https://shopify-ship-refactor-trimakas.c9users.io/receive_zone_info", SelectedZones); 
    }
  }
};  

</script>

<style>

  .chip__content {
    background-color: #68007d !important;
    color: white !important;
  }

  .come_closer {
     margin-top: -15px !important; 
  }
</style>

And the above page is a component inside this page:

<template>
  <v-app>
    <credential_instructions class="no_background"></credential_instructions>
    <credential_details
      xs12
      class="no_background"
      id="amazon_credentials"
      v-for="(item, index) in components"
      :index="index"
      :key="'fourth' + index "
      >
    </credential_details>
  </v-app>  
</template>

<script>
/*global top*/

import {dataShare} from '../packs/application.js';
import credential_instructions from '../components/credential_instructions.vue';
import credential_details from '../components/credential_details.vue';
import axios from 'axios';

export default {
  data: function() {
    return {
      components: [1],
    };
  },
  components: {
    credential_instructions,
    credential_details
  },
  created() {
    dataShare.$on('addComponent', (data) => {
      this.components.push(data);
    });
    dataShare.$on('removeComponent', (data) => {
      this.components.pop();
    });
  },
  methods: {
    sendToBilling() {
      axios.post('https://new-ship-trimakas.c9users.io/create_billing_plan').then(response => {
        console.log(response.data);
        top.location.href = response.data.url_redirect;
      });
    }
  }
};  

</script>

<style>

.dark-green-button {
  background-color: #43A047 !important;
}

.green-font {
  color: #43A047 !important;
}

.red-font {
  color: #E53935 !important;
}

.full-height .flex{
  display: flex !important; 
}

.full-height .flex > .card{
 flex: 1 1 auto !important; 
}


.textfield-background-beige {
  background-color: #f7f1ec !important;
}

.theme--light .input-group input:disabled {
  color: rgba(0,0,0,.87) !important;
}

.lightbeige {
  background-color: #f1e7df !important;
}

.lightblue {
  background-color: #d9d6e1 !important;
}

.lightpurple {
  background-color: #e9daea !important;
}

.match-to-text-field {
  margin-left: -17px !important;
  height: 46px !important;
  margin-top: 2px !important;
}
</style>

And then finally here is my package.json

{
  "name": "shopify-ship-refactor",
  "version": "1.0.0",
  "description": "Complete Shopify shipping app refactor",
  "main": "index.js",
  "author": "Todd",
  "license": "MIT",
  "dependencies": {
    "@rails/webpacker": "3.5",
    "axios": "^0.18.0",
    "v-clipboard": "^2.0.1",
    "vue": "^2.5.16",
    "vue-loader": "^14.2.2",
    "vue-router": "^3.0.1",
    "vue-template-compiler": "^2.5.17",
    "vuelidate": "^0.7.4",
    "vuetify": "^1.0.19"
  },
  "devDependencies": {
    "webpack-dev-server": "2.11.2"
  }
}

I'm not getting any errors, or warnings, its just the data that should populate in the select box is not. Any ideas?

like image 545
ToddT Avatar asked Aug 30 '18 15:08

ToddT


4 Answers

Another reason it occurs, it's because you have no <v-app></v-app> in your code. My problem was that. Adding it again, fixed the problem.

See Sumurai8's answer at "Vuetify issue with v-menu" for details.

like image 104
Márcio Antônio Slivak Avatar answered Nov 01 '22 08:11

Márcio Antônio Slivak


I believe that since you are passing an array of objects to the v-select component, you need to tell it what to display as text, and set as a value.

So in your case it should look something like this:

<v-select
              required
              :items="marketplaces"
              item-text="text"
              item-value="value"
              label="Select your Amazon Marketplace"
              :error-messages="marketplaceErrors"
              v-model="selected_marketplace"
              color="purple darken-3"
              prepend-icon="map"
              @input="$v.selected_marketplace.$touch()"
              @blur="$v.selected_marketplace.$touch()"                  
            ></v-select>

They have a section on this in their documentation, but it is a bit buried on that page: Customized Item and Text Value

Hope this helps.

like image 30
Nathan Bland Avatar answered Nov 01 '22 07:11

Nathan Bland


Wow,this was a NIGHTMARE. It only took about a friggin' day to find the resolution. Hopefully if you're seeing this, it can be a solution for you as well.

Part of the problem was I was also getting a vue is installed twice error and various other warnings.

So I found this post: Vuetify Bug

Then this post:Webpacker config change

And finally this: webpacker custom.js

And this was the end result. I created custom.js in /config/webpack/custom.js and it looks like this:

module.exports = {
  resolve: {
    alias: {
      vue$: 'vue/dist/vue.esm.js'
    }
  }
}

And I also had to update the environment.js to this:

const { environment } = require('@rails/webpacker')
const vue =  require('./loaders/vue')
const customConfig = require('./custom')

environment.config.set('resolve.extensions', ['.foo', '.bar'])
environment.config.set('output.filename', '[name].js')

// Merge custom config
environment.config.merge(customConfig)

// Delete a property
environment.config.delete('output.chunkFilename')

environment.loaders.append('vue', vue)
module.exports = environment

Those two config files resolved my issues. Also for reference I'm running Vuetify 1.2.1 and Vue 2.5.17 along with Rails and Ruby.

like image 26
ToddT Avatar answered Nov 01 '22 07:11

ToddT


for future reference , i too had a similar problem with a code base i worked on, seems that the component "v-select" was overwritten by a library named vue-select.

in there installation docs, they show how to registed there component like this :

Vue.component('v-select', vSelect)
like image 22
codeWisperer Avatar answered Nov 01 '22 08:11

codeWisperer