isuke
10/20/2017 - 9:14 AM

SmartLink.vue

<template lang="pug">
form.smart-link(method="post", :action="href")
  input(type="hidden" name="_method" :value="method.toUpperCase()")
  input(type="hidden" name="authenticity_token" :value="token")
  input(type="submit", :value="text")
</template>

<script lang="coffee">
export default
  props:
    href:
      type: String
      required: true
    method:
      type: String
      required: true
      validator: (val) -> ['put', 'delete'].includes(val)
    text:
      type: String
      required: true
  data: ->
    token: window.global.csrfToken
</script>

<style lang="scss" scoped>
.smart-link {
}
</style>