Skip to content

feat: toggle analysis table column#1115

Draft
MitanOmar wants to merge 8 commits intoadfinis:mainfrom
MitanOmar:toggle-analysis-table-columns
Draft

feat: toggle analysis table column#1115
MitanOmar wants to merge 8 commits intoadfinis:mainfrom
MitanOmar:toggle-analysis-table-columns

Conversation

@MitanOmar
Copy link
Copy Markdown
Member

@MitanOmar MitanOmar commented Mar 16, 2026

fix: #1083

@MitanOmar MitanOmar self-assigned this Mar 16, 2026
@MitanOmar MitanOmar requested a review from derrabauke March 16, 2026 12:16
@MitanOmar MitanOmar force-pushed the toggle-analysis-table-columns branch from b44fe84 to 43c9aa4 Compare March 16, 2026 14:28
@MitanOmar MitanOmar changed the title feat: WIP toggle analysis table column feat: toggle analysis table column Mar 16, 2026
@MitanOmar MitanOmar marked this pull request as ready for review March 16, 2026 14:42
@MitanOmar MitanOmar requested a review from a team as a code owner March 16, 2026 14:42
Copy link
Copy Markdown
Member

@derrabauke derrabauke left a comment

Choose a reason for hiding this comment

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

Generally don't scope only to analysis. That's a feature we will apply to other tables with a high probability. So all the analysis-** prefixed naming --> re-usable component.

Comment thread frontend/app/components/analysis-columns-modal.hbs
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we make this more re-usable? Think of it as a service for multiple tables/components. There will be future scenarios where users need to store some UI relevant settings. And that will be the service for it. We don't want to create a new service for each UI setting topic.

I'd suggest the naming UserSettingsService. And probably it's best to store the table column configurations in a configuration file like app/config/table-columns.js so it's easy to extract this service+config in the future to the ui-core addon and we can add column configurations for other tables easily.

Copy link
Copy Markdown
Member

@derrabauke derrabauke Apr 1, 2026

Choose a reason for hiding this comment

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

As discussed:

  • UserSettingsService handles the storing/loading
  • We gonna provide default settings ala:
    • app/config/table-columns.js (this can include multiple table configurations)
    • app/config/appearance.js
  • The default setting should also define the storage (sub-) key, format: `${user-settings-key}-${sub-setting-key}

@derrabauke
Copy link
Copy Markdown
Member

And of course tests are missing. :-)

@MitanOmar
Copy link
Copy Markdown
Member Author

And of course tests are missing. :-)

i did not write tests yet, just to get confirmation about if this is the right way to implement it

@@ -0,0 +1,5 @@
<colgroup>
{{#each @columns as |column|}}
<col class={{concat "w-[" column.width "%]"}} />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

that only works if the classes w-[x%] are defined/used elsewhere (with their full name), otherwise tailwind won't include them in the CSS bundle

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the same issue you @MitanOmar faced with #1139 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@derrabauke will take care of that as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

export default class AnalysisTableColumnsService extends Service {
localStorageKey = "hidden-analysis-table-column";
@tracked hiddenColumns = [];
@tracked allTableColumns = [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is constant, why is it tracked?

nitpick: move it, and the localStorageKey outside of the class (and rename them so its clear they're constants, e.g. ALL_TABLE_COLUMNS and LOCAL_STORAGE_KEY)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could also make this more agnostic. analysis-columns-modal -> column-selector-modal

@MitanOmar MitanOmar force-pushed the toggle-analysis-table-columns branch from 43c9aa4 to 7568aa5 Compare April 10, 2026 00:49
@MitanOmar MitanOmar marked this pull request as draft April 10, 2026 00:56
@MitanOmar MitanOmar force-pushed the toggle-analysis-table-columns branch from cbc4c1b to 27766d1 Compare April 13, 2026 07:43
@action
save() {
this.userSettings.updateHiddenColumns("analysisTable", this.localhidden);
this.notify.success("The columns are updated successfully");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not necessary, only notify the user if it fails.

Comment thread frontend/app/services/user-settings.js Outdated
constructor(userSettings) {
this.userSettings = userSettings;
this.loadConfiguration();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is that? Why not inject the service as normal? Or extend it?

Comment on lines +15 to +23
load(subServiceKey, defaultValue) {
const fullKey = `${USER_SETTINGS_KEY}.${subServiceKey}`;
const localStorageValue = localStorage.getItem(fullKey);
if (!localStorageValue && typeof defaultValue !== "undefined") {
localStorage.setItem(fullKey, JSON.stringify(defaultValue));
return defaultValue;
}
return localStorageValue ? JSON.parse(localStorageValue) : defaultValue;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Drop the whole sub-service thingy. Make it flat & simple.

Comment thread frontend/app/analysis/index/controller.js Outdated
Comment thread frontend/app/services/user-settings.js Outdated
return {
...col,
isVisible:
userPreference !== undefined ? userPreference : col.isVisible,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
userPreference !== undefined ? userPreference : col.isVisible,
userPreference !== undefined ? userPreference.isVisible : col.isVisible,

Comment thread frontend/app/services/user-settings.js Outdated
...this._overrides,
[tableId]: {
...(this._overrides[tableId] || {}),
[columnId]: isVisible,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
[columnId]: isVisible,
[columnId]: { isVisible },

Comment on lines +6 to +59
export default class AnalysisColumnsModal extends Component {
@service userSettings;
@service notify;

/** just to not call the update with each toggle,
* we are saving a local copy,
* and updating with save function
*/
@tracked localhidden = [];

get hiddenColumns() {
return this.localhidden;
}

constructor(...args) {
super(...args);
this.localhidden = this.userSettings
.getTableColumns("analysis")
.filter((col) => !col.isVisible)
.map((col) => col.lable);
}

get allTableColumns() {
return this.userSettings.getTableColumns("analysis");
}

@action
toggleColumn(columnLabel) {
if (this.localhidden.includes(columnLabel)) {
this.localhidden = this.localhidden.filter(
(label) => label !== columnLabel,
);
return;
}
this.localhidden.push(columnLabel);
}

@action
save() {
try {
for (const column of this.allTableColumns) {
this.userSettings.updateColumnVisibility(
"analysis",
column.label,
this.localhidden.includes(column.label),
);
}
this.args.onClose();
} catch (error) {
console.log({ error });
this.notify.error("An error when updating the columns visibility");
}
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export default class AnalysisColumnsModal extends Component {
@service userSettings;
@service notify;
/** just to not call the update with each toggle,
* we are saving a local copy,
* and updating with save function
*/
@tracked localhidden = [];
get hiddenColumns() {
return this.localhidden;
}
constructor(...args) {
super(...args);
this.localhidden = this.userSettings
.getTableColumns("analysis")
.filter((col) => !col.isVisible)
.map((col) => col.lable);
}
get allTableColumns() {
return this.userSettings.getTableColumns("analysis");
}
@action
toggleColumn(columnLabel) {
if (this.localhidden.includes(columnLabel)) {
this.localhidden = this.localhidden.filter(
(label) => label !== columnLabel,
);
return;
}
this.localhidden.push(columnLabel);
}
@action
save() {
try {
for (const column of this.allTableColumns) {
this.userSettings.updateColumnVisibility(
"analysis",
column.label,
this.localhidden.includes(column.label),
);
}
this.args.onClose();
} catch (error) {
console.log({ error });
this.notify.error("An error when updating the columns visibility");
}
}
}
import { tracked } from "tracked-built-ins";
export default class AnalysisColumnsModal extends Component {
@service userSettings;
@service notify;
columns = tracked(this.userSettings.getTableColumns("analysis")); // that's all you need
@action
toggleColumn(column) {
column.isVisible = !column.isVisible
this.columns = [...this.columns]
}
@action
save() {
try {
for (const column of this.columns) {
this.userSettings.updateColumnVisibility(
"analysis",
column.label,
column.isVisible,
);
}
this.args.onClose();
} catch (error) {
console.log({ error });
this.notify.error("An error when updating the columns visibility");
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT]: Configurable columns in analysis tab

3 participants