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

Dynamic slot detection #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Dynamic slot detection #79

wants to merge 1 commit into from

Conversation

pyrello
Copy link

@pyrello pyrello commented Mar 14, 2017

This feature removes the need for the __slot special field. Simply by creating a scoped slot template where the slot attribute matches the name of the field, it will be used as the output of that field.

Here is condensed version of what it looks like adapted from the changes I made to the demo:

<vuetable ref="vuetable"
  api-url="http://vuetable.ratiw.net/api/users"
  :fields="fields"
>
  <!-- Custom actions scoped slot -->
  <template slot="custom-actions" scope="props">
    <div>
      <button class="ui red button" @click="onClick('view-item', props.rowData)"><i class="zoom icon"></i></button>
      <button class="ui blue button" @click="onClick('edit-item', props.rowData)"><i class="edit icon"></i></button>
      <button class="ui green button" @click="onClick('delete-item', props.rowData)"><i class="delete icon"></i></button>
    </div>
  </template>
</vuetable>
let vm = new Vue({
  data: {
    fields: {
      // other fields...
      {
        name: 'custom-actions',
        title: '',
        dataClass: 'center aligned'
      },
    },
  },
  methods: {
    // other methods...
    onClick: function(action, data) {
      console.log('actions: on-click', data.name)
      sweetAlert(action, data.name)
    }
  }
})

Ideally, this could probably use a little more clean-up, but I figured I would get this out so you could try it out for yourself. Also, I have only tested a couple different scenarios with this, but I think it could replace the '__component' special field too, as you could just embed the component inside the scoped slot.

Hope you like it!

Edit: This is in reference to #73

@ratiw
Copy link
Owner

ratiw commented May 30, 2017

@pyrello Sorry for leaving this for so long. I really love the idea and simplicity of your PR, but I really think it would be better to push this for the next major release as it might introduce a breaking change that caught people off guard. I have some idea that really could benefit from your PR.

@pyrello
Copy link
Author

pyrello commented May 30, 2017

@ratiw Fair enough. Let me know how I can help when you are thinking about moving towards a new major release.

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

Successfully merging this pull request may close these issues.

2 participants