directus / v8-archive

Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
https://docs.directus.io/api/reference.html
507 stars 203 forks source link

Custom status interface doesn't work #2255

Open zghib opened 4 years ago

zghib commented 4 years ago

Hi everybody. I'm trying to show Status-field as dropdown in Directus 8.6.2 per docs https://docs.directus.io/guides/status.html#custom-status-interfaces

My steps to reproduce:

  1. Copy system Status interface from https://github.com/directus/app/tree/master/src/interfaces/status
  2. change <v-radio with <v-simple-select in input.vue
  3. deploy to /directus/public/extensions/custom/interfaces
  4. The interface appears and I can add it as a field to my collection
  5. When add/edit an item from this collection I obtain an error vue.runtime.esm.js:1888 TypeError: Cannot read property 'draft' of undefined at a.permission (item.vue:513) at nr.get (vue.runtime.esm.js:4479) at nr.evaluate (vue.runtime.esm.js:4584) at a.permission (vue.runtime.esm.js:4836) at a.se (item.vue?bd7a:1) at vue-composition-api.module.js:604 at te (vue-composition-api.module.js:565) at a.t.render (vue-composition-api.module.js:604) at a.e._render (vue.runtime.esm.js:3548) at a.r (vue.runtime.esm.js:4066)

Any help?

rijkvanzanten commented 4 years ago

Do you have the source code of your custom interface somewhere? Based on the error, it looks like it's trying to read from permissions that don't exist

zghib commented 4 years ago

PTAL https://github.com/zghib/directus-extensions commits per my steps

zghib commented 4 years ago

One more thing it appears in Permissions

Screen Shot 2020-04-06 at 09 05 33
ryanrobertsname commented 4 years ago

This is interesting, I'm having the same issue as well. I tried copying the existing status interface without changes and still received the error.

I've noticed that adding an additional field that uses the "stock" status interface eliminates the error. So essentially two status fields, one with the custom interface and one with the stock one, works. Not really a solution that I'm resorting to at this point, but it's an additional clue.

My errors are coming from the routes/item.vue file.

Screen Shot 2020-08-06 at 12 46 58 PM

The first error is coming from this section in the permission computed method:

if (this.status) { return permission.statuses[this.status]; }

"permission" was defined via this:

const permission = this.$store.state.permissions[this.collection];

@rijkvanzanten I know you're busy with v9 and life, but figured you might have an idea what the issue is based on these clues? I'm happy to work on the fix, if you have any ideas.

rijkvanzanten commented 4 years ago

@ryanrobertsname Does your status interface have a status_mapping for options? Both app and API try to use the status mapping defined in the interface's options in order to extract what's permitted and what isn't.

I know you're busy with v9 and life

Absolutely 😁 Coming together nicely though! (v9 that is, though life isn't too bad now either)

ryanrobertsname commented 4 years ago

@rijkvanzanten yeah it does, I literally just copied the stock status interface, renamed it and loaded it in the extensions folder.

Thanks for your feedback, I'll poke around a bit more and see if I can dig up anything.

Thanks for the work on v9, excited for it!