danielbrendel / hortusfox-web

Self-hosted collaborative plant management and tracking system for plant enthusiasts
https://www.hortusfox.com
MIT License
674 stars 34 forks source link

Disable/hide buttons when attribute unchecked #224

Closed brianw777 closed 5 months ago

brianw777 commented 5 months ago

Description of your request When an attribute like last_watered, last_repotted and last_fertilised are unchecked so they don't appear as an attribute on plants the button under the location is still there and will set the attribute anyway. I believe a better thing would be to not display the button for attributes that are not activated.

Describe the solution you'd like I suggest altering the code that displays the button by inserting an if statement that checks for the attribute setting. An example would be:

    @if (plant_attr('last_watered'))
    <div class="is-inline-block is-action-button-margin"><a class="button is-info" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_watered', '{{ __('app.bulk_set_watered') }}', '{{ __('app.set_watered') }}');">{{ __('app.set_watered') }}</a></div>
    @endif

Describe alternatives you've considered N/A

Additional context I have forked the repository and created a branch with the changes in the file app/views/plants.php. There is only an addition of 6 lines (3 if statements and 3 endif statements). I am not exactly sure about doing a pull request since I have never done one before but it is there.

I am also looking at submitting a feature request for the addition of a Last Weeded attribute (I have already tested it and will introduce the request after v3.2 is released and I test with the new code) and with all the buttons it might get cluttered. Some people won't use all the attributes (I probably wouldn't use repotted and others won't use weeded) so not displaying the button might be logical.

Here is the code:

Original:

    <div class="is-inline-block is-action-button-margin"><a class="button is-info" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_watered', '{{ __('app.bulk_set_watered') }}', '{{ __('app.set_watered') }}');">{{ __('app.set_watered') }}</a></div>
    <div class="is-inline-block is-action-button-margin"><a class="button is-warning" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_repotted', '{{ __('app.bulk_set_repotted') }}', '{{ __('app.set_repotted') }}');">{{ __('app.set_repotted') }}</a></div>
    <div class="is-inline-block is-action-button-margin"><a class="button is-chocolate" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_fertilised', '{{ __('app.bulk_set_fertilised') }}', '{{ __('app.set_fertilised') }}');">{{ __('app.set_fertilised') }}</a></div>

New

    @if (plant_attr('last_watered'))
    <div class="is-inline-block is-action-button-margin"><a class="button is-info" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_watered', '{{ __('app.bulk_set_watered') }}', '{{ __('app.set_watered') }}');">{{ __('app.set_watered') }}</a></div>
    @endif
    @if (plant_attr('last_repotted'))
    <div class="is-inline-block is-action-button-margin"><a class="button is-warning" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_repotted', '{{ __('app.bulk_set_repotted') }}', '{{ __('app.set_repotted') }}');">{{ __('app.set_repotted') }}</a></div>
    @endif
    @if (plant_attr('last_fertilised'))
    <div class="is-inline-block is-action-button-margin"><a class="button is-chocolate" href="javascript:void(0);" onclick="window.vue.showPerformBulkUpdate('last_fertilised', '{{ __('app.bulk_set_fertilised') }}', '{{ __('app.set_fertilised') }}');">{{ __('app.set_fertilised') }}</a></div>
    @endif
danielbrendel commented 5 months ago

Resolved.