Skip to content

Commit

Permalink
#3368: Fix create/edit pages for person, report, task
Browse files Browse the repository at this point in the history
As they assume custom fields exist
  • Loading branch information
cemalettin-work committed Dec 21, 2020
1 parent 66fb0ed commit e6b1f10
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 50 deletions.
18 changes: 10 additions & 8 deletions client/src/pages/people/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ const PersonEdit = ({ pageDispatchers }) => {
? "Update profile"
: "Save Person"

// set initial invisible custom fields
person[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.person.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
person
)
if (Settings.fields.person.customFields) {
// set initial invisible custom fields
person[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.person.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
person
)
}

return (
<div>
Expand Down
18 changes: 10 additions & 8 deletions client/src/pages/people/New.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ const PersonNew = ({ pageDispatchers }) => {
})

const person = new Person()
// set initial invisible custom fields
person[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.person.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
person
)
if (Settings.fields.person.customFields) {
// set initial invisible custom fields
person[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.person.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
person
)
}

return <PersonForm initialValues={person} title="Create a new Person" />
}
Expand Down
19 changes: 11 additions & 8 deletions client/src/pages/reports/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ const ReportEdit = ({ pageDispatchers }) => {
report.getTasksEngagementAssessments(),
report.getAttendeesEngagementAssessments()
)
// set initial invisible custom fields
reportInitialValues[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.report.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
report
)

if (Settings.fields.report.customFields) {
// set initial invisible custom fields
reportInitialValues[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.report.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
report
)
}
reportInitialValues.tasks = Task.fromArray(reportInitialValues.tasks)
reportInitialValues.reportPeople = Person.fromArray(
reportInitialValues.reportPeople
Expand Down
16 changes: 9 additions & 7 deletions client/src/pages/reports/New.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ const ReportNew = ({ pageDispatchers }) => {
const report = new Report()

// set initial invisible custom fields
report[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.report.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
report
)
if (Settings.fields.report.customFields) {
report[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.report.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
report
)
}

if (currentUser && currentUser.uuid) {
const person = new Person(currentUser)
Expand Down
19 changes: 10 additions & 9 deletions client/src/pages/tasks/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,16 @@ const TaskEdit = ({ pageDispatchers }) => {
}
const task = new Task(data ? data.task : {})

// set initial invisible custom fields
task[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.task.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
task
)

if (Settings.fields.task.customFields) {
// set initial invisible custom fields
task[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.task.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
task
)
}
return (
<div>
<RelatedObjectNotes
Expand Down
19 changes: 10 additions & 9 deletions client/src/pages/tasks/New.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ const TaskNewConditional = ({
task.taskedOrganizations = [new Organization(data.organization)]
}

// set initial invisible custom fields
task[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.task.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
task
)

if (Settings.fields.task.customFields) {
// set initial invisible custom fields
task[DEFAULT_CUSTOM_FIELDS_PARENT][
INVISIBLE_CUSTOM_FIELDS_FIELD
] = getInvisibleFields(
Settings.fields.task.customFields,
DEFAULT_CUSTOM_FIELDS_PARENT,
task
)
}
return (
<TaskForm
initialValues={task}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// import { expect } from "chai"
import CreateAuthorizationGroup from "../pages/createAuthorizationGroup.page"
import CreateOrganization from "../pages/createNewOrganization.page"
import CreatePerson from "../pages/createNewPerson.page"
import CreateTask from "../pages/createNewTask.page"
import CreateOrganization from "../pages/CreateOrganization.page"
import CreateReport from "../pages/createReport.page"
import EditPosition from "../pages/editPosition.page"
import CreateNewLocation from "../pages/location/createNewLocation.page"
Expand Down

0 comments on commit e6b1f10

Please sign in to comment.