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

Feature Request: Models custom fields preloaded with data #2608

Closed
korio77 opened this issue Sep 14, 2016 · 7 comments
Closed

Feature Request: Models custom fields preloaded with data #2608

korio77 opened this issue Sep 14, 2016 · 7 comments

Comments

@korio77
Copy link

korio77 commented Sep 14, 2016

I think it would be good to have the possibility to fill the "standard" values of the custom fields you apply to a new "model" when you are creating the model, so later when you assign that model those values are already written.

Can be a really time saver when you need to add multiple items of the same model.

For an example, think about new computers for the office, all the same boxes and the same model, and you need to store the ram, storage and processor they have (for later exports to excel), so you create the custom fields, the custom group and assign it to the model, but later you need to fill it up for every new asset you make, what i am asking for is the same as this, but filling it up only one time in the model creation, so later when you create the asset its already filled.

And latter, if you buy more of that model and the specs had changed (very usual with pc models) you can just simply change it on the model so all new ones have the new values.

I think i have explained myself good, tell me if any more info is needed.

P.D: i know we have the "components", but i dont find it useful in the case i explained before.

@uberbrady
Copy link
Collaborator

We've talked about 'default values' in custom fields before, but this is the first proposal that makes enough sense to me.

I was thinking about how many "U" a particular rack server is - and if you put in, say, a Dell xyz server, that will always be 5U. If you could use the fieldset to say "Rack Server", but then within the Dell xyz server model, you could say "Default height in U: 5" that would really help going forward.

And then when you're looking at the individual asset, you still see how many U it is.

For implementation, I think you don't need anything crazy or high-performance or denormalized or anything - it could just be as simple as:

id? model_id custom_field_id default_value
1 1 17 5
2 1 32 orange
3 1 57 3.285

I'm not sure we'd need the id column, but I think we pretty consistently try to keep those around just to be able to more easily specifically look at one particular element in this join table.

Code-wise, it'd probably be something like:

// in Model class - 
function default_values()
{
   return $this->belongsToMany('CustomFields')->withPivot('default_value');
}

That would be a little clunky when you're walking through the custom fields to pluck out the defaults, so you might want to make a helper -

//also in Model class?
function default_array()
{
    $results=[];
    foreach($this->default_values() AS $custom_field) {
        $results[$custom_field->id]=$custom_field->pivot('default_value');
    }
}

Then when you're trying to generate default values in a new template for an asset, you could just refer to $asset->model->default_array()[$field_id]

@snipe snipe added this to the v4.1 milestone Oct 11, 2017
@snipe snipe modified the milestones: v4.1, 4.2 Nov 21, 2017
@stale
Copy link

stale bot commented Jan 21, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the stale label Jan 21, 2018
@cromat200
Copy link

Hello,
This feature would be also interesting for us. At least custom fields for models would be nice wether they are filled with default values or not.
Thanks for your contribution on this so far!

@stale stale bot removed the stale label Jan 24, 2018
@grantemsley
Copy link

This would be very useful for me as well.

I have custom fields for things like what OEM OS license comes with the machine - it's almost always going to be the same for a particular model. So the option to set a default would be a time saver.

@snipe snipe modified the milestones: v4.2.0, v4.3.0 Mar 23, 2018
@brycewc
Copy link

brycewc commented Apr 9, 2018

This feature would be amazing! Please add! I don't know if this is exactly the same thing as I need, but I would like the default values for a custom field to be for list fields as well as text and tied to a specific asset model rather than every single asset that uses that field. Thanks!

@stale
Copy link

stale bot commented Jun 8, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the stale label Jun 8, 2018
@stale stale bot closed this as completed Jun 15, 2018
@willwalsh96
Copy link

me too

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

No branches or pull requests

7 participants