< 242022-02-25⋎26 >

Topic for #farmOS is: farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Forum: farmOS.discourse.groupSet by mstenta on 2021-06-15 at 12:52
09:00*shane_aldrich[m] has quit (Quit: You have been kicked for being idle)
12:58skipper_is[m]Left the migration going overnight, seems to be all in order this morning! Now I can start to migrate across some modules
12:58mstenta[m]wahoo!
12:59mstenta[m]well - glad we identified those mysql migration issues
12:59mstenta[m]hopefully that won't affect many folks... but good to have a bug report open for them
12:59mstenta[m]i'll add the bit about sensors being affected as well
13:01skipper_is[m]Has anyone made a start on the Quick Form for births?
13:02mstenta[m]nope not yet
13:03skipper_is[m]Ok, I'll maybe make a start there as the goats are kidding now
13:04mstenta[m]might be a pretty easy one to throw together!
13:04skipper_is[m]I'll do it as a contrib module, that way if someone wants to make a better one they can :)
13:04mstenta[m]i wish i had a few spare moments! i would help!
13:04mstenta[m]sounds good - yea i hope to rebuild it in farmOS core too - but anything you start with would be great!
13:04skipper_is[m]Well, I'll see where I get stuck and then give you a shout for when you're free
13:06mstenta[m]i have a few moments right now - want me to start a quick branch with a skeleton module?
13:07skipper_is[m]You can, but I was going to do it as a contrib just so I can drop it into sites/all/modules for easy quick testing, rather than mapping out an extra folder for the core modules
13:07skipper_is[m]Then if it works, it can go across to the core
13:14skipper_is[m]Does this comment section do anything?... (full message at libera.ems.host/_matrix/media/r0/downloa)
13:16mstenta[m]github.com/farmOS/farmOS/compare/2.x...m
13:16mstenta[m]here's a quick start, if it's helpful!
13:16mstenta[m]yes that's a "PHP annotation" which is used for some plugin metadata
13:17skipper_is[m]Ah ok
13:17mstenta[m](feel free to copy those files i started to your own repo)
13:18skipper_is[m]Ah, forgot we're getting electricians over today. I'd better shut my computer down before they turn off the power!
13:18skipper_is[m]That is rather annoying... another day
13:18mstenta[m]haha well if i have some free time maybe i'll add a bit more to this :-)
13:18mstenta[m]you've got me inspired
13:18skipper_is[m]Go for it!
13:18skipper_is[m]I'll pick another one :P
18:28*uploaded an image: (50KiB) < libera.ems.host/_matrix/media/r0/downloa >
19:56skipper_is[m]quantity_measure_options() brings in the available quantity units doesnt it?
19:58skipper_is[m]But what is this even doing:... (full message at libera.ems.host/_matrix/media/r0/downloa)
19:58skipper_is[m]Is it just returning an empty array if there are no quantity options?
19:59skipper_is[m]Oh, nvm, you can pass measures to the overall function, so it just filters it for them
20:17mstenta[m]ps skipper_is i made some progress on the birth quick form this morning
20:17skipper_is[m]I saw, I'm working on the quick weight module now
20:17skipper_is[m]Defined the form, now working on the submit logic
20:18*uploaded an image: (194KiB) < libera.ems.host/_matrix/media/r0/downloa >
20:18mstenta[m]no submit logic yet... but i sketched out the basic fields (parity with farmOS v1 anyway)
20:18skipper_is[m]Needs birth weight :P
20:19mstenta[m](oh also the "group membership" piece still needs to be added too... that part will be conditional based on whether or not `farm_group` is installed)
20:19mstenta[m]oh good idea - we should add birth weight
20:19skipper_is[m]There is one in 1x isn't there?
20:19mstenta[m]i suppose that should be in a separate observation log for each child?
20:19skipper_is[m]Or is that something custom in mine?
20:19mstenta[m]no v1 didn't have that
20:19skipper_is[m]Oh... Is that something I've added? I was sure not
20:20*uploaded an image: (47KiB) < libera.ems.host/_matrix/media/r0/downloa >
20:20skipper_is[m]It creates an observation log at the same time
20:21mstenta[m]hmm yea that must have been custom?
20:21mstenta[m]here's the v1 code: github.com/farmOS/farmOS/blob/7.x-1.x/mo
20:21skipper_is[m]How do we get the asset from what they've typed? In 1.x it was through _form_validate
20:21mstenta[m]oh wait!
20:21mstenta[m]ah ha!
20:21mstenta[m]github.com/farmOS/farmOS/blob/509cfb2e92
20:22mstenta[m]the `farm_livestock_weight` module actually altered the birth quick form in v1 to add birth weight! i totally forgot about that
20:22mstenta[m]whelp - yea i guess we should add that too
20:22skipper_is[m]Ah! I was wildly looking through my repo trying to find if I'd put it in
20:23mstenta[m]i have no memory of writing that code 😆
20:25skipper_is[m]But yea, getting the asset they've typed in, is there a 2.x version of form_validate?
20:26skipper_is[m]The planting one the asset is created, so it can just be passed to the log builder, similar in the egg module,
20:27mstenta[m]yea `public function validateForm()` (same arguments as `submitForm()`)
20:27mstenta[m]oh wait is that what you're asking?
20:28skipper_is[m]It is, and would that be similar to 1.x in terms of validating what the use has put in for asset?
20:28mstenta[m]that's where you can perform any custom validation you might need, and use `$form_state->setError()` (iirc)
20:28skipper_is[m]eg in the birth log, that they've put in a valid mother
20:28mstenta[m]yes - `$form_state->getValue()` will get the submitted values
20:28mstenta[m]oh ok so... some of that is handled automatically
20:28mstenta[m]via the `"#type" => "entity_autocomplete"` widget
20:28skipper_is[m]Aah
20:28mstenta[m]so you don't even need to validate that
20:28skipper_is[m]Sweet
20:29skipper_is[m]Oh that saves me a right headache!
20:30skipper_is[m]but I can pull the asset from that via `$asset = $form_state->getValue("asset");`?
20:33mstenta[m]yea take a look at the way the planting quick form submit logic works... there may be some "gotchas" if i remember correctly... i forget exactly what that gives you
20:33skipper_is[m]The planting submit creates a new asset of planting, so it doesn't need to get the asset from entity_autocomplete
20:34skipper_is[m]it is just passed the newly created asset I think
20:36skipper_is[m]Oh, but location does some additional logic on the field value to get the location_id, and from that the location asset... (full message at libera.ems.host/_matrix/media/r0/downloa)
20:37mstenta[m]oh right... yes it references a few other things - location, crop/variety etc
20:37mstenta[m]there's a bit of a different behavior depending on whether or not you are "auto-creating" a new asset
20:37mstenta[m]but i think referencing and existing asset is simpler
20:37mstenta[m]s/and/an/
20:37skipper_is[m]crop/variety are just taxonomy terms through aren't they?
20:37mstenta[m]yup
20:37mstenta[m]but those are entities too - so the same type of widget is used
20:37skipper_is[m]Ooh ok
20:39skipper_is[m]$asset_id = $form_state->getValue('asset');... (full message at libera.ems.host/_matrix/media/r0/downloa)
20:39skipper_is[m]I'm not happy with the chance of it returning nothing though...
20:39skipper_is[m]It shouldn't... the form has it required....
20:41skipper_is[m]..Oh what if it's more than one asset...
20:41skipper_is[m]Ahh, []...
20:54skipper_is[m]`[$this->prepareQuantity($log_values['quantity'])],` Where is this function defined? I cannot seem to find a definition to see what args it takes?
20:55mstenta[m]oh that's specific to the planting quick form class
20:55mstenta[m]easier way is:... (full message at libera.ems.host/_matrix/media/r0/downloa)
20:56skipper_is[m]Ah nice :)
20:56skipper_is[m]units?
20:56mstenta[m]the `createLog()` method will handle that automatically
20:56mstenta[m]i forget... i think you can just put the unit name
20:56mstenta[m](in a meeting at the moment)
20:57skipper_is[m]'quantity' => [
20:57skipper_is[m] ['value' => $weight,
20:57skipper_is[m] 'unit' => $unit,],
20:57skipper_is[m] ],
20:57skipper_is[m]oh, measure not value
20:58skipper_is[m]no, ignore measure...
21:55skipper_is[m]Got an autocomplete issue... go to extract the asset from the form field, using `$asset = $this->entityTypeManager->getStorage('asset')->load($id);` where $id is the value from the form field, (I'm using a similar pattern to the planting seasons taxonomy). My animals names are recorded as "Nala (71)" where 71 is her eartag number. The id is returning her eartag number as her asset id number, and then saying it obviously cannot find asset
21:55skipper_is[m]with id number of 71 because that isn't her number...
21:59mstenta[m]Ohh man... I ran into this recently too
21:59skipper_is[m]One of those gotchas...
22:00mstenta[m]github.com/farmOS/farmOS/issues/503
22:00mstenta[m]Similar to that issue... I think this same thing happens in a few different places when you have entities with parentheses in the name
22:01skipper_is[m]It probably would've happened in 1.x with the square brackets, but very few people put square brackets in names..
22:01mstenta[m]Oh was it square bracket in v1? I forget
22:02skipper_is[m]although that was [id:123]
22:02mstenta[m]That's all Drupal core behavior
22:02skipper_is[m]so probably less likely
22:02mstenta[m]So a bit out of our control
22:02mstenta[m]Dang huh. I wonder why they changed it
22:02mstenta[m]That's no good
22:02mstenta[m]I link to the upstream core issue in that GitHub link
22:02skipper_is[m]But the ids aren't being referenced in the name, so if I pull in a different asset without that (), there isn't the asset id in it's place
22:03*uploaded an image: (7KiB) < libera.ems.host/_matrix/media/r0/downloa >
22:03mstenta[m]Oh wait actually
22:04skipper_is[m]He doesn't get a (id)
22:04mstenta[m]skipper_is: there might be a partial fix in the 2.x branch
22:04mstenta[m]Soon to be in beta3
22:04mstenta[m]github.com/farmOS/farmOS/issues/502
22:05mstenta[m]Sorry need to run... You might consider applying that change to your code manually and see if it works better
22:05mstenta[m]It is already committed, but after beta2
22:06skipper_is[m]No worries
22:07mstenta[m]I think that parentheses issue is coming up in a few places though so that might only fix one
22:07mstenta[m]Not sure if it's the same one you are experiencing but worth a try!
22:21skipper_is[m]It was first reported on Drupal forums 7 years ago! Still broken!
22:22skipper_is[m]6 years ago it was reported..
22:23skipper_is[m]www.drupal.org/node/2520416

< 242022-02-25⋏26 >