* Basic thumbsup, thumbsdown and vomit * Refined UI of flags and vomits * If check * Optimised code and added a method in article.rb * Removed public keyword * Nit fixes * Section for flags and quality details * Basic vomit item * Quality item UI * Separated code into partials * UI changes and empty state added * With correct implementation * Fixed showing reaction items in all cases * Dropdown visible * Enabled click listerners and call functions for dropdown-button clicks * Empty state UI fixed * Tabs and divider UI * Mark as valid/invalid conditions * Nit fixes * Logical fixes * Added comments * Partial item status update fix * Reload page feature fixed * Removed snackbar * I18n strings * Bug fix * I18n strings * Nit fixes * Added date * Added view details button * Added view details test * Sample test * Test fixes * Added tests for new article * Flagged item tests added * Added more tests * Nit fix * Suggested design changes * Nit design fixes * Tests with cy.intercept * Nit fixes * Nit fixes * Hero Billboard Placement (#19467) * init * add option to swagger docs * in_house validation * filtered ad quesry changes * styling and prioritizing home hero banner over campaign banner * rubocop * typo * broken spec * more spec fixes * found the spec break culprit * derp * Update app/views/shared/_display_ad.html.erb Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> * Update app/controllers/stories_controller.rb Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> * remove immediate return * styling feedback and moving banner to articles index * remove nil * updated styling * add signed in bool * add feature flag * remove feature flag data scripts --------- Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> * Fix typo / erroneous word in Admin Section (#19488) * Typo fixes * Update admin_menu.rb * Minor background and shadow change (#19501) * Refresh audience segment for 'active' user (#19470) * Refresh an individual user's segmentation * Refresh segment if creating a published article * Quick refactor * Refresh segment if update publishing * Quick refactor * Refresh segment if update user settings * Refresh segments after user update + role change * Using latest_article_updated_at * Sidekiq uses JSON for arguments, needs basic types * Fix test issues with last_updated_at and sidekiq params * Tests update continues * Consolidate dependencies * Method names acknowledging manual exclusive * Fix test name copypasta * Rubocop * Try to clarify Creator#series * Try to avoid naming predicate * Remove erroneously included helper * Improve onboarding “suggested tags” page design (#19475) * Onboarding tags * Logical design issue fixes * Posts count added * Checkbox design fixes * Optimised css * Nit fixes * Test case added * Reduced data * Nit fix * Added more tests * Nit fix * Tests updatedt * Update @honeybadger-io/js to version 5.4.1 (#19479) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> * Update sidekiq-cron to version 1.10.1 (#19473) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> * Update nokogiri to version 1.15.0 (#19495) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> * use tabindex instead of disabled to get proper keyboard nav on /onboarding tags (#19513) * Add billboard to safe param list in Fastly vcl (#19515) * Removed static article id from setup * All tests passing * Nit fixes * Nit fixes * Fixed tests with Joshua's help * Added trusted user related tests * Fixed few tests * Added intercept and wait * Removed tab and enter key * Updated comment * Updated tests --------- Co-authored-by: Lawrence <lawrence@forem.com> Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> Co-authored-by: Peter Frank <peter.kim.frank@gmail.com> Co-authored-by: Joshua Wehner <joshua@forem.com> Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
import { Controller } from '@hotwired/stimulus';
|
|
|
|
export default class ReactionController extends Controller {
|
|
static targets = ['invalid', 'confirmed'];
|
|
static values = {
|
|
id: Number,
|
|
url: String,
|
|
};
|
|
|
|
updateReaction(status, removeElement = true) {
|
|
const id = this.idValue;
|
|
|
|
fetch(this.urlValue, {
|
|
method: 'PATCH',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
'X-CSRF-Token': document.querySelector("meta[name='csrf-token']")
|
|
?.content,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
id,
|
|
status,
|
|
}),
|
|
credentials: 'same-origin',
|
|
}).then((response) =>
|
|
response
|
|
.json()
|
|
.then((json) => {
|
|
if (json.outcome === 'Success') {
|
|
if (removeElement === true) {
|
|
this.element.remove();
|
|
document.getElementById(`js__reaction__div__hr__${id}`).remove();
|
|
} else {
|
|
// TODO (#19531): Code Optimisation- avoid reloading entire page for this minor item change.
|
|
// Once the status of item gets updated in admin/content_manager/articles/<article-id>, we
|
|
// reload the entire page here. Ideally we should only re-render the item which was updated
|
|
// but given the case that this feature is used by internal-team, for now its fine.
|
|
location.reload();
|
|
}
|
|
} else {
|
|
window.alert(json.error);
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
window.alert(error);
|
|
}),
|
|
);
|
|
}
|
|
|
|
updateReactionInvalid(event) {
|
|
const { removeElement } = event.target.dataset;
|
|
this.updateReaction(this.invalidStatus, removeElement);
|
|
}
|
|
|
|
updateReactionConfirmed(event) {
|
|
const { removeElement } = event.target.dataset;
|
|
this.updateReaction(this.confirmedStatus, removeElement);
|
|
}
|
|
|
|
reactableUserCheck() {
|
|
if (this.reactableType === 'user') {
|
|
if (
|
|
window.confirm('You are confirming a User flag reaction; are you sure?')
|
|
) {
|
|
this.updateReaction(this.confirmedStatus);
|
|
}
|
|
} else {
|
|
this.updateReaction(this.confirmedStatus);
|
|
}
|
|
}
|
|
|
|
get reactableType() {
|
|
return this.confirmedTarget.dataset.reactable;
|
|
}
|
|
|
|
get confirmedStatus() {
|
|
return this.confirmedTarget.dataset.status;
|
|
}
|
|
|
|
get invalidStatus() {
|
|
return this.invalidTarget.dataset.altstatus;
|
|
}
|
|
}
|