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

Subject field #2158

Merged
merged 7 commits into from
Dec 18, 2024
Merged

Conversation

thecalcc
Copy link
Contributor

@thecalcc thecalcc commented Dec 13, 2024

STT-63

Front-end checklist

  • This pull request is adding missing TypeScript types to modified code segments where it's easy to do so with confidence
  • This pull request is using TypeScript interfaces instead of prop-types and updates usages where it's quick to do so
  • This pull request is using memo or PureComponent to define new React components (and updates existing usages in modified code segments)
  • This pull request is replacing lodash.get with optional chaining and nullish coalescing for modified code segments
  • This pull request is not importing anything from client-core directly (use superdeskApi)
  • This pull request is importing UI components from superdesk-ui-framework and superdeskApi when possible instead of using ones defined in this repository.
  • This pull request is not using planningApi where it is possible to use superdeskApi
  • This pull request is not adding redux based modals
  • In this pull request, properties of redux state are not being passed as props to components; instead, we connect it to the component that needs them. Except components where using a react key is required - do not connect those due to performance reasons.
  • This pull request is not adding redux actions that do not modify state (e.g. only calling angular services; those should be moved to planningApi)

subject: allSubjects.map(({qcode, name, parent}) => {
var itemToStore: IStorageFormat = {qcode, name, parent};

if (parent != null) {
Copy link
Member

Choose a reason for hiding this comment

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

When would this condition make a difference?

const a = {x: 1}
const b = {...a}

if (b.x != null) { // <-- would never make a difference because if a.x and b.x are the same
    b.x = a.x;
}

Copy link
Contributor Author

@thecalcc thecalcc Dec 18, 2024

Choose a reason for hiding this comment

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

Doesn't, I had it copied over from the subject in client-core


return itemToStore;
}),
subject: allSubjects,
Copy link
Member

Choose a reason for hiding this comment

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

allSubjects is confusing naming, because if you filter it, you can't call it "all" anymore

@@ -36,12 +36,12 @@ export function getSubjectField(): IFieldDefinition {
return (item.subject ?? []).map(({qcode}) => qcode);
},
storeValue: (item, operationalValue: Array<ISubjectCode['qcode']>) => {
const allSubjects: Array<ISubjectCode> = (planningApi.redux.store.getState().subjects ?? [])
const filteredSubjects: Array<ISubjectCode> = (planningApi.redux.store.getState().subjects ?? [])
Copy link
Member

Choose a reason for hiding this comment

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

filteredSubjects isn't much better. It doesn't make sense to mention programming operations (filter,map,reduce etc.) that you performed - but what is being achieved by those programming operations. When it's something small and obvious like here I'd call it subjects simply without elaborating. If you wanted more details, then maybe subjectsFull since the purpose of the operation is to return full objects instead of qcodes only.

@thecalcc thecalcc merged commit 680c4ae into superdesk:authoring-react-planning Dec 18, 2024
9 of 13 checks passed
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