snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Often and for no reason, the selection of columns in tables is disabled

Open UserGoodtm opened this issue 5 years ago • 1 comments

Please confirm you have done the following before posting your bug report:

Describe the bug Often and for no reason, the selection of columns in tables is disabled

To Reproduce For example, I open a user and want to see the assets assigned to him. But all the columns in the table are deactivated, and I often need to re-enable them to see the data. I cannot understand why this is happening. There is no logic to keep track of what it might be. This problem is not only on my computer, it happens on different computers. Also here, on github, in the problems of snipeit, I met similar complaints.

Expected behavior So that the required fields in the table are active. In general, it would be useful to have certain columns in the table active "by default".

Screenshots 1

UserGoodtm avatar Feb 26 '21 19:02 UserGoodtm

The fields that are active by default are controlled by the Presenters and are stored in cookies by your browser.

For example, the code that controls the screenshot you're showing here:

 <table
                    data-click-to-select="true"
                    data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
                    data-cookie-id-table="userAssetsListingTable"
                    data-pagination="true"
                    data-id-table="userAssetsListingTable"
                    data-search="true"
                    data-side-pagination="server"
                    data-show-columns="true"
                    data-show-export="true"
                    data-show-footer="true"
                    data-show-refresh="true"
                    data-sort-order="asc"
                    data-sort-name="name"
                    data-toolbar="#toolbar"
                    id="userAssetsListingTable"
                    class="table table-striped snipe-table"
                    data-url="{{ route('api.assets.index',['assigned_to' => e($user->id), 'assigned_type' => 'App\Models\User']) }}"
                    data-export-options='{
                "fileName": "export-{{ str_slug($user->present()->fullName()) }}-assets-{{ date('Y-m-d') }}",
                "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
                }'>
            </table>

The code that controls whether something is visible or not by default is in the Presenter:

/**
     * Json Column Layout for bootstrap table
     * @return string
     */
    public static function dataTableLayout()
    {
        $layout = [
            [
                "field" => "checkbox",
                "checkbox" => true
            ], [
                "field" => "id",
                "searchable" => false,
                "sortable" => true,
                "switchable" => true,
                "title" => trans('general.id'),
                "visible" => false
            ], [
                "field" => "company",
                "searchable" => true,
                "sortable" => true,
                "switchable" => true,
                "title" => trans('general.company'),
                "visible" => false,
                "formatter" => 'assetCompanyObjFilterFormatter'
            ], [
                "field" => "name",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/form.name'),
                "visible" => true,
                "formatter" => "hardwareLinkFormatter"
            ], [
                "field" => "image",
                "searchable" => false,
                "sortable" => true,
                "switchable" => true,
                "title" => trans('admin/hardware/table.image'),
                "visible" => true,
                "formatter" => "imageFormatter"
            ], [
                "field" => "asset_tag",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/table.asset_tag'),
                "visible" => true,
                "formatter" => "hardwareLinkFormatter"
            ], [
                "field" => "serial",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/form.serial'),
                "visible" => true,
                "formatter" => "hardwareLinkFormatter"
            ],  [
                "field" => "model",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/form.model'),
                "visible" => true,
                "formatter" => "modelsLinkObjFormatter"
            ], [
                "field" => "model_number",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/models/table.modelnumber'),
                "visible" => false
            ], [
                "field" => "category",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('general.category'),
                "visible" => true,
                "formatter" => "categoriesLinkObjFormatter"
            ], [
                "field" => "status_label",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/table.status'),
                "visible" => true,
                "formatter" => "statuslabelsLinkObjFormatter"
            ], [
                "field" => "assigned_to",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/form.checkedout_to'),
                "visible" => true,
                "formatter" => "polymorphicItemFormatter"
            ], [
                "field" => "employee_number",
                "searchable" => false,
                "sortable" => false,
                "title" => trans('admin/users/table.employee_num'),
                "visible" => false,
                "formatter" => "employeeNumFormatter"
            ],[
                "field" => "location",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/table.location'),
                "visible" => true,
                "formatter" => "deployedLocationFormatter"
            ], [
                "field" => "rtd_location",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('admin/hardware/form.default_location'),
                "visible" => false,
                "formatter" => "deployedLocationFormatter"
            ], [
                "field" => "manufacturer",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('general.manufacturer'),
                "visible" => false,
                "formatter" => "manufacturersLinkObjFormatter"
            ],[
                "field" => "supplier",
                "searchable" => true,
                "sortable" => true,
                "title" => trans('general.supplier'),
                "visible" => false,
                "formatter" => "suppliersLinkObjFormatter"
            ],
...

The columns that are shown or not shown, after selections have been made, is in userAssetsListingTable.

snipe avatar Feb 26 '21 19:02 snipe