Pending/Done & "Now" option for logs

Morning community
I am not at Dol Guldur, so plan on not resurrecting the thread at https://farmos.discourse.group/t/log-category-defaults-setting-or-avoiding-them/1730/10 to raise one point from it.

I am still on a mission to relieve the extra cumbersome steps while logging. Pretty sure it’s not bugging everyone, just me, so looking for some hack or idea. Perhaps you may know of a plugin that can help?

  1. The pending/done status. Done makes sense when logging, and pending only makes sense if future date (why isn’t this auto?). I log a lot, and would prefer done as default. (as with the log cats, it’s not a browser thing, and occurs on all browsers and all platforms)
  2. The timestamp, is blank. Why? Can this also not just default to the (mysql style) “now”? Perhaps a hack anyone’s done with a ‘now’ button?

I can see where to put a bit of code to do it, but it will just be wiped out when I upgrade. See screenshot, if I didn’t make sense [the security warning is a part of my life, ignore that]

Regards
Marlon


using FF (chrome is not an option, i am degoogled)

2 Likes

Not exactly the case here, but do you know of this? It could help in other cases.

Timestamp is prefilled with current date/time for me…

Me too. Brave Browser works very well too. Brave and Firefox has a bit different handling of datepicker in farmOS. But it seems they are more like now than before.
I tend to use Brave whenever Chrome reccomended for websites.

2 Likes

Thanks for raising this again @marlonv! Let’s get something done! (pun intended)

I do agree that it might make more sense for logs to be “done” by default, in general. That would be a very quick solution. A better solution would be to use JS to auto-toggle done/pending based on timestamp, as we described in the past: Log Category defaults - setting or avoiding them - #5 by mstenta

I will add both of these to my near-term todo list and see what I can do…

In the meantime, if you would like a temporary solution, add these two files to a new sites/all/modules/log_done directory, and then enable this module in your instance:

log_done.info.yml:

name: Default logs to done
description: Sets the default value for log status to done.
type: module
package: farmOS Contrib
core_version_requirement: ^10
dependencies:
  - log:log

log_done.module

<?php

/**
 * Implements hook_entity_base_field_info_alter().
 */
function log_done_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'log') {
    $fields['status']->setDefaultValue('done');
  }
}

That will set the default value of the log status field to done everywhere. Once we get a “proper” solution in farmOS core (which may end up being the same as this!) you’ll be able to uninstall and delete this temporary module.

Hope that helps in the short term!

Oh you may be experiencing a bug that we found and fixed in 3.0.1: Patch drupal/core for issue 3414883 by paul121 · Pull Request #771 · farmOS/farmOS · GitHub

It requires a patch to Drupal core. If you update to 3.0.1 then that patch will be included with farmOS.

1 Like

I went ahead and made a quick pull request with a summary/justification for making “done” the default log status in farmOS: Make "done" the default log status by mstenta · Pull Request #782 · farmOS/farmOS · GitHub

I noted that this can be a first step, to set the baseline, and that we can pursue a follow-up feature to use JavaScript to automatically set the status to “pending” in the UI if the timestamp is > now.

3 Likes

Thanks!
These are great solutions and the module trick taught me a few other things that I am playing with now.
I appreciate all the replies and advice.
I did update to latest, so not sure - could also be why I am seeing the security banner. Ill go re-update and try again.
Have a good weekend!

1 Like

Feel free to hop into #farmOS chat on Element/IRC if you want some help debugging!

https://webchat.oftc.net/?channels=#farmOS

@marlonv Curious: are you using PHP composer to manage your farmOS dependencies and updates via composer update? There’s a bug that @paul121 and I are investigating… just wondering if it might explain your update issues. If you are not using composer update then it would not apply.

1 Like

Hi Mike. Apologies for only replying now. Crazy days in the 110’s F, etc
I am using composer update, yes. It’s nice to know there’s a bug. I have always had weird issues when updating.

1 Like

OK I’m not sure if this is what you’re experiencing, but I would be curious if it is…

Tl;dr: you need to run composer update TWICE to be sure that all updates are applied, in some cases. It’s a tricky issue that we’re trying to find an elegant solution for, but in the meantime you can avoid it by always running your composer update command twice.

Next time you do an update, see if that helps. I would be curious to know if that’s what caused your issues in the past. It may be!

1 Like