Skip to content

Comments

dqt: replace $.ajax with lorisFetch#10335

Open
Montekkundan wants to merge 3 commits intoaces:mainfrom
Montekkundan:montek/issue-4213-dqt-fetch
Open

dqt: replace $.ajax with lorisFetch#10335
Montekkundan wants to merge 3 commits intoaces:mainfrom
Montekkundan:montek/issue-4213-dqt-fetch

Conversation

@Montekkundan
Copy link

Summary

Replace $.ajax calls with lorisFetch in dqt.

Why

This removes jQuery AJAX usage in this module for issue #4213.

Scope

Only AJAX replacement in this module. No unrelated jQuery refactors.

Dependency

Depends on PR #10333.

Verification

git grep '\$\.ajax' is clean for touched files.

@github-actions github-actions bot added Language: Javascript PR or issue that update Javascript code Module: dqt PR or issue related to (old) dqt module labels Feb 5, 2026
@driusan driusan added the State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed label Feb 5, 2026
@HenriRabalais HenriRabalais self-assigned this Feb 10, 2026
@Montekkundan
Copy link
Author

Follow-up pushed to align with #9999 Client guidance for JSON/data requests.

Updated

  • Added module client: modules/dqt/jsx/DQTClient.js
  • Migrated JSON/data calls in modules/dqt/jsx/react.app.js to client methods.

Notes

  • Stream-reader setup/session loaders remain on lorisFetch intentionally because they process streamed responses (response.body.getReader()), not standard JSON request flows.

Comment on lines 506 to 513
const data = await this.client.getJSON(
loris.BaseURL + '/AjaxHelper.php?Module=dqt&script=' + script + '&' +
new URLSearchParams({
category: rule.instrument,
field: rule.field,
value: rule.value,
})
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Client is designed to avoid manually contructed the URL like this, the Query class should be used in this case.

Comment on lines 20 to 25
getJSON(url) {
return this.fetchJSON(new URL(url, window.location.origin), {
method: 'GET',
headers: {'Accept': 'application/json'},
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the get function in the Client class is designed to do this.

Comment on lines 168 to 170
const response = await lorisFetch(
`${loris.BaseURL}/dqt/dqt_setup/?format=json`,
{credentials: 'same-origin', method: 'GET'}
{method: 'GET'}
Copy link
Collaborator

@HenriRabalais HenriRabalais Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Client get function with a Query param for the format and a setSubEndpoint should be able to handle this

Comment on lines 255 to 257
const response = await lorisFetch(
`${loris.BaseURL}/dqt/sessions/?format=json`,
{credentials: 'same-origin', method: 'GET'}
{method: 'GET'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Client get function with a Query param for the format and a setSubEndpoint should be able to handle this

Comment on lines 59 to 68
});
if (!response.ok) {
const error = new Error('request_failed');
error.status = response.status;
error.response = response;
throw error;
}
return response.text();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use fetch or fetchJSON directly here. The Client class is an abstraction layer designed to handle URL building and error reporting for you. By calling fetch directly, you're losing the /dqt base path and our custom error-handling system.

If you need to fetch raw text or send URL-encoded data, I would do that using lorisFetch.

Comment on lines 143 to 147
curRequest = this.client.getJSON(
loris.BaseURL
+ '/AjaxHelper.php?Module=dqt&script=GetDoc.php&DocID='
+ encodeURIComponent(this.state.queryIDs[key][i])), {
data: {
DocID: this.state.queryIDs[key][i],
},
dataType: 'json',
}).then((value) => {
let queries = this.state.savedQueries;
queries[value._id] = value;
this.setState({savedQueries: queries});
});
+ encodeURIComponent(this.state.queryIDs[key][i])
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Client get function with a Query param for the format and a setSubEndpoint should be able to handle this

Comment on lines 699 to 703
this.client.getJSON(
loris.BaseURL + '/dqt/ajax/datadictionary.php?' +
new URLSearchParams({keys: JSON.stringify(fieldsList)})
)
.then((data) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Client get function with a Query param for the format and a setSubEndpoint should be able to handle this

Copy link
Collaborator

@HenriRabalais HenriRabalais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Across the refactors I notice a pattern here of bypassing the established Http.Client abstraction. By using native fetch, manual URL string concatenation, and custom error handling inside the Client extension classes, we lose the benefits of our centralized system for predictable URL building, standardized logging, error and response handling.

Our design goal is to keep the Client strictly for modern JSON/REST interactions. As I outlined in my original comment on your lorisFetch PR, I think legacy PHP helpers that require URL-encoding or return raw text should use your lorisFetch.

Copy link
Collaborator

@HenriRabalais HenriRabalais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client implementation looks good!

@HenriRabalais HenriRabalais removed their assignment Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: Javascript PR or issue that update Javascript code Module: dqt PR or issue related to (old) dqt module State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants