cityofaustin / atd-data-tech

Austin Transportation Data & Technology Services
17 stars 2 forks source link

Auto Refresh the Finance Service Request form page when new jobs are added #12589

Closed ChristinaTremel closed 2 months ago

ChristinaTremel commented 1 year ago

When submitting new jobs on a Service Request, the job information shows up under all of the Service Request job tables until the page is refreshed. Can we auto refresh the page when a user clicks "Add Job"?

ChristinaTremel commented 1 year ago

@ChrispinP could you provide details on how you've addressed auto refreshing pages in the past?

ChrispinP commented 1 year ago

Sent code to Christina & Diana for review

dianamartin commented 1 year ago

7/31

dianamartin commented 1 year ago

9/11

We are testing the code that Chrispin shared with us and the Street Banners.

These are the values for the pages we need the code applied to:

New Service Request | BRAND NEW SR

Add/Edit Service Request | REQUESTER

New Service Request | ADMIN

Page Refresh with the button on a Table view

/*****************************/
/*** Refresh Table Button ***/
/*****************************/
$(document).on("knack-view-render.view_322", function (event, page) {
  var button = $(
    "<span style='width: 2em'></span>" +
    "<button id='refresh-view_322' style='border-radius: .35em' class='kn-button is-primary'>" +
    "<i class='fa fa-refresh'></i>" +
    "<span style='width: .5em'></span>Refresh Table</button>"
  );

  button.insertAfter( //places button next to keyword search option
    $("#view_322").find("form.table-keyword-search").find("a")[0]
  );

  $("#refresh-view_322").click(function (e) {
    e.preventdefault();
    Knack.views["view_322"].model.fetch();
  });
});

Auto-Submitting a Form view:

$(document).on('knack-scene-render.scene_446', function(event, scene) {
    $('button[type=submit]').submit();
});

Street Banner Code - when a user selects a value and clicks the submit button

// Reload LPB Application when Design Ready "Yes"
$(document).on("knack-scene-render.scene_1212", function () {
  $('#view_3392 .kn-link:contains("Yes")').on("click", function(){
    location.reload();
  })
});

// Reload OTS Application when Design Ready "Yes"
$(document).on("knack-scene-render.scene_1234", function () {
  $('#view_3397 .kn-link:contains("Yes")').on("click", function(){
    location.reload();
  })
dianamartin commented 1 year ago

The Issue

Proposed

Steps to Recreate Issue

2023-09-11_Finance_Jobs_Page_adding_to_multiple_table

ChristinaTremel commented 1 year ago

John recommended we try this code:

  $("#refresh-view_322").click(function (e) {
    e.preventdefault();
    Knack.views["view_322"].model.fetch();
  });
});
johnclary commented 1 year ago

I mentioned this grooming—if you want to try testing again by running this line in the javacsript console in your browser:

Knack.views["<view_id>"].model.fetch();

You should replace <view_id> with the view ID of the table you want to refresh. Hopefully that works!

dianamartin commented 1 year ago

9/14

chiaberry commented 12 months ago

I am going to look into this!

chiaberry commented 12 months ago

I have code in test app but this is what I found to work:

var viewsToFetch = ["view_1070", "view_1067", "view_1065", "view_1060", "view_1057"]
// When the form in view 1045 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1045", function (event, view, data) {
    viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})
ChristinaTremel commented 12 months ago

@chiaberry Thank you! I just tested that form in the test app and that code seems to be working. 🙏🏼 I'll sync with Diana early next week to test it out again/implement it in the prod app.

ChristinaTremel commented 7 months ago

Had to update the code to include Subprojects, but this code worked in test 🎉

var viewsToFetch = ["view_1070", "view_1067", "view_1065", "view_1060", "view_1057", "view_1056]
// When the form in view 1045 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1045", function (event, view, data) {
    viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})

Need to identify views in production, but then we're ready to implement!

dianamartin commented 7 months ago

1/24/24

Updated Prod Code


var viewsToFetch = ["view_867", "view_865", "view_870", "view_857", "view_1062", "view_1061", "view_1068"]
// When the form in view 1045 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1045", function (event, view, data) {
    viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})
dianamartin commented 3 months ago

6/14/24

Initial Creation - Add Job - 1020

Subprojects - view_1161 FDUs - view_1162 TK - view_1163 JV - view_1165 IET - view_1166 Other - view_1167

Requester Details - Add Job - 1181

Subprojects - view_867 FDU - view_865 TK - view_870 JV - view_1062 IET - view_1061 Other - view_1068

Manage SRs - Add Job - 1182

Subprojects - view_1183 FDU - view_1191 TK - view_1185 JV - view_1186 IET - view_1187 Other - view_1188

Add FDU to Mange SRs - Add Job page

ChristinaTremel commented 3 months ago

Code for Initial Creation - Add Job

var viewsToFetch = ["view_1161", "view_1162", "view_1165", "view_1163", "view_1166", "view_1167"]
// When the form in view 1020 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1020", function (event, view, data) {
    viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})

Code for Requester Details - Add Job

var viewsToFetchUserAdd = ["view_867", "view_865", "view_870", "view_1062", "view_1061", "view_1068"]
// When the form in view 1181 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1181", function (event, view, data) {
    viewsToFetchUserAdd.forEach(view => Knack.views[view].model.fetch())
})

Code for Admin - Add Job

var viewsToFetchAdmin = ["view_1183, "view_1191", "view_1185", "view_1186", "view_1187", "view_1188"]
// When the form in view 1182 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1182", function (event, view, data) {
    viewsToFetchAdmin.forEach(view => Knack.views[view].model.fetch())
})
ChristinaTremel commented 2 months ago

Chia helped us fix the code by renaming the viewstofetch for each page we were refreshing. Diana and I tested and this works ✅

Still need to do PR @dianamartin

dianamartin commented 2 months ago

7/12/24