Jump to content

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 comment
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 comment
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 comment
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 comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...