susom / redcap-em-shazam

Shazam External Module
MIT License
18 stars 11 forks source link

Is there a way to use REDCap action-tags with Shazam ? #36

Closed padmanabhv closed 3 years ago

padmanabhv commented 4 years ago

My specific use case (which led to me making this issue) I have a field, on which I use @HIDDEN-SURVEY action-tag (https://www.iths.org/blog/news/redcap-tip/action-tag-spotlight-hidden/)

Using the same field in Shazam, however negates the action tag and still makes the field visible.

I did try using

But that makes it invisible in Record dashboard and surveys as opposed to only in surveys .

Is there a way to combine the two, or is it asking too much ?

123andy commented 4 years ago

I think you saying: you want to use shazam to move a field for use on Data Entry forms, but you don't want to display it on surveys. However, the shazam during the survey is showing a field marked as @HIDDEN-SURVEY correct?

So, shazam doesn't distinguish between survey data entry and regular 'data entry' and by how it works, it moves the input out of the container that @HIDDEN-SURVEY hides so this undoes the hiding.

Here is a work-around:

1) add a class to the container that wraps this field in Shazam's HTML tab

<div class='shazam'>text1</div>

becomes

<div class='shazam hide-survey'>text1</div>

2) then add a css rule that hides this class by default under the CSS tab

.hide-survey {display:none;}

This means that the field will NOT be shown during surveys or data entry. 3) Now, undo this CSS behavior when you are not in survey mode using the javascript tab:

$(document).ready(function(){
    Shazam.beforeDisplayCallback = function() {
        if (page !== "surveys/index.php") {
            $(".hide-survey").show();
        }
    }
});
123andy commented 3 years ago

Closing this with work-around as the complexity of trying to guess the right behavior is unclear to me.

I suppose one could say that if a field specified to be relocated in shazam has an actiontag like hide-survey and it is a survey then Shazam should not copy that field? I'm not sure if that is correct or not. If you have a clear set of rules we could re-open and perhaps try to build that into the module...