Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ember-data v5.3 #436

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

c0rydoras
Copy link
Collaborator

No description provided.

@c0rydoras c0rydoras requested a review from a team as a code owner August 21, 2024 16:07
@c0rydoras c0rydoras force-pushed the refactor/frontend/data-fetching branch from 6126e16 to b0eb346 Compare August 23, 2024 13:44
@c0rydoras c0rydoras changed the title Refactor/frontend/data fetching ember-data v5.3 Aug 26, 2024
@c0rydoras c0rydoras force-pushed the refactor/frontend/data-fetching branch 14 times, most recently from a04b28b to f54c3c5 Compare September 3, 2024 11:37
@c0rydoras c0rydoras force-pushed the refactor/frontend/data-fetching branch 2 times, most recently from 0b7a287 to 8d36e6c Compare September 3, 2024 14:58
.includes(this.user?.get("id"));
}

async canAedit() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the naming is not ideal. What do you think of canEditAsync? Then it would be more obvious what that thing does.

frontend/app/analysis/index/controller.js Outdated Show resolved Hide resolved
const selected = this.selectedReportIds;

if (selected.includes(report.id)) {
this.selectedReportIds = A([
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could get rid of that A(...), what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Naming things 😅 -- What ya think about promise-wrapper?

import Component from "@glimmer/component";
import { dropTask } from "ember-concurrency";
import ReportValidations from "timed/validations/report";

export default class ReportRowComponent extends Component {
@service abilities;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that stay here? It's used in canEdit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yea

Comment on lines +2 to +4
{{#let (can "edit report" @report) as |syncEditable|}}
{{#let this.canEdit syncEditable as |promise|}}
<PromiseThing @await={{not syncEditable}} @promise={{promise}} @value={{syncEditable}} as |t|>
Copy link
Contributor

Choose a reason for hiding this comment

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

See above combination of or (can syncEdit) (can asyncEdit)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'd have to await the (can asyncEdit) as it returns a promise

frontend/app/components/statistic-list/template.hbs Outdated Show resolved Hide resolved
@@ -212,7 +213,7 @@ export default class ActivitiesIndexController extends Controller {
data.duration.add(report.get("duration"));
report.set("duration", data.duration);
} else {
report = this.store.createRecord("report", data);
report = await this.store.createRecord("report", data);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a sync function afaik 🤔

frontend/app/statistics/controller.js Outdated Show resolved Hide resolved
frontend/app/users/index/template.hbs Outdated Show resolved Hide resolved
@c0rydoras c0rydoras force-pushed the refactor/frontend/data-fetching branch 2 times, most recently from be7b7e2 to 257a350 Compare September 4, 2024 11:54
@c0rydoras c0rydoras force-pushed the refactor/frontend/data-fetching branch 3 times, most recently from c8e5958 to 45287c2 Compare September 4, 2024 12:42
this changes `ability.canEdit` into 2 parts, `ability.canEdit` which
checks if for if you are superuser, if the report hasn't been verified
and if the report is your own.

the other parts of the ability, checking for reviewer and supervisee have
been moved into `ability.canAedit`, which is an async ability.

places where this is used first check with `canEdit`, if thats false
they `await canAedit(report)`.

this is ugly and hacky but it works.
@c0rydoras c0rydoras force-pushed the refactor/frontend/data-fetching branch from 45287c2 to bb24fc6 Compare September 4, 2024 13:01
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.

2 participants