Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Index and Detail View #10

Closed
OliverZiegler opened this issue Sep 3, 2019 · 4 comments
Closed

Custom Index and Detail View #10

OliverZiegler opened this issue Sep 3, 2019 · 4 comments

Comments

@OliverZiegler
Copy link

Would be nice if there was a possibility to easily overwrite how data is displayed.

Or is there some easy way I don't see? :)

@dillingham
Copy link
Owner

@OliverZiegler

You can change the vue component that will be looped

->detailItemComponent('some-component');

These are the props to accept

resource, resourceName, resourceId, field
php artisan nova:asset some-component
Nova.booting((Vue, router) => {
    Vue.component('some-component', require('./components/SomeCmponent').default);
})

^ Have to register the component to the vue instance Nova uses

@OliverZiegler
Copy link
Author

Ah nice. Didn't know that. Thanks a lot!

closing 👍

@vesper8
Copy link

vesper8 commented Dec 4, 2020

Thanks for the tip.

I wanted to modify the index field and you didn't define a ->indexItemComponent() meta method to allow us to easily override

However I remembered that you can simply override the original component if you use the exact same name so I did that:

asset.js

Nova.booting((Vue, router, store) => {
    Vue.component('index-nova-items-field', require('./components/IndexField'))
    // Vue.component('detail-nova-items-field', require('./components/DetailField'))
    // Vue.component('form-nova-items-field', require('./components/FormField'))
    // Vue.component('detail-nova-items-field-item', require('./components/DetailFieldItem'))
})

IndexField.vue

<template>
  <div class="text-xs">
    <div v-if="field.value">
      <pre>{{ field.value }}</pre>
    </div>
  </div>
</template>

<script>
export default {
  props: ['resourceName', 'field'],
};
</script>

And it works : )

@bamatic
Copy link

bamatic commented Feb 28, 2021

In editing view input text controls could be replaced by select controls ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants