Skip to content

Commit

Permalink
project creation: proj attrs in store on create
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Oct 31, 2024
1 parent f249b10 commit 84dcdd8
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 46 deletions.
37 changes: 22 additions & 15 deletions client/app/components/projects/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export default class ProjectsNewFormComponent extends Component {
applicantType: this.args.package.applicantType.code,
};

console.log("projectInformation", projectInformation);

const primaryContactInput = {
first: this.args.package.primaryContactFirstName,
last: this.args.package.primaryContactLastName,
Expand All @@ -51,6 +53,16 @@ export default class ProjectsNewFormComponent extends Component {
role: 'applicant',
};

let newProject = this.store.createRecord("project", {
dcpProjectname: projectInformation.projectName,
dcpBorough: projectInformation.borough,
dcpApplicanttype: projectInformation.applicantType,
});
// return projectModel.save();

console.log('new project?', newProject);
console.log('new project?', newProject.changedAttributes());

const contactInputs = [primaryContactInput, applicantInput];

try {
Expand Down Expand Up @@ -78,21 +90,16 @@ export default class ProjectsNewFormComponent extends Component {
return contact;
});

const saveProjectInformation = () => {
const projectModel = this.store.createRecord('project', {
dcpProjectName: projectInformation.projectName,
dcpBorough: projectInformation.borough,
dcoApplicantType: projectInformation.applicantType,
});
return projectModel.save();
};

await Promise.all(
[
verifiedContactPromises,
saveProjectInformation,
],
)
// const saveProjectInformation = () => {
// const projectModel = this.store.createRecord('project', {
// dcpProjectName: projectInformation.projectName,
// dcpBorough: projectInformation.borough,
// dcoApplicantType: projectInformation.applicantType,
// });
// return projectModel.save();
// };

await Promise.all(verifiedContactPromises)
.then(
await this.args.package.submit(),
);
Expand Down
134 changes: 103 additions & 31 deletions client/app/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { optionset } from '../helpers/optionset';

export default class ProjectModel extends Model {
// The human-readable, descriptive name.
// e.g. "Marcus Garvey Blvd Project"
// e.g. 'Marcus Garvey Blvd Project'
@attr dcpProjectname;

// The CRM Project 5-letter ID.
Expand Down Expand Up @@ -68,6 +68,37 @@ export default class ProjectModel extends Model {
@attr('number')
dcpNewcommunityfacilitysqft;

// new project attributes

// either 'Other Public entity' or 'Private'
// either 717170000 or 717170002
@attr('string')
dcpApplicanttype;

@attr('string')
primaryContactFirstName;

@attr('string')
primaryContactLastName;

@attr('string')
primaryContactEmail;

@attr('string')
primaryContactPhone;

@attr('string')
applicantFirstName;

@attr('string')
applicantLastName;

@attr('string')
applicantEmail;

@attr('string')
applicantPhone;

// We assume there's only one. If there's >1 in crm, the backend
// should return the first one.
@belongsTo('artifact', { async: false })
Expand All @@ -85,18 +116,24 @@ export default class ProjectModel extends Model {
@hasMany('milestone', { async: false })
milestones;

get isDirty () {
get isDirty() {
return this.hasDirtyAttributes || (this.artifact && this.artifact.isDirty);
}

get publicStatusGeneralPublicProject() {
const isGeneralPublic = this.dcpVisibility === optionset(['project', 'dcpVisibility', 'code', 'GENERAL_PUBLIC']);
const isGeneralPublic =
this.dcpVisibility ===
optionset(['project', 'dcpVisibility', 'code', 'GENERAL_PUBLIC']);
return this.dcpPublicstatus && isGeneralPublic;
}

get pasPackages() {
const pasPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'PAS_PACKAGE']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'PAS_PACKAGE'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -105,7 +142,11 @@ export default class ProjectModel extends Model {

get rwcdsPackages() {
const rwcdsPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'RWCDS']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'RWCDS'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -124,7 +165,11 @@ export default class ProjectModel extends Model {

get draftLandusePackages() {
const landusePackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_LU_PACKAGE']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_LU_PACKAGE'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -133,7 +178,11 @@ export default class ProjectModel extends Model {

get filedLandusePackages() {
const landusePackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'FILED_LU_PACKAGE']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'FILED_LU_PACKAGE'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -142,23 +191,28 @@ export default class ProjectModel extends Model {

get postCertLUPackages() {
return this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'POST_CERT_LU']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'POST_CERT_LU'])
)
.sortBy('dcpPackageversion')
.reverse();
}

get easPackages() {
const easPackages = [
...this.filedEasPackages,
...this.draftEasPackages,
];
const easPackages = [...this.filedEasPackages, ...this.draftEasPackages];

return easPackages;
}

get draftEasPackages() {
const easPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_EAS']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_EAS'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -167,7 +221,11 @@ export default class ProjectModel extends Model {

get filedEasPackages() {
const easPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'FILED_EAS']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'FILED_EAS'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -176,27 +234,35 @@ export default class ProjectModel extends Model {

get scopeOfWorkDraftPackages() {
const scopeOfWorkDraftPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_SCOPE_OF_WORK']))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset([
'package',
'dcpPackagetype',
'code',
'DRAFT_SCOPE_OF_WORK',
])
)
.sortBy('dcpPackageversion')
.reverse();

return scopeOfWorkDraftPackages;
}

get eisPackages() {
const eisPackages = [
...this.feisPackages,
...this.deisPackages,
];
const eisPackages = [...this.feisPackages, ...this.deisPackages];

return eisPackages;
}

get deisPackages() {
const eisPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(
['package', 'dcpPackagetype', 'code', 'PDEIS'],
))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'PDEIS'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -205,9 +271,11 @@ export default class ProjectModel extends Model {

get feisPackages() {
const eisPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(
['package', 'dcpPackagetype', 'code', 'EIS'],
))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'EIS'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -216,9 +284,11 @@ export default class ProjectModel extends Model {

get technicalMemoPackages() {
const technicalMemoPackages = this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(
['package', 'dcpPackagetype', 'code', 'TECHNICAL_MEMO'],
))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'TECHNICAL_MEMO'])
)
.sortBy('dcpPackageversion')
.reverse();

Expand All @@ -227,9 +297,11 @@ export default class ProjectModel extends Model {

get workingPackages() {
return this.packages
.filter((projectPackage) => projectPackage.dcpPackagetype === optionset(
['package', 'dcpPackagetype', 'code', 'WORKING_PACKAGE'],
))
.filter(
(projectPackage) =>
projectPackage.dcpPackagetype ===
optionset(['package', 'dcpPackagetype', 'code', 'WORKING_PACKAGE'])
)
.sortBy('dcpPackageversion')
.reverse();
}
Expand Down

0 comments on commit 84dcdd8

Please sign in to comment.