Jump to content
AlanJCraven

Prefill Date Selection Widget

Recommended Posts

We are fairly new to Froglearn and are currently building our parent portal. I would like to use the date selection widget along with the MIS linked documents widget but I would like to prefill the date selection widget so that the default is to display all linked documents for this academic year. Is this possible? Has anyone tried this before?

Any suggestions gratefully accepted.

Thanks

Alan

Link to post
Share on other sites
5 hours ago, AlanJCraven said:

We are fairly new to Froglearn and are currently building our parent portal. I would like to use the date selection widget along with the MIS linked documents widget but I would like to prefill the date selection widget so that the default is to display all linked documents for this academic year. Is this possible? Has anyone tried this before?

Any suggestions gratefully accepted.

Thanks

Alan

 

Hey Alan,

 

I put together a little snippit of code that might do what you want. You'd need to add this to a HTML widget and put it on the same page as your Linked Documents widget. It won't change the dates on the select date widget, but it will broadcast a new set of dates to the system, which the linked documents widget should pick up on and act upon.

I've not had time to test it, so (disclaimer) it may not work at all!

<script type="text/javascript">
    setTimeout(function(){
    var prefs = {
            'associations': {
                'type': 'associations',
                'label': 'Widget Collections',
                'value': JSON.stringify({
                    'associations': [],
                    'publisher': true,
                    'subscriber': false
                })
            }
        },
        sept,
        end = moment().valueOf();
    
    var year = moment().format("Y");
    var month = moment().format("M");
    
    if (month < 9) {
        year -= 1;
    }
    
    var date_string = "01-09-" + year;
    sept = moment(date_string).valueOf();

    var controller = new Frog.Widget.Controller($.find(".widget_html"), {}, {prefs: prefs});
        controller.broadcast('selectedInterval', new Broadcast.Models.Interval({
                    startTime: sept,
                    endTime: end
                }));
    }, 1000);

</script>

 

If you don't have the HTML widget on your Frog platform then speak to the service desk and they can enable it for you. If you have any problems let either me or @Graham Quince know.

Hopefully it'll just work though :)

 

  • Thanks 1
Link to post
Share on other sites

Hi Adam,

I have been playing with the code and I think the date format at line 24 is in the US format i.e. mm-dd-yyyy as I was getting a few more records than I expected. I have changed it to the following

 

   var date_string = "09-01-" + year;
    sept = moment(date_string).valueOf();

This seems to work fine.

Thanks for your efforts.

Alan

  • Thanks 1
Link to post
Share on other sites
8 hours ago, AlanJCraven said:

Hi Adam,

I have been playing with the code and I think the date format at line 24 is in the US format i.e. mm-dd-yyyy as I was getting a few more records than I expected. I have changed it to the following

 

   var date_string = "09-01-" + year;
    sept = moment(date_string).valueOf();

This seems to work fine.

Thanks for your efforts.

Alan

Glad it's working for you :)

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...