cortexrd / Knack-Toolkit-Library

Knack Toolkit Library
MIT License
26 stars 6 forks source link

_rdclk Doesn't work if there is no text #302

Closed CSWinnall closed 3 months ago

CSWinnall commented 4 months ago

Hi Norm

We tested the rdclk keyword and there is an issue that it doesn't work if there is no text in the cell. We have cells that only show data once it's been added using the pop up. Do you think this could be done? It would be great if it took on the .knViewLink__label class and the icon from the target link too. I think the cursor should change to the pointer as well.

This will be a great keyword.

Craig

cortexrd commented 4 months ago

Oh yes, you're right, I forgot to mention this and I had the same issue while developing it for Morbern. In some cases, there's no text to show and the user had to click on a precise and invisible pixel in the cell to get it working, which is a pain. So, I added an icon as a dummy target, but though it does offer a larger region to click on, it doesn't change to a finger pointer when hovered.

I guess I'll have to manually insert a "Click" text to cover that use case. Or add a parameter to override the default with you own text.

ND

CSWinnall commented 4 months ago

We really notice the the click target as we make our whole cell clickable across the app but it doesn't work on your link. I am sure we can update the css to work with your link though.

CSWinnall commented 4 months ago

I've just realised we do this but in reverse. We replace the link text with the text from the hidden column. Is there a reason you didn't do it that way? It means that everything still works on the link like icons.

CSWinnall commented 4 months ago

This is the function we use :

function replaceTextInGrid(viewId, sourceField, targetField) {
        const targetIndex = $(`#${viewId} .kn-table thead th.${targetField}`).index();
        const rows = $(`#${viewId} .kn-table tbody tr`);

        rows.each(function() {
            const span = $(this).find(`td:eq(${targetIndex}) span.knViewLink__label`);
            const text = $(this).find(`td.${sourceField}`).find('span').html();
            span.html(text)
        });
    }

Craig

cortexrd commented 4 months ago

Hi Craig,

I've revisited this feature and considered what you've proposed. It makes sense. And it's a lot simpler too. But it led me to consider a much broader feature that I had in mind for a while, that would be an variation of the existing _cpyfrom keyword.

_cpytxt to copy text from one place to another in the scene. From any field/view to any other, including from a column to another one in the same grid. Would support Detail, Grid, Search and Form views.

That would be super powerful and address a lot of use cases that have been requested to me in the past, including the one I currently have with Morbern.

Food for thoughts... Norm

CSWinnall commented 4 months ago

Hi Norm

I think that's a great idea. We do this quite a lot in forms.

It would be really good if the target input is a connection field and the source field has a connection id or class that would be used.

Craig