[Missing action] While creating a document containing an array, I can't remove an item from it (at creation time)

Hey,

I might have found a bug or a missing action in Forest Admin :slight_smile:

The issue is quite easy to reproduce, create these two models:

item.ts

import { Schema, Document, model} from 'mongoose';
import * as notes, {INotes} from './notes.ts';

interface IItem extends Document {
  name: string,  
  notes: [INote],
  // ...
}

const schema = new Schema({
  'name': String
  'notes': [notes]
  // ...
}, {
  timestamps: false,
});

export default model<IItem>('items', schema, 'Items');

So, note is basically a simple model which isn’t a collection itself and used only as nested document schema.

note.ts

import { Schema, Document, model, Types} from 'mongoose';

export interface INote extends Document {
  title: string,
  message: string,
  // ...
}

const schema = new Schema({
  "title": String,
  "message": String,
  // ...
}, {
  timestamps: false,
});

export default model<INote>('notes', schema);

Now that you have your collection items ready, let’s create an Item by clicking on the top/right on [Add] action:

image

Once you clicked on it, the screen gets updated and you can edit each field of your new document. The part that we want to focus on will be on the left, within the Related data section.

image

Now I let you create some new Notes from the related data section.

Let’s say you created more than ONE note, I let you try to remove one :slight_smile:

As you can see… you can’t remove any :slight_smile: you will first need to create the item (or validate the creation of your Item) then edit it to be able to remove one or more notes from the ones you just created :slight_smile:

Hope it helps :slight_smile: I am quiete sure it’s a very small bug because the “Delete” action (mono or bulk) is present from the update (and it’s almost the same screen/UI)

Best,

Max

Hi again @Emixam23, let me look into this…
Could you share a video of what you are trying to do ?

Hello,

Sorry again for the late reply. Hmm I can’t really share a video of my work but I am open to show you through a “share screen conversation” if you agree :slight_smile: I don’t think it would take more than 5mins, it’s as easy as I wrote to reproduce.

Also I am french so it should be really easy to communicate around the subject if required.

Best,

Max

Hello @Emixam23 :wave:,

Just to be sure, this only happens when creating new records right?
I just did a quick test on my end, but I’m able to remove related data while creating a new record. Is this the behavior you are expecting but not having ?

Sorry again for the late reply. Hmm I can’t really share a video of my work but I am open to show you through a “share screen conversation” if you agree

We tend to prefer discussion here over a call when possible, so other users can benefit from these thread :slight_smile:

Let me know if I got this right or if I’m missing your point :pray:

Hey :slight_smile:

Yes I get you, it’s ok :slight_smile:
Alright wow that’s weird because, it works partially on my end…

I have a list of foreign IDs where, each time I add an ID (at create time), I can’t select/remove
However, when having the situation I gave you (with nested documents with in an array), I can only create new item to add to this array… Only when I am done creating, while editing, I can select/remove…

Did you recreate exactly the behavior I gave you above? I really don’t get why it works for you tbh :confused:

Thanks,

Max

Hi @Emixam23 :wave: unfortunately is not possible today. I “reproduce” your behavior and i deep dive into the code and it’s not a bug. I will push your request in our product board thank you for your feedback.

1 Like